diff --git a/.custom-gcl.yml b/.custom-gcl.yml index 311dc036bd..5cb5c80a64 100644 --- a/.custom-gcl.yml +++ b/.custom-gcl.yml @@ -1,6 +1,6 @@ # yaml-language-server: $schema=https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json -version: v2.5.0 +version: v2.6.2 destination: ./_tools diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3e08356c0b..ebc13f5b12 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,21 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/universal +// README at: https://github.com/devcontainers/templates/tree/main/src/go { "name": "TypeScript Compiler Development", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/universal:2-linux", - + "image": "mcr.microsoft.com/devcontainers/go:2-1.25-bookworm", // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts", + "pnpmVersion": "latest", + "nvmVersion": "latest" + }, + "ghcr.io/devcontainers-extra/features/dprint-asdf:2": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/rust:1": {} + }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], diff --git a/.dprint.jsonc b/.dprint.jsonc index 6196f06cd4..21e468d10f 100644 --- a/.dprint.jsonc +++ b/.dprint.jsonc @@ -58,8 +58,8 @@ // Note: if adding new languages, make sure settings.template.json is updated too. // Also, if updating typescript, update the one in package.json. "plugins": [ - "https://plugins.dprint.dev/typescript-0.95.11.wasm", - "https://plugins.dprint.dev/json-0.20.0.wasm", + "https://plugins.dprint.dev/typescript-0.95.12.wasm", + "https://plugins.dprint.dev/json-0.21.0.wasm", "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm", "https://plugins.dprint.dev/exec-0.6.0.json@a054130d458f124f9b5c91484833828950723a5af3f8ff2bd1523bd47b83b364" ] diff --git a/.github/ISSUE_TEMPLATE/02-behavior-difference.md b/.github/ISSUE_TEMPLATE/02-behavior-difference.md index 489da4d083..e2d0eb325e 100644 --- a/.github/ISSUE_TEMPLATE/02-behavior-difference.md +++ b/.github/ISSUE_TEMPLATE/02-behavior-difference.md @@ -1,6 +1,6 @@ --- name: Behavior Difference -about: tsgo produces different results than TypeScript 5.8 +about: tsgo produces different results than TypeScript 5.9 title: '' labels: '' assignees: '' @@ -11,6 +11,6 @@ assignees: '' -## Behavior with `typescript@5.8` +## Behavior with `typescript@5.9` ## Behavior with `tsgo` diff --git a/.github/ISSUE_TEMPLATE/03-vscode-editor-issue.yml b/.github/ISSUE_TEMPLATE/03-vscode-editor-issue.yml new file mode 100644 index 0000000000..ada6878520 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/03-vscode-editor-issue.yml @@ -0,0 +1,48 @@ +name: 'VS Code Editor Issue' +description: 'Issue using tsgo in VS Code' +labels: 'Domain: Editor' +assignees: [] +body: + - type: input + id: extension_version + attributes: + label: Extension Version + description: The version of the TypeScript (native preview) extension + placeholder: '0.20251016.x' + validations: + required: true + - type: input + id: vscode_version + attributes: + label: VS Code Version + description: The version of the VS Code you are using + placeholder: '1.105.x' + validations: + required: true + - type: input + id: os_version + attributes: + label: Operating system Version + description: Your operating system and version + validations: + required: true + - type: textarea + id: steps + attributes: + label: 'Steps to reproduce' + description: | + Information about how to reproduce the issue and expected behavior + value: | + 1. + 2. + 3. + validations: + required: true + - type: textarea + id: bug_info + attributes: + label: 'Issue' + description: | + Information about the bug, such as expected vs actual behavior + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/03-other.md b/.github/ISSUE_TEMPLATE/04-other.md similarity index 100% rename from .github/ISSUE_TEMPLATE/03-other.md rename to .github/ISSUE_TEMPLATE/04-other.md diff --git a/.github/ISSUE_TEMPLATE/04-copilot-pr-porting.md b/.github/ISSUE_TEMPLATE/05-copilot-pr-porting.md similarity index 100% rename from .github/ISSUE_TEMPLATE/04-copilot-pr-porting.md rename to .github/ISSUE_TEMPLATE/05-copilot-pr-porting.md diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index aa4d0ea3b7..4db30978d9 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -3,8 +3,8 @@ description: Setup Go inputs: go-version: - description: Go version range to set up. - default: '>=1.25.0' + description: Go version to set up in go-install.ps1 format + default: 'go1.25' create: description: Create the cache default: 'false' @@ -18,19 +18,51 @@ runs: steps: - name: Install Go id: install-go - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 - with: - go-version: ${{ inputs.go-version }} - cache: false + shell: pwsh + run: | + # https://github.com/microsoft/go-infra/blob/main/goinstallscript/powershell/go-install.ps1 + ${{ github.action_path }}/go-install.ps1 -Version ${{ inputs.go-version }} -GitHubActionsPath + + $goVersionOutput = go version + Write-Host $goVersionOutput + # Extract version like "1.23.4" from "go version go1.23.4 windows/amd64" + if ($goVersionOutput -match 'go version go([\d\.]+)') { + $exactVersion = $matches[1] + "go-version=$exactVersion" >> $env:GITHUB_OUTPUT + Write-Host "Exact Go version: $exactVersion" + } else { + Write-Error "Failed to parse Go version from: $goVersionOutput" + exit 1 + } + + - name: Verify Microsoft Go + shell: pwsh + run: | + $goPath = (Get-Command go).Source + Write-Host "Go executable path: $goPath" + if ($goPath -notlike "*microsoft-go*") { + Write-Error "Go installation is not from microsoft-go. Path: $goPath" + exit 1 + } + Write-Host "✓ Verified: Microsoft Go is active" + + - name: Add GOBIN to PATH + shell: bash + run: | + GOBIN=$(go env GOBIN) + if [ -z "$GOBIN" ]; then + GOBIN="$(go env GOPATH)/bin" + fi + echo "$GOBIN" >> $GITHUB_PATH # Avoid hardcoding the cache keys more than once. - name: Get cache info shell: bash id: cache-info env: - MODULES_KEY: go-modules-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }} - LINT_KEY: golangci-lint-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }} - BUILD_KEY: go-build-cache-${{ runner.os }}-${{ steps.install-go.outputs.go-version }} + MODULES_KEY: go-modules-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }} + LINT_KEY: golangci-lint-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }} + BUILD_KEY: go-build-cache-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }} run: | echo "modules-key=$MODULES_KEY" >> $GITHUB_OUTPUT echo "lint-key=$LINT_KEY" >> $GITHUB_OUTPUT diff --git a/.github/actions/setup-go/go-install.ps1 b/.github/actions/setup-go/go-install.ps1 new file mode 100644 index 0000000000..8a58699318 --- /dev/null +++ b/.github/actions/setup-go/go-install.ps1 @@ -0,0 +1,908 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +<# +.SYNOPSIS + Installs Microsoft build of Go +.DESCRIPTION + Installs the Microsoft build of Go toolset. + + Note that the intended use of this script is for Continuous Integration (CI) scenarios, where: + - The toolset needs to be installed without user interaction and without admin rights. + - The toolset installation doesn't need to persist across multiple CI runs. + Visit https://github.com/microsoft/go for a list of other ways to install Microsoft build of Go. + +.PARAMETER Version + Default: Latest + Download the specified version. Supports some aliases. Possible values: + - Latest - the most recent major version. + - Previous - the second most recent major version. + - 2-part version in format go1.A - represents a specific major version. + examples: go1.18, go1.23 + - 3-part version in format go1.A.B - latest revision of a specific release. + examples: go1.18.0, go1.23.1 + - 4-part version in format go1.A.B-C - a specific revision of Microsoft build of Go, immutable. + examples: go1.18.0-1, go1.23.1-3 + Microsoft build of Go doesn't publish prereleases, so they are not available. +.PARAMETER InstallDir + Path to where to install Microsoft build of Go. Note that if a directory is given, GOROOT is placed + directly in that directory. + Default: - a folder automatically selected inside LocalApplicationData as evaluated by PowerShell. + Example auto on Windows: C:\Users\myself\AppData\Local\microsoft-go\ + Example auto on Linux: /home/myself/.local/share/microsoft-go/ + If OS or Architecture are not , the path includes OS and Architecture. This avoids + overlapping installations but still allows for a shorter path for ordinary situations. +.PARAMETER OS + Default: - this value represents currently running OS + Operating system of prebuilt toolset binaries to be installed. + Possible values are: , windows, linux, darwin +.PARAMETER Architecture + Default: - this value represents currently running OS architecture + Architecture of prebuilt toolset binaries to be installed. + Possible values are: , amd64, x64, 386, x86, arm64, arm +.PARAMETER DryRun + If set, it will not perform installation. Instead, it displays what command line to use to + consistently install currently requested version of Microsoft build of Go. For example, if you specify + Version 'Latest', it will print a command with the specific 4-part version so this command can + be used deterministicly in a build script. + It also prints the location the binaries would have been installed to. +.PARAMETER NoPath + By default, this script will update the environment variable PATH for the current process to + include the binaries folder inside installation folder. + If set, it will print the binaries location but not set any environment variable. +.PARAMETER AzurePipelinePath + If set, it will print an Azure DevOps logging command that causes the Azure DevOps to update the + PATH environment variable of subsequent build steps to include the binaries folder. +.PARAMETER GitHubActionsPath + If set, it will append the binaries folder to the GITHUB_PATH environment file, causing GitHub Actions + to update the PATH environment variable of subsequent build steps to include the binaries folder. +.PARAMETER ProxyAddress + If set, it will use the proxy when making web requests +.PARAMETER ProxyUseDefaultCredentials + Default: false + Use default credentials when using ProxyAddress. +.PARAMETER ProxyBypassList + If set, when using ProxyAddress, this comma separated url list is passed to the underlying + HttpClientHandler. +.PARAMETER DownloadTimeout + Determines timeout duration in seconds for downloading the toolset file. + Default: 1200 seconds (20 minutes) +.PARAMETER KeepArchive + If set, the downloaded file is kept. +.PARAMETER ArchivePath + A path to use to store the toolset archive file, a zip or tar.gz. + Default: a generated random filename in the system's temporary directory. +.PARAMETER Help + Displays this help message. +.PARAMETER Verbose + Displays diagnostics information. +.EXAMPLE + go-install.ps1 + Installs the latest released Microsoft build of Go version. +.EXAMPLE + go-install.ps1 -Version Previous + Installs the latest version of the previous major (1.X) version of Microsoft build of Go. +#> +[cmdletbinding()] +param( + [string]$Version="Latest", + [Alias('i')][string]$InstallDir="", + [string]$OS="", + [string]$Architecture="", + [switch]$DryRun, + [switch]$NoPath, + [switch]$AzurePipelinePath, + [switch]$GitHubActionsPath, + [string]$ProxyAddress, + [switch]$ProxyUseDefaultCredentials, + [string[]]$ProxyBypassList=@(), + [int]$DownloadTimeout=1200, + [switch]$KeepArchive, + [string]$ArchivePath, + [switch]$Help +) + +Set-StrictMode -Version Latest +$ErrorActionPreference="Stop" +$ProgressPreference="SilentlyContinue" + +$MicrosoftGoInstallScriptVersion = "0.0.1" + +function Say($str) { + try { + Write-Host "go-install: $str" + } + catch { + # Some platforms cannot utilize Write-Host (Azure Functions, for instance). Fall back to Write-Output + Write-Output "go-install: $str" + } +} + +function Say-Warning($str) { + try { + Write-Warning "go-install: $str" + } + catch { + # Some platforms cannot utilize Write-Warning (Azure Functions, for instance). Fall back to Write-Output + Write-Output "go-install: Warning: $str" + } +} + +# Writes a line with error style settings. +# Use this function to show a human-readable comment along with an exception. +function Say-Error($str) { + try { + # Write-Error is quite oververbose for the purpose of the function, let's write one line with error style settings. + $Host.UI.WriteErrorLine("go-install: $str") + } + catch { + Write-Output "go-install: Error: $str" + } +} + +function Say-Verbose($str) { + try { + Write-Verbose "go-install: $str" + } + catch { + # Some platforms cannot utilize Write-Verbose (Azure Functions, for instance). Fall back to Write-Output + Write-Output "go-install: $str" + } +} + +function Measure-Action($name, $block) { + $time = Measure-Command $block + $totalSeconds = $time.TotalSeconds + Say-Verbose "⏱ Action '$name' took $totalSeconds seconds" +} + +function Get-Remote-File-Size($zipUri) { + try { + $response = Invoke-WebRequest -Uri $zipUri -Method Head + $fileSize = $response.Headers["Content-Length"] + if ((![string]::IsNullOrEmpty($fileSize))) { + Say "Remote file $zipUri size is $fileSize bytes." + + return $fileSize + } + } + catch { + Say-Verbose "Content-Length header was not extracted for $zipUri." + } + + return $null +} + +function Say-Invocation($Invocation) { + $command = $Invocation.MyCommand; + $args = (($Invocation.BoundParameters.Keys | foreach { "-$_ `"$($Invocation.BoundParameters[$_])`"" }) -join " ") + Say-Verbose "$command $args" +} + +function Invoke-With-Retry([ScriptBlock]$ScriptBlock, [System.Threading.CancellationToken]$cancellationToken = [System.Threading.CancellationToken]::None, [int]$MaxAttempts = 3, [int]$SecondsBetweenAttempts = 1) { + $Attempts = 0 + $local:startTime = $(get-date) + + while ($true) { + try { + return & $ScriptBlock + } + catch { + $Attempts++ + if (($Attempts -lt $MaxAttempts) -and -not $cancellationToken.IsCancellationRequested) { + Start-Sleep $SecondsBetweenAttempts + } + else { + $local:elapsedTime = $(get-date) - $local:startTime + if (($local:elapsedTime.TotalSeconds - $DownloadTimeout) -gt 0 -and -not $cancellationToken.IsCancellationRequested) { + throw New-Object System.TimeoutException("Failed to reach the server: connection timeout: default timeout is $DownloadTimeout second(s)"); + } + throw; + } + } + } +} + +function Get-Machine-Architecture() { + Say-Invocation $MyInvocation + + # Try the .NET API. If we don't get anything, this is probably PowerShell on Windows. + try { + $Architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture + if ($Architecture) { + # Possible values: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.architecture + return $Architecture.ToString().ToLowerInvariant() + } + } + catch { + Say-Verbose "Failed to get the machine architecture using .NET API. Falling back to environment variables." + } + + # On PS x86, PROCESSOR_ARCHITECTURE reports x86 even on x64 systems. + # To get the correct architecture, we need to use PROCESSOR_ARCHITEW6432. + # PS x64 doesn't define this, so we fall back to PROCESSOR_ARCHITECTURE. + # Possible values: amd64, x64, x86, arm64, arm + if( $ENV:PROCESSOR_ARCHITEW6432 -ne $null ) { + return $ENV:PROCESSOR_ARCHITEW6432 + } + + return $ENV:PROCESSOR_ARCHITECTURE +} + +function Get-CLIArchitecture-From-Architecture([string]$Architecture) { + Say-Invocation $MyInvocation + + if ($Architecture -eq "") { + $Architecture = Get-Machine-Architecture + } + + switch ($Architecture.ToLowerInvariant()) { + { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "amd64" } + { ($_ -eq "386") -or ($_ -eq "x86") } { return "386" } + { $_ -eq "arm" } { return "armv6l" } + { $_ -eq "arm64" } { return "arm64" } + default { throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/microsoft/go/issues" } + } +} + +function Get-CLIOS-From-OS([string]$OS) { + Say-Invocation $MyInvocation + + if (!(Test-Path -LiteralPath 'variable:IsWindows')) { + # If we don't have IsWindows, this is Windows PowerShell (powershell), not PowerShell Core (pwsh). + # So, we can't use the variable, but we know we're on Windows. + $IsWindows = $true + } + + if ($OS -eq "") { + if ($IsWindows -or [System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Win32NT) { + $OS = "windows" + } + elseif ($IsLinux) { + $OS = "linux" + } + elseif ($IsMacOS) { + $OS = "darwin" + } + else { + throw "Unable to automatically determine the OS." + } + } + + switch ($OS.ToLowerInvariant()) { + { $_ -eq "windows" } { return "windows" } + { $_ -eq "linux" } { return "linux" } + { $_ -eq "darwin" } { return "darwin" } + default { throw "OS '$OS' not supported. If you think this is a bug, report it at https://github.com/microsoft/go/issues" } + } +} + +function Get-GeneratedArchivePath([string]$CLIOS) { + Say-Invocation $MyInvocation + + $Extension = switch ($CLIOS) { + "windows" { ".zip" } + default { ".tar.gz" } + } + + return [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName()) + $Extension +} + +function Fetch-SupportedVersion([string]$StableKey) { + # Figure out what's latest by querying the list of release branches. + $ReleaseBranchData = DownloadJson "https://aka.ms/golang/release/latest/release-branch-links.json" + + # Find first thing in the array of objects where the key by name is true. + foreach ($branch in $ReleaseBranchData) { + if (Get-OrNull $branch $StableKey) { + return $branch.version + } + } + + throw "Failed to find a branch where '$StableKey' is true." +} + +function Get-NormalizedVersion([string]$Version) { + Say-Invocation $MyInvocation + + if ([string]::IsNullOrEmpty($Version)) { + return "" + } + switch ($Version.ToLowerInvariant()) { + { $_ -eq "latest" } { return Fetch-SupportedVersion -StableKey "latestStable" } + { $_ -eq "previous" } { return Fetch-SupportedVersion -StableKey "previousStable" } + { $_ -like "go1.*" } { return $_ } + default { throw "Version '$Version' not recognized. Missing 'go' prefix? If you think this is a bug, report it at https://github.com/microsoft/go/issues" } + } +} + +function Load-Assembly([string] $Assembly) { + try { + Add-Type -Assembly $Assembly | Out-Null + } + catch { + # On Nano Server, Powershell Core Edition is used. Add-Type is unable to resolve base class assemblies because they are not GAC'd. + # Loading the base class assemblies is not unnecessary as the types will automatically get resolved. + } +} + +function GetHTTPResponse([Uri] $Uri, [bool]$HeaderOnly, [bool]$DisableRedirect) +{ + $cts = New-Object System.Threading.CancellationTokenSource + + $downloadScript = { + + $HttpClient = $null + + try { + # HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet. + Load-Assembly -Assembly System.Net.Http + + if (-not $ProxyAddress) { + try { + # Despite no proxy being explicitly specified, we may still be behind a default proxy + $DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy; + if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))) { + if ($null -ne $DefaultProxy.GetProxy($Uri)) { + $ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString + } else { + $ProxyAddress = $null + } + $ProxyUseDefaultCredentials = $true + } + } + catch { + # Eat the exception and move forward as the above code is an attempt + # at resolving the DefaultProxy that may not have been a problem. + $ProxyAddress = $null + Say-Verbose("Exception ignored: $_.Exception.Message - moving forward...") + } + } + + $HttpClientHandler = New-Object System.Net.Http.HttpClientHandler + if ($ProxyAddress) { + $HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{ + Address=$ProxyAddress; + UseDefaultCredentials=$ProxyUseDefaultCredentials; + BypassList = $ProxyBypassList; + } + } + if ($DisableRedirect) { + $HttpClientHandler.AllowAutoRedirect = $false + } + $HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler + + # Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out + # Defaulting to 20 minutes allows it to work over much slower connections. + $HttpClient.Timeout = New-TimeSpan -Seconds $DownloadTimeout + + if ($HeaderOnly){ + $completionOption = [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead + } + else { + $completionOption = [System.Net.Http.HttpCompletionOption]::ResponseContentRead + } + + $Task = $HttpClient.GetAsync("$Uri", $completionOption).ConfigureAwait("false"); + $Response = $Task.GetAwaiter().GetResult(); + + if (($null -eq $Response) -or ((-not $HeaderOnly) -and (-not ($Response.IsSuccessStatusCode)))) { + # The feed credential is potentially sensitive info. Do not log FeedCredential to console output. + $DownloadException = [System.Exception] "Unable to download $Uri." + + if ($null -ne $Response) { + $DownloadException.Data["StatusCode"] = [int] $Response.StatusCode + $DownloadException.Data["ErrorMessage"] = "Unable to download $Uri. Returned HTTP status code: " + $DownloadException.Data["StatusCode"] + + if (404 -eq [int] $Response.StatusCode) { + $cts.Cancel() + } + } + + throw $DownloadException + } + + return $Response + } + catch [System.Net.Http.HttpRequestException] { + $DownloadException = [System.Exception] "Unable to download $Uri." + + # Pick up the exception message and inner exceptions' messages if they exist + $CurrentException = $PSItem.Exception + $ErrorMsg = $CurrentException.Message + "`r`n" + while ($CurrentException.InnerException) { + $CurrentException = $CurrentException.InnerException + $ErrorMsg += $CurrentException.Message + "`r`n" + } + + # Check if there is an issue concerning TLS. + if ($ErrorMsg -like "*SSL/TLS*") { + $ErrorMsg += "Ensure that TLS 1.2 or higher is enabled to use this script.`r`n" + } + + $DownloadException.Data["ErrorMessage"] = $ErrorMsg + throw $DownloadException + } + finally { + if ($null -ne $HttpClient) { + $HttpClient.Dispose() + } + } + } + + try { + return Invoke-With-Retry $downloadScript $cts.Token + } + finally { + if ($null -ne $cts) { + $cts.Dispose() + } + } +} + +function Resolve-Installation-Path([string]$InstallDir) { + Say-Invocation $MyInvocation + + if ($InstallDir -eq "") { + $Dir = Join-Path -Path ([Environment]::GetFolderPath('LocalApplicationData')) -ChildPath "microsoft-go" + if ($OS -ne "" -or $Architecture -ne "") { + $Dir = Join-Path -Path $Dir -ChildPath "$($CLIOS)_$CLIArchitecture" + } + return $Dir + } + return $InstallDir +} + +function Resolve-Versioned-Installation-Path([string]$InstallRoot, [string]$SpecificVersion) { + Say-Invocation $MyInvocation + + return Join-Path -Path $InstallRoot -ChildPath "go$SpecificVersion" +} + +function Is-ToolsetInstalled([string]$InstallRoot, [string]$SpecificVersion) { + Say-Invocation $MyInvocation + + $GoToolsetPath = Resolve-Versioned-Installation-Path $InstallRoot $SpecificVersion + $GoBinPath = (Join-Path $GoToolsetPath "bin") + Say-Verbose "Is-ToolsetInstalled: GoToolsetPath=$GoToolsetPath" + # A few basic checks to see if a likely usable toolset is installed. + # If these fail, it will be reinstalled. + return (Test-Path $GoToolsetPath -PathType Container) -and + ( + (Test-Path (Join-Path $GoBinPath "go") -PathType Leaf) -or + (Test-Path (Join-Path $GoBinPath "go.exe") -PathType Leaf) + ) +} + +function Get-Absolute-Path([string]$RelativeOrAbsolutePath) { + # Too much spam + # Say-Invocation $MyInvocation + + return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RelativeOrAbsolutePath) +} + +function Extract-Zip([string]$ArchivePath, [string]$OutPath) { + Say-Invocation $MyInvocation + + Load-Assembly -Assembly System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($ArchivePath, $OutPath) +} + +function Extract-TarGz([string]$ArchivePath, [string]$OutPath) { + Say-Invocation $MyInvocation + + if (-not (Test-Path $OutPath)) { + New-Item -ItemType Directory -Force -Path $OutPath + } + + try { + & tar -C $OutPath -xzf $ArchivePath + if ($LASTEXITCODE -ne 0) { + throw "tar exit code: $LASTEXITCODE" + } + } + catch { + throw "Failed to extract the tar.gz archive `"$ArchivePath`". Error: $_" + } +} + +function Extract-ToolsetArchive([string]$ArchivePath, [string]$InstallRoot, [string]$SpecificVersion) { + Say-Invocation $MyInvocation + + $GoRootPath = Resolve-Versioned-Installation-Path $InstallRoot $SpecificVersion + # First extract to a temporary directory to avoid partial extraction to the final location. This + # makes it so rerunning the script fixes a problem in case of an interruption. Don't use + # systemwide temp directory because Move-Item from there has been observed to fail on Linux. + $TempGoExtractDir = Join-Path $InstallRoot ".tmp-extract" + $TempGoRootPath = Resolve-Versioned-Installation-Path $TempGoExtractDir $SpecificVersion + + # Clean up directories from a previous attempt. + if (Test-Path $GoRootPath) { + Remove-Item $GoRootPath -Recurse -Force + } + if (Test-Path $TempGoExtractDir) { + Remove-Item $TempGoExtractDir -Recurse -Force + } + if (Test-Path $TempGoRootPath) { + Remove-Item $TempGoRootPath -Recurse -Force + } + + try { + switch ([System.IO.Path]::GetExtension($ArchivePath).ToLowerInvariant()) { + ".zip" { Extract-Zip $ArchivePath $TempGoRootPath } + ".gz" { Extract-TarGz $ArchivePath $TempGoRootPath } + default { throw "Unsupported archive type: $ArchivePath" } + } + + # Move contents of inner "go" dir to the output path to avoid unwanted extra dir. + Move-Item (Join-Path $TempGoRootPath "go") $GoRootPath + + $GoRootPath = "" + } + finally { + if ($GoRootPath -ne "" -and (Test-Path $GoRootPath)) { + Remove-Item $GoRootPath -Recurse -Force + } + if (Test-Path $TempGoExtractDir) { + Remove-Item $TempGoExtractDir -Recurse -Force + } + if (Test-Path $TempGoRootPath) { + Remove-Item $TempGoRootPath -Recurse -Force + } + } +} + +function DownloadJson([string]$Source) { + $Text = DownloadString $Source + + try { + return ConvertFrom-Json $Text + } + catch { + Say-Verbose "Failed to parse the JSON response from '$Source': $Text" + throw $_ + } +} + +function DownloadString([string]$Source) { + $Stream = $null + $Reader = $null + + # To make sure errors are accurate and useful, attempt to get the target first. This prevents a + # situation where we succesfully download bing.com after a failed redirect, try to parse the + # HTML as JSON, and present a confusing error message. + if ($Source -like "https://aka.ms/*") { + $DirectSource = Get-AkaMSRedirectTarget $Source + if (!$DirectSource) { + throw "Failed to aka.ms redirect for URL: $Source" + } + $Source = $DirectSource + } + + try { + $Response = GetHTTPResponse -Uri $Source + $Stream = $Response.Content.ReadAsStreamAsync().Result + $Reader = New-Object System.IO.StreamReader($Stream) + return $Reader.ReadToEnd() + } + finally { + if ($null -ne $Stream) { + $Stream.Dispose() + } + if ($null -ne $Reader) { + $Reader.Dispose() + } + } +} + +function DownloadFile($Source, [string]$OutPath) { + if ($Source -notlike "http*") { + # Using System.IO.Path.GetFullPath to get the current directory + # does not work in this context - $pwd gives the current directory + if (![System.IO.Path]::IsPathRooted($Source)) { + $Source = $(Join-Path -Path $pwd -ChildPath $Source) + } + $Source = Get-Absolute-Path $Source + Say "Copying file from $Source to $OutPath" + Copy-Item $Source $OutPath + return + } + + $Stream = $null + + try { + $Response = GetHTTPResponse -Uri $Source + $Stream = $Response.Content.ReadAsStreamAsync().Result + $File = [System.IO.File]::Create($OutPath) + $Stream.CopyTo($File) + $File.Close() + + ValidateRemoteLocalFileSizes -LocalFileOutPath $OutPath -SourceUri $Source + } + finally { + if ($null -ne $Stream) { + $Stream.Dispose() + } + } +} + +function ValidateRemoteLocalFileSizes([string]$LocalFileOutPath, $SourceUri) { + try { + $remoteFileSize = Get-Remote-File-Size -zipUri $SourceUri + $fileSize = [long](Get-Item $LocalFileOutPath).Length + Say "Downloaded file $SourceUri size is $fileSize bytes." + + if ((![string]::IsNullOrEmpty($remoteFileSize)) -and !([string]::IsNullOrEmpty($fileSize)) ) { + if ($remoteFileSize -ne $fileSize) { + Say "The remote and local file sizes are not equal. Remote file size is $remoteFileSize bytes and local size is $fileSize bytes. The local package may be corrupted." + } + else { + Say "The remote and local file sizes are equal." + } + } + else { + Say "Either downloaded or local package size can not be measured. One of them may be corrupted." + } + } + catch { + Say "Either downloaded or local package size can not be measured. One of them may be corrupted." + } +} + +function Remove-FileSafely($Path) { + try { + if (Test-Path $Path) { + Remove-Item $Path + Say-Verbose "The temporary file `"$Path`" was removed." + } + else { + Say-Verbose "The temporary file `"$Path`" does not exist, therefore is not removed." + } + } + catch { + Say-Warning "Failed to remove the temporary file: `"$Path`", remove it manually." + } +} + +function Prepend-ToolsetPathEnv([string]$InstallRoot, [string]$SpecificVersion) { + Say-Invocation $MyInvocation + + $GoRootPath = Resolve-Versioned-Installation-Path $InstallRoot $SpecificVersion + $BinPath = Get-Absolute-Path (Join-Path -Path $GoRootPath -ChildPath "bin") + + if (-Not $NoPath) { + $SuffixedBinPath = $BinPath + [System.IO.Path]::PathSeparator + if (-Not $env:PATH.Contains($SuffixedBinPath)) { + Say "Adding to current process PATH: $BinPath" + Say "Note: This change will not be visible if PowerShell was run as a child process." + $env:PATH = $SuffixedBinPath + $env:PATH + Say-Verbose "The current process PATH is now `"$env:PATH`"." + } + else { + Say "Current process PATH already contains `"$BinPath`"" + } + } + else { + Say "Binaries can be found in $BinPath" + } + + if ($AzurePipelinePath) { + Say "Running an Azure Pipelines logging command to prepend `"$BinPath`" to the PATH." + Say "##vso[task.prependpath]$BinPath" + } + + if ($GitHubActionsPath) { + Say "Appending `"$BinPath`" to the GITHUB_PATH file." + $BinPath | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + } +} + +function PrintDryRunOutput($Invocation) { + $RepeatableCommand = ".\$ScriptName -Version `"go$SpecificVersion`" -InstallDir `"$InstallRoot`" -OS `"$CLIOS`" -Architecture `"$CLIArchitecture`"" + + foreach ($key in $Invocation.BoundParameters.Keys) { + if (-not (@("Version","InstallDir","OS","Architecture","DryRun") -contains $key)) { + $RepeatableCommand+=" -$key `"$($Invocation.BoundParameters[$key])`"" + } + } + Say "Repeatable invocation: $RepeatableCommand" +} + +function Get-AkaMSRedirectTarget([string] $akaMsLink) { + $akaMsDownloadLink=$null + + for ($maxRedirections = 9; $maxRedirections -ge 0; $maxRedirections--) + { + #get HTTP response + #do not pass credentials as a part of the $akaMsLink and do not apply credentials in the GetHTTPResponse function + #otherwise the redirect link would have credentials as well + #it would result in applying credentials twice to the resulting link and thus breaking it, and in echoing credentials to the output as a part of redirect link + $Response= GetHTTPResponse -Uri $akaMsLink -HeaderOnly $true -DisableRedirect $true -DisableFeedCredential $true + Say-Verbose "Received response:`n$Response" + + if ([string]::IsNullOrEmpty($Response)) { + Say-Verbose "The link '$akaMsLink' is not valid: failed to get redirect location. The resource is not available." + return $null + } + + #if HTTP code is 301 (Moved Permanently), the redirect link exists + if ($Response.StatusCode -eq 301) + { + try { + $akaMsDownloadLink = $Response.Headers.GetValues("Location")[0] + + if ([string]::IsNullOrEmpty($akaMsDownloadLink)) { + Say-Verbose "The link '$akaMsLink' is not valid: server returned 301 (Moved Permanently), but the headers do not contain the redirect location." + return $null + } + + Say-Verbose "The redirect location retrieved: '$akaMsDownloadLink'." + # This may yet be a link to another redirection. Attempt to retrieve the page again. + $akaMsLink = $akaMsDownloadLink + continue + } + catch { + Say-Verbose "The link '$akaMsLink' is not valid: failed to get redirect location." + return $null + } + } + elseif ((($Response.StatusCode -lt 300) -or ($Response.StatusCode -ge 400)) -and (-not [string]::IsNullOrEmpty($akaMsDownloadLink))) + { + # Redirections have ended. + return $akaMsDownloadLink + } + + Say-Verbose "The link '$akaMsLink' is not valid: failed to retrieve the redirection location." + return $null + } + + Say-Verbose "Aka.ms links have redirected more than the maximum allowed redirections. This may be caused by a cyclic redirection of aka.ms links." + return $null +} + +# Strict mode means attempting to access a JSON key that doesn't exist fails harshly. +# This utility helps make JSON access a bit more concise under those rules. +# https://github.com/PowerShell/PowerShell/issues/10875 +function Get-OrNull($Target, $Property) { + if ($Target -and $Target.PSObject.Properties[$Property]) { + return $Target.PSObject.Properties[$Property].Value + } + return $null +} + +function Get-AssetInformation([string]$NormalizedVersion, [string]$OS, [string]$Architecture) { + Say-Invocation $MyInvocation + + #construct aka.ms link like "https://aka.ms/golang/release/latest/go1.23.assets.json" + $AkaMsLink = "https://aka.ms/golang/release/latest" + $AkaMsLink +="/$NormalizedVersion.assets.json" + Say-Verbose "Constructed assets.json aka.ms link: '$AkaMsLink'." + + $Assets = DownloadJson $AkaMsLink + $MatchingArches = @($Assets.arches | Where-Object { + $Env = Get-OrNull $_ 'env' + return (Get-OrNull $Env 'GOOS') -eq $OS -and + (Get-OrNull $Env 'GOARCH') -eq $Architecture + }) + + foreach ($arch in $MatchingArches) { + Say-Verbose "Matching env '$($arch.env)'." + } + + if ($MatchingArches.Count -ne 1) { + throw "Failed to find exactly one matching asset for OS '$OS' and architecture '$Architecture'." + } + + return ($MatchingArches[0], $Assets.version) +} + +function Prepare-Install-Directory { + New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null +} + +# The following marker is used by microsoft/go-infra tests to insert more logic that runs before any +# installation happens and may stop the script before installation. This allows unit testing without +# adding additional inputs and complexity only used by tests. + +# [END OF FUNCTIONS] + +if ($Help) { + Get-Help $PSCommandPath -Examples + exit +} + +Say "Microsoft build of Go Install Script version $MicrosoftGoInstallScriptVersion" + +Say-Verbose "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" +Say-Verbose "- The toolset needs to be installed without user interaction and without admin rights." +Say-Verbose "- The toolset installation doesn't need to persist across multiple CI runs." +Say-Verbose "Visit https://github.com/microsoft/go for a list of other ways to install Microsoft build of Go.`r`n" + +Measure-Action "Product discovery" { + $script:CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture + $script:CLIOS = Get-CLIOS-From-OS $OS + $script:NormalizedVersion = Get-NormalizedVersion $Version + Say-Verbose "Normalized version: '$NormalizedVersion'" +} + +if ($ArchivePath -eq "") { + $ArchivePath = Get-GeneratedArchivePath $CLIOS + Say-Verbose "Generated archive path: $ArchivePath" +} + +$InstallRoot = Resolve-Installation-Path $InstallDir +Say-Verbose "InstallRoot: $InstallRoot" + +$ScriptName = $MyInvocation.MyCommand.Name + +Say "Fetching information for version '$Version'." +($Arch, $SpecificVersion) = Get-AssetInformation $NormalizedVersion $CLIOS $CLIArchitecture + +$DownloadLink = $Arch.url +Say-Verbose "Found download link $DownloadLink with version $SpecificVersion" + +if (-Not $DryRun) { + Say-Verbose "Checking if the version $SpecificVersion is already installed" + if (Is-ToolsetInstalled -InstallRoot $InstallRoot -SpecificVersion $SpecificVersion) { + Say "Microsoft build of Go version '$SpecificVersion' is already installed." + Measure-Action "Setting up shell environment" { Prepend-ToolsetPathEnv -InstallRoot $InstallRoot -SpecificVersion $SpecificVersion } + return + } +} + +if ($DryRun) { + PrintDryRunOutput $MyInvocation + return +} + +Measure-Action "Installation directory preparation" { Prepare-Install-Directory } + +Say-Verbose "Zip path: $ArchivePath" + +Say-Verbose "Downloading link $DownloadLink" + +try { + Measure-Action "Package download" { DownloadFile -Source $DownloadLink -OutPath $ArchivePath } + Say-Verbose "Download succeeded." +} +catch { + $StatusCode = $null + $ErrorMessage = $null + + if ($PSItem.Exception.Data.Contains("StatusCode")) { + $StatusCode = $PSItem.Exception.Data["StatusCode"] + } + + if ($PSItem.Exception.Data.Contains("ErrorMessage")) { + $ErrorMessage = $PSItem.Exception.Data["ErrorMessage"] + } else { + $ErrorMessage = $PSItem.Exception.Message + } + + if (-not $KeepArchive) { + Remove-FileSafely -Path $ArchivePath + } + + throw "Downloading has failed with error:`nUri: $DownloadLink`nStatusCode: $StatusCode`nError: $ErrorMessage" +} + +Say "Extracting the archive." +Measure-Action "Archive extraction" { Extract-ToolsetArchive -ArchivePath $ArchivePath -InstallRoot $InstallRoot -SpecificVersion $SpecificVersion } + +Say-Verbose "Checking installation: version = $SpecificVersion" +$isAssetInstalled = Is-ToolsetInstalled -InstallRoot $InstallRoot -SpecificVersion $SpecificVersion + +# Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm. +if (!$isAssetInstalled) { + Say-Error "Failed to verify that the toolset was installed.`nInstallation source: $DownloadLink.`nInstallation location: $InstallRoot.`nReport the bug at https://github.com/microsoft/go/issues." + throw "Toolset with version $SpecificVersion failed to install with an unknown error." +} + +if (-not $KeepArchive) { + Remove-FileSafely -Path $ArchivePath +} + +Measure-Action "Setting up environment PATH to find 'go' command" { Prepend-ToolsetPathEnv -InstallRoot $InstallRoot -SpecificVersion $SpecificVersion } + +Say "Installed version is $SpecificVersion" +Say "Installation finished" diff --git a/.github/agents/issue-investigator.md b/.github/agents/issue-investigator.md new file mode 100644 index 0000000000..dd7138ee34 --- /dev/null +++ b/.github/agents/issue-investigator.md @@ -0,0 +1,14 @@ +--- +name: Issue Investigator +description: An expert at reproducing, investigating, and diagnosing issues +--- + +Investigate the provided issue or problem description and open a PR with your investigation notes included as an additional markdown file. If you discover the solution, you can try fixing it, but your top priority is reproducing the problem and determining the root cause. + +First try to reproduce by making a test case using existing test infrastructure, but if you can't reproduce that way, you can add a temporary test project in a separate directory and use any means necessary to reproduce. Just make sure to commit your reproduction so someone can pick up your line of investigation if needed. + +- Command-line compiler tests: `testdata/tests/cases/compiler/` +- Language server tests: `internal/fourslash/tests/` +- Unit tests: colocated with implementations + +Remember, your top goal is providing good information, not generating a production-ready fix. \ No newline at end of file diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d1d78dc6d5..27d34bb431 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -110,3 +110,4 @@ The TypeScript submodule serves as the reference implementation for behavior and - Do not add or change existing dependencies unless asked to. - Do not remove any debug assertions or panic calls. Existing assertions are never too strict or incorrect. +- Do not use the `timeout` command when running tests or other commands, unless specifically debugging a hanging issue. Commands should be run directly without timeout wrappers in normal operation. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eec6228a33..837bc3b717 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go @@ -190,13 +190,19 @@ jobs: # env: # TSGO_HEREBY_NOEMBED: ${{ (matrix.config.noembed && 'true') || 'false' }} - # steps: - # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - # - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 - # - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - # - uses: ./.github/actions/setup-go - # with: - # lint-cache: 'true' + # steps: + # - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + # with: + # large-packages: false + # docker-images: false + # swap-storage: false + # dotnet: false + # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + # - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 + # - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable + # - uses: ./.github/actions/setup-go + # with: + # lint-cache: 'true' # # Avoid duplicate PR annotations. # - if: ${{ ! matrix.config.main }} @@ -215,7 +221,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go @@ -242,126 +248,143 @@ jobs: # - run: node --experimental-strip-types ./internal/lsp/lsproto/_generate/fetchModel.mts # - run: node --experimental-strip-types ./internal/lsp/lsproto/_generate/generate.mts - # - name: Regenerate fourslash tests and update failing test list - # run: npm run updatefailing - - # - run: git add . - # - run: git diff --staged --exit-code --stat - - # tidy: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - # - uses: ./.github/actions/setup-go - - # - run: go mod tidy -diff - # - run: go -C ./_tools mod tidy -diff - - # smoke: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - # with: - # submodules: true - # - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 - # - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - # - uses: ./.github/actions/setup-go - - # # Avoid duplicate PR annotations. - # - name: Disable PR annotations - # run: | - # echo "::remove-matcher owner=eslint-compact::" - # echo "::remove-matcher owner=eslint-stylish::" - # echo "::remove-matcher owner=tsc::" - # echo "::remove-matcher owner=go::" - - # - run: npm ci - - # - run: npx hereby build --race - - # - run: npm ci && npx hereby generate-diagnostics - # working-directory: ./_submodules/TypeScript - - # - run: ./built/local/tsgo -p ./_submodules/TypeScript/src/compiler --singleThreaded - # - run: ./built/local/tsgo -p ./_submodules/TypeScript/src/compiler - - # misc: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - # - uses: ./.github/actions/setup-go - - # - run: go -C ./_tools run ./cmd/checkmodpaths $PWD - - # baselines: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - # with: - # submodules: true - # - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 - # - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - # - uses: ./.github/actions/setup-go - - # - run: npm ci - - # - name: Remove all baselines - # run: rm -rf testdata/baselines/reference - - # - name: Run tests - # run: npx hereby test &> /dev/null || exit 0 - - # - name: Accept baselines - # run: | - # npx hereby baseline-accept - # git add testdata/baselines/reference - - # - name: Run tests - # run: npx hereby test - - # - name: Check baselines - # id: check-baselines - # run: | - # function print_diff() { - # if ! git diff --staged --exit-code --quiet --diff-filter=$1; then - # echo "$2:" - # git diff --staged --name-only --diff-filter=$1 - # fi - # } - - # if ! git diff --staged --exit-code --quiet; then - # print_diff ACR "Missing baselines" - # print_diff MTUXB "Modified baselines" - # print_diff D "Unused baselines" - # git diff --staged > fix_baselines.patch - # exit 1 - # fi - - # - name: Upload baseline diff artifact - # if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }} - # uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - # with: - # name: fix_baselines.patch - # path: fix_baselines.patch - - # required: - # runs-on: ubuntu-latest - # if: ${{ always() }} - # needs: - # - baselines - # - build - # - extension - # - format - # - generate - # - lint - # - misc - # - smoke - # - test - # - tidy - - # steps: - # - name: Check required jobs - # env: - # NEEDS: ${{ toJson(needs) }} - # run: | - # ! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select((.result == "success" or .result == "skipped") | not)' +# - name: Regenerate fourslash tests and update failing test list +# run: | +# set -x +# echo "" > ./internal/fourslash/_scripts/failingTests.txt +# npm run convertfourslash >/dev/null 2>&1 || true +# npx hereby test >/dev/null || true +# npx hereby baseline-accept || true +# npm run updatefailing >/dev/null 2>&1 || true +# npx hereby baseline-accept || true +# rm -rf testdata/baselines/reference/fourslash || true +# npx hereby test >/dev/null || true +# npx hereby baseline-accept || true +# npx hereby test || true + +# - run: git add . +# - run: git diff --staged --exit-code --stat + +# tidy: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 +# - uses: ./.github/actions/setup-go + +# - run: go mod tidy -diff +# - run: go -C ./_tools mod tidy -diff + +# smoke: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 +# with: +# submodules: true +# - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 +# - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable +# - uses: ./.github/actions/setup-go + +# # Avoid duplicate PR annotations. +# - name: Disable PR annotations +# run: | +# echo "::remove-matcher owner=eslint-compact::" +# echo "::remove-matcher owner=eslint-stylish::" +# echo "::remove-matcher owner=tsc::" +# echo "::remove-matcher owner=go::" + +# - run: npm ci + +# - run: npx hereby build --race + +# - run: npm ci && npx hereby generate-diagnostics +# working-directory: ./_submodules/TypeScript + +# - run: ./built/local/tsgo -p ./_submodules/TypeScript/src/compiler --singleThreaded +# - run: ./built/local/tsgo -p ./_submodules/TypeScript/src/compiler + +# misc: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 +# - uses: ./.github/actions/setup-go + +# - run: go -C ./_tools run ./cmd/checkmodpaths $PWD + +# baselines: +# runs-on: ubuntu-latest +# steps: +# - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 +# with: +# large-packages: false +# docker-images: false +# swap-storage: false +# dotnet: false +# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 +# with: +# submodules: true +# - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 +# - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable +# - uses: ./.github/actions/setup-go + +# - run: npm ci + +# - name: Remove all baselines +# run: rm -rf testdata/baselines/reference + +# - name: Run tests +# run: npx hereby test &> /dev/null || exit 0 + +# - name: Accept baselines +# run: | +# npx hereby baseline-accept +# git add testdata/baselines/reference + +# - name: Run tests +# run: npx hereby test + +# - name: Check baselines +# id: check-baselines +# run: | +# function print_diff() { +# if ! git diff --staged --exit-code --quiet --diff-filter=$1; then +# echo "$2:" +# git diff --staged --name-only --diff-filter=$1 +# fi +# } + +# if ! git diff --staged --exit-code --quiet; then +# print_diff ACR "Missing baselines" +# print_diff MTUXB "Modified baselines" +# print_diff D "Unused baselines" +# git diff --staged > fix_baselines.patch +# exit 1 +# fi + +# - name: Upload baseline diff artifact +# if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }} +# uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 +# with: +# name: fix_baselines.patch +# path: fix_baselines.patch + +# required: +# runs-on: ubuntu-latest +# if: ${{ always() }} +# needs: +# - baselines +# - build +# - extension +# - format +# - generate +# - lint +# - misc +# - smoke +# - test +# - tidy + +# steps: +# - name: Check required jobs +# env: +# NEEDS: ${{ toJson(needs) }} +# run: | +# ! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select((.result == "success" or .result == "skipped") | not)' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 21ba9905a5..7b1341a3e3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -48,7 +48,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.29.5 + uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2 with: config-file: ./.github/codeql/codeql-configuration.yml # Override language selection by uncommenting this and choosing your languages @@ -58,7 +58,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below). - name: Autobuild - uses: github/codeql-action/autobuild@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.29.5 + uses: github/codeql-action/autobuild@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -72,4 +72,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.29.5 + uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2 diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index a7f408a406..84dc543657 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -16,15 +16,24 @@ jobs: # You can define any steps you want, and they will run before the agent starts. # If you do not check out your code, Copilot will do this for you. steps: + - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + with: + large-packages: false + docker-images: false + swap-storage: false + dotnet: false - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: true - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 + with: + node-version: '>=22.16.0' - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go with: lint-cache: 'true' - run: npm i -g @playwright/mcp@0.0.28 + - run: go install golang.org/x/tools/gopls@latest - run: npm ci # pull dprint caches before network access is blocked - run: npx hereby check:format || true diff --git a/.github/workflows/create-cache.yml b/.github/workflows/create-cache.yml index 618f19422e..d1b97e8ce7 100644 --- a/.github/workflows/create-cache.yml +++ b/.github/workflows/create-cache.yml @@ -20,6 +20,8 @@ # jobs: # cache: +# if: github.repository == 'microsoft/typescript-go' + # strategy: # fail-fast: false # matrix: @@ -27,22 +29,26 @@ # - ubuntu-latest # - windows-latest # - macos-latest -# go-version: -# - '>=1.25.0' # runs-on: ${{ matrix.os }} -# steps: -# - run: git config --system core.longpaths true -# if: ${{ matrix.os == 'windows-latest' }} - -# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 -# with: -# submodules: true -# - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 -# - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - -# - uses: ./.github/actions/setup-go -# with: -# go-version: ${{ matrix.go-version }} -# create: 'true' +# steps: +# - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 +# with: +# large-packages: false +# docker-images: false +# swap-storage: false +# dotnet: false + +# - run: git config --system core.longpaths true +# if: ${{ matrix.os == 'windows-latest' }} + +# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 +# with: +# submodules: true +# - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 +# - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable + +# - uses: ./.github/actions/setup-go +# with: +# create: 'true' diff --git a/.golangci.yml b/.golangci.yml index afb62f07e9..469b2bbbb1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,7 @@ linters: - errname - errorlint - fatcontext + - forbidigo - gocheckcompilerdirectives - goprintffuncname - govet @@ -32,6 +33,7 @@ linters: - makezero - mirror - misspell + - modernize - musttag - nakedret - nolintlint @@ -70,11 +72,30 @@ linters: - pkg: 'encoding/json$' desc: 'Use "github.com/go-json-experiment/json" instead.' + forbidigo: + analyze-types: true + forbid: + - pattern: '.*' + msg: tspath should likely be used instead + pkg: ^(path|path/filepath)$ + - pattern: '.*' + msg: a host implementation should likely be used instead + pkg: ^os(/|$) + - pattern: 'GOOS' + msg: a host implementation should likely be used instead + pkg: ^runtime$ + exclusions: rules: - path: internal/fourslash/tests/gen/ linters: - misspell + - path: 'internal/(repo|testutil|testrunner|vfs|pprof|execute/tsctests|bundled)|cmd/tsgo' + text: should likely be used instead + - path: '(.+)_test\.go$' + text: should likely be used instead + - path: '_tools' + text: should likely be used instead presets: - comments diff --git a/CHANGES.md b/CHANGES.md index 619b821b82..86394dfcc0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,84 @@ -CHANGES.md lists intentional changes between the Strada (Typescript) and Corsa (Go) compilers. +CHANGES.md lists intentional changes between the Strada (TypeScript) and Corsa (Go) compilers. + +# JavaScript support + +At a high level, JavaScript support in Corsa is intended to expose TypeScript features in a .js file, working exactly as they do in TypeScript with different syntax. +This differs from Strada, which has many JavaScript features that do not exist in TypeScript at all, and quite a few differences in features that overlap. +For example, Corsa uses the same rule for checking calls in both TypeScript and JavaScript; Strada lets you skip parameters with type `any`. +And because Corsa uses the same rule for optional parameters, it fixes subtle Strada bugs with `"strict": true` in JavaScript. + +We primarily want to support people writing modern JavaScript, using things like ES modules, classes, destructuring, etc. +Not CommonJS modules and constructor functions, although those do still work. +However, we have trimmed a lot of unused or underused features. +This makes the implementation much simpler and more like TypeScript. + +The biggest single removed area is support for Closure header files--any Closure-specific features, in fact. +The tables below list removed Closure features along with the other removed features. + +Reminder: JavaScript support in TypeScript falls into three main categories: + +- JSDoc Tags +- Expando declarations +- CommonJS syntax + +An expando declaration is when you declare a property just by assigning to it, on a function, class or empty object literal: + +```js +function f() {} +f.called = false; +``` + +## JSDoc Tags and Types + +| Name | Example | Substitute | Note | +| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| UnknownType | `?` | `any` | | +| NamepathType | `Module:file~id` | `import("file").id` | TS has never had semantics for this | +| `@class` |
/** @class */
function C() {
this.p = 1
}
| Infer from this.p= or C.prototype.m= | Only inference from this.p= or C.prototype.m= is supported. | +| `@throws` | `/** @throws {E} */` | Keep the same | TS never had semantics for this | +| `@enum` |
/\** @enum {number} */
const E = { A: 1, B: 2 }
|
/** @typedef {number} E \*/
/** @type {Record} */
const E = { A: 1, B: 2 }
| Closure feature. | +| `@author` | `/** @author Finn */` | Keep the same | `@treehouse` parses as a new tag in Corsa. | +| Postfix optional type | `T?` | `T \| undefined` | This was legacy in _Closure_ | +| Postfix definite type | `T!` | `T` | This was legacy in _Closure_ | +| Uppercase synonyms | `String`, `Void`, `array` | `string`, `void`, `Array` | | +| JSDoc index signatures | `Object.` | `Record` | | +| Identifier-named typedefs | `/** @typedef {T} */ typeName;` | `/** @typedef {T} typeName */` | Closure feature. | +| Closure function syntax | `function(string): void` | `(s: string) => void` | | +| Automatic typeof insertion |
const o = { a: 1 }
/\** @type {o} */
var o2 = { a: 1 }
|
const o = { a: 1 }
/\** @type {typeof o} */
var o2 = { a: 1 }
| | +| `@typedef` nested names | `/** @typedef {1} NS.T */` | Translate to .d.ts | Also applies to `@callback` | + +## Expando declarations + +| Name | Example | Substitute | Note | +| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| Fallback initialisers | `f.x = f.x \| init` | `if (!f.x) f.x = init` | | +| Nested, undeclared expandos |
var N = {};
N.X.Y = {}
|
var N = {};
N.X = {};
N.X.Y = {}
| All intermediate expandos have to be assigned. Closure feature. | +| Constructor function whole-prototype assignment |
C.prototype = {
m: function() { }
n: function() { }
}
|
C.prototype.m = function() { }
C.prototype.n = function() { }
| Constructor function feature. See note at end. | +| Identifier declarations |
class C {
constructor() {
/\** @type {T} */
identifier;
}
}
|
class C {
/\** @type {T} */
identifier;
constructor() { }
}
| Closure feature. | +| `this` aliases |
function C() {
var that = this
that.x = 12
}
|
function C() {
this.x = 12
}
| even better:
class C { this.x = 12 } | | +| `this` alias for `globalThis` | `this.globby = true` | `globalThis.globby = true` | When used at the top level of a script | + +## CommonJS syntax + +| Name | Example | Substitute | Note | +| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | +| Nested, undeclared exports | `exports.N.X.p = 1` |
exports.N = {}
exports.N.X = {}
exports.N.X.p = 1
| Same as expando rules. | +| Ignored empty module.exports assignment | `module.exports = {}` | Delete this line | People used to write in this in case module.exports was not defined. | +| `this` alias for `module.exports` | `this.p = 1` | `exports.p = 1` | When used at the top level of a CommonJS module. | +| Multiple assignments narrow with control flow |
if (isWindows) {
exports.platform = 'win32'
} else {
exports.platform = 'posix'
}
| Keep the same in most cases | This now unions instead; most uses have the same type in both branches. | +| Single-property access `require` | `var readFile = require('fs').readFile` | `var { readFile } = require('fs')` | | +| Aliasing of `module.exports` |
var mod = module.exports
mod.x = 1
| `module.exports.x = 1` | | + +## Features yet to be implemented + +`Object.defineProperty` for CommonJS exports and expandos. The compiler treats this as an alternate to the usual assignment syntax: + +```js +function f() {} +Object.defineProperty(f, "p", { value: 1, writable: true }); +``` + +# Component-Level Changes ## Scanner @@ -24,7 +104,277 @@ JSDoc types are parsed in normal type annotation position but show a grammar err Corsa no longer parses the following JSDoc tags with a specific node type. They now parse as generic JSDocTag nodes. -1. `@class` +1. `@class`/`@constructor` 2. `@throws` 3. `@author` 4. `@enum` + +## Checker + +### Miscellaneous + +#### When `"strict": false`, Corsa no longer allows omitting arguments for parameters with type `undefined`, `unknown`, or `any`: + +```js +/** @param {unknown} x */ +function f(x) { + return x; +} +f(); // Previously allowed, now an error +``` + +`void` can still be omitted, regardless of strict mode: + +```js +/** @param {void} x */ +function f(x) { + return x; +} +f(); // Still allowed +``` + +#### Strada's JS-specific rules for inferring type arguments no longer apply in Corsa. + +Inferred type arguments may change. For example: + +```js +/** @type {any} */ +var x = { a: 1, b: 2 }; +var entries = Object.entries(x); +``` + +In Strada, `entries: Array<[string, any]>`. +In Corsa it has type `Array<[string, unknown]>`, the same as in TypeScript. + +#### Values are no longer resolved as types in JSDoc type positions. + +```js +/** @typedef {FORWARD | BACKWARD} Direction */ +const FORWARD = 1, + BACKWARD = 2; +``` + +Must now use `typeof` the same way TS does: + +```js +/** @typedef {typeof FORWARD | typeof BACKWARD} Direction */ +const FORWARD = 1, + BACKWARD = 2; +``` + +### JSDoc Types + +#### JSDoc variadic types are now only synonyms for array types. + +```js +/** @param {...number} ns */ +function sum(...ns) {} +``` + +is equivalent to + +```js +/** @param {number[]} ns */ +function sum(...ns) {} +``` + +They have no other semantics. + +#### A variadic type on a parameter no longer makes it a rest parameter. The parameter must use standard rest syntax. + +```js +/** @param {...number} ns */ +function sum(ns) {} +``` + +Must now be written as + +```js +/** @param {...number} ns */ +function sum(...ns) {} +``` + +#### The postfix `=` type no longer adds `undefined` even when `strictNullChecks` is off + +This is a bug in Strada: it adds `undefined` to the type even when `strictNullChecks` is off. +This bug is fixed in Corsa. + +```js +/** @param {number=} x */ +function f(x) { + return x; +} +``` + +will now have `x?: number` not `x?: number | undefined` with `strictNullChecks` off. +Regardless of strictness, it still makes parameters optional when used in a `@param` tag. + +### JSDoc Tags + +#### `asserts` annotation for an arrow function must be on the declaring variable, not on the arrow itself. This no longer works: + +```js +/** + * @param {A} a + * @returns { asserts a is B } + */ +const foo = (a) => { + if (/** @type { B } */ (a).y !== 0) throw TypeError(); + return undefined; +}; +``` + +And must be written like this: + +```js +/** + * @type {(a: A) => asserts a is B} + */ +const foo = (a) => { + if (/** @type { B } */ (a).y !== 0) throw TypeError(); + return undefined; +}; +``` + +This is identical to the TypeScript rule. + +#### Error messages on async functions that incorrectly return non-Promises now use the same error as TS. + +#### `@typedef` and `@callback` in a class body are no longer accessible outside the class. + +They must be moved outside the class to use them outside the class. + +#### `@class` or `@constructor` does not make a function into a constructor function. + +Corsa ignores `@class` and `@constructor`. +This makes a difference on a function without this-property assignments or associated prototype-function assignments. + +#### `@param` tags now apply to at most one function. + +If they're in a place where they could apply to multiple functions, they apply only to the first one. +If you have `"strict": true`, you will see a noImplicitAny error on the now-untyped parameters. + +```js +/** @param {number} x */ +var f = (x) => x, + g = (x) => x; +``` + +#### Optional marking on parameter names now makes the parameter both optional and undefined: + +```js +/** @param {number} [x] */ +function f(x) { + return x; +} +``` + +This behaves the same as TypeScript's `x?: number` syntax. +Strada makes the parameter optional but does not add `undefined` to the type. + +#### Type assertions with `@type` tags now prevent narrowing of the type. + +```js +/** @param {C | undefined} cu */ +function f(cu) { + if (/** @type {any} */ (cu).undeclaredProperty) { + cu; // still has type C | undefined + } +} +``` + +In Strada, `cu` incorrectly narrows to `C` inside the `if` block, unlike with TS assertion syntax. +In Corsa, the behaviour is the same between TS and JS. + +### Expandos + +#### Expando assignments of `void 0` are no longer ignored as a special case: + +```js +var o = {}; +o.y = void 0; +``` + +creates a property `y: undefined` on `o` (which will widen to `y: any` if strictNullChecks is off). + +#### A this-property expression with a type annotation in the constructor no longer creates a property: + +```js +class SharedClass { + constructor() { + /** @type {SharedId} */ + this.id; + } +} +``` + +Provide an initializer or use a property declaration in the class body: + +```js +class SharedClass1 { + /** @type {SharedId} */ + id; +} +class SharedClass2 { + constructor() { + /** @type {SharedId} */ + this.id = 1; + } +} +``` + +#### Assigning an object literal to the `prototype` property of a function no longer makes it a constructor function: + +```js +function Foo() {} +Foo.prototype = { + /** @param {number} x */ + bar(x) { + return x; + }, +}; +``` + +If you still need to use constructor functions instead of classes, you should declare methods individually on the prototype: + +```js +function Foo() {} +/** @param {number} x */ +Foo.prototype.bar = function (x) { + return x; +}; +``` + +Although classes are a much better way to write this code. + +### CommonJS + +#### Chained exports no longer work: + +```js +exports.x = exports.y = 12; +``` + +Now only exports `x`, not `y` as well. + +#### Exporting `void 0` is no longer ignored as a special case: + +```js +exports.x = void 0; +// several lines later... +exports.x = theRealExport; +``` + +This exports `x: undefined` not `x: typeof theRealExport`. + +#### Property access on `require` no longer imports a single property from a module: + +```js +const x = require("y").x; +``` + +If you can't configure your package to use ESM syntax, you can use destructuring instead: + +```js +const { x } = require("y"); +``` diff --git a/Herebyfile.mjs b/Herebyfile.mjs index 81109df321..b1b7e03b91 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -57,6 +57,7 @@ const { values: rawOptions } = parseArgs({ tests: { type: "string", short: "t" }, fix: { type: "boolean" }, debug: { type: "boolean" }, + dirty: { type: "boolean" }, insiders: { type: "boolean" }, @@ -325,6 +326,12 @@ function goTest(taskName) { async function runTests() { warnIfTypeScriptSubmoduleNotCloned(); + + if (!options.dirty) { + await rimraf(localBaseline); + await fs.promises.mkdir(localBaseline, { recursive: true }); + } + await $test`${gotestsum("tests")} ./... ${isCI ? ["--timeout=45m"] : []}`; } @@ -520,10 +527,13 @@ function baselineAcceptTask(localBaseline, refBaseline) { }; } +const localBaseline = "testdata/baselines/local/"; +const refBaseline = "testdata/baselines/reference/"; + export const baselineAccept = task({ name: "baseline-accept", description: "Makes the most recent test results the new baseline, overwriting the old baseline.", - run: baselineAcceptTask("testdata/baselines/local/", "testdata/baselines/reference/"), + run: baselineAcceptTask(localBaseline, refBaseline), }); /** @@ -1127,7 +1137,7 @@ export const buildNativePreviewPackages = task({ const readme = [ `# \`${npmPackageName}\``, "", - `This package provides ${nodeOs}-${nodeArch} support for [${packageJson.name}](https://www.npmjs.com/package/${packageJson.name}).`, + `This package provides ${nodeOs}-${nodeArch} support for [${mainNativePreviewPackage.npmPackageName}](https://www.npmjs.com/package/${mainNativePreviewPackage.npmPackageName}).`, ]; fs.promises.writeFile(path.join(npmDir, "README.md"), readme.join("\n") + "\n"); diff --git a/NOTICE.txt b/NOTICE.txt index 68395c04eb..41ef21490a 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -221,7 +221,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --------------------------------------------------------- -github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 - BSD-3-Clause +github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e - BSD-3-Clause Copyright 2010 The Go Authors @@ -251,7 +251,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --------------------------------------------------------- -golang.org/x/sync v0.17.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/sync v0.18.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang Copyright 2009 The Go Authors @@ -266,7 +266,7 @@ BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang --------------------------------------------------------- -golang.org/x/sys v0.36.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/sys v0.38.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang Copyright 2009 The Go Authors @@ -294,7 +294,7 @@ BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang --------------------------------------------------------- -golang.org/x/term v0.35.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/term v0.37.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang Copyright 2009 The Go Authors @@ -309,7 +309,7 @@ BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang --------------------------------------------------------- -golang.org/x/text v0.29.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/text v0.31.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang (c) (c) A diff --git a/README.md b/README.md index 67c0887fc5..de888a4014 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,11 @@ This is still a work in progress and is not yet at full feature parity with Type | Feature | Status | Notes | |---------|--------|-------| -| Program creation | done | Same files and module resolution as TS 5.8. Not all resolution modes supported yet. | -| Parsing/scanning | done | Exact same syntax errors as TS 5.8 | -| Commandline and `tsconfig.json` parsing | mostly done | Missing --help, --init. | -| Type resolution | done | Same types as TS 5.8. | -| Type checking | done | Same errors, locations, and messages as TS 5.8. Types printback in errors may display differently. | +| Program creation | done | Same files and module resolution as TS 5.9. Not all resolution modes supported yet. | +| Parsing/scanning | done | Exact same syntax errors as TS 5.9 | +| Commandline and `tsconfig.json` parsing | done | Done, though `tsconfig` errors may not be as helpful. | +| Type resolution | done | Same types as TS 5.9. | +| Type checking | done | Same errors, locations, and messages as TS 5.9. Types printback in errors may display differently. | | JavaScript-specific inference and JSDoc | in progress | Mostly complete, but intentionally lacking some features. Declaration emit not complete. | | JSX | done | - | | Declaration emit | in progress | Most common features are in place, but some edge cases and feature flags are still unhandled. | @@ -39,7 +39,7 @@ This is still a work in progress and is not yet at full feature parity with Type | Watch mode | prototype | Watches files and rebuilds, but no incremental rechecking. Not optimized. | | Build mode / project references | done | - | | Incremental build | done | - | -| Language service (LSP) | in progress | Some functionality (errors, hover, go to def, refs, sig help). More features coming soon. | +| Language service (LSP) | in progress | Most functionality. More features coming soon. | | API | not ready | - | Definitions: @@ -54,7 +54,7 @@ Definitions: Long-term, we expect that this repo and its contents will be merged into `microsoft/TypeScript`. As a result, the repo and issue tracker for typescript-go will eventually be closed, so treat discussions/issues accordingly. -For a list of intentional changes with respect to TypeScript 5.7, see CHANGES.md. +For a list of intentional changes with respect to TypeScript 5.9, see CHANGES.md. ## Contributing diff --git a/_build/azure-pipelines.compliance.yml b/_build/azure-pipelines.compliance.yml index 1fd082cc13..fead5613a0 100644 --- a/_build/azure-pipelines.compliance.yml +++ b/_build/azure-pipelines.compliance.yml @@ -15,7 +15,7 @@ extends: parameters: pool: name: TypeScript-AzurePipelines-EO - image: 1ESPT-Mariner2.0 + image: 1ESPT-AzureLinux3 os: linux sdl: diff --git a/_extension/package.json b/_extension/package.json index 6fd7113d63..1a1f2864a5 100644 --- a/_extension/package.json +++ b/_extension/package.json @@ -85,6 +85,12 @@ "title": "Show LSP Trace", "enablement": "typescript.native-preview.serverRunning", "category": "TypeScript Native Preview" + }, + { + "command": "typescript.native-preview.reportIssue", + "title": "Report Issue", + "enablement": "typescript.native-preview.serverRunning", + "category": "TypeScript Native Preview" } ] }, @@ -106,7 +112,7 @@ }, "devDependencies": { "@types/vscode": "^1.100.0", - "@vscode/vsce": "^3.6.2", - "esbuild": "^0.25.10" + "@vscode/vsce": "^3.7.0", + "esbuild": "^0.27.0" } } diff --git a/_extension/src/commands.ts b/_extension/src/commands.ts index 18da6a3ca1..a2e0a58065 100644 --- a/_extension/src/commands.ts +++ b/_extension/src/commands.ts @@ -34,6 +34,12 @@ export function registerLanguageCommands(context: vscode.ExtensionContext, clien disposables.push(vscode.commands.registerCommand("typescript.native-preview.showMenu", showCommands)); + disposables.push(vscode.commands.registerCommand("typescript.native-preview.reportIssue", () => { + vscode.commands.executeCommand("workbench.action.openIssueReporter", { + extensionId: "TypeScriptTeam.native-preview", + }); + })); + return disposables; } @@ -74,6 +80,11 @@ async function showCommands(): Promise { description: "Show the LSP communication trace", command: "typescript.native-preview.lsp-trace.focus", }, + { + label: "$(report) Report Issue", + description: "Report an issue with TypeScript Native Preview", + command: "typescript.native-preview.reportIssue", + }, { label: "$(stop-circle) Disable TypeScript Native Preview", description: "Switch back to the built-in TypeScript extension", diff --git a/_packages/api/test/api.test.ts b/_packages/api/test/api.test.ts index a01b029fac..1a097cf1b3 100644 --- a/_packages/api/test/api.test.ts +++ b/_packages/api/test/api.test.ts @@ -8,6 +8,7 @@ import { cast, isImportDeclaration, isNamedImports, + isStringLiteral, isTemplateHead, isTemplateMiddle, isTemplateTail, @@ -113,6 +114,31 @@ describe("SourceFile", () => { }); }); +test("unicode escapes", () => { + const srcFiles = { + "/src/1.ts": `"😃"`, + "/src/2.ts": `"\\ud83d\\ude03"`, // this is "😃" + }; + + const api = spawnAPI({ + "/tsconfig.json": "{}", + ...srcFiles, + }); + const project = api.loadProject("/tsconfig.json"); + + Object.keys(srcFiles).forEach(file => { + const sourceFile = project.getSourceFile(file); + assert.ok(sourceFile); + + sourceFile.forEachChild(function visit(node) { + if (isStringLiteral(node)) { + assert.equal(node.text, "😃"); + } + node.forEachChild(visit); + }); + }); +}); + test("Object equality", () => { const api = spawnAPI(); const project = api.loadProject("/tsconfig.json"); diff --git a/_submodules/TypeScript b/_submodules/TypeScript index 1ee9e0d9a2..9e8eaa1746 160000 --- a/_submodules/TypeScript +++ b/_submodules/TypeScript @@ -1 +1 @@ -Subproject commit 1ee9e0d9a24b629da3a8cae2748616af1dc8fc0c +Subproject commit 9e8eaa1746b0d09c3cd29048126ef9cf24f29c03 diff --git a/_tools/customlint/plugin.go b/_tools/customlint/plugin.go index d8e8a8365d..42f381f04d 100644 --- a/_tools/customlint/plugin.go +++ b/_tools/customlint/plugin.go @@ -17,6 +17,7 @@ func (f *plugin) BuildAnalyzers() ([]*analysis.Analyzer, error) { return []*analysis.Analyzer{ emptyCaseAnalyzer, shadowAnalyzer, + unexportedAPIAnalyzer, }, nil } diff --git a/_tools/customlint/testdata/shadow/shadow.go.golden b/_tools/customlint/testdata/shadow/shadow.go.golden index 4273805b91..9f390fc1b9 100644 --- a/_tools/customlint/testdata/shadow/shadow.go.golden +++ b/_tools/customlint/testdata/shadow/shadow.go.golden @@ -62,6 +62,8 @@ type isType int func F5() isType { + ~ +!!! unexportedapi: exported API references unexported identifier isType var isType isType // OK return isType } @@ -69,6 +71,8 @@ type isAlias int func F6() isAlias { + ~ +!!! unexportedapi: exported API references unexported identifier isAlias var isAlias isAlias // OK return isAlias } diff --git a/_tools/customlint/testdata/unexportedapi/unexportedapi.go b/_tools/customlint/testdata/unexportedapi/unexportedapi.go new file mode 100644 index 0000000000..c84fd2edb1 --- /dev/null +++ b/_tools/customlint/testdata/unexportedapi/unexportedapi.go @@ -0,0 +1,211 @@ +package unexportedapi + +type Foo struct { + Bar *oops +} + +type oops struct { + v int +} + +type Okay struct { + Sure int + Value ***Okay2 +} + +type Okay2 struct { + VeryGood struct{} +} + +func OkayFunc(v *Okay) *Okay2 { + if v == nil { + return nil + } + return **v.Value +} + +// Test cases for various scenarios + +// Exported function with unexported parameter type +func BadFunc(x unexported) {} + +// Exported function with unexported return type +func AnotherBadFunc() *unexported { + return nil +} + +// Exported function with unexported type in slice +func SliceFunc(x []unexported) {} + +// Exported function with unexported type in map +func MapFunc(x map[string]unexported) {} + +// Exported function with unexported type in map key +func MapKeyFunc(x map[unexported]string) {} + +// Exported function with unexported type in channel +func ChanFunc(x chan unexported) {} + +// Exported type alias to unexported type +type BadAlias = unexported + +// Exported type with unexported embedded field (OK since unexported has no exported members) +type OkayEmbed struct { + unexported +} + +// Unexported type with exported field +type unexportedWithExportedField struct { + ExportedField int +} + +// Bad - exported type embedding unexported type with exported members +type BadEmbed struct { + unexportedWithExportedField +} + +// Unexported type - should not trigger +type okayUnexported struct { + field unexported +} + +// Exported interface with unexported type in method +type BadInterface interface { + Method(x unexported) +} + +// Exported interface with unexported return type +type AnotherBadInterface interface { + Method() unexported +} + +type unexported struct { + x int +} + +// Exported function with multiple return values including unexported +func MultiReturn() (int, unexported, error) { + return 0, unexported{}, nil +} + +// Exported variable with unexported type +var BadVar unexported + +// Exported const with unexported type (should not be possible, but let's be safe) +// const BadConst unexported = unexported{} // This won't compile anyway + +// Array of unexported type +type BadArray [10]unexported + +// Exported function with variadic unexported parameter +func VariadicFunc(args ...unexported) {} + +// Exported type with method returning unexported type +type ExportedWithMethod struct{} + +func (e ExportedWithMethod) Method() unexported { + return unexported{} +} + +// Exported type with pointer receiver method returning unexported type +func (e *ExportedWithMethod) PointerMethod() *unexported { + return nil +} + +// Generic type with unexported type constraint (Go 1.18+) +type GenericExported[T any] struct { + Value T +} + +// Okay - unexported method on exported type (methods are not part of exported API unless on exported interface) +func (e ExportedWithMethod) unexportedMethod() unexported { + return unexported{} +} + +// Test variables initialized with function calls + +// Helper functions for testing +func helperReturnsExported() *Okay2 { + return &Okay2{} +} + +func helperReturnsUnexported() unexported { + return unexported{} +} + +// Okay - exported variable initialized by calling unexported function that returns exported type +var OkayVarFromUnexportedFunc = helperReturnsExported() + +// Bad - exported variable initialized by calling exported function that returns unexported type +var BadVarFromFunc = helperReturnsUnexported() + +// Okay - exported variable with explicit type (implementation doesn't matter) +var OkayVarExplicitType *Okay2 = helperReturnsExported() + +// Bad - exported variable with explicit unexported type +var BadVarExplicitType unexported = helperReturnsUnexported() + +// Test type aliases +type ( + ExportedString string + unexportedString string +) + +// Okay - exported function using exported type alias +func OkayTypeAlias(s ExportedString) {} + +// Bad - exported function using unexported type alias +func BadTypeAlias(s unexportedString) {} + +// Test unexported types with exported methods (for interface satisfaction) +type unexportedImpl struct { + value int +} + +// Okay - exported method on unexported type (not part of public API, often used for interface satisfaction) +func (u *unexportedImpl) ExportedMethod() int { + return u.value +} + +// Okay - exported method on unexported type can return unexported types +func (u *unexportedImpl) AnotherMethod() unexported { + return unexported{} +} + +// Test for avoiding duplicate errors on embedded types with methods + +type BaseWithBadMethod struct{} + +// This method has an unexported return type - should be flagged once +func (b *BaseWithBadMethod) GetUnexported() *unexported { + return nil +} + +// This type embeds BaseWithBadMethod - should NOT re-report the GetUnexported method issue +type DerivedEmbedding struct { + BaseWithBadMethod +} + +// Test embedding unexported type with exported method that references unexported type +type unexportedBase struct{} + +// This exported method on unexported type won't be checked (unexported type methods are skipped) +func (u *unexportedBase) MethodWithBadReturn() *unexported { + return nil +} + +// This embeds an unexported type - what happens? +// OK because methods on unexported types aren't checked +type EmbeddingUnexportedBase struct { + unexportedBase +} + +// Test embedding unexported type with exported field that references unexported type +type unexportedBaseWithField struct { + ExportedField *unexported +} + +// Bad - embeds unexported type with exported field that references unexported type +type EmbeddingUnexportedBaseWithField struct { + unexportedBaseWithField +} diff --git a/_tools/customlint/testdata/unexportedapi/unexportedapi.go.golden b/_tools/customlint/testdata/unexportedapi/unexportedapi.go.golden new file mode 100644 index 0000000000..1c4c011a4f --- /dev/null +++ b/_tools/customlint/testdata/unexportedapi/unexportedapi.go.golden @@ -0,0 +1,256 @@ + package unexportedapi + + type Foo struct { + Bar *oops + ~ +!!! unexportedapi: exported API references unexported identifier oops + } + + type oops struct { + v int + } + + type Okay struct { + Sure int + Value ***Okay2 + } + + type Okay2 struct { + VeryGood struct{} + } + + func OkayFunc(v *Okay) *Okay2 { + if v == nil { + return nil + } + return **v.Value + } + + // Test cases for various scenarios + + // Exported function with unexported parameter type + func BadFunc(x unexported) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported function with unexported return type + func AnotherBadFunc() *unexported { + ~ +!!! unexportedapi: exported API references unexported identifier unexported + return nil + } + + // Exported function with unexported type in slice + func SliceFunc(x []unexported) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported function with unexported type in map + func MapFunc(x map[string]unexported) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported function with unexported type in map key + func MapKeyFunc(x map[unexported]string) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported function with unexported type in channel + func ChanFunc(x chan unexported) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported type alias to unexported type + type BadAlias = unexported + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported type with unexported embedded field (OK since unexported has no exported members) + type OkayEmbed struct { + unexported + } + + // Unexported type with exported field + type unexportedWithExportedField struct { + ExportedField int + } + + // Bad - exported type embedding unexported type with exported members + type BadEmbed struct { + unexportedWithExportedField + } + + // Unexported type - should not trigger + type okayUnexported struct { + field unexported + } + + // Exported interface with unexported type in method + type BadInterface interface { + Method(x unexported) + ~ +!!! unexportedapi: exported API references unexported identifier unexported + } + + // Exported interface with unexported return type + type AnotherBadInterface interface { + Method() unexported + ~ +!!! unexportedapi: exported API references unexported identifier unexported + } + + type unexported struct { + x int + } + + // Exported function with multiple return values including unexported + func MultiReturn() (int, unexported, error) { + ~ +!!! unexportedapi: exported API references unexported identifier unexported + return 0, unexported{}, nil + } + + // Exported variable with unexported type + var BadVar unexported + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported const with unexported type (should not be possible, but let's be safe) + // const BadConst unexported = unexported{} // This won't compile anyway + + // Array of unexported type + type BadArray [10]unexported + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported function with variadic unexported parameter + func VariadicFunc(args ...unexported) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Exported type with method returning unexported type + type ExportedWithMethod struct{} + + func (e ExportedWithMethod) Method() unexported { + ~ +!!! unexportedapi: exported API references unexported identifier unexported + return unexported{} + } + + // Exported type with pointer receiver method returning unexported type + func (e *ExportedWithMethod) PointerMethod() *unexported { + ~ +!!! unexportedapi: exported API references unexported identifier unexported + return nil + } + + // Generic type with unexported type constraint (Go 1.18+) + type GenericExported[T any] struct { + Value T + } + + // Okay - unexported method on exported type (methods are not part of exported API unless on exported interface) + func (e ExportedWithMethod) unexportedMethod() unexported { + return unexported{} + } + + // Test variables initialized with function calls + + // Helper functions for testing + func helperReturnsExported() *Okay2 { + return &Okay2{} + } + + func helperReturnsUnexported() unexported { + return unexported{} + } + + // Okay - exported variable initialized by calling unexported function that returns exported type + var OkayVarFromUnexportedFunc = helperReturnsExported() + + // Bad - exported variable initialized by calling exported function that returns unexported type + var BadVarFromFunc = helperReturnsUnexported() + ~ +!!! unexportedapi: exported API references unexported type unexported + + // Okay - exported variable with explicit type (implementation doesn't matter) + var OkayVarExplicitType *Okay2 = helperReturnsExported() + + // Bad - exported variable with explicit unexported type + var BadVarExplicitType unexported = helperReturnsUnexported() + ~ +!!! unexportedapi: exported API references unexported identifier unexported + + // Test type aliases + type ( + ExportedString string + unexportedString string + ) + + // Okay - exported function using exported type alias + func OkayTypeAlias(s ExportedString) {} + + // Bad - exported function using unexported type alias + func BadTypeAlias(s unexportedString) {} + ~ +!!! unexportedapi: exported API references unexported identifier unexportedString + + // Test unexported types with exported methods (for interface satisfaction) + type unexportedImpl struct { + value int + } + + // Okay - exported method on unexported type (not part of public API, often used for interface satisfaction) + func (u *unexportedImpl) ExportedMethod() int { + return u.value + } + + // Okay - exported method on unexported type can return unexported types + func (u *unexportedImpl) AnotherMethod() unexported { + return unexported{} + } + + // Test for avoiding duplicate errors on embedded types with methods + + type BaseWithBadMethod struct{} + + // This method has an unexported return type - should be flagged once + func (b *BaseWithBadMethod) GetUnexported() *unexported { + ~ +!!! unexportedapi: exported API references unexported identifier unexported + return nil + } + + // This type embeds BaseWithBadMethod - should NOT re-report the GetUnexported method issue + type DerivedEmbedding struct { + BaseWithBadMethod + } + + // Test embedding unexported type with exported method that references unexported type + type unexportedBase struct{} + + // This exported method on unexported type won't be checked (unexported type methods are skipped) + func (u *unexportedBase) MethodWithBadReturn() *unexported { + return nil + } + + // This embeds an unexported type - what happens? + // OK because methods on unexported types aren't checked + type EmbeddingUnexportedBase struct { + ~ +!!! unexportedapi: exported API references unexported type unexported + unexportedBase + } + + // Test embedding unexported type with exported field that references unexported type + type unexportedBaseWithField struct { + ExportedField *unexported + } + + // Bad - embeds unexported type with exported field that references unexported type + type EmbeddingUnexportedBaseWithField struct { + ~ +!!! unexportedapi: exported API references unexported type unexported + unexportedBaseWithField + } + diff --git a/_tools/customlint/unexportedapi.go b/_tools/customlint/unexportedapi.go new file mode 100644 index 0000000000..aa5440a26d --- /dev/null +++ b/_tools/customlint/unexportedapi.go @@ -0,0 +1,389 @@ +package customlint + +import ( + "bytes" + "fmt" + "go/ast" + "go/format" + "go/types" + "slices" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +var unexportedAPIAnalyzer = &analysis.Analyzer{ + Name: "unexportedapi", + Doc: "finds exported APIs referencing unexported identifiers", + Requires: []*analysis.Analyzer{ + inspect.Analyzer, + }, + Run: func(pass *analysis.Pass) (any, error) { + return (&unexportedAPIPass{pass: pass}).run() + }, +} + +type unexportedAPIPass struct { + pass *analysis.Pass + file *ast.File + currDecl ast.Node + // Track which types/objects we've already checked to avoid duplicates + checked map[types.Object]bool +} + +func (u *unexportedAPIPass) run() (any, error) { + u.checked = make(map[types.Object]bool) + inspect := u.pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.File)(nil), + (*ast.FuncDecl)(nil), + (*ast.TypeSpec)(nil), + (*ast.ValueSpec)(nil), + } + + inspect.Preorder(nodeFilter, func(n ast.Node) { + u.currDecl = n + switch n := n.(type) { + case *ast.File: + u.file = n + case *ast.FuncDecl: + u.checkFuncDecl(n) + case *ast.TypeSpec: + u.checkTypeSpec(n) + case *ast.ValueSpec: + u.checkValueSpec(n) + } + }) + + return nil, nil +} + +func (u *unexportedAPIPass) checkFuncDecl(fn *ast.FuncDecl) { + if !fn.Name.IsExported() { + return + } + + // Get the method object to mark it as checked + var methodObj types.Object + if fn.Name != nil { + methodObj = u.pass.TypesInfo.Defs[fn.Name] + } + + // If this is a method on an unexported type, skip it + // Unexported types and their methods (even if exported) are not part of the public API + if fn.Recv != nil && len(fn.Recv.List) > 0 { + recvType := fn.Recv.List[0].Type + // Unwrap pointer receiver if needed + if star, ok := recvType.(*ast.StarExpr); ok { + recvType = star.X + } + // Check if the receiver type is unexported + if ident, ok := recvType.(*ast.Ident); ok && !ident.IsExported() { + return + } + } + + // Mark this method as checked so we don't check it again through embedding + if methodObj != nil { + u.checked[methodObj] = true + } + + u.checkExpr(fn.Type) +} + +func (u *unexportedAPIPass) checkTypeSpec(ts *ast.TypeSpec) { + if !ts.Name.IsExported() { + return + } + + if ts.TypeParams != nil { + for _, param := range ts.TypeParams.List { + if anyIdentExported(param.Names) { + if u.checkField(param) { + return + } + } + } + } + + u.checkExpr(ts.Type) +} + +func (u *unexportedAPIPass) checkValueSpec(vs *ast.ValueSpec) { + if !anyIdentExported(vs.Names) { + return + } + + // If there's an explicit type annotation, check it + if vs.Type != nil { + u.checkExpr(vs.Type) + return + } + + // If there's no explicit type, we need to check the inferred type, not the initialization expression + // The initialization expression is an implementation detail and not part of the API + // For example: var Foo = unexportedFunc() where unexportedFunc returns an exported type is OK + for _, name := range vs.Names { + if !name.IsExported() { + continue + } + obj := u.pass.TypesInfo.Defs[name] + if obj != nil { + if u.checkType(obj.Type()) { + return + } + } + } +} + +func anyIdentExported(idents []*ast.Ident) bool { + for _, ident := range idents { + if ident.IsExported() { + return true + } + } + return false +} + +func (u *unexportedAPIPass) checkFieldIfNamesExported(field *ast.Field) (stop bool) { + // For embedded fields (no names), handle specially + if len(field.Names) == 0 { + return u.checkEmbeddedField(field) + } + // For named fields, only check if at least one name is exported + if anyIdentExported(field.Names) { + return u.checkField(field) + } + return false +} + +func (u *unexportedAPIPass) checkEmbeddedField(field *ast.Field) (stop bool) { + if field.Type == nil { + return false + } + + // Get the type of the embedded field + typ := u.pass.TypesInfo.TypeOf(field.Type) + if typ == nil { + // Fallback to regular checking if we can't get type info + return u.checkField(field) + } + + // For embedded fields, walk through all exported members and check them. + // Use the checked map to avoid re-checking members we've already seen. + + // Dereference pointers + if ptr, ok := typ.(*types.Pointer); ok { + typ = ptr.Elem() + } + + // Check exported fields in structs + if structType, ok := typ.Underlying().(*types.Struct); ok { + for field := range structType.Fields() { + if field.Exported() && u.checkObjectType(field) { + return true + } + } + } + + // Check exported methods on the type + if named, ok := typ.(*types.Named); ok { + for method := range named.Methods() { + if method.Exported() && u.checkObjectType(method) { + return true + } + } + } + + return false +} + +// checkObjectType checks a types.Object and memoizes it to avoid duplicate checks +func (u *unexportedAPIPass) checkObjectType(obj types.Object) (stop bool) { + if obj == nil { + return false + } + + // If we've already checked this object, skip it + if u.checked[obj] { + return false + } + u.checked[obj] = true + + return u.checkType(obj.Type()) +} + +func (u *unexportedAPIPass) checkFieldsIgnoringNames(fields *ast.FieldList) (stop bool) { + if fields == nil { + return false + } + return slices.ContainsFunc(fields.List, u.checkField) +} + +func (u *unexportedAPIPass) checkField(field *ast.Field) (stop bool) { + if field.Type == nil { + return false + } + return u.checkExpr(field.Type) +} + +func (u *unexportedAPIPass) checkExpr(expr ast.Expr) (stop bool) { + if expr == nil { + return false + } + + switch expr := expr.(type) { + case *ast.StructType: + return slices.ContainsFunc(expr.Fields.List, u.checkFieldIfNamesExported) + case *ast.StarExpr: + return u.checkExpr(expr.X) + case *ast.Ident: + // First check Defs (for defining occurrences), then Uses (for referring occurrences) + obj := u.pass.TypesInfo.Defs[expr] + if obj == nil { + obj = u.pass.TypesInfo.Uses[expr] + } + if obj == nil { + return false + } + if !expr.IsExported() { + if obj.Parent() == types.Universe { + return false + } + // Only report if the unexported identifier is from the same package + if obj.Pkg() != nil && obj.Pkg() == u.pass.Pkg { + u.pass.Reportf(expr.Pos(), "exported API references unexported identifier %s", expr.Name) + return true + } + } + return u.checkType(obj.Type()) + case *ast.MapType: + return u.checkExpr(expr.Key) || u.checkExpr(expr.Value) + case *ast.ArrayType: + return u.checkExpr(expr.Len) || u.checkExpr(expr.Elt) + case *ast.SelectorExpr: + if !expr.Sel.IsExported() { + u.pass.Reportf(u.currDecl.Pos(), "exported API %s references unexported identifier %s", u.file.Name.Name, expr.Sel.Name) + return true + } + return false + case *ast.InterfaceType: + return slices.ContainsFunc(expr.Methods.List, u.checkFieldIfNamesExported) + case *ast.ChanType: + return u.checkExpr(expr.Value) + case *ast.FuncType: + return u.checkFieldsIgnoringNames(expr.TypeParams) || + u.checkFieldsIgnoringNames(expr.Params) || + u.checkFieldsIgnoringNames(expr.Results) + case *ast.Ellipsis: + return u.checkExpr(expr.Elt) + case *ast.CompositeLit: + return u.checkExpr(expr.Type) + case *ast.IndexListExpr: + return u.checkExpr(expr.X) || slices.ContainsFunc(expr.Indices, u.checkExpr) + case *ast.IndexExpr: + return u.checkExpr(expr.X) || u.checkExpr(expr.Index) + case *ast.UnaryExpr: + return u.checkExpr(expr.X) + case *ast.BinaryExpr: + return u.checkExpr(expr.X) || u.checkExpr(expr.Y) + case *ast.BasicLit: + return false + case *ast.CallExpr: + // For call expressions, check the function being called + // We don't check arguments since those are values, not types in the API + return u.checkExpr(expr.Fun) + case *ast.FuncLit: + // Function literals - check the function type + return u.checkExpr(expr.Type) + case *ast.ParenExpr: + return u.checkExpr(expr.X) + default: + var buf bytes.Buffer + _ = format.Node(&buf, u.pass.Fset, expr) + panic(fmt.Sprintf("%T, unhandled case %T: %s", u.currDecl, expr, buf.String())) + } +} + +func (u *unexportedAPIPass) checkType(typ types.Type) (stop bool) { + if typ == nil { + return false + } + + switch typ := typ.(type) { + case *types.Named: + // Check if the named type itself is unexported + obj := typ.Obj() + if obj != nil && !obj.Exported() && obj.Pkg() == u.pass.Pkg { + u.pass.Reportf(u.currDecl.Pos(), "exported API references unexported type %s", obj.Name()) + return true + } + // Check type arguments if any (for generics) + if typ.TypeArgs() != nil { + for t := range typ.TypeArgs().Types() { + if u.checkType(t) { + return true + } + } + } + return false + case *types.Pointer: + return u.checkType(typ.Elem()) + case *types.Slice: + return u.checkType(typ.Elem()) + case *types.Array: + return u.checkType(typ.Elem()) + case *types.Chan: + return u.checkType(typ.Elem()) + case *types.Map: + return u.checkType(typ.Key()) || u.checkType(typ.Elem()) + case *types.Signature: + // Check parameters + if typ.Params() != nil { + for v := range typ.Params().Variables() { + if u.checkType(v.Type()) { + return true + } + } + } + // Check results + if typ.Results() != nil { + for v := range typ.Results().Variables() { + if u.checkType(v.Type()) { + return true + } + } + } + return false + case *types.Struct: + // Check all fields + for field := range typ.Fields() { + // Only check exported fields + if field.Exported() { + if u.checkType(field.Type()) { + return true + } + } + } + return false + case *types.Interface: + // Check all methods + for method := range typ.Methods() { + // Only check exported methods + if method.Exported() { + if u.checkType(method.Type()) { + return true + } + } + } + return false + case *types.Basic, *types.TypeParam: + // Basic types and type parameters are always OK + return false + default: + // For any unhandled type, be conservative and don't report + return false + } +} diff --git a/_tools/go.mod b/_tools/go.mod index be2523d4e5..a030c40db3 100644 --- a/_tools/go.mod +++ b/_tools/go.mod @@ -4,12 +4,12 @@ go 1.25 require ( github.com/golangci/plugin-module-register v0.1.2 - golang.org/x/mod v0.28.0 - golang.org/x/tools v0.37.0 + golang.org/x/mod v0.30.0 + golang.org/x/tools v0.39.0 gotest.tools/v3 v3.5.2 ) require ( github.com/google/go-cmp v0.6.0 // indirect - golang.org/x/sync v0.17.0 // indirect + golang.org/x/sync v0.18.0 // indirect ) diff --git a/_tools/go.sum b/_tools/go.sum index 10687374b2..2417d167bd 100644 --- a/_tools/go.sum +++ b/_tools/go.sum @@ -2,11 +2,11 @@ github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3H github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= -golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= -golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= diff --git a/cmd/tsgo/lsp.go b/cmd/tsgo/lsp.go index 35c973a3a0..0dd04c57fb 100644 --- a/cmd/tsgo/lsp.go +++ b/cmd/tsgo/lsp.go @@ -1,10 +1,14 @@ package main import ( + "context" "flag" "fmt" "os" + "os/exec" + "os/signal" "runtime" + "syscall" "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/core" @@ -49,9 +53,17 @@ func runLSP(args []string) int { FS: fs, DefaultLibraryPath: defaultLibraryPath, TypingsLocation: typingsLocation, + NpmInstall: func(cwd string, args []string) ([]byte, error) { + cmd := exec.Command("npm", args...) + cmd.Dir = cwd + return cmd.Output() + }, }) - if err := s.Run(); err != nil { + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + if err := s.Run(ctx); err != nil { return 1 } return 0 diff --git a/go.mod b/go.mod index 8f5243215c..cbad191cae 100644 --- a/go.mod +++ b/go.mod @@ -4,22 +4,22 @@ go 1.25 require ( github.com/dlclark/regexp2 v1.11.5 - github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 + github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e github.com/google/go-cmp v0.7.0 github.com/peter-evans/patience v0.3.0 github.com/zeebo/xxh3 v1.0.2 - golang.org/x/sync v0.17.0 - golang.org/x/sys v0.36.0 - golang.org/x/term v0.35.0 - golang.org/x/text v0.29.0 + golang.org/x/sync v0.18.0 + golang.org/x/sys v0.38.0 + golang.org/x/term v0.37.0 + golang.org/x/text v0.31.0 gotest.tools/v3 v3.5.2 ) require ( github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/matryer/moq v0.6.0 // indirect - golang.org/x/mod v0.27.0 // indirect - golang.org/x/tools v0.36.0 // indirect + golang.org/x/mod v0.29.0 // indirect + golang.org/x/tools v0.38.0 // indirect mvdan.cc/gofumpt v0.9.1 // indirect ) diff --git a/go.sum b/go.sum index 78724d28be..9d97697342 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 h1:02WINGfSX5w0Mn+F28UyRoSt9uvMhKguwWMlOAh6U/0= -github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3/go.mod h1:uNVvRXArCGbZ508SxYYTC5v1JWoz2voff5pm25jU1Ok= +github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e h1:Lf/gRkoycfOBPa42vU2bbgPurFong6zXeFtPoxholzU= +github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e/go.mod h1:uNVvRXArCGbZ508SxYYTC5v1JWoz2voff5pm25jU1Ok= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -24,18 +24,18 @@ github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= -golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= -golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= -golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= -golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= +golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= +golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= mvdan.cc/gofumpt v0.9.1 h1:p5YT2NfFWsYyTieYgwcQ8aKV3xRvFH4uuN/zB2gBbMQ= diff --git a/internal/api/encoder/encoder_test.go b/internal/api/encoder/encoder_test.go index 4d1be79d36..232c0fec37 100644 --- a/internal/api/encoder/encoder_test.go +++ b/internal/api/encoder/encoder_test.go @@ -35,6 +35,24 @@ func TestEncodeSourceFile(t *testing.T) { }) } +func TestEncodeSourceFileWithUnicodeEscapes(t *testing.T) { + t.Parallel() + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, `let a = "😃"; let b = "\ud83d\ude03"; let c = "\udc00\ud83d\ude03"; let d = "\ud83d\ud83d\ude03"`, core.ScriptKindTS) + t.Run("baseline", func(t *testing.T) { + t.Parallel() + buf, err := encoder.EncodeSourceFile(sourceFile, "") + assert.NilError(t, err) + + str := formatEncodedSourceFile(buf) + baseline.Run(t, "encodeSourceFileWithUnicodeEscapes.txt", str, baseline.Options{ + Subfolder: "api", + }) + }) +} + func BenchmarkEncodeSourceFile(b *testing.B) { repo.SkipIfNoTypeScriptSubmodule(b) filePath := filepath.Join(repo.TypeScriptSubmodulePath, "src/compiler/checker.ts") diff --git a/internal/api/server.go b/internal/api/server.go index e80458f445..3cb37c8579 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -19,6 +19,7 @@ import ( "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/packagejson" @@ -157,8 +158,8 @@ func (h *hostWrapper) SeenFiles() *collections.SyncSet[tspath.Path] { } // Trace implements project.ProjectHost. -func (h *hostWrapper) Trace(msg string) { - h.inner.Trace(msg) +func (h *hostWrapper) Trace(msg *diagnostics.Message, args ...any) { + h.inner.Trace(msg, args...) } // UpdateSeenFiles implements project.ProjectHost. @@ -290,7 +291,7 @@ func (r *resolverWrapper) GetPackageScopeForPath(directory string) *packagejson. } // ResolveModuleName implements module.ResolverInterface. -func (r *resolverWrapper) ResolveModuleName(moduleName string, containingFile string, importAttributeType *string, resolutionMode core.ResolutionMode, redirectedReference module.ResolvedProjectReference) (*module.ResolvedModule, []string) { +func (r *resolverWrapper) ResolveModuleName(moduleName string, containingFile string, importAttributeType *string, resolutionMode core.ResolutionMode, redirectedReference module.ResolvedProjectReference) (*module.ResolvedModule, []module.DiagAndArgs) { if r.server.CallbackEnabled(CallbackResolveModuleName) { result, err := r.server.call("resolveModuleName", map[string]any{ "moduleName": moduleName, @@ -314,7 +315,7 @@ func (r *resolverWrapper) ResolveModuleName(moduleName string, containingFile st } // ResolveTypeReferenceDirective implements module.ResolverInterface. -func (r *resolverWrapper) ResolveTypeReferenceDirective(typeReferenceDirectiveName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference module.ResolvedProjectReference) (*module.ResolvedTypeReferenceDirective, []string) { +func (r *resolverWrapper) ResolveTypeReferenceDirective(typeReferenceDirectiveName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference module.ResolvedProjectReference) (*module.ResolvedTypeReferenceDirective, []module.DiagAndArgs) { if r.server.CallbackEnabled(CallbackResolveTypeReferenceDirective) { result, err := r.server.call("resolveTypeReferenceDirective", map[string]any{ "typeReferenceDirectiveName": typeReferenceDirectiveName, diff --git a/internal/api/stringer_generated.go b/internal/api/stringer_generated.go index 0a740d353b..fab0c57d13 100644 --- a/internal/api/stringer_generated.go +++ b/internal/api/stringer_generated.go @@ -22,8 +22,9 @@ const _MessageType_name = "MessageTypeUnknownMessageTypeRequestMessageTypeCallRe var _MessageType_index = [...]uint8{0, 18, 36, 59, 79, 98, 114, 129} func (i MessageType) String() string { - if i >= MessageType(len(_MessageType_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_MessageType_index)-1 { return "MessageType(" + strconv.FormatInt(int64(i), 10) + ")" } - return _MessageType_name[_MessageType_index[i]:_MessageType_index[i+1]] + return _MessageType_name[_MessageType_index[idx]:_MessageType_index[idx+1]] } diff --git a/internal/ast/ast.go b/internal/ast/ast.go index fb91b32bf6..1ea7ed0b4c 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -24,7 +24,7 @@ func visit(v Visitor, node *Node) bool { } func visitNodes(v Visitor, nodes []*Node) bool { - for _, node := range nodes { + for _, node := range nodes { //nolint:modernize if v(node) { return true } @@ -266,10 +266,10 @@ func (n *Node) TemplateLiteralLikeData() *TemplateLiteralLikeBase { func (n *Node) KindString() string { return n.Kind.String() } func (n *Node) KindValue() int16 { return int16(n.Kind) } -type mutableNode Node +type MutableNode Node -func (n *Node) AsMutable() *mutableNode { return (*mutableNode)(n) } -func (n *mutableNode) SetModifiers(modifiers *ModifierList) { n.data.setModifiers(modifiers) } +func (n *Node) AsMutable() *MutableNode { return (*MutableNode)(n) } +func (n *MutableNode) SetModifiers(modifiers *ModifierList) { n.data.setModifiers(modifiers) } func (n *Node) Symbol() *Symbol { data := n.DeclarationData() @@ -420,7 +420,19 @@ func (n *Node) Expression() *Node { panic("Unhandled case in Node.Expression: " + n.Kind.String()) } -func (m *mutableNode) SetExpression(expr *Node) { +func (n *Node) RawText() string { + switch n.Kind { + case KindTemplateHead: + return n.AsTemplateHead().RawText + case KindTemplateMiddle: + return n.AsTemplateMiddle().RawText + case KindTemplateTail: + return n.AsTemplateTail().RawText + } + panic("Unhandled case in Node.RawText: " + n.Kind.String()) +} + +func (m *MutableNode) SetExpression(expr *Node) { n := (*Node)(m) switch n.Kind { case KindPropertyAccessExpression: @@ -611,6 +623,8 @@ func (n *Node) StatementList() *NodeList { return n.AsBlock().Statements case KindModuleBlock: return n.AsModuleBlock().Statements + case KindCaseClause, KindDefaultClause: + return n.AsCaseOrDefaultClause().Statements } panic("Unhandled case in Node.StatementList: " + n.Kind.String()) } @@ -623,6 +637,15 @@ func (n *Node) Statements() []*Node { return nil } +func (n *Node) CanHaveStatements() bool { + switch n.Kind { + case KindSourceFile, KindBlock, KindModuleBlock, KindCaseClause, KindDefaultClause: + return true + default: + return false + } +} + func (n *Node) ModifierFlags() ModifierFlags { modifiers := n.Modifiers() if modifiers != nil { @@ -701,7 +724,7 @@ func (n *Node) Type() *Node { return nil } -func (m *mutableNode) SetType(t *Node) { +func (m *MutableNode) SetType(t *Node) { n := (*Node)(m) switch m.Kind { case KindVariableDeclaration: @@ -793,7 +816,7 @@ func (n *Node) Initializer() *Node { panic("Unhandled case in Node.Initializer") } -func (m *mutableNode) SetInitializer(initializer *Node) { +func (m *MutableNode) SetInitializer(initializer *Node) { n := (*Node)(m) switch n.Kind { case KindVariableDeclaration: @@ -1032,6 +1055,10 @@ func (n *Node) Statement() *Statement { return n.AsForStatement().Statement case KindForInStatement, KindForOfStatement: return n.AsForInOrOfStatement().Statement + case KindWithStatement: + return n.AsWithStatement().Statement + case KindLabeledStatement: + return n.AsLabeledStatement().Statement } panic("Unhandled case in Node.Statement: " + n.Kind.String()) } @@ -1062,8 +1089,11 @@ func (n *Node) ElementList() *NodeList { return n.AsNamedExports().Elements case KindObjectBindingPattern, KindArrayBindingPattern: return n.AsBindingPattern().Elements + case KindArrayLiteralExpression: + return n.AsArrayLiteralExpression().Elements + case KindTupleType: + return n.AsTupleTypeNode().Elements } - panic("Unhandled case in Node.ElementList: " + n.Kind.String()) } @@ -1075,22 +1105,22 @@ func (n *Node) Elements() []*Node { return nil } -func (n *Node) postfixToken() *Node { +func (n *Node) PostfixToken() *Node { switch n.Kind { - case KindEnumMember: - return n.AsEnumMember().PostfixToken - case KindPropertyAssignment: - return n.AsPropertyAssignment().PostfixToken + case KindMethodDeclaration: + return n.AsMethodDeclaration().PostfixToken case KindShorthandPropertyAssignment: return n.AsShorthandPropertyAssignment().PostfixToken + case KindMethodSignature: + return n.AsMethodSignatureDeclaration().PostfixToken case KindPropertySignature: return n.AsPropertySignatureDeclaration().PostfixToken + case KindPropertyAssignment: + return n.AsPropertyAssignment().PostfixToken case KindPropertyDeclaration: return n.AsPropertyDeclaration().PostfixToken - case KindMethodSignature: - return n.AsMethodSignatureDeclaration().PostfixToken - case KindMethodDeclaration: - return n.AsMethodDeclaration().PostfixToken + case KindEnumMember: + return n.AsEnumMember().PostfixToken case KindGetAccessor: return n.AsGetAccessorDeclaration().PostfixToken case KindSetAccessor: @@ -1110,7 +1140,7 @@ func (n *Node) QuestionToken() *TokenNode { case KindNamedTupleMember: return n.AsNamedTupleMember().QuestionToken } - postfix := n.postfixToken() + postfix := n.PostfixToken() if postfix != nil && postfix.Kind == KindQuestionToken { return postfix } @@ -1157,26 +1187,6 @@ func (n *Node) ClassName() *Node { panic("Unhandled case in Node.ClassName: " + n.Kind.String()) } -func (n *Node) PostfixToken() *Node { - switch n.Kind { - case KindParameter: - return n.AsParameterDeclaration().QuestionToken - case KindMethodDeclaration: - return n.AsMethodDeclaration().PostfixToken - case KindShorthandPropertyAssignment: - return n.AsShorthandPropertyAssignment().PostfixToken - case KindMethodSignature: - return n.AsMethodSignatureDeclaration().PostfixToken - case KindPropertySignature: - return n.AsPropertySignatureDeclaration().PostfixToken - case KindPropertyAssignment: - return n.AsPropertyAssignment().PostfixToken - case KindPropertyDeclaration: - return n.AsPropertyDeclaration().PostfixToken - } - return nil -} - // Determines if `n` contains `descendant` by walking up the `Parent` pointers from `descendant`. This method panics if // `descendant` or one of its ancestors is not parented except when that node is a `SourceFile`. func (n *Node) Contains(descendant *Node) bool { @@ -2065,59 +2075,63 @@ type NodeBase struct { // Aliases for Node unions type ( - Statement = Node // Node with StatementBase - Declaration = Node // Node with DeclarationBase - Expression = Node // Node with ExpressionBase - TypeNode = Node // Node with TypeNodeBase - TypeElement = Node // Node with TypeElementBase - ClassElement = Node // Node with ClassElementBase - NamedMember = Node // Node with NamedMemberBase - ObjectLiteralElement = Node // Node with ObjectLiteralElementBase - BlockOrExpression = Node // Block | Expression - AccessExpression = Node // PropertyAccessExpression | ElementAccessExpression - DeclarationName = Node // Identifier | PrivateIdentifier | StringLiteral | NumericLiteral | BigIntLiteral | NoSubstitutionTemplateLiteral | ComputedPropertyName | BindingPattern | ElementAccessExpression - ModuleName = Node // Identifier | StringLiteral - ModuleExportName = Node // Identifier | StringLiteral - PropertyName = Node // Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | BigIntLiteral - ModuleBody = Node // ModuleBlock | ModuleDeclaration - ForInitializer = Node // Expression | MissingDeclaration | VariableDeclarationList - ModuleReference = Node // Identifier | QualifiedName | ExternalModuleReference - NamedImportBindings = Node // NamespaceImport | NamedImports - NamedExportBindings = Node // NamespaceExport | NamedExports - MemberName = Node // Identifier | PrivateIdentifier - EntityName = Node // Identifier | QualifiedName - BindingName = Node // Identifier | BindingPattern - ModifierLike = Node // Modifier | Decorator - JsxChild = Node // JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment - JsxAttributeLike = Node // JsxAttribute | JsxSpreadAttribute - JsxAttributeName = Node // Identifier | JsxNamespacedName - JsxAttributeValue = Node // StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment - JsxTagNameExpression = Node // IdentifierReference | KeywordExpression | JsxTagNamePropertyAccess | JsxNamespacedName - ClassLikeDeclaration = Node // ClassDeclaration | ClassExpression - AccessorDeclaration = Node // GetAccessorDeclaration | SetAccessorDeclaration - LiteralLikeNode = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | TemplateLiteralLikeNode | JsxText - LiteralExpression = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | NoSubstitutionTemplateLiteral - UnionOrIntersectionTypeNode = Node // UnionTypeNode | IntersectionTypeNode - TemplateLiteralLikeNode = Node // TemplateHead | TemplateMiddle | TemplateTail - TemplateMiddleOrTail = Node // TemplateMiddle | TemplateTail - TemplateLiteral = Node // TemplateExpression | NoSubstitutionTemplateLiteral - TypePredicateParameterName = Node // Identifier | ThisTypeNode - ImportAttributeName = Node // Identifier | StringLiteral - LeftHandSideExpression = Node // subset of Expression - JSDocComment = Node // JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain; - JSDocTag = Node // Node with JSDocTagBase - SignatureDeclaration = Node // CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - StringLiteralLike = Node // StringLiteral | NoSubstitutionTemplateLiteral - AnyValidImportOrReExport = Node // (ImportDeclaration | ExportDeclaration | JSDocImportTag) & { moduleSpecifier: StringLiteral } | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral }} | RequireOrImportCall | ValidImportTypeNode - ValidImportTypeNode = Node // ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } } - NumericOrStringLikeLiteral = Node // StringLiteralLike | NumericLiteral - TypeOnlyImportDeclaration = Node // ImportClause | ImportEqualsDeclaration | ImportSpecifier | NamespaceImport with isTypeOnly: true - ObjectLiteralLike = Node // ObjectLiteralExpression | ObjectBindingPattern - ObjectTypeDeclaration = Node // ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode - JsxOpeningLikeElement = Node // JsxOpeningElement | JsxSelfClosingElement - NamedImportsOrExports = Node // NamedImports | NamedExports - BreakOrContinueStatement = Node // BreakStatement | ContinueStatement - CallLikeExpression = Node // CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxCallLike | InstanceofExpression + Statement = Node // Node with StatementBase + Declaration = Node // Node with DeclarationBase + Expression = Node // Node with ExpressionBase + TypeNode = Node // Node with TypeNodeBase + TypeElement = Node // Node with TypeElementBase + ClassElement = Node // Node with ClassElementBase + NamedMember = Node // Node with NamedMemberBase + ObjectLiteralElement = Node // Node with ObjectLiteralElementBase + BlockOrExpression = Node // Block | Expression + AccessExpression = Node // PropertyAccessExpression | ElementAccessExpression + DeclarationName = Node // Identifier | PrivateIdentifier | StringLiteral | NumericLiteral | BigIntLiteral | NoSubstitutionTemplateLiteral | ComputedPropertyName | BindingPattern | ElementAccessExpression + ModuleName = Node // Identifier | StringLiteral + ModuleExportName = Node // Identifier | StringLiteral + PropertyName = Node // Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | BigIntLiteral + ModuleBody = Node // ModuleBlock | ModuleDeclaration + ForInitializer = Node // Expression | MissingDeclaration | VariableDeclarationList + ModuleReference = Node // Identifier | QualifiedName | ExternalModuleReference + NamedImportBindings = Node // NamespaceImport | NamedImports + NamedExportBindings = Node // NamespaceExport | NamedExports + MemberName = Node // Identifier | PrivateIdentifier + EntityName = Node // Identifier | QualifiedName + BindingName = Node // Identifier | BindingPattern + ModifierLike = Node // Modifier | Decorator + JsxChild = Node // JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment + JsxAttributeLike = Node // JsxAttribute | JsxSpreadAttribute + JsxAttributeName = Node // Identifier | JsxNamespacedName + JsxAttributeValue = Node // StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment + JsxTagNameExpression = Node // IdentifierReference | KeywordExpression | JsxTagNamePropertyAccess | JsxNamespacedName + ClassLikeDeclaration = Node // ClassDeclaration | ClassExpression + AccessorDeclaration = Node // GetAccessorDeclaration | SetAccessorDeclaration + LiteralLikeNode = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | TemplateLiteralLikeNode | JsxText + LiteralExpression = Node // StringLiteral | NumericLiteral | BigIntLiteral | RegularExpressionLiteral | NoSubstitutionTemplateLiteral + UnionOrIntersectionTypeNode = Node // UnionTypeNode | IntersectionTypeNode + TemplateLiteralLikeNode = Node // TemplateHead | TemplateMiddle | TemplateTail + TemplateMiddleOrTail = Node // TemplateMiddle | TemplateTail + TemplateLiteral = Node // TemplateExpression | NoSubstitutionTemplateLiteral + TypePredicateParameterName = Node // Identifier | ThisTypeNode + ImportAttributeName = Node // Identifier | StringLiteral + LeftHandSideExpression = Node // subset of Expression + JSDocComment = Node // JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain; + JSDocTag = Node // Node with JSDocTagBase + SignatureDeclaration = Node // CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + StringLiteralLike = Node // StringLiteral | NoSubstitutionTemplateLiteral + AnyValidImportOrReExport = Node // (ImportDeclaration | ExportDeclaration | JSDocImportTag) & { moduleSpecifier: StringLiteral } | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral }} | RequireOrImportCall | ValidImportTypeNode + ValidImportTypeNode = Node // ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } } + NumericOrStringLikeLiteral = Node // StringLiteralLike | NumericLiteral + TypeOnlyImportDeclaration = Node // ImportClause | ImportEqualsDeclaration | ImportSpecifier | NamespaceImport with isTypeOnly: true + ObjectLiteralLike = Node // ObjectLiteralExpression | ObjectBindingPattern + ObjectTypeDeclaration = Node // ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode + JsxOpeningLikeElement = Node // JsxOpeningElement | JsxSelfClosingElement + NamedImportsOrExports = Node // NamedImports | NamedExports + BreakOrContinueStatement = Node // BreakStatement | ContinueStatement + CallLikeExpression = Node // CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxCallLike | InstanceofExpression + FunctionLikeDeclaration = Node // FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction + VariableOrParameterDeclaration = Node // VariableDeclaration | ParameterDeclaration + VariableOrPropertyDeclaration = Node // VariableDeclaration | PropertyDeclaration + CallOrNewExpression = Node // CallExpression | NewExpression ) // Aliases for node singletons @@ -2168,6 +2182,7 @@ type ( LiteralType = Node JSDocNode = Node BindingPatternNode = Node + TypePredicateNodeNode = Node ) type ( @@ -2287,6 +2302,7 @@ func declarationIsWriteAccess(decl *Node) bool { KindParameter, KindShorthandPropertyAssignment, KindTypeAliasDeclaration, + KindJSTypeAliasDeclaration, KindTypeParameter: return true @@ -2359,6 +2375,9 @@ func IsArrayLiteralOrObjectLiteralDestructuringPattern(node *Node) bool { func accessKind(node *Node) AccessKind { parent := node.Parent + if parent == nil { + return AccessKindRead + } switch parent.Kind { case KindParenthesizedExpression: return accessKind(parent) @@ -2410,8 +2429,9 @@ func accessKind(node *Node) AccessKind { return AccessKindWrite } return AccessKindRead + default: + return AccessKindRead } - return AccessKindRead } func reverseAccessKind(a AccessKind) AccessKind { @@ -4846,6 +4866,10 @@ func IsImportDeclaration(node *Node) bool { return node.Kind == KindImportDeclaration } +func IsJSImportDeclaration(node *Node) bool { + return node.Kind == KindJSImportDeclaration +} + func IsImportDeclarationOrJSImportDeclaration(node *Node) bool { return node.Kind == KindImportDeclaration || node.Kind == KindJSImportDeclaration } @@ -5141,7 +5165,7 @@ func (node *ExportAssignment) Clone(f NodeFactoryCoercible) *Node { } func (node *ExportAssignment) computeSubtreeFacts() SubtreeFacts { - return propagateModifierListSubtreeFacts(node.modifiers) | propagateSubtreeFacts(node.Type) | propagateSubtreeFacts(node.Expression) + return propagateModifierListSubtreeFacts(node.modifiers) | propagateSubtreeFacts(node.Type) | propagateSubtreeFacts(node.Expression) | core.IfElse(node.IsExportEquals, SubtreeContainsTypeScript, SubtreeFactsNone) } func IsExportAssignment(node *Node) bool { @@ -8712,6 +8736,10 @@ func (node *TemplateHead) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateHead(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateHead(node *Node) bool { + return node.Kind == KindTemplateHead +} + // TemplateMiddle type TemplateMiddle struct { @@ -8732,6 +8760,10 @@ func (node *TemplateMiddle) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateMiddle(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateMiddle(node *Node) bool { + return node.Kind == KindTemplateMiddle +} + // TemplateTail type TemplateTail struct { @@ -8752,6 +8784,10 @@ func (node *TemplateTail) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateTail(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateTail(node *Node) bool { + return node.Kind == KindTemplateTail +} + // TemplateLiteralTypeNode type TemplateLiteralTypeNode struct { @@ -9641,6 +9677,10 @@ func (node *JSDocTypeExpression) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewJSDocTypeExpression(node.Type), node.AsNode(), f.AsNodeFactory().hooks) } +func IsJSDocTypeExpression(node *Node) bool { + return node.Kind == KindJSDocTypeExpression +} + // JSDocNonNullableType type JSDocNonNullableType struct { @@ -10571,6 +10611,10 @@ func (node *JSDocTypeLiteral) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewJSDocTypeLiteral(node.JSDocPropertyTags, node.IsArrayType), node.AsNode(), f.AsNodeFactory().hooks) } +func IsJSDocTypeLiteral(node *Node) bool { + return node.Kind == KindJSDocTypeLiteral +} + // JSDocSignature type JSDocSignature struct { TypeNodeBase @@ -10719,7 +10763,9 @@ type SourceFile struct { NodeCount int TextCount int CommonJSModuleIndicator *Node - ExternalModuleIndicator *Node + // If this is the SourceFile itself, then this module was "forced" + // to be an external module (previously "true"). + ExternalModuleIndicator *Node // Fields set by binder @@ -10944,7 +10990,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { result := make(map[string][]*Node) addDeclaration := func(declaration *Node) { - name := getDeclarationName(declaration) + name := GetDeclarationName(declaration) if name != "" { result[name] = append(result[name], declaration) } @@ -10954,7 +11000,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { visit = func(node *Node) bool { switch node.Kind { case KindFunctionDeclaration, KindFunctionExpression, KindMethodDeclaration, KindMethodSignature: - declarationName := getDeclarationName(node) + declarationName := GetDeclarationName(node) if declarationName != "" { declarations := result[declarationName] var lastDeclaration *Node @@ -10986,7 +11032,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { break } fallthrough - case KindVariableDeclaration, KindBindingElement: + case KindVariableDeclaration, KindBindingElement, KindCommonJSExport: name := node.Name() if name != nil { if IsBindingPattern(name) { @@ -11006,7 +11052,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { exportClause := node.AsExportDeclaration().ExportClause if exportClause != nil { if IsNamedExports(exportClause) { - for _, element := range exportClause.AsNamedExports().Elements.Nodes { + for _, element := range exportClause.Elements() { visit(element) } } else { @@ -11029,12 +11075,18 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { if namedBindings.Kind == KindNamespaceImport { addDeclaration(namedBindings) } else { - for _, element := range namedBindings.AsNamedImports().Elements.Nodes { + for _, element := range namedBindings.Elements() { visit(element) } } } } + case KindBinaryExpression: + switch GetAssignmentDeclarationKind(node.AsBinaryExpression()) { + case JSDeclarationKindThisProperty, JSDeclarationKindProperty: + addDeclaration(node) + } + node.ForEachChild(visit) default: node.ForEachChild(visit) } @@ -11044,7 +11096,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { return result } -func getDeclarationName(declaration *Node) string { +func GetDeclarationName(declaration *Node) string { name := GetNonAssignedNameOfDeclaration(declaration) if name != nil { if IsComputedPropertyName(name) { diff --git a/internal/ast/diagnostic.go b/internal/ast/diagnostic.go index 7757501881..324b7b4d07 100644 --- a/internal/ast/diagnostic.go +++ b/internal/ast/diagnostic.go @@ -7,16 +7,20 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/locale" ) // Diagnostic type Diagnostic struct { - file *SourceFile - loc core.TextRange - code int32 - category diagnostics.Category - message string + file *SourceFile + loc core.TextRange + code int32 + category diagnostics.Category + // Original message; may be nil. + message *diagnostics.Message + messageKey diagnostics.Key + messageArgs []string messageChain []*Diagnostic relatedInformation []*Diagnostic reportsUnnecessary bool @@ -31,7 +35,9 @@ func (d *Diagnostic) Len() int { return d.loc.Len() } func (d *Diagnostic) Loc() core.TextRange { return d.loc } func (d *Diagnostic) Code() int32 { return d.code } func (d *Diagnostic) Category() diagnostics.Category { return d.category } -func (d *Diagnostic) Message() string { return d.message } +func (d *Diagnostic) Message() string { return d.message.String() } +func (d *Diagnostic) MessageKey() diagnostics.Key { return d.messageKey } +func (d *Diagnostic) MessageArgs() []string { return d.messageArgs } func (d *Diagnostic) MessageChain() []*Diagnostic { return d.messageChain } func (d *Diagnostic) RelatedInformation() []*Diagnostic { return d.relatedInformation } func (d *Diagnostic) ReportsUnnecessary() bool { return d.reportsUnnecessary } @@ -72,12 +78,22 @@ func (d *Diagnostic) Clone() *Diagnostic { return &result } -func NewDiagnosticWith( +func (d *Diagnostic) Localize(locale locale.Locale) string { + return diagnostics.Localize(locale, d.message, d.messageKey, d.messageArgs...) +} + +// For debugging only. +func (d *Diagnostic) String() string { + return diagnostics.Localize(locale.Default, d.message, d.messageKey, d.messageArgs...) +} + +func NewDiagnosticFromSerialized( file *SourceFile, loc core.TextRange, code int32, category diagnostics.Category, - message string, + messageKey diagnostics.Key, + messageArgs []string, messageChain []*Diagnostic, relatedInformation []*Diagnostic, reportsUnnecessary bool, @@ -89,7 +105,8 @@ func NewDiagnosticWith( loc: loc, code: code, category: category, - message: message, + messageKey: messageKey, + messageArgs: messageArgs, messageChain: messageChain, relatedInformation: relatedInformation, reportsUnnecessary: reportsUnnecessary, @@ -104,7 +121,9 @@ func NewDiagnostic(file *SourceFile, loc core.TextRange, message *diagnostics.Me loc: loc, code: message.Code(), category: message.Category(), - message: message.Format(args...), + message: message, + messageKey: message.Key(), + messageArgs: diagnostics.StringifyArgs(args), reportsUnnecessary: message.ReportsUnnecessary(), reportsDeprecated: message.ReportsDeprecated(), } @@ -185,13 +204,13 @@ func EqualDiagnosticsNoRelatedInfo(d1, d2 *Diagnostic) bool { return getDiagnosticPath(d1) == getDiagnosticPath(d2) && d1.Loc() == d2.Loc() && d1.Code() == d2.Code() && - d1.Message() == d2.Message() && + slices.Equal(d1.MessageArgs(), d2.MessageArgs()) && slices.EqualFunc(d1.MessageChain(), d2.MessageChain(), equalMessageChain) } func equalMessageChain(c1, c2 *Diagnostic) bool { return c1.Code() == c2.Code() && - c1.Message() == c2.Message() && + slices.Equal(c1.MessageArgs(), c2.MessageArgs()) && slices.EqualFunc(c1.MessageChain(), c2.MessageChain(), equalMessageChain) } @@ -211,7 +230,7 @@ func compareMessageChainSize(c1, c2 []*Diagnostic) int { func compareMessageChainContent(c1, c2 []*Diagnostic) int { for i := range c1 { - c := strings.Compare(c1[i].Message(), c2[i].Message()) + c := slices.Compare(c1[i].MessageArgs(), c2[i].MessageArgs()) if c != 0 { return c } @@ -256,7 +275,7 @@ func CompareDiagnostics(d1, d2 *Diagnostic) int { if c != 0 { return c } - c = strings.Compare(d1.Message(), d2.Message()) + c = slices.Compare(d1.MessageArgs(), d2.MessageArgs()) if c != 0 { return c } diff --git a/internal/ast/kind.go b/internal/ast/kind.go index 57cdaf6f98..ed98bd68ff 100644 --- a/internal/ast/kind.go +++ b/internal/ast/kind.go @@ -339,7 +339,6 @@ const ( KindEnumMember // Top-level nodes KindSourceFile - KindBundle // JSDoc nodes KindJSDocTypeExpression KindJSDocNameReference diff --git a/internal/ast/kind_stringer_generated.go b/internal/ast/kind_stringer_generated.go index ac4a204fba..3430cc2cb1 100644 --- a/internal/ast/kind_stringer_generated.go +++ b/internal/ast/kind_stringer_generated.go @@ -316,63 +316,63 @@ func _() { _ = x[KindSpreadAssignment-305] _ = x[KindEnumMember-306] _ = x[KindSourceFile-307] - _ = x[KindBundle-308] - _ = x[KindJSDocTypeExpression-309] - _ = x[KindJSDocNameReference-310] - _ = x[KindJSDocMemberName-311] - _ = x[KindJSDocAllType-312] - _ = x[KindJSDocNullableType-313] - _ = x[KindJSDocNonNullableType-314] - _ = x[KindJSDocOptionalType-315] - _ = x[KindJSDocVariadicType-316] - _ = x[KindJSDoc-317] - _ = x[KindJSDocText-318] - _ = x[KindJSDocTypeLiteral-319] - _ = x[KindJSDocSignature-320] - _ = x[KindJSDocLink-321] - _ = x[KindJSDocLinkCode-322] - _ = x[KindJSDocLinkPlain-323] - _ = x[KindJSDocTag-324] - _ = x[KindJSDocAugmentsTag-325] - _ = x[KindJSDocImplementsTag-326] - _ = x[KindJSDocDeprecatedTag-327] - _ = x[KindJSDocPublicTag-328] - _ = x[KindJSDocPrivateTag-329] - _ = x[KindJSDocProtectedTag-330] - _ = x[KindJSDocReadonlyTag-331] - _ = x[KindJSDocOverrideTag-332] - _ = x[KindJSDocCallbackTag-333] - _ = x[KindJSDocOverloadTag-334] - _ = x[KindJSDocParameterTag-335] - _ = x[KindJSDocReturnTag-336] - _ = x[KindJSDocThisTag-337] - _ = x[KindJSDocTypeTag-338] - _ = x[KindJSDocTemplateTag-339] - _ = x[KindJSDocTypedefTag-340] - _ = x[KindJSDocSeeTag-341] - _ = x[KindJSDocPropertyTag-342] - _ = x[KindJSDocSatisfiesTag-343] - _ = x[KindJSDocImportTag-344] - _ = x[KindSyntaxList-345] - _ = x[KindJSTypeAliasDeclaration-346] - _ = x[KindJSExportAssignment-347] - _ = x[KindCommonJSExport-348] - _ = x[KindJSImportDeclaration-349] - _ = x[KindNotEmittedStatement-350] - _ = x[KindPartiallyEmittedExpression-351] - _ = x[KindCommaListExpression-352] - _ = x[KindSyntheticReferenceExpression-353] - _ = x[KindNotEmittedTypeElement-354] - _ = x[KindCount-355] + _ = x[KindJSDocTypeExpression-308] + _ = x[KindJSDocNameReference-309] + _ = x[KindJSDocMemberName-310] + _ = x[KindJSDocAllType-311] + _ = x[KindJSDocNullableType-312] + _ = x[KindJSDocNonNullableType-313] + _ = x[KindJSDocOptionalType-314] + _ = x[KindJSDocVariadicType-315] + _ = x[KindJSDoc-316] + _ = x[KindJSDocText-317] + _ = x[KindJSDocTypeLiteral-318] + _ = x[KindJSDocSignature-319] + _ = x[KindJSDocLink-320] + _ = x[KindJSDocLinkCode-321] + _ = x[KindJSDocLinkPlain-322] + _ = x[KindJSDocTag-323] + _ = x[KindJSDocAugmentsTag-324] + _ = x[KindJSDocImplementsTag-325] + _ = x[KindJSDocDeprecatedTag-326] + _ = x[KindJSDocPublicTag-327] + _ = x[KindJSDocPrivateTag-328] + _ = x[KindJSDocProtectedTag-329] + _ = x[KindJSDocReadonlyTag-330] + _ = x[KindJSDocOverrideTag-331] + _ = x[KindJSDocCallbackTag-332] + _ = x[KindJSDocOverloadTag-333] + _ = x[KindJSDocParameterTag-334] + _ = x[KindJSDocReturnTag-335] + _ = x[KindJSDocThisTag-336] + _ = x[KindJSDocTypeTag-337] + _ = x[KindJSDocTemplateTag-338] + _ = x[KindJSDocTypedefTag-339] + _ = x[KindJSDocSeeTag-340] + _ = x[KindJSDocPropertyTag-341] + _ = x[KindJSDocSatisfiesTag-342] + _ = x[KindJSDocImportTag-343] + _ = x[KindSyntaxList-344] + _ = x[KindJSTypeAliasDeclaration-345] + _ = x[KindJSExportAssignment-346] + _ = x[KindCommonJSExport-347] + _ = x[KindJSImportDeclaration-348] + _ = x[KindNotEmittedStatement-349] + _ = x[KindPartiallyEmittedExpression-350] + _ = x[KindCommaListExpression-351] + _ = x[KindSyntheticReferenceExpression-352] + _ = x[KindNotEmittedTypeElement-353] + _ = x[KindCount-354] } -const _Kind_name = "KindUnknownKindEndOfFileKindSingleLineCommentTriviaKindMultiLineCommentTriviaKindNewLineTriviaKindWhitespaceTriviaKindConflictMarkerTriviaKindNonTextFileMarkerTriviaKindNumericLiteralKindBigIntLiteralKindStringLiteralKindJsxTextKindJsxTextAllWhiteSpacesKindRegularExpressionLiteralKindNoSubstitutionTemplateLiteralKindTemplateHeadKindTemplateMiddleKindTemplateTailKindOpenBraceTokenKindCloseBraceTokenKindOpenParenTokenKindCloseParenTokenKindOpenBracketTokenKindCloseBracketTokenKindDotTokenKindDotDotDotTokenKindSemicolonTokenKindCommaTokenKindQuestionDotTokenKindLessThanTokenKindLessThanSlashTokenKindGreaterThanTokenKindLessThanEqualsTokenKindGreaterThanEqualsTokenKindEqualsEqualsTokenKindExclamationEqualsTokenKindEqualsEqualsEqualsTokenKindExclamationEqualsEqualsTokenKindEqualsGreaterThanTokenKindPlusTokenKindMinusTokenKindAsteriskTokenKindAsteriskAsteriskTokenKindSlashTokenKindPercentTokenKindPlusPlusTokenKindMinusMinusTokenKindLessThanLessThanTokenKindGreaterThanGreaterThanTokenKindGreaterThanGreaterThanGreaterThanTokenKindAmpersandTokenKindBarTokenKindCaretTokenKindExclamationTokenKindTildeTokenKindAmpersandAmpersandTokenKindBarBarTokenKindQuestionTokenKindColonTokenKindAtTokenKindQuestionQuestionTokenKindBacktickTokenKindHashTokenKindEqualsTokenKindPlusEqualsTokenKindMinusEqualsTokenKindAsteriskEqualsTokenKindAsteriskAsteriskEqualsTokenKindSlashEqualsTokenKindPercentEqualsTokenKindLessThanLessThanEqualsTokenKindGreaterThanGreaterThanEqualsTokenKindGreaterThanGreaterThanGreaterThanEqualsTokenKindAmpersandEqualsTokenKindBarEqualsTokenKindBarBarEqualsTokenKindAmpersandAmpersandEqualsTokenKindQuestionQuestionEqualsTokenKindCaretEqualsTokenKindIdentifierKindPrivateIdentifierKindJSDocCommentTextTokenKindBreakKeywordKindCaseKeywordKindCatchKeywordKindClassKeywordKindConstKeywordKindContinueKeywordKindDebuggerKeywordKindDefaultKeywordKindDeleteKeywordKindDoKeywordKindElseKeywordKindEnumKeywordKindExportKeywordKindExtendsKeywordKindFalseKeywordKindFinallyKeywordKindForKeywordKindFunctionKeywordKindIfKeywordKindImportKeywordKindInKeywordKindInstanceOfKeywordKindNewKeywordKindNullKeywordKindReturnKeywordKindSuperKeywordKindSwitchKeywordKindThisKeywordKindThrowKeywordKindTrueKeywordKindTryKeywordKindTypeOfKeywordKindVarKeywordKindVoidKeywordKindWhileKeywordKindWithKeywordKindImplementsKeywordKindInterfaceKeywordKindLetKeywordKindPackageKeywordKindPrivateKeywordKindProtectedKeywordKindPublicKeywordKindStaticKeywordKindYieldKeywordKindAbstractKeywordKindAccessorKeywordKindAsKeywordKindAssertsKeywordKindAssertKeywordKindAnyKeywordKindAsyncKeywordKindAwaitKeywordKindBooleanKeywordKindConstructorKeywordKindDeclareKeywordKindGetKeywordKindImmediateKeywordKindInferKeywordKindIntrinsicKeywordKindIsKeywordKindKeyOfKeywordKindModuleKeywordKindNamespaceKeywordKindNeverKeywordKindOutKeywordKindReadonlyKeywordKindRequireKeywordKindNumberKeywordKindObjectKeywordKindSatisfiesKeywordKindSetKeywordKindStringKeywordKindSymbolKeywordKindTypeKeywordKindUndefinedKeywordKindUniqueKeywordKindUnknownKeywordKindUsingKeywordKindFromKeywordKindGlobalKeywordKindBigIntKeywordKindOverrideKeywordKindOfKeywordKindDeferKeywordKindQualifiedNameKindComputedPropertyNameKindTypeParameterKindParameterKindDecoratorKindPropertySignatureKindPropertyDeclarationKindMethodSignatureKindMethodDeclarationKindClassStaticBlockDeclarationKindConstructorKindGetAccessorKindSetAccessorKindCallSignatureKindConstructSignatureKindIndexSignatureKindTypePredicateKindTypeReferenceKindFunctionTypeKindConstructorTypeKindTypeQueryKindTypeLiteralKindArrayTypeKindTupleTypeKindOptionalTypeKindRestTypeKindUnionTypeKindIntersectionTypeKindConditionalTypeKindInferTypeKindParenthesizedTypeKindThisTypeKindTypeOperatorKindIndexedAccessTypeKindMappedTypeKindLiteralTypeKindNamedTupleMemberKindTemplateLiteralTypeKindTemplateLiteralTypeSpanKindImportTypeKindObjectBindingPatternKindArrayBindingPatternKindBindingElementKindArrayLiteralExpressionKindObjectLiteralExpressionKindPropertyAccessExpressionKindElementAccessExpressionKindCallExpressionKindNewExpressionKindTaggedTemplateExpressionKindTypeAssertionExpressionKindParenthesizedExpressionKindFunctionExpressionKindArrowFunctionKindDeleteExpressionKindTypeOfExpressionKindVoidExpressionKindAwaitExpressionKindPrefixUnaryExpressionKindPostfixUnaryExpressionKindBinaryExpressionKindConditionalExpressionKindTemplateExpressionKindYieldExpressionKindSpreadElementKindClassExpressionKindOmittedExpressionKindExpressionWithTypeArgumentsKindAsExpressionKindNonNullExpressionKindMetaPropertyKindSyntheticExpressionKindSatisfiesExpressionKindTemplateSpanKindSemicolonClassElementKindBlockKindEmptyStatementKindVariableStatementKindExpressionStatementKindIfStatementKindDoStatementKindWhileStatementKindForStatementKindForInStatementKindForOfStatementKindContinueStatementKindBreakStatementKindReturnStatementKindWithStatementKindSwitchStatementKindLabeledStatementKindThrowStatementKindTryStatementKindDebuggerStatementKindVariableDeclarationKindVariableDeclarationListKindFunctionDeclarationKindClassDeclarationKindInterfaceDeclarationKindTypeAliasDeclarationKindEnumDeclarationKindModuleDeclarationKindModuleBlockKindCaseBlockKindNamespaceExportDeclarationKindImportEqualsDeclarationKindImportDeclarationKindImportClauseKindNamespaceImportKindNamedImportsKindImportSpecifierKindExportAssignmentKindExportDeclarationKindNamedExportsKindNamespaceExportKindExportSpecifierKindMissingDeclarationKindExternalModuleReferenceKindJsxElementKindJsxSelfClosingElementKindJsxOpeningElementKindJsxClosingElementKindJsxFragmentKindJsxOpeningFragmentKindJsxClosingFragmentKindJsxAttributeKindJsxAttributesKindJsxSpreadAttributeKindJsxExpressionKindJsxNamespacedNameKindCaseClauseKindDefaultClauseKindHeritageClauseKindCatchClauseKindImportAttributesKindImportAttributeKindPropertyAssignmentKindShorthandPropertyAssignmentKindSpreadAssignmentKindEnumMemberKindSourceFileKindBundleKindJSDocTypeExpressionKindJSDocNameReferenceKindJSDocMemberNameKindJSDocAllTypeKindJSDocNullableTypeKindJSDocNonNullableTypeKindJSDocOptionalTypeKindJSDocVariadicTypeKindJSDocKindJSDocTextKindJSDocTypeLiteralKindJSDocSignatureKindJSDocLinkKindJSDocLinkCodeKindJSDocLinkPlainKindJSDocTagKindJSDocAugmentsTagKindJSDocImplementsTagKindJSDocDeprecatedTagKindJSDocPublicTagKindJSDocPrivateTagKindJSDocProtectedTagKindJSDocReadonlyTagKindJSDocOverrideTagKindJSDocCallbackTagKindJSDocOverloadTagKindJSDocParameterTagKindJSDocReturnTagKindJSDocThisTagKindJSDocTypeTagKindJSDocTemplateTagKindJSDocTypedefTagKindJSDocSeeTagKindJSDocPropertyTagKindJSDocSatisfiesTagKindJSDocImportTagKindSyntaxListKindJSTypeAliasDeclarationKindJSExportAssignmentKindCommonJSExportKindJSImportDeclarationKindNotEmittedStatementKindPartiallyEmittedExpressionKindCommaListExpressionKindSyntheticReferenceExpressionKindNotEmittedTypeElementKindCount" +const _Kind_name = "KindUnknownKindEndOfFileKindSingleLineCommentTriviaKindMultiLineCommentTriviaKindNewLineTriviaKindWhitespaceTriviaKindConflictMarkerTriviaKindNonTextFileMarkerTriviaKindNumericLiteralKindBigIntLiteralKindStringLiteralKindJsxTextKindJsxTextAllWhiteSpacesKindRegularExpressionLiteralKindNoSubstitutionTemplateLiteralKindTemplateHeadKindTemplateMiddleKindTemplateTailKindOpenBraceTokenKindCloseBraceTokenKindOpenParenTokenKindCloseParenTokenKindOpenBracketTokenKindCloseBracketTokenKindDotTokenKindDotDotDotTokenKindSemicolonTokenKindCommaTokenKindQuestionDotTokenKindLessThanTokenKindLessThanSlashTokenKindGreaterThanTokenKindLessThanEqualsTokenKindGreaterThanEqualsTokenKindEqualsEqualsTokenKindExclamationEqualsTokenKindEqualsEqualsEqualsTokenKindExclamationEqualsEqualsTokenKindEqualsGreaterThanTokenKindPlusTokenKindMinusTokenKindAsteriskTokenKindAsteriskAsteriskTokenKindSlashTokenKindPercentTokenKindPlusPlusTokenKindMinusMinusTokenKindLessThanLessThanTokenKindGreaterThanGreaterThanTokenKindGreaterThanGreaterThanGreaterThanTokenKindAmpersandTokenKindBarTokenKindCaretTokenKindExclamationTokenKindTildeTokenKindAmpersandAmpersandTokenKindBarBarTokenKindQuestionTokenKindColonTokenKindAtTokenKindQuestionQuestionTokenKindBacktickTokenKindHashTokenKindEqualsTokenKindPlusEqualsTokenKindMinusEqualsTokenKindAsteriskEqualsTokenKindAsteriskAsteriskEqualsTokenKindSlashEqualsTokenKindPercentEqualsTokenKindLessThanLessThanEqualsTokenKindGreaterThanGreaterThanEqualsTokenKindGreaterThanGreaterThanGreaterThanEqualsTokenKindAmpersandEqualsTokenKindBarEqualsTokenKindBarBarEqualsTokenKindAmpersandAmpersandEqualsTokenKindQuestionQuestionEqualsTokenKindCaretEqualsTokenKindIdentifierKindPrivateIdentifierKindJSDocCommentTextTokenKindBreakKeywordKindCaseKeywordKindCatchKeywordKindClassKeywordKindConstKeywordKindContinueKeywordKindDebuggerKeywordKindDefaultKeywordKindDeleteKeywordKindDoKeywordKindElseKeywordKindEnumKeywordKindExportKeywordKindExtendsKeywordKindFalseKeywordKindFinallyKeywordKindForKeywordKindFunctionKeywordKindIfKeywordKindImportKeywordKindInKeywordKindInstanceOfKeywordKindNewKeywordKindNullKeywordKindReturnKeywordKindSuperKeywordKindSwitchKeywordKindThisKeywordKindThrowKeywordKindTrueKeywordKindTryKeywordKindTypeOfKeywordKindVarKeywordKindVoidKeywordKindWhileKeywordKindWithKeywordKindImplementsKeywordKindInterfaceKeywordKindLetKeywordKindPackageKeywordKindPrivateKeywordKindProtectedKeywordKindPublicKeywordKindStaticKeywordKindYieldKeywordKindAbstractKeywordKindAccessorKeywordKindAsKeywordKindAssertsKeywordKindAssertKeywordKindAnyKeywordKindAsyncKeywordKindAwaitKeywordKindBooleanKeywordKindConstructorKeywordKindDeclareKeywordKindGetKeywordKindImmediateKeywordKindInferKeywordKindIntrinsicKeywordKindIsKeywordKindKeyOfKeywordKindModuleKeywordKindNamespaceKeywordKindNeverKeywordKindOutKeywordKindReadonlyKeywordKindRequireKeywordKindNumberKeywordKindObjectKeywordKindSatisfiesKeywordKindSetKeywordKindStringKeywordKindSymbolKeywordKindTypeKeywordKindUndefinedKeywordKindUniqueKeywordKindUnknownKeywordKindUsingKeywordKindFromKeywordKindGlobalKeywordKindBigIntKeywordKindOverrideKeywordKindOfKeywordKindDeferKeywordKindQualifiedNameKindComputedPropertyNameKindTypeParameterKindParameterKindDecoratorKindPropertySignatureKindPropertyDeclarationKindMethodSignatureKindMethodDeclarationKindClassStaticBlockDeclarationKindConstructorKindGetAccessorKindSetAccessorKindCallSignatureKindConstructSignatureKindIndexSignatureKindTypePredicateKindTypeReferenceKindFunctionTypeKindConstructorTypeKindTypeQueryKindTypeLiteralKindArrayTypeKindTupleTypeKindOptionalTypeKindRestTypeKindUnionTypeKindIntersectionTypeKindConditionalTypeKindInferTypeKindParenthesizedTypeKindThisTypeKindTypeOperatorKindIndexedAccessTypeKindMappedTypeKindLiteralTypeKindNamedTupleMemberKindTemplateLiteralTypeKindTemplateLiteralTypeSpanKindImportTypeKindObjectBindingPatternKindArrayBindingPatternKindBindingElementKindArrayLiteralExpressionKindObjectLiteralExpressionKindPropertyAccessExpressionKindElementAccessExpressionKindCallExpressionKindNewExpressionKindTaggedTemplateExpressionKindTypeAssertionExpressionKindParenthesizedExpressionKindFunctionExpressionKindArrowFunctionKindDeleteExpressionKindTypeOfExpressionKindVoidExpressionKindAwaitExpressionKindPrefixUnaryExpressionKindPostfixUnaryExpressionKindBinaryExpressionKindConditionalExpressionKindTemplateExpressionKindYieldExpressionKindSpreadElementKindClassExpressionKindOmittedExpressionKindExpressionWithTypeArgumentsKindAsExpressionKindNonNullExpressionKindMetaPropertyKindSyntheticExpressionKindSatisfiesExpressionKindTemplateSpanKindSemicolonClassElementKindBlockKindEmptyStatementKindVariableStatementKindExpressionStatementKindIfStatementKindDoStatementKindWhileStatementKindForStatementKindForInStatementKindForOfStatementKindContinueStatementKindBreakStatementKindReturnStatementKindWithStatementKindSwitchStatementKindLabeledStatementKindThrowStatementKindTryStatementKindDebuggerStatementKindVariableDeclarationKindVariableDeclarationListKindFunctionDeclarationKindClassDeclarationKindInterfaceDeclarationKindTypeAliasDeclarationKindEnumDeclarationKindModuleDeclarationKindModuleBlockKindCaseBlockKindNamespaceExportDeclarationKindImportEqualsDeclarationKindImportDeclarationKindImportClauseKindNamespaceImportKindNamedImportsKindImportSpecifierKindExportAssignmentKindExportDeclarationKindNamedExportsKindNamespaceExportKindExportSpecifierKindMissingDeclarationKindExternalModuleReferenceKindJsxElementKindJsxSelfClosingElementKindJsxOpeningElementKindJsxClosingElementKindJsxFragmentKindJsxOpeningFragmentKindJsxClosingFragmentKindJsxAttributeKindJsxAttributesKindJsxSpreadAttributeKindJsxExpressionKindJsxNamespacedNameKindCaseClauseKindDefaultClauseKindHeritageClauseKindCatchClauseKindImportAttributesKindImportAttributeKindPropertyAssignmentKindShorthandPropertyAssignmentKindSpreadAssignmentKindEnumMemberKindSourceFileKindJSDocTypeExpressionKindJSDocNameReferenceKindJSDocMemberNameKindJSDocAllTypeKindJSDocNullableTypeKindJSDocNonNullableTypeKindJSDocOptionalTypeKindJSDocVariadicTypeKindJSDocKindJSDocTextKindJSDocTypeLiteralKindJSDocSignatureKindJSDocLinkKindJSDocLinkCodeKindJSDocLinkPlainKindJSDocTagKindJSDocAugmentsTagKindJSDocImplementsTagKindJSDocDeprecatedTagKindJSDocPublicTagKindJSDocPrivateTagKindJSDocProtectedTagKindJSDocReadonlyTagKindJSDocOverrideTagKindJSDocCallbackTagKindJSDocOverloadTagKindJSDocParameterTagKindJSDocReturnTagKindJSDocThisTagKindJSDocTypeTagKindJSDocTemplateTagKindJSDocTypedefTagKindJSDocSeeTagKindJSDocPropertyTagKindJSDocSatisfiesTagKindJSDocImportTagKindSyntaxListKindJSTypeAliasDeclarationKindJSExportAssignmentKindCommonJSExportKindJSImportDeclarationKindNotEmittedStatementKindPartiallyEmittedExpressionKindCommaListExpressionKindSyntheticReferenceExpressionKindNotEmittedTypeElementKindCount" -var _Kind_index = [...]uint16{0, 11, 24, 51, 77, 94, 114, 138, 165, 183, 200, 217, 228, 253, 281, 314, 330, 348, 364, 382, 401, 419, 438, 458, 479, 491, 509, 527, 541, 561, 578, 600, 620, 643, 669, 690, 716, 743, 775, 801, 814, 828, 845, 870, 884, 900, 917, 936, 961, 992, 1034, 1052, 1064, 1078, 1098, 1112, 1139, 1154, 1171, 1185, 1196, 1221, 1238, 1251, 1266, 1285, 1305, 1328, 1359, 1379, 1401, 1432, 1469, 1517, 1541, 1559, 1580, 1613, 1644, 1664, 1678, 1699, 1724, 1740, 1755, 1771, 1787, 1803, 1822, 1841, 1859, 1876, 1889, 1904, 1919, 1936, 1954, 1970, 1988, 2002, 2021, 2034, 2051, 2064, 2085, 2099, 2114, 2131, 2147, 2164, 2179, 2195, 2210, 2224, 2241, 2255, 2270, 2286, 2301, 2322, 2342, 2356, 2374, 2392, 2412, 2429, 2446, 2462, 2481, 2500, 2513, 2531, 2548, 2562, 2578, 2594, 2612, 2634, 2652, 2666, 2686, 2702, 2722, 2735, 2751, 2768, 2788, 2804, 2818, 2837, 2855, 2872, 2889, 2909, 2923, 2940, 2957, 2972, 2992, 3009, 3027, 3043, 3058, 3075, 3092, 3111, 3124, 3140, 3157, 3181, 3198, 3211, 3224, 3245, 3268, 3287, 3308, 3339, 3354, 3369, 3384, 3401, 3423, 3441, 3458, 3475, 3491, 3510, 3523, 3538, 3551, 3564, 3580, 3592, 3605, 3625, 3644, 3657, 3678, 3690, 3706, 3727, 3741, 3756, 3776, 3799, 3826, 3840, 3864, 3887, 3905, 3931, 3958, 3986, 4013, 4031, 4048, 4076, 4103, 4130, 4152, 4169, 4189, 4209, 4227, 4246, 4271, 4297, 4317, 4342, 4364, 4383, 4400, 4419, 4440, 4471, 4487, 4508, 4524, 4547, 4570, 4586, 4611, 4620, 4638, 4659, 4682, 4697, 4712, 4730, 4746, 4764, 4782, 4803, 4821, 4840, 4857, 4876, 4896, 4914, 4930, 4951, 4974, 5001, 5024, 5044, 5068, 5092, 5111, 5132, 5147, 5160, 5190, 5217, 5238, 5254, 5273, 5289, 5308, 5328, 5349, 5365, 5384, 5403, 5425, 5452, 5466, 5491, 5512, 5533, 5548, 5570, 5592, 5608, 5625, 5647, 5664, 5685, 5699, 5716, 5734, 5749, 5769, 5788, 5810, 5841, 5861, 5875, 5889, 5899, 5922, 5944, 5963, 5979, 6000, 6024, 6045, 6066, 6075, 6088, 6108, 6126, 6139, 6156, 6174, 6186, 6206, 6228, 6250, 6268, 6287, 6308, 6328, 6348, 6368, 6388, 6409, 6427, 6443, 6459, 6479, 6498, 6513, 6533, 6554, 6572, 6586, 6612, 6634, 6652, 6675, 6698, 6728, 6751, 6783, 6808, 6817} +var _Kind_index = [...]uint16{0, 11, 24, 51, 77, 94, 114, 138, 165, 183, 200, 217, 228, 253, 281, 314, 330, 348, 364, 382, 401, 419, 438, 458, 479, 491, 509, 527, 541, 561, 578, 600, 620, 643, 669, 690, 716, 743, 775, 801, 814, 828, 845, 870, 884, 900, 917, 936, 961, 992, 1034, 1052, 1064, 1078, 1098, 1112, 1139, 1154, 1171, 1185, 1196, 1221, 1238, 1251, 1266, 1285, 1305, 1328, 1359, 1379, 1401, 1432, 1469, 1517, 1541, 1559, 1580, 1613, 1644, 1664, 1678, 1699, 1724, 1740, 1755, 1771, 1787, 1803, 1822, 1841, 1859, 1876, 1889, 1904, 1919, 1936, 1954, 1970, 1988, 2002, 2021, 2034, 2051, 2064, 2085, 2099, 2114, 2131, 2147, 2164, 2179, 2195, 2210, 2224, 2241, 2255, 2270, 2286, 2301, 2322, 2342, 2356, 2374, 2392, 2412, 2429, 2446, 2462, 2481, 2500, 2513, 2531, 2548, 2562, 2578, 2594, 2612, 2634, 2652, 2666, 2686, 2702, 2722, 2735, 2751, 2768, 2788, 2804, 2818, 2837, 2855, 2872, 2889, 2909, 2923, 2940, 2957, 2972, 2992, 3009, 3027, 3043, 3058, 3075, 3092, 3111, 3124, 3140, 3157, 3181, 3198, 3211, 3224, 3245, 3268, 3287, 3308, 3339, 3354, 3369, 3384, 3401, 3423, 3441, 3458, 3475, 3491, 3510, 3523, 3538, 3551, 3564, 3580, 3592, 3605, 3625, 3644, 3657, 3678, 3690, 3706, 3727, 3741, 3756, 3776, 3799, 3826, 3840, 3864, 3887, 3905, 3931, 3958, 3986, 4013, 4031, 4048, 4076, 4103, 4130, 4152, 4169, 4189, 4209, 4227, 4246, 4271, 4297, 4317, 4342, 4364, 4383, 4400, 4419, 4440, 4471, 4487, 4508, 4524, 4547, 4570, 4586, 4611, 4620, 4638, 4659, 4682, 4697, 4712, 4730, 4746, 4764, 4782, 4803, 4821, 4840, 4857, 4876, 4896, 4914, 4930, 4951, 4974, 5001, 5024, 5044, 5068, 5092, 5111, 5132, 5147, 5160, 5190, 5217, 5238, 5254, 5273, 5289, 5308, 5328, 5349, 5365, 5384, 5403, 5425, 5452, 5466, 5491, 5512, 5533, 5548, 5570, 5592, 5608, 5625, 5647, 5664, 5685, 5699, 5716, 5734, 5749, 5769, 5788, 5810, 5841, 5861, 5875, 5889, 5912, 5934, 5953, 5969, 5990, 6014, 6035, 6056, 6065, 6078, 6098, 6116, 6129, 6146, 6164, 6176, 6196, 6218, 6240, 6258, 6277, 6298, 6318, 6338, 6358, 6378, 6399, 6417, 6433, 6449, 6469, 6488, 6503, 6523, 6544, 6562, 6576, 6602, 6624, 6642, 6665, 6688, 6718, 6741, 6773, 6798, 6807} func (i Kind) String() string { - if i < 0 || i >= Kind(len(_Kind_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_Kind_index)-1 { return "Kind(" + strconv.FormatInt(int64(i), 10) + ")" } - return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] + return _Kind_name[_Kind_index[idx]:_Kind_index[idx+1]] } diff --git a/internal/ast/nodeflags.go b/internal/ast/nodeflags.go index 2feb4f2a52..3261fc277c 100644 --- a/internal/ast/nodeflags.go +++ b/internal/ast/nodeflags.go @@ -42,6 +42,7 @@ const ( NodeFlagsInWithStatement NodeFlags = 1 << 24 // If any ancestor of node was the `statement` of a WithStatement (not the `expression`) NodeFlagsJsonFile NodeFlags = 1 << 25 // If node was parsed in a Json NodeFlagsDeprecated NodeFlags = 1 << 26 // If has '@deprecated' JSDoc tag + NodeFlagsUnreachable NodeFlags = 1 << 27 // If node is unreachable according to the binder NodeFlagsBlockScoped = NodeFlagsLet | NodeFlagsConst | NodeFlagsUsing NodeFlagsConstant = NodeFlagsConst | NodeFlagsUsing diff --git a/internal/ast/parseoptions.go b/internal/ast/parseoptions.go index f464a4523d..a697eceb75 100644 --- a/internal/ast/parseoptions.go +++ b/internal/ast/parseoptions.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -type JSDocParsingMode int +type JSDocParsingMode uint8 const ( JSDocParsingModeParseAll JSDocParsingMode = iota @@ -31,8 +31,8 @@ func GetSourceFileAffectingCompilerOptions(fileName string, options *core.Compil } type ExternalModuleIndicatorOptions struct { - jsx bool - force bool + JSX bool + Force bool } func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOptions, metadata SourceFileMetaData) ExternalModuleIndicatorOptions { @@ -43,7 +43,7 @@ func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOp switch options.GetEmitModuleDetectionKind() { case core.ModuleDetectionKindForce: // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule - return ExternalModuleIndicatorOptions{force: true} + return ExternalModuleIndicatorOptions{Force: true} case core.ModuleDetectionKindLegacy: // Files are modules if they have imports, exports, or import.meta return ExternalModuleIndicatorOptions{} @@ -52,8 +52,8 @@ func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOp // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness return ExternalModuleIndicatorOptions{ - jsx: options.Jsx == core.JsxEmitReactJSX || options.Jsx == core.JsxEmitReactJSXDev, - force: isFileForcedToBeModuleByFormat(fileName, options, metadata), + JSX: options.Jsx == core.JsxEmitReactJSX || options.Jsx == core.JsxEmitReactJSXDev, + Force: isFileForcedToBeModuleByFormat(fileName, options, metadata), } default: return ExternalModuleIndicatorOptions{} @@ -89,13 +89,13 @@ func getExternalModuleIndicator(file *SourceFile, opts ExternalModuleIndicatorOp return nil } - if opts.jsx { + if opts.JSX { if node := isFileModuleFromUsingJSXTag(file); node != nil { return node } } - if opts.force { + if opts.Force { return file.AsNode() } diff --git a/internal/ast/precedence.go b/internal/ast/precedence.go index e23d5278c9..9acf84a78f 100644 --- a/internal/ast/precedence.go +++ b/internal/ast/precedence.go @@ -203,7 +203,7 @@ func getOperator(expression *Expression) Kind { func GetExpressionPrecedence(expression *Expression) OperatorPrecedence { operator := getOperator(expression) var flags OperatorPrecedenceFlags - if expression.Kind == KindNewExpression && expression.AsNewExpression().Arguments == nil { + if expression.Kind == KindNewExpression && expression.ArgumentList() == nil { flags = OperatorPrecedenceFlagsNewWithoutArguments } else if IsOptionalChain(expression) { flags = OperatorPrecedenceFlagsOptionalChain diff --git a/internal/ast/subtreefacts.go b/internal/ast/subtreefacts.go index fcd6885044..08d2ce14de 100644 --- a/internal/ast/subtreefacts.go +++ b/internal/ast/subtreefacts.go @@ -4,7 +4,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" ) -type SubtreeFacts int32 +type SubtreeFacts uint32 const ( // Facts diff --git a/internal/ast/symbol.go b/internal/ast/symbol.go index e38cfa0500..e3581a7786 100644 --- a/internal/ast/symbol.go +++ b/internal/ast/symbol.go @@ -27,6 +27,18 @@ type Symbol struct { GlobalExports SymbolTable // Conditional global UMD exports } +func (s *Symbol) IsExternalModule() bool { + return s.Flags&SymbolFlagsModule != 0 && len(s.Name) > 0 && s.Name[0] == '"' +} + +func (s *Symbol) IsStatic() bool { + if s.ValueDeclaration == nil { + return false + } + modifierFlags := s.ValueDeclaration.ModifierFlags() + return modifierFlags&ModifierFlagsStatic != 0 +} + // SymbolTable // type SymbolTable map[string]*Symbol @@ -147,7 +159,6 @@ const ( InternalSymbolNameClass = InternalSymbolNamePrefix + "class" // Unnamed class expression InternalSymbolNameFunction = InternalSymbolNamePrefix + "function" // Unnamed function expression InternalSymbolNameComputed = InternalSymbolNamePrefix + "computed" // Computed property name declaration with dynamic name - InternalSymbolNameResolving = InternalSymbolNamePrefix + "resolving" // Indicator symbol used to mark partially resolved type aliases InternalSymbolNameInstantiationExpression = InternalSymbolNamePrefix + "instantiationExpression" // Instantiation expressions InternalSymbolNameImportAttributes = InternalSymbolNamePrefix + "importAttributes" InternalSymbolNameExportEquals = "export=" // Export assignment symbol diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 32dfebdd8e..4effc1e5d6 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -197,7 +197,7 @@ func GetAssignmentTarget(node *Node) *Node { } return nil case KindForInStatement, KindForOfStatement: - if parent.AsForInOrOfStatement().Initializer == node { + if parent.Initializer() == node { return parent } return nil @@ -244,7 +244,7 @@ func IsLogicalOrCoalescingAssignmentExpression(expr *Node) bool { func IsLogicalExpression(node *Node) bool { for { if node.Kind == KindParenthesizedExpression { - node = node.AsParenthesizedExpression().Expression + node = node.Expression() } else if node.Kind == KindPrefixUnaryExpression && node.AsPrefixUnaryExpression().Operator == KindExclamationToken { node = node.AsPrefixUnaryExpression().Operand } else { @@ -302,9 +302,9 @@ func IsIdentifierName(node *Node) bool { case KindQualifiedName: return parent.AsQualifiedName().Right == node case KindBindingElement: - return parent.AsBindingElement().PropertyName == node + return parent.PropertyName() == node case KindImportSpecifier: - return parent.AsImportSpecifier().PropertyName == node + return parent.PropertyName() == node case KindExportSpecifier, KindJsxAttribute, KindJsxSelfClosingElement, KindJsxOpeningElement, KindJsxClosingElement: return true } @@ -363,15 +363,7 @@ func IsOptionalChain(node *Node) bool { } func getQuestionDotToken(node *Expression) *TokenNode { - switch node.Kind { - case KindPropertyAccessExpression: - return node.AsPropertyAccessExpression().QuestionDotToken - case KindElementAccessExpression: - return node.AsElementAccessExpression().QuestionDotToken - case KindCallExpression: - return node.AsCallExpression().QuestionDotToken - } - panic("Unhandled case in getQuestionDotToken") + return node.QuestionDotToken() } // Determines if node is the root expression of an OptionalChain @@ -489,7 +481,7 @@ func IsIterationStatement(node *Node, lookInLabeledStatements bool) bool { KindWhileStatement: return true case KindLabeledStatement: - return lookInLabeledStatements && IsIterationStatement((node.AsLabeledStatement()).Statement, lookInLabeledStatements) + return lookInLabeledStatements && IsIterationStatement(node.Statement(), lookInLabeledStatements) } return false @@ -571,7 +563,7 @@ func IsClassElement(node *Node) bool { return false } -func isMethodOrAccessor(node *Node) bool { +func IsMethodOrAccessor(node *Node) bool { switch node.Kind { case KindMethodDeclaration, KindGetAccessor, KindSetAccessor: return true @@ -580,7 +572,7 @@ func isMethodOrAccessor(node *Node) bool { } func IsPrivateIdentifierClassElementDeclaration(node *Node) bool { - return (IsPropertyDeclaration(node) || isMethodOrAccessor(node)) && IsPrivateIdentifier(node.Name()) + return (IsPropertyDeclaration(node) || IsMethodOrAccessor(node)) && IsPrivateIdentifier(node.Name()) } func IsObjectLiteralOrClassExpressionMethodOrAccessor(node *Node) bool { @@ -736,18 +728,6 @@ func IsFunctionBlock(node *Node) bool { return node != nil && node.Kind == KindBlock && node.Parent != nil && IsFunctionLike(node.Parent) } -func GetStatementsOfBlock(block *Node) *StatementList { - switch block.Kind { - case KindBlock: - return block.AsBlock().Statements - case KindModuleBlock: - return block.AsModuleBlock().Statements - case KindSourceFile: - return block.AsSourceFile().Statements - } - panic("Unhandled case in getStatementsOfBlock") -} - func IsBlockOrCatchScoped(declaration *Node) bool { return GetCombinedNodeFlags(declaration)&NodeFlagsBlockScoped != 0 || IsCatchClauseVariableDeclarationOrBindingElement(declaration) } @@ -796,7 +776,7 @@ func isJSDocTypeAssertion(_ *Node) bool { func IsPrologueDirective(node *Node) bool { return node.Kind == KindExpressionStatement && - node.AsExpressionStatement().Expression.Kind == KindStringLiteral + node.Expression().Kind == KindStringLiteral } type OuterExpressionKinds int16 @@ -847,7 +827,7 @@ func SkipParentheses(node *Expression) *Expression { func SkipTypeParentheses(node *Node) *Node { for IsParenthesizedTypeNode(node) { - node = node.AsParenthesizedTypeNode().Type + node = node.Type() } return node } @@ -1232,7 +1212,7 @@ func IsVarLet(node *Node) bool { func IsImportMeta(node *Node) bool { if node.Kind == KindMetaProperty { - return node.AsMetaProperty().KeywordToken == KindImportKeyword && node.AsMetaProperty().Name().AsIdentifier().Text == "meta" + return node.AsMetaProperty().KeywordToken == KindImportKeyword && node.AsMetaProperty().Name().Text() == "meta" } return false } @@ -1411,16 +1391,6 @@ func GetNameOfDeclaration(declaration *Node) *Node { return nil } -func GetImportClauseOfDeclaration(declaration *Declaration) *ImportClause { - switch declaration.Kind { - case KindImportDeclaration: - return declaration.AsImportDeclaration().ImportClause.AsImportClause() - case KindJSDocImportTag: - return declaration.AsJSDocImportTag().ImportClause.AsImportClause() - } - return nil -} - func GetNonAssignedNameOfDeclaration(declaration *Node) *Node { // !!! switch declaration.Kind { @@ -1436,7 +1406,7 @@ func GetNonAssignedNameOfDeclaration(declaration *Node) *Node { } return nil case KindExportAssignment, KindJSExportAssignment: - expr := declaration.AsExportAssignment().Expression + expr := declaration.Expression() if IsIdentifier(expr) { return expr } @@ -1489,8 +1459,6 @@ const ( /// exports.name = expr /// module.exports.name = expr JSDeclarationKindExportsProperty - /// className.prototype.name = expr - JSDeclarationKindPrototypeProperty /// this.name = expr JSDeclarationKindThisProperty /// F.name = expr, F[name] = expr @@ -1535,7 +1503,7 @@ func IsDynamicName(name *Node) bool { var expr *Node switch name.Kind { case KindComputedPropertyName: - expr = name.AsComputedPropertyName().Expression + expr = name.Expression() case KindElementAccessExpression: expr = SkipParentheses(name.AsElementAccessExpression().ArgumentExpression) default: @@ -1591,7 +1559,7 @@ func HasSamePropertyAccessName(node1, node2 *Node) bool { return node1.Text() == node2.Text() } else if node1.Kind == KindPropertyAccessExpression && node2.Kind == KindPropertyAccessExpression { return node1.AsPropertyAccessExpression().Name().Text() == node2.AsPropertyAccessExpression().Name().Text() && - HasSamePropertyAccessName(node1.AsPropertyAccessExpression().Expression, node2.AsPropertyAccessExpression().Expression) + HasSamePropertyAccessName(node1.Expression(), node2.Expression()) } return false } @@ -1801,7 +1769,7 @@ func GetImmediatelyInvokedFunctionExpression(fn *Node) *Node { prev = parent parent = parent.Parent } - if IsCallExpression(parent) && parent.AsCallExpression().Expression == prev { + if IsCallExpression(parent) && parent.Expression() == prev { return parent } } @@ -1813,7 +1781,7 @@ func IsEnumConst(node *Node) bool { } func ExportAssignmentIsAlias(node *Node) bool { - e := node.AsExportAssignment().Expression + e := node.Expression() return IsEntityNameExpression(e) || IsClassExpression(e) } @@ -1839,19 +1807,17 @@ func IsInJsonFile(node *Node) bool { func GetExternalModuleName(node *Node) *Expression { switch node.Kind { - case KindImportDeclaration, KindJSImportDeclaration: - return node.AsImportDeclaration().ModuleSpecifier - case KindExportDeclaration: - return node.AsExportDeclaration().ModuleSpecifier + case KindImportDeclaration, KindJSImportDeclaration, KindExportDeclaration: + return node.ModuleSpecifier() case KindImportEqualsDeclaration: if node.AsImportEqualsDeclaration().ModuleReference.Kind == KindExternalModuleReference { - return node.AsImportEqualsDeclaration().ModuleReference.AsExternalModuleReference().Expression + return node.AsImportEqualsDeclaration().ModuleReference.Expression() } return nil case KindImportType: return getImportTypeNodeLiteral(node) case KindCallExpression: - return core.FirstOrNil(node.AsCallExpression().Arguments.Nodes) + return core.FirstOrNil(node.Arguments()) case KindModuleDeclaration: if IsStringLiteral(node.AsModuleDeclaration().Name()) { return node.AsModuleDeclaration().Name() @@ -1897,7 +1863,7 @@ func IsExpressionNode(node *Node) bool { return true case KindMetaProperty: // `import.defer` in `import.defer(...)` is not an expression - return !IsImportCall(node.Parent) || node.Parent.AsCallExpression().Expression != node + return !IsImportCall(node.Parent) || node.Parent.Expression() != node case KindExpressionWithTypeArguments: return !IsHeritageClause(node.Parent) case KindQualifiedName: @@ -1922,60 +1888,24 @@ func IsExpressionNode(node *Node) bool { func IsInExpressionContext(node *Node) bool { parent := node.Parent switch parent.Kind { - case KindVariableDeclaration: - return parent.AsVariableDeclaration().Initializer == node - case KindParameter: - return parent.AsParameterDeclaration().Initializer == node - case KindPropertyDeclaration: - return parent.AsPropertyDeclaration().Initializer == node - case KindPropertySignature: - return parent.AsPropertySignatureDeclaration().Initializer == node - case KindEnumMember: - return parent.AsEnumMember().Initializer == node - case KindPropertyAssignment: - return parent.AsPropertyAssignment().Initializer == node - case KindBindingElement: - return parent.AsBindingElement().Initializer == node - case KindExpressionStatement: - return parent.AsExpressionStatement().Expression == node - case KindIfStatement: - return parent.AsIfStatement().Expression == node - case KindDoStatement: - return parent.AsDoStatement().Expression == node - case KindWhileStatement: - return parent.AsWhileStatement().Expression == node - case KindReturnStatement: - return parent.AsReturnStatement().Expression == node - case KindWithStatement: - return parent.AsWithStatement().Expression == node - case KindSwitchStatement: - return parent.AsSwitchStatement().Expression == node - case KindCaseClause, KindDefaultClause: - return parent.AsCaseOrDefaultClause().Expression == node - case KindThrowStatement: - return parent.AsThrowStatement().Expression == node + case KindVariableDeclaration, KindParameter, KindPropertyDeclaration, KindPropertySignature, KindEnumMember, KindPropertyAssignment, KindBindingElement: + return parent.Initializer() == node + case KindExpressionStatement, KindIfStatement, KindDoStatement, KindWhileStatement, KindReturnStatement, KindWithStatement, KindSwitchStatement, + KindCaseClause, KindDefaultClause, KindThrowStatement, KindTypeAssertionExpression, KindAsExpression, KindTemplateSpan, KindComputedPropertyName, + KindSatisfiesExpression: + return parent.Expression() == node case KindForStatement: s := parent.AsForStatement() return s.Initializer == node && s.Initializer.Kind != KindVariableDeclarationList || s.Condition == node || s.Incrementor == node case KindForInStatement, KindForOfStatement: s := parent.AsForInOrOfStatement() return s.Initializer == node && s.Initializer.Kind != KindVariableDeclarationList || s.Expression == node - case KindTypeAssertionExpression: - return parent.AsTypeAssertion().Expression == node - case KindAsExpression: - return parent.AsAsExpression().Expression == node - case KindTemplateSpan: - return parent.AsTemplateSpan().Expression == node - case KindComputedPropertyName: - return parent.AsComputedPropertyName().Expression == node case KindDecorator, KindJsxExpression, KindJsxSpreadAttribute, KindSpreadAssignment: return true case KindExpressionWithTypeArguments: - return parent.AsExpressionWithTypeArguments().Expression == node && !IsPartOfTypeNode(parent) + return parent.Expression() == node && !IsPartOfTypeNode(parent) case KindShorthandPropertyAssignment: return parent.AsShorthandPropertyAssignment().ObjectAssignmentInitializer == node - case KindSatisfiesExpression: - return parent.AsSatisfiesExpression().Expression == node default: return IsExpressionNode(parent) } @@ -2064,25 +1994,21 @@ func IsJSDocTag(node *Node) bool { func isJSXTagName(node *Node) bool { parent := node.Parent switch parent.Kind { - case KindJsxOpeningElement: - return parent.AsJsxOpeningElement().TagName == node - case KindJsxSelfClosingElement: - return parent.AsJsxSelfClosingElement().TagName == node - case KindJsxClosingElement: - return parent.AsJsxClosingElement().TagName == node + case KindJsxOpeningElement, KindJsxSelfClosingElement, KindJsxClosingElement: + return parent.TagName() == node } return false } func IsSuperCall(node *Node) bool { - return IsCallExpression(node) && node.AsCallExpression().Expression.Kind == KindSuperKeyword + return IsCallExpression(node) && node.Expression().Kind == KindSuperKeyword } func IsImportCall(node *Node) bool { if !IsCallExpression(node) { return false } - e := node.AsCallExpression().Expression + e := node.Expression() return e.Kind == KindImportKeyword || IsMetaProperty(e) && e.AsMetaProperty().KeywordToken == KindImportKeyword && e.Text() == "defer" } @@ -2338,7 +2264,7 @@ func getModuleInstanceStateWorker(node *Node, ancestors []*Node, visited map[Nod state := ModuleInstanceStateNonInstantiated ancestors = pushAncestor(ancestors, node) ancestors = pushAncestor(ancestors, decl.ExportClause) - for _, specifier := range decl.ExportClause.AsNamedExports().Elements.Nodes { + for _, specifier := range decl.ExportClause.Elements() { specifierState := getModuleInstanceStateForAliasTarget(specifier, ancestors, visited) if specifierState > state { state = specifierState @@ -2374,21 +2300,16 @@ func getModuleInstanceStateWorker(node *Node, ancestors []*Node, visited map[Nod } func getModuleInstanceStateForAliasTarget(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState) ModuleInstanceState { - spec := node.AsExportSpecifier() - name := spec.PropertyName - if name == nil { - name = spec.Name() - } + name := node.PropertyNameOrName() if name.Kind != KindIdentifier { // Skip for invalid syntax like this: export { "x" } return ModuleInstanceStateInstantiated } for ancestors, p := popAncestor(ancestors, node); p != nil; ancestors, p = popAncestor(ancestors, p) { if IsBlock(p) || IsModuleBlock(p) || IsSourceFile(p) { - statements := GetStatementsOfBlock(p) found := ModuleInstanceStateUnknown statementsAncestors := pushAncestor(ancestors, p) - for _, statement := range statements.Nodes { + for _, statement := range p.Statements() { if NodeHasName(statement, name) { state := getModuleInstanceStateCached(statement, statementsAncestors, visited) if found == ModuleInstanceStateUnknown || state > found { @@ -2415,10 +2336,16 @@ func getModuleInstanceStateForAliasTarget(node *Node, ancestors []*Node, visited return ModuleInstanceStateInstantiated } +func IsInstantiatedModule(node *Node, preserveConstEnums bool) bool { + moduleState := GetModuleInstanceState(node) + return moduleState == ModuleInstanceStateInstantiated || + (preserveConstEnums && moduleState == ModuleInstanceStateConstEnumOnly) +} + func NodeHasName(statement *Node, id *Node) bool { name := statement.Name() if name != nil { - return IsIdentifier(name) && name.AsIdentifier().Text == id.AsIdentifier().Text + return IsIdentifier(name) && name.Text() == id.Text() } if IsVariableStatement(statement) { declarations := statement.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes @@ -2431,22 +2358,10 @@ func IsInternalModuleImportEqualsDeclaration(node *Node) bool { return IsImportEqualsDeclaration(node) && node.AsImportEqualsDeclaration().ModuleReference.Kind != KindExternalModuleReference } -func GetAssertedTypeNode(node *Node) *Node { - switch node.Kind { - case KindAsExpression: - return node.AsAsExpression().Type - case KindSatisfiesExpression: - return node.AsSatisfiesExpression().Type - case KindTypeAssertionExpression: - return node.AsTypeAssertion().Type - } - panic("Unhandled case in getAssertedTypeNode") -} - func IsConstAssertion(node *Node) bool { switch node.Kind { case KindAsExpression, KindTypeAssertionExpression: - return IsConstTypeReference(GetAssertedTypeNode(node)) + return IsConstTypeReference(node.Type()) } return false } @@ -2477,8 +2392,8 @@ func GetDeclarationOfKind(symbol *Symbol, kind Kind) *Node { } func FindConstructorDeclaration(node *ClassLikeDeclaration) *Node { - for _, member := range node.ClassLikeData().Members.Nodes { - if IsConstructorDeclaration(member) && NodeIsPresent(member.AsConstructorDeclaration().Body) { + for _, member := range node.Members() { + if IsConstructorDeclaration(member) && NodeIsPresent(member.Body()) { return member } } @@ -2500,7 +2415,7 @@ func GetFirstIdentifier(node *Node) *Node { func GetNamespaceDeclarationNode(node *Node) *Node { switch node.Kind { case KindImportDeclaration, KindJSImportDeclaration: - importClause := node.AsImportDeclaration().ImportClause + importClause := node.ImportClause() if importClause != nil && importClause.AsImportClause().NamedBindings != nil && IsNamespaceImport(importClause.AsImportClause().NamedBindings) { return importClause.AsImportClause().NamedBindings } @@ -2524,7 +2439,7 @@ func ModuleExportNameIsDefault(node *Node) bool { func IsDefaultImport(node *Node /*ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration*/) bool { switch node.Kind { case KindImportDeclaration, KindJSImportDeclaration: - importClause := node.AsImportDeclaration().ImportClause + importClause := node.ImportClause() return importClause != nil && importClause.AsImportClause().name != nil } return false @@ -2641,7 +2556,7 @@ func GetNodeAtPosition(file *SourceFile, position int, includeJSDoc bool) *Node } if child == nil { current.ForEachChild(func(node *Node) bool { - if nodeContainsPosition(node, position) { + if nodeContainsPosition(node, position) && node.Kind != KindJSExportAssignment && node.Kind != KindCommonJSExport { child = node return true } @@ -2808,9 +2723,9 @@ func IsVariableDeclarationInitializedToRequire(node *Node) bool { } return node.Parent.Parent.ModifierFlags()&ModifierFlagsExport == 0 && - node.AsVariableDeclaration().Initializer != nil && + node.Initializer() != nil && node.Type() == nil && - IsRequireCall(node.AsVariableDeclaration().Initializer, true /*requireStringLiteralLikeArgument*/) + IsRequireCall(node.Initializer(), true /*requireStringLiteralLikeArgument*/) } func IsModuleExportsAccessExpression(node *Node) bool { @@ -2855,12 +2770,12 @@ func IsTypeOnlyImportDeclaration(node *Node) bool { func isTypeOnlyExportDeclaration(node *Node) bool { switch node.Kind { case KindExportSpecifier: - return node.AsExportSpecifier().IsTypeOnly || node.Parent.Parent.AsExportDeclaration().IsTypeOnly + return node.IsTypeOnly() || node.Parent.Parent.IsTypeOnly() case KindExportDeclaration: d := node.AsExportDeclaration() return d.IsTypeOnly && d.ModuleSpecifier != nil && d.ExportClause == nil case KindNamespaceExport: - return node.Parent.AsExportDeclaration().IsTypeOnly + return node.Parent.IsTypeOnly() } return false } @@ -2872,13 +2787,13 @@ func IsTypeOnlyImportOrExportDeclaration(node *Node) bool { func IsExclusivelyTypeOnlyImportOrExport(node *Node) bool { switch node.Kind { case KindExportDeclaration: - return node.AsExportDeclaration().IsTypeOnly + return node.IsTypeOnly() case KindImportDeclaration, KindJSImportDeclaration: - if importClause := node.AsImportDeclaration().ImportClause; importClause != nil { + if importClause := node.ImportClause(); importClause != nil { return importClause.AsImportClause().IsTypeOnly() } case KindJSDocImportTag: - if importClause := node.AsJSDocImportTag().ImportClause; importClause != nil { + if importClause := node.ImportClause(); importClause != nil { return importClause.AsImportClause().IsTypeOnly() } } @@ -3086,7 +3001,7 @@ func GetPropertyNameForPropertyNameNode(name *Node) string { KindNumericLiteral, KindBigIntLiteral, KindJsxNamespacedName: return name.Text() case KindComputedPropertyName: - nameExpression := name.AsComputedPropertyName().Expression + nameExpression := name.Expression() if IsStringOrNumericLiteralLike(nameExpression) { return nameExpression.Text() } @@ -3113,11 +3028,9 @@ func IsPartOfExclusivelyTypeOnlyImportOrExportDeclaration(node *Node) bool { func IsEmittableImport(node *Node) bool { switch node.Kind { case KindImportDeclaration: - return node.AsImportDeclaration().ImportClause != nil && !node.AsImportDeclaration().ImportClause.IsTypeOnly() - case KindExportDeclaration: - return !node.AsExportDeclaration().IsTypeOnly - case KindImportEqualsDeclaration: - return !node.AsImportEqualsDeclaration().IsTypeOnly + return node.ImportClause() != nil && !node.ImportClause().IsTypeOnly() + case KindExportDeclaration, KindImportEqualsDeclaration: + return !node.IsTypeOnly() case KindCallExpression: return IsImportCall(node) } @@ -3169,7 +3082,7 @@ func IsTemplateLiteralToken(node *Node) bool { func GetExternalModuleImportEqualsDeclarationExpression(node *Node) *Node { debug.Assert(IsExternalModuleImportEqualsDeclaration(node)) - return node.AsImportEqualsDeclaration().ModuleReference.AsExternalModuleReference().Expression + return node.AsImportEqualsDeclaration().ModuleReference.Expression() } func CreateModifiersFromModifierFlags(flags ModifierFlags, createModifier func(kind Kind) *Node) []*Node { @@ -3249,7 +3162,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL modifierArray, node.AsParameterDeclaration().DotDotDotToken, node.Name(), - node.AsParameterDeclaration().QuestionToken, + node.QuestionToken(), node.Type(), node.Initializer(), ) @@ -3266,7 +3179,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL node.AsPropertySignatureDeclaration(), modifierArray, node.Name(), - node.AsPropertySignatureDeclaration().PostfixToken, + node.PostfixToken(), node.Type(), node.Initializer(), ) @@ -3275,7 +3188,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL node.AsPropertyDeclaration(), modifierArray, node.Name(), - node.AsPropertyDeclaration().PostfixToken, + node.PostfixToken(), node.Type(), node.Initializer(), ) @@ -3284,7 +3197,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL node.AsMethodSignatureDeclaration(), modifierArray, node.Name(), - node.AsMethodSignatureDeclaration().PostfixToken, + node.PostfixToken(), node.TypeParameterList(), node.ParameterList(), node.Type(), @@ -3295,7 +3208,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL modifierArray, node.AsMethodDeclaration().AsteriskToken, node.Name(), - node.AsMethodDeclaration().PostfixToken, + node.PostfixToken(), node.TypeParameterList(), node.ParameterList(), node.Type(), @@ -3444,8 +3357,8 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL return factory.UpdateImportDeclaration( node.AsImportDeclaration(), modifierArray, - node.AsImportDeclaration().ImportClause, - node.AsImportDeclaration().ModuleSpecifier, + node.ImportClause(), + node.ModuleSpecifier(), node.AsImportDeclaration().Attributes, ) case KindExportAssignment: @@ -3461,7 +3374,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL modifierArray, node.IsTypeOnly(), node.AsExportDeclaration().ExportClause, - node.AsExportDeclaration().ModuleSpecifier, + node.ModuleSpecifier(), node.AsExportDeclaration().Attributes, ) } @@ -3510,11 +3423,9 @@ func IsTypeDeclaration(node *Node) bool { case KindTypeParameter, KindClassDeclaration, KindInterfaceDeclaration, KindTypeAliasDeclaration, KindJSTypeAliasDeclaration, KindEnumDeclaration: return true case KindImportClause: - return node.AsImportClause().PhaseModifier == KindTypeKeyword - case KindImportSpecifier: - return node.Parent.Parent.AsImportClause().PhaseModifier == KindTypeKeyword - case KindExportSpecifier: - return node.Parent.Parent.AsExportDeclaration().IsTypeOnly + return node.IsTypeOnly() + case KindImportSpecifier, KindExportSpecifier: + return node.Parent.Parent.IsTypeOnly() default: return false } @@ -3526,6 +3437,10 @@ func IsTypeDeclarationName(name *Node) bool { GetNameOfDeclaration(name.Parent) == name } +func IsRightSideOfPropertyAccess(node *Node) bool { + return node.Parent.Kind == KindPropertyAccessExpression && node.Parent.Name() == node +} + func IsRightSideOfQualifiedNameOrPropertyAccess(node *Node) bool { parent := node.Parent switch parent.Kind { @@ -3548,7 +3463,7 @@ func ShouldTransformImportCall(fileName string, options *core.CompilerOptions, i } func HasQuestionToken(node *Node) bool { - return IsQuestionToken(node.PostfixToken()) + return IsQuestionToken(node.QuestionToken()) } func IsJsxOpeningLikeElement(node *Node) bool { @@ -3659,16 +3574,13 @@ func IsAssignmentPattern(node *Node) bool { func GetElementsOfBindingOrAssignmentPattern(name *Node) []*Node { switch name.Kind { - case KindObjectBindingPattern, KindArrayBindingPattern: + case KindObjectBindingPattern, KindArrayBindingPattern, KindArrayLiteralExpression: // `a` in `{a}` // `a` in `[a]` - return name.AsBindingPattern().Elements.Nodes - case KindArrayLiteralExpression: - // `a` in `[a]` - return name.AsArrayLiteralExpression().Elements.Nodes + return name.Elements() case KindObjectLiteralExpression: // `a` in `{a}` - return name.AsObjectLiteralExpression().Properties.Nodes + return name.Properties() } return nil } @@ -3726,7 +3638,7 @@ func GetTargetOfBindingOrAssignmentElement(bindingElement *Node) *Node { return bindingElement.Name() case KindSpreadAssignment: // `a` in `({ ...a } = ...)` - return GetTargetOfBindingOrAssignmentElement(bindingElement.AsSpreadAssignment().Expression) + return GetTargetOfBindingOrAssignmentElement(bindingElement.Expression()) } // no target @@ -3744,7 +3656,7 @@ func GetTargetOfBindingOrAssignmentElement(bindingElement *Node) *Node { if IsSpreadElement(bindingElement) { // `a` in `[...a] = ...` - return GetTargetOfBindingOrAssignmentElement(bindingElement.AsSpreadElement().Expression) + return GetTargetOfBindingOrAssignmentElement(bindingElement.Expression()) } // `a` in `[a] = ...` @@ -3762,13 +3674,13 @@ func TryGetPropertyNameOfBindingOrAssignmentElement(bindingElement *Node) *Node // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` // `1` in `let { 1: b } = ...` - if bindingElement.AsBindingElement().PropertyName != nil { - propertyName := bindingElement.AsBindingElement().PropertyName + if bindingElement.PropertyName() != nil { + propertyName := bindingElement.PropertyName() // if ast.IsPrivateIdentifier(propertyName) { // return Debug.failBadSyntaxKind(propertyName) // !!! // } - if IsComputedPropertyName(propertyName) && IsStringOrNumericLiteralLike(propertyName.AsComputedPropertyName().Expression) { - return propertyName.AsComputedPropertyName().Expression + if IsComputedPropertyName(propertyName) && IsStringOrNumericLiteralLike(propertyName.Expression()) { + return propertyName.Expression() } return propertyName } @@ -3782,8 +3694,8 @@ func TryGetPropertyNameOfBindingOrAssignmentElement(bindingElement *Node) *Node // if ast.IsPrivateIdentifier(propertyName) { // return Debug.failBadSyntaxKind(propertyName) // !!! // } - if IsComputedPropertyName(propertyName) && IsStringOrNumericLiteralLike(propertyName.AsComputedPropertyName().Expression) { - return propertyName.AsComputedPropertyName().Expression + if IsComputedPropertyName(propertyName) && IsStringOrNumericLiteralLike(propertyName.Expression()) { + return propertyName.Expression() } return propertyName } @@ -3833,11 +3745,11 @@ func ContainsObjectRestOrSpread(node *Node) bool { } func IsEmptyObjectLiteral(expression *Node) bool { - return expression.Kind == KindObjectLiteralExpression && len(expression.AsObjectLiteralExpression().Properties.Nodes) == 0 + return IsObjectLiteralExpression(expression) && len(expression.Properties()) == 0 } func IsEmptyArrayLiteral(expression *Node) bool { - return expression.Kind == KindArrayLiteralExpression && len(expression.AsArrayLiteralExpression().Elements.Nodes) == 0 + return IsArrayLiteralExpression(expression) && len(expression.Elements()) == 0 } func GetRestIndicatorOfBindingOrAssignmentElement(bindingElement *Node) *Node { @@ -3882,7 +3794,7 @@ func IsExpandoInitializer(initializer *Node) bool { return true } if IsInJSFile(initializer) { - return IsClassExpression(initializer) || (IsObjectLiteralExpression(initializer) && len(initializer.AsObjectLiteralExpression().Properties.Nodes) == 0) + return IsClassExpression(initializer) || (IsObjectLiteralExpression(initializer) && len(initializer.Properties()) == 0) } return false } @@ -3890,3 +3802,57 @@ func IsExpandoInitializer(initializer *Node) bool { func GetContainingFunction(node *Node) *Node { return FindAncestor(node.Parent, IsFunctionLike) } + +func IsImplicitlyExportedJSTypeAlias(node *Node) bool { + return IsJSTypeAliasDeclaration(node) && IsSourceFile(node.Parent) && IsExternalOrCommonJSModule(node.Parent.AsSourceFile()) +} + +func HasContextSensitiveParameters(node *Node) bool { + // Functions with type parameters are not context sensitive. + if node.TypeParameters() == nil { + // Functions with any parameters that lack type annotations are context sensitive. + if core.Some(node.Parameters(), func(p *Node) bool { return p.Type() == nil }) { + return true + } + if !IsArrowFunction(node) { + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. + parameter := core.FirstOrNil(node.Parameters()) + if parameter == nil || !IsThisParameter(parameter) { + return true + } + } + } + return false +} + +func IsInfinityOrNaNString(name string) bool { + return name == "Infinity" || name == "-Infinity" || name == "NaN" +} + +func GetFirstConstructorWithBody(node *Node) *Node { + for _, member := range node.Members() { + if IsConstructorDeclaration(member) && NodeIsPresent(member.Body()) { + return member + } + } + return nil +} + +// Returns true for nodes that are considered executable for the purposes of unreachable code detection. +func IsPotentiallyExecutableNode(node *Node) bool { + if KindFirstStatement <= node.Kind && node.Kind <= KindLastStatement { + if IsVariableStatement(node) { + declarationList := node.AsVariableStatement().DeclarationList + if GetCombinedNodeFlags(declarationList)&NodeFlagsBlockScoped != 0 { + return true + } + declarations := declarationList.AsVariableDeclarationList().Declarations.Nodes + return core.Some(declarations, func(d *Node) bool { + return d.Initializer() != nil + }) + } + return true + } + return IsClassDeclaration(node) || IsEnumDeclaration(node) || IsModuleDeclaration(node) +} diff --git a/internal/astnav/tokens.go b/internal/astnav/tokens.go index a7b4750034..85fa79801e 100644 --- a/internal/astnav/tokens.go +++ b/internal/astnav/tokens.go @@ -65,6 +65,10 @@ func getTokenAtPosition( // `left` tracks the lower boundary of the node/token that could be returned, // and is eventually the scanner's start position, if the scanner is used. left := 0 + // `allowReparsed` is set when we're navigating inside an AsExpression or + // SatisfiesExpression, which allows visiting their reparsed children to reach + // the actual identifier from JSDoc type assertions. + allowReparsed := false testNode := func(node *ast.Node) int { if node.Kind != ast.KindEndOfFile && node.End() == position && includePrecedingTokenAtEndPosition != nil { @@ -74,7 +78,8 @@ func getTokenAtPosition( if node.End() < position || node.Kind != ast.KindEndOfFile && node.End() == position { return -1 } - if getPosition(node, sourceFile, allowPositionInLeadingTrivia) > position { + nodePos := getPosition(node, sourceFile, allowPositionInLeadingTrivia) + if nodePos > position { return 1 } return 0 @@ -86,18 +91,29 @@ func getTokenAtPosition( visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node { // We can't abort visiting children, so once a match is found, we set `next` // and do nothing on subsequent visits. - if node != nil && node.Flags&ast.NodeFlagsReparsed == 0 && next == nil { - switch testNode(node) { - case -1: - if !ast.IsJSDocKind(node.Kind) { - // We can't move the left boundary into or beyond JSDoc, - // because we may end up returning the token after this JSDoc, - // constructing it with the scanner, and we need to include - // all its leading trivia in its position. - left = node.End() + if node != nil && next == nil { + // Skip reparsed nodes unless: + // 1. The node itself is AsExpression or SatisfiesExpression, OR + // 2. We're already inside an AsExpression or SatisfiesExpression (allowReparsed=true) + // These are special cases where reparsed nodes from JSDoc type assertions + // should still be navigable to reach identifiers. + isSpecialReparsed := node.Flags&ast.NodeFlagsReparsed != 0 && + (node.Kind == ast.KindAsExpression || node.Kind == ast.KindSatisfiesExpression) + + if node.Flags&ast.NodeFlagsReparsed == 0 || isSpecialReparsed || allowReparsed { + result := testNode(node) + switch result { + case -1: + if !ast.IsJSDocKind(node.Kind) { + // We can't move the left boundary into or beyond JSDoc, + // because we may end up returning the token after this JSDoc, + // constructing it with the scanner, and we need to include + // all its leading trivia in its position. + left = node.End() + } + case 0: + next = node } - case 0: - next = node } } return node @@ -194,6 +210,11 @@ func getTokenAtPosition( current = next left = current.Pos() next = nil + // When navigating into AsExpression or SatisfiesExpression, allow visiting + // their reparsed children to reach identifiers from JSDoc type assertions. + if current.Kind == ast.KindAsExpression || current.Kind == ast.KindSatisfiesExpression { + allowReparsed = true + } } } @@ -651,3 +672,60 @@ func shouldSkipChild(node *ast.Node) bool { ast.IsJSDocLinkLike(node) || ast.IsJSDocTag(node) } + +// FindChildOfKind searches for a child node or token of the specified kind within a containing node. +// This function scans through both AST nodes and intervening tokens to find the first match. +func FindChildOfKind(containingNode *ast.Node, kind ast.Kind, sourceFile *ast.SourceFile) *ast.Node { + lastNodePos := containingNode.Pos() + scan := scanner.GetScannerForSourceFile(sourceFile, lastNodePos) + + var foundChild *ast.Node + visitNode := func(node *ast.Node) bool { + if node == nil || node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + // Look for child in preceding tokens. + startPos := lastNodePos + for startPos < node.Pos() { + tokenKind := scan.Token() + tokenFullStart := scan.TokenFullStart() + tokenEnd := scan.TokenEnd() + token := sourceFile.GetOrCreateToken(tokenKind, tokenFullStart, tokenEnd, containingNode) + if tokenKind == kind { + foundChild = token + return true + } + startPos = tokenEnd + scan.Scan() + } + if node.Kind == kind { + foundChild = node + return true + } + + lastNodePos = node.End() + scan.ResetPos(lastNodePos) + return false + } + + ast.ForEachChildAndJSDoc(containingNode, sourceFile, visitNode) + + if foundChild != nil { + return foundChild + } + + // Look for child in trailing tokens. + startPos := lastNodePos + for startPos < containingNode.End() { + tokenKind := scan.Token() + tokenFullStart := scan.TokenFullStart() + tokenEnd := scan.TokenEnd() + token := sourceFile.GetOrCreateToken(tokenKind, tokenFullStart, tokenEnd, containingNode) + if tokenKind == kind { + return token + } + startPos = tokenEnd + scan.Scan() + } + return nil +} diff --git a/internal/astnav/tokens_test.go b/internal/astnav/tokens_test.go index b5eb7ba39f..0a0d180646 100644 --- a/internal/astnav/tokens_test.go +++ b/internal/astnav/tokens_test.go @@ -43,6 +43,52 @@ func TestGetTokenAtPosition(t *testing.T) { ) }) + t.Run("JSDoc type assertion", func(t *testing.T) { + t.Parallel() + fileText := `function foo(x) { + const s = /**@type {string}*/(x) +}` + file := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.js", + Path: "/test.js", + }, fileText, core.ScriptKindJS) + + // Position of 'x' inside the parenthesized expression (position 52) + position := 52 + + // This should not panic - it previously panicked with: + // "did not expect KindParenthesizedExpression to have KindIdentifier in its trivia" + token := astnav.GetTouchingPropertyName(file, position) + if token == nil { + t.Fatal("Expected to get a token, got nil") + } + + // The function may return either the identifier itself or the containing + // parenthesized expression, depending on how the AST is structured + if token.Kind != ast.KindIdentifier && token.Kind != ast.KindParenthesizedExpression { + t.Errorf("Expected identifier or parenthesized expression, got %s", token.Kind) + } + }) + + t.Run("JSDoc type assertion with comment", func(t *testing.T) { + t.Parallel() + // Exact code from the issue report + fileText := `function foo(x) { + const s = /**@type {string}*/(x) // Go-to-definition on x causes panic +}` + file := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.js", + Path: "/test.js", + }, fileText, core.ScriptKindJS) + + // Find position of 'x' in the type assertion + xPos := 52 // Position of 'x' in (x) + + // This should not panic + token := astnav.GetTouchingPropertyName(file, xPos) + assert.Assert(t, token != nil, "Expected to get a token") + }) + t.Run("pointer equality", func(t *testing.T) { t.Parallel() fileText := ` diff --git a/internal/binder/binder.go b/internal/binder/binder.go index baab837d74..18653bd7b4 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -42,10 +42,9 @@ const ( ) type Binder struct { - file *ast.SourceFile - bindFunc func(*ast.Node) bool - unreachableFlow *ast.FlowNode - reportedUnreachableFlow *ast.FlowNode + file *ast.SourceFile + bindFunc func(*ast.Node) bool + unreachableFlow *ast.FlowNode container *ast.Node thisContainer *ast.Node @@ -122,7 +121,6 @@ func bindSourceFile(file *ast.SourceFile) { b.file = file b.inStrictMode = b.options().BindInStrictMode && !file.IsDeclarationFile || ast.IsExternalModule(file) b.unreachableFlow = b.newFlowNode(ast.FlowFlagsUnreachable) - b.reportedUnreachableFlow = b.newFlowNode(ast.FlowFlagsUnreachable) b.bind(file.AsNode()) file.SymbolCount = b.symbolCount file.ClassifiableNames = b.classifiableNames @@ -259,9 +257,9 @@ func (b *Binder) declareSymbolEx(symbolTable ast.SymbolTable, parent *ast.Symbol } else { diag = b.createDiagnosticForNode(declarationName, message) } - if ast.IsTypeAliasDeclaration(node) && ast.NodeIsMissing(node.AsTypeAliasDeclaration().Type) && ast.HasSyntacticModifier(node, ast.ModifierFlagsExport) && symbol.Flags&(ast.SymbolFlagsAlias|ast.SymbolFlagsType|ast.SymbolFlagsNamespace) != 0 { + if ast.IsTypeAliasDeclaration(node) && ast.NodeIsMissing(node.Type()) && ast.HasSyntacticModifier(node, ast.ModifierFlagsExport) && symbol.Flags&(ast.SymbolFlagsAlias|ast.SymbolFlagsType|ast.SymbolFlagsNamespace) != 0 { // export type T; - may have meant export type { T }? - diag.AddRelatedInfo(b.createDiagnosticForNode(node, diagnostics.Did_you_mean_0, "export type { "+node.AsTypeAliasDeclaration().Name().AsIdentifier().Text+" }")) + diag.AddRelatedInfo(b.createDiagnosticForNode(node, diagnostics.Did_you_mean_0, "export type { "+node.AsTypeAliasDeclaration().Name().Text()+" }")) } for index, declaration := range symbol.Declarations { var decl *ast.Node = ast.GetNameOfDeclaration(declaration) @@ -333,7 +331,7 @@ func (b *Binder) getDeclarationName(node *ast.Node) string { return name.Text() } if ast.IsComputedPropertyName(name) { - nameExpression := name.AsComputedPropertyName().Expression + nameExpression := name.Expression() // treat computed property names where expression is string/numeric literal as just string/numeric literal if ast.IsStringOrNumericLiteralLike(nameExpression) { return nameExpression.Text() @@ -381,10 +379,10 @@ func GetSymbolNameForPrivateIdentifier(containingClassSymbol *ast.Symbol, descri func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags) *ast.Symbol { container := b.container - if node.Kind == ast.KindCommonJSExport { + if ast.IsCommonJSExport(node) { container = b.file.AsNode() } - hasExportModifier := ast.GetCombinedModifierFlags(node)&ast.ModifierFlagsExport != 0 + hasExportModifier := ast.GetCombinedModifierFlags(node)&ast.ModifierFlagsExport != 0 || ast.IsImplicitlyExportedJSTypeAlias(node) if symbolFlags&ast.SymbolFlagsAlias != 0 { if node.Kind == ast.KindExportSpecifier || (node.Kind == ast.KindImportEqualsDeclaration && hasExportModifier) { return b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes) @@ -406,7 +404,7 @@ func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - if !ast.IsAmbientModule(node) && (hasExportModifier || container.Flags&ast.NodeFlagsExportContext != 0) { + if !ast.IsAmbientModule(node) && (hasExportModifier || ast.IsCommonJSExport(node) || container.Flags&ast.NodeFlagsExportContext != 0) { if !ast.IsLocalsContainer(container) || (ast.HasSyntacticModifier(node, ast.ModifierFlagsDefault) && b.getDeclarationName(node) == ast.InternalSymbolNameMissing) || ast.IsCommonJSExport(node) { return b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes) // No local symbol for an unnamed default! @@ -689,7 +687,9 @@ func (b *Binder) bind(node *ast.Node) bool { case ast.KindInterfaceDeclaration: b.bindBlockScopedDeclaration(node, ast.SymbolFlagsInterface, ast.SymbolFlagsInterfaceExcludes) case ast.KindCallExpression: - b.bindCallExpression(node) + if ast.IsInJSFile(node) { + b.bindCallExpression(node) + } case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: b.bindBlockScopedDeclaration(node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) case ast.KindEnumDeclaration: @@ -707,14 +707,14 @@ func (b *Binder) bind(node *ast.Node) bool { case ast.KindExportAssignment, ast.KindJSExportAssignment: b.bindExportAssignment(node) case ast.KindSourceFile: - b.updateStrictModeStatementList(node.AsSourceFile().Statements) + b.updateStrictModeStatementList(node.StatementList()) b.bindSourceFileIfExternalModule() case ast.KindBlock: if ast.IsFunctionLikeOrClassStaticBlockDeclaration(node.Parent) { - b.updateStrictModeStatementList(node.AsBlock().Statements) + b.updateStrictModeStatementList(node.StatementList()) } case ast.KindModuleBlock: - b.updateStrictModeStatementList(node.AsModuleBlock().Statements) + b.updateStrictModeStatementList(node.StatementList()) case ast.KindJsxAttributes: b.bindJsxAttributes(node) case ast.KindJsxAttribute: @@ -785,10 +785,10 @@ func (b *Binder) bindModuleDeclaration(node *ast.Node) { symbol := b.declareSymbolAndAddToSymbolTable(node, ast.SymbolFlagsValueModule, ast.SymbolFlagsValueModuleExcludes) if ast.IsStringLiteral(name) { - pattern := core.TryParsePattern(name.AsStringLiteral().Text) + pattern := core.TryParsePattern(name.Text()) if !pattern.IsValid() { // An invalid pattern - must have multiple wildcards. - b.errorOnFirstToken(name, diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, name.AsStringLiteral().Text) + b.errorOnFirstToken(name, diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, name.Text()) } else if pattern.StarIndex >= 0 { b.file.PatternAmbientModules = append(b.file.PatternAmbientModules, &ast.PatternAmbientModule{Pattern: pattern, Symbol: symbol}) } @@ -797,7 +797,7 @@ func (b *Binder) bindModuleDeclaration(node *ast.Node) { } else { state := b.declareModuleSymbol(node) if state != ast.ModuleInstanceStateNonInstantiated { - symbol := node.AsModuleDeclaration().Symbol + symbol := node.Symbol() if symbol.Flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsClass|ast.SymbolFlagsRegularEnum) != 0 || state != ast.ModuleInstanceStateConstEnumOnly { // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only symbol.Flags &^= ast.SymbolFlagsConstEnumOnlyModule @@ -893,11 +893,11 @@ func (b *Binder) hasExportDeclarations(node *ast.Node) bool { var statements []*ast.Node switch node.Kind { case ast.KindSourceFile: - statements = node.AsSourceFile().Statements.Nodes + statements = node.Statements() case ast.KindModuleDeclaration: - body := node.AsModuleDeclaration().Body + body := node.Body() if body != nil && ast.IsModuleBlock(body) { - statements = body.AsModuleBlock().Statements.Nodes + statements = body.Statements() } } return core.Some(statements, func(s *ast.Node) bool { @@ -910,22 +910,30 @@ func (b *Binder) bindFunctionExpression(node *ast.Node) { bindingName := ast.InternalSymbolNameFunction if ast.IsFunctionExpression(node) && node.AsFunctionExpression().Name() != nil { b.checkStrictModeFunctionName(node) - bindingName = node.AsFunctionExpression().Name().AsIdentifier().Text + bindingName = node.AsFunctionExpression().Name().Text() } b.bindAnonymousDeclaration(node, ast.SymbolFlagsFunction, bindingName) } func (b *Binder) bindCallExpression(node *ast.Node) { - // !!! for ModuleDetectionKind.Force, external module indicator is forced to `true` in Strada for source files, in which case - // we should set the commonjs module indicator but not call b.bindSourceFileAsExternalModule - // !!! && file.externalModuleIndicator !== true (used for ModuleDetectionKind.Force) - if ast.IsInJSFile(node) && - b.file.ExternalModuleIndicator == nil && - b.file.CommonJSModuleIndicator == nil && - ast.IsRequireCall(node, false /*requireStringLiteralLikeArgument*/) { + // We're only inspecting call expressions to detect CommonJS modules, so we can skip + // this check if we've already seen the module indicator + if b.file.CommonJSModuleIndicator == nil && ast.IsRequireCall(node, false /*requireStringLiteralLikeArgument*/) { + b.setCommonJSModuleIndicator(node) + } +} + +func (b *Binder) setCommonJSModuleIndicator(node *ast.Node) bool { + if b.file.ExternalModuleIndicator != nil && b.file.ExternalModuleIndicator != b.file.AsNode() { + return false + } + if b.file.CommonJSModuleIndicator == nil { b.file.CommonJSModuleIndicator = node - b.bindSourceFileAsExternalModule() + if b.file.ExternalModuleIndicator == nil { + b.bindSourceFileAsExternalModule() + } } + return true } func (b *Binder) bindClassLikeDeclaration(node *ast.Node) { @@ -936,7 +944,7 @@ func (b *Binder) bindClassLikeDeclaration(node *ast.Node) { case ast.KindClassExpression: nameText := ast.InternalSymbolNameClass if name != nil { - nameText = name.AsIdentifier().Text + nameText = name.Text() b.classifiableNames.Add(nameText) } b.bindAnonymousDeclaration(node, ast.SymbolFlagsClass, nameText) @@ -1015,7 +1023,7 @@ func getInitializerSymbol(symbol *ast.Symbol) *ast.Symbol { // For an assignment 'fn.xxx = ...', where 'fn' is a previously declared function or a previously // declared const variable initialized with a function expression or arrow function, we add expando // property declarations to the function's symbol. - // This also applies to class expressions and empty object literals. + // This also applies to class expressions and empty object literals in JS files. switch { case ast.IsFunctionDeclaration(declaration) || ast.IsInJSFile(declaration) && ast.IsClassDeclaration(declaration): return symbol @@ -1190,10 +1198,9 @@ func (b *Binder) bindTypeParameter(node *ast.Node) { func (b *Binder) lookupEntity(node *ast.Node, container *ast.Node) *ast.Symbol { if ast.IsIdentifier(node) { - return b.lookupName(node.AsIdentifier().Text, container) + return b.lookupName(node.Text(), container) } - if ast.IsPropertyAccessExpression(node) && node.AsPropertyAccessExpression().Expression.Kind == ast.KindThisKeyword || - ast.IsElementAccessExpression(node) && node.AsElementAccessExpression().Expression.Kind == ast.KindThisKeyword { + if (ast.IsPropertyAccessExpression(node) || ast.IsElementAccessExpression(node)) && node.Expression().Kind == ast.KindThisKeyword { if _, symbolTable := b.getThisClassAndSymbolTable(); symbolTable != nil { if name := ast.GetElementOrPropertyAccessName(node); name != nil { return symbolTable.Get(name.Text()) @@ -1238,7 +1245,7 @@ func (b *Binder) checkContextualIdentifier(node *ast.Node) { // Report error only if there are no parse errors in file if len(b.file.Diagnostics()) == 0 && node.Flags&ast.NodeFlagsAmbient == 0 && node.Flags&ast.NodeFlagsJSDoc == 0 && !ast.IsIdentifierName(node) { // strict mode identifiers - originalKeywordKind := scanner.GetIdentifierToken(node.AsIdentifier().Text) + originalKeywordKind := scanner.GetIdentifierToken(node.Text()) if originalKeywordKind == ast.KindIdentifier { return } @@ -1257,7 +1264,7 @@ func (b *Binder) checkContextualIdentifier(node *ast.Node) { } func (b *Binder) checkPrivateIdentifier(node *ast.Node) { - if node.AsPrivateIdentifier().Text == "#constructor" { + if node.Text() == "#constructor" { // Report error only if there are no parse errors in file if len(b.file.Diagnostics()) == 0 { b.errorOnNode(node, diagnostics.X_constructor_is_a_reserved_word, scanner.DeclarationNameToString(node)) @@ -1288,7 +1295,7 @@ func (b *Binder) updateStrictModeStatementList(statements *ast.NodeList) { // Should be called only on prologue directives (ast.IsPrologueDirective(node) should be true) func isUseStrictPrologueDirective(sourceFile *ast.SourceFile, node *ast.Node) bool { - nodeText := scanner.GetSourceTextOfNodeFromSourceFile(sourceFile, node.AsExpressionStatement().Expression, false /*includeTrivia*/) + nodeText := scanner.GetSourceTextOfNodeFromSourceFile(sourceFile, node.Expression(), false /*includeTrivia*/) // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). return nodeText == "\"use strict\"" || nodeText == "'use strict'" @@ -1393,7 +1400,7 @@ func (b *Binder) checkStrictModeLabeledStatement(node *ast.Node) { func isEvalOrArgumentsIdentifier(node *ast.Node) bool { if ast.IsIdentifier(node) { - text := node.AsIdentifier().Text + text := node.Text() return text == "eval" || text == "arguments" } return false @@ -1403,7 +1410,7 @@ func (b *Binder) checkStrictModeEvalOrArguments(contextNode *ast.Node, name *ast if name != nil && isEvalOrArgumentsIdentifier(name) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. - b.errorOnNode(name, b.getStrictModeEvalOrArgumentsMessage(contextNode), name.AsIdentifier().Text) + b.errorOnNode(name, b.getStrictModeEvalOrArgumentsMessage(contextNode), name.Text()) } } @@ -1549,18 +1556,25 @@ func (b *Binder) bindChildren(node *ast.Node) { // Most nodes aren't valid in an assignment pattern, so we clear the value here // and set it before we descend into nodes that could actually be part of an assignment pattern. b.inAssignmentPattern = false - if b.checkUnreachable(node) { + + if b.currentFlow == b.unreachableFlow { + if flowNodeData := node.FlowNodeData(); flowNodeData != nil { + flowNodeData.FlowNode = nil + } + if ast.IsPotentiallyExecutableNode(node) { + node.Flags |= ast.NodeFlagsUnreachable + } b.bindEachChild(node) b.inAssignmentPattern = saveInAssignmentPattern return } - kind := node.Kind - if kind >= ast.KindFirstStatement && kind <= ast.KindLastStatement && (b.options().AllowUnreachableCode != core.TSTrue || kind == ast.KindReturnStatement) { - hasFlowNodeData := node.FlowNodeData() - if hasFlowNodeData != nil { - hasFlowNodeData.FlowNode = b.currentFlow + + if ast.KindFirstStatement <= node.Kind && node.Kind <= ast.KindLastStatement { + if flowNodeData := node.FlowNodeData(); flowNodeData != nil { + flowNodeData.FlowNode = b.currentFlow } } + switch node.Kind { case ast.KindWhileStatement: b.bindWhileStatement(node) @@ -1621,10 +1635,8 @@ func (b *Binder) bindChildren(node *ast.Node) { sourceFile := node.AsSourceFile() b.bindEachStatementFunctionsFirst(sourceFile.Statements) b.bind(sourceFile.EndOfFileToken) - case ast.KindBlock: - b.bindEachStatementFunctionsFirst(node.AsBlock().Statements) - case ast.KindModuleBlock: - b.bindEachStatementFunctionsFirst(node.AsModuleBlock().Statements) + case ast.KindBlock, ast.KindModuleBlock: + b.bindEachStatementFunctionsFirst(node.StatementList()) case ast.KindBindingElement: b.bindBindingElementFlow(node) case ast.KindParameter: @@ -1673,94 +1685,6 @@ func (b *Binder) bindEachStatementFunctionsFirst(statements *ast.NodeList) { } } -func (b *Binder) checkUnreachable(node *ast.Node) bool { - if b.currentFlow.Flags&ast.FlowFlagsUnreachable == 0 { - return false - } - if b.currentFlow == b.unreachableFlow { - // report errors on all statements except empty ones - // report errors on class declarations - // report errors on enums with preserved emit - // report errors on instantiated modules - reportError := ast.IsStatementButNotDeclaration(node) && !ast.IsEmptyStatement(node) || - ast.IsClassDeclaration(node) || - isEnumDeclarationWithPreservedEmit(node, b.options()) || - ast.IsModuleDeclaration(node) && b.shouldReportErrorOnModuleDeclaration(node) - if reportError { - b.currentFlow = b.reportedUnreachableFlow - if b.options().AllowUnreachableCode != core.TSTrue { - // unreachable code is reported if - // - user has explicitly asked about it AND - // - statement is in not ambient context (statements in ambient context is already an error - // so we should not report extras) AND - // - node is not variable statement OR - // - node is block scoped variable statement OR - // - node is not block scoped variable statement and at least one variable declaration has initializer - // Rationale: we don't want to report errors on non-initialized var's since they are hoisted - // On the other side we do want to report errors on non-initialized 'lets' because of TDZ - isError := unreachableCodeIsError(b.options()) && node.Flags&ast.NodeFlagsAmbient == 0 && (!ast.IsVariableStatement(node) || - ast.GetCombinedNodeFlags(node.AsVariableStatement().DeclarationList)&ast.NodeFlagsBlockScoped != 0 || - core.Some(node.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes, func(d *ast.Node) bool { - return d.AsVariableDeclaration().Initializer != nil - })) - b.errorOnEachUnreachableRange(node, isError) - } - } - } - return true -} - -func (b *Binder) shouldReportErrorOnModuleDeclaration(node *ast.Node) bool { - instanceState := ast.GetModuleInstanceState(node) - return instanceState == ast.ModuleInstanceStateInstantiated || (instanceState == ast.ModuleInstanceStateConstEnumOnly && b.options().ShouldPreserveConstEnums) -} - -func (b *Binder) errorOnEachUnreachableRange(node *ast.Node, isError bool) { - if b.isExecutableStatement(node) && ast.IsBlock(node.Parent) { - statements := node.Parent.AsBlock().Statements.Nodes - index := slices.Index(statements, node) - var first, last *ast.Node - for _, s := range statements[index:] { - if b.isExecutableStatement(s) { - if first == nil { - first = s - } - last = s - } else if first != nil { - b.errorOrSuggestionOnRange(isError, first, last, diagnostics.Unreachable_code_detected) - first = nil - } - } - if first != nil { - b.errorOrSuggestionOnRange(isError, first, last, diagnostics.Unreachable_code_detected) - } - } else { - b.errorOrSuggestionOnNode(isError, node, diagnostics.Unreachable_code_detected) - } -} - -// As opposed to a pure declaration like an `interface` -func (b *Binder) isExecutableStatement(s *ast.Node) bool { - // Don't remove statements that can validly be used before they appear. - return !ast.IsFunctionDeclaration(s) && !b.isPurelyTypeDeclaration(s) && !(ast.IsVariableStatement(s) && ast.GetCombinedNodeFlags(s)&ast.NodeFlagsBlockScoped == 0 && - core.Some(s.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes, func(d *ast.Node) bool { - return d.AsVariableDeclaration().Initializer == nil - })) -} - -func (b *Binder) isPurelyTypeDeclaration(s *ast.Node) bool { - switch s.Kind { - case ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: - return true - case ast.KindModuleDeclaration: - return ast.GetModuleInstanceState(s) != ast.ModuleInstanceStateInstantiated - case ast.KindEnumDeclaration: - return !isEnumDeclarationWithPreservedEmit(s, b.options()) - default: - return false - } -} - func (b *Binder) setContinueTarget(node *ast.Node, target *ast.FlowLabel) *ast.FlowLabel { label := b.activeLabelList for label != nil && node.Parent.Kind == ast.KindLabeledStatement { @@ -1806,22 +1730,22 @@ func isLogicalAssignmentExpression(node *ast.Node) bool { func (b *Binder) bindAssignmentTargetFlow(node *ast.Node) { switch node.Kind { case ast.KindArrayLiteralExpression: - for _, e := range node.AsArrayLiteralExpression().Elements.Nodes { + for _, e := range node.Elements() { if e.Kind == ast.KindSpreadElement { - b.bindAssignmentTargetFlow(e.AsSpreadElement().Expression) + b.bindAssignmentTargetFlow(e.Expression()) } else { b.bindDestructuringTargetFlow(e) } } case ast.KindObjectLiteralExpression: - for _, p := range node.AsObjectLiteralExpression().Properties.Nodes { + for _, p := range node.Properties() { switch p.Kind { case ast.KindPropertyAssignment: - b.bindDestructuringTargetFlow(p.AsPropertyAssignment().Initializer) + b.bindDestructuringTargetFlow(p.Initializer()) case ast.KindShorthandPropertyAssignment: b.bindAssignmentTargetFlow(p.AsShorthandPropertyAssignment().Name()) case ast.KindSpreadAssignment: - b.bindAssignmentTargetFlow(p.AsSpreadAssignment().Expression) + b.bindAssignmentTargetFlow(p.Expression()) } } default: @@ -1922,7 +1846,7 @@ func (b *Binder) bindIfStatement(node *ast.Node) { } func (b *Binder) bindReturnStatement(node *ast.Node) { - b.bind(node.AsReturnStatement().Expression) + b.bind(node.Expression()) if b.currentReturnTarget != nil { b.addAntecedent(b.currentReturnTarget, b.currentFlow) } @@ -1932,23 +1856,23 @@ func (b *Binder) bindReturnStatement(node *ast.Node) { } func (b *Binder) bindThrowStatement(node *ast.Node) { - b.bind(node.AsThrowStatement().Expression) + b.bind(node.Expression()) b.currentFlow = b.unreachableFlow b.hasFlowEffects = true } func (b *Binder) bindBreakStatement(node *ast.Node) { - b.bindBreakOrContinueStatement(node.AsBreakStatement().Label, b.currentBreakTarget, (*ActiveLabel).BreakTarget) + b.bindBreakOrContinueStatement(node.Label(), b.currentBreakTarget, (*ActiveLabel).BreakTarget) } func (b *Binder) bindContinueStatement(node *ast.Node) { - b.bindBreakOrContinueStatement(node.AsContinueStatement().Label, b.currentContinueTarget, (*ActiveLabel).ContinueTarget) + b.bindBreakOrContinueStatement(node.Label(), b.currentContinueTarget, (*ActiveLabel).ContinueTarget) } func (b *Binder) bindBreakOrContinueStatement(label *ast.Node, currentTarget *ast.FlowNode, getTarget func(*ActiveLabel) *ast.FlowNode) { b.bind(label) if label != nil { - activeLabel := b.findActiveLabel(label.AsIdentifier().Text) + activeLabel := b.findActiveLabel(label.Text()) if activeLabel != nil { activeLabel.referenced = true b.bindBreakOrContinueFlow(getTarget(activeLabel)) @@ -2084,7 +2008,7 @@ func (b *Binder) bindCaseBlock(node *ast.Node) { var fallthroughFlow *ast.FlowNode = b.unreachableFlow for i := 0; i < len(clauses); i++ { clauseStart := i - for len(clauses[i].AsCaseOrDefaultClause().Statements.Nodes) == 0 && i+1 < len(clauses) { + for len(clauses[i].Statements()) == 0 && i+1 < len(clauses) { if fallthroughFlow == b.unreachableFlow { b.currentFlow = b.preSwitchCaseFlow } @@ -2140,15 +2064,16 @@ func (b *Binder) bindLabeledStatement(node *ast.Node) { postStatementLabel := b.createBranchLabel() b.activeLabelList = &ActiveLabel{ next: b.activeLabelList, - name: stmt.Label.AsIdentifier().Text, + name: stmt.Label.Text(), breakTarget: postStatementLabel, continueTarget: nil, referenced: false, } b.bind(stmt.Label) b.bind(stmt.Statement) - if !b.activeLabelList.referenced && b.options().AllowUnusedLabels != core.TSTrue { - b.errorOrSuggestionOnNode(unusedLabelIsError(b.options()), stmt.Label, diagnostics.Unused_label) + if !b.activeLabelList.referenced { + // Mark the label as unused; the checker will decide whether to report it + stmt.Label.Flags |= ast.NodeFlagsUnreachable } b.activeLabelList = b.activeLabelList.next b.addAntecedent(postStatementLabel, b.currentFlow) @@ -2297,7 +2222,7 @@ func (b *Binder) bindConditionalExpressionFlow(node *ast.Node) { func (b *Binder) bindVariableDeclarationFlow(node *ast.Node) { b.bindEachChild(node) - if node.AsVariableDeclaration().Initializer != nil || ast.IsForInOrOfStatement(node.Parent.Parent) { + if node.Initializer() != nil || ast.IsForInOrOfStatement(node.Parent.Parent) { b.bindInitializedVariableFlow(node) } } @@ -2311,7 +2236,7 @@ func (b *Binder) bindInitializedVariableFlow(node *ast.Node) { name = node.AsBindingElement().Name() } if name != nil && ast.IsBindingPattern(name) { - for _, child := range name.AsBindingPattern().Elements.Nodes { + for _, child := range name.Elements() { b.bindInitializedVariableFlow(child) } } else { @@ -2382,15 +2307,15 @@ func (b *Binder) bindOptionalExpression(node *ast.Node, trueTarget *ast.FlowLabe func (b *Binder) bindOptionalChainRest(node *ast.Node) bool { switch node.Kind { case ast.KindPropertyAccessExpression: - b.bind(node.AsPropertyAccessExpression().QuestionDotToken) - b.bind(node.AsPropertyAccessExpression().Name()) + b.bind(node.QuestionDotToken()) + b.bind(node.Name()) case ast.KindElementAccessExpression: - b.bind(node.AsElementAccessExpression().QuestionDotToken) + b.bind(node.QuestionDotToken()) b.bind(node.AsElementAccessExpression().ArgumentExpression) case ast.KindCallExpression: - b.bind(node.AsCallExpression().QuestionDotToken) - b.bindNodeList(node.AsCallExpression().TypeArguments) - b.bindEach(node.AsCallExpression().Arguments.Nodes) + b.bind(node.QuestionDotToken()) + b.bindNodeList(node.TypeArgumentList()) + b.bindEach(node.Arguments()) } return false } @@ -2470,10 +2395,6 @@ func (b *Binder) bindInitializer(node *ast.Node) { b.currentFlow = b.finishFlowLabel(exitFlow) } -func isEnumDeclarationWithPreservedEmit(node *ast.Node, options core.SourceFileAffectingCompilerOptions) bool { - return node.Kind == ast.KindEnumDeclaration && (!ast.IsEnumConst(node) || options.ShouldPreserveConstEnums) -} - func setFlowNode(node *ast.Node, flowNode *ast.FlowNode) { data := node.FlowNodeData() if data != nil { @@ -2571,7 +2492,7 @@ func GetContainerFlags(node *ast.Node) ContainerFlags { case ast.KindModuleBlock: return ContainerFlagsIsControlFlowContainer case ast.KindPropertyDeclaration: - if node.AsPropertyDeclaration().Initializer != nil { + if node.Initializer() != nil { return ContainerFlagsIsControlFlowContainer | ContainerFlagsIsThisContainer } else { return ContainerFlagsNone @@ -2596,16 +2517,12 @@ func isNarrowingExpression(expr *ast.Node) bool { return containsNarrowableReference(expr) case ast.KindCallExpression: return hasNarrowableArgument(expr) - case ast.KindParenthesizedExpression: - return isNarrowingExpression(expr.AsParenthesizedExpression().Expression) - case ast.KindNonNullExpression: - return isNarrowingExpression(expr.AsNonNullExpression().Expression) + case ast.KindParenthesizedExpression, ast.KindNonNullExpression, ast.KindTypeOfExpression: + return isNarrowingExpression(expr.Expression()) case ast.KindBinaryExpression: return isNarrowingBinaryExpression(expr.AsBinaryExpression()) case ast.KindPrefixUnaryExpression: return expr.AsPrefixUnaryExpression().Operator == ast.KindExclamationToken && isNarrowingExpression(expr.AsPrefixUnaryExpression().Operand) - case ast.KindTypeOfExpression: - return isNarrowingExpression(expr.AsTypeOfExpression().Expression) } return false } @@ -2616,14 +2533,8 @@ func containsNarrowableReference(expr *ast.Node) bool { } if expr.Flags&ast.NodeFlagsOptionalChain != 0 { switch expr.Kind { - case ast.KindPropertyAccessExpression: - return containsNarrowableReference(expr.AsPropertyAccessExpression().Expression) - case ast.KindElementAccessExpression: - return containsNarrowableReference(expr.AsElementAccessExpression().Expression) - case ast.KindCallExpression: - return containsNarrowableReference(expr.AsCallExpression().Expression) - case ast.KindNonNullExpression: - return containsNarrowableReference(expr.AsNonNullExpression().Expression) + case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression, ast.KindCallExpression, ast.KindNonNullExpression: + return containsNarrowableReference(expr.Expression()) } } return false @@ -2633,12 +2544,8 @@ func isNarrowableReference(node *ast.Node) bool { switch node.Kind { case ast.KindIdentifier, ast.KindThisKeyword, ast.KindSuperKeyword, ast.KindMetaProperty: return true - case ast.KindPropertyAccessExpression: - return isNarrowableReference(node.AsPropertyAccessExpression().Expression) - case ast.KindParenthesizedExpression: - return isNarrowableReference(node.AsParenthesizedExpression().Expression) - case ast.KindNonNullExpression: - return isNarrowableReference(node.AsNonNullExpression().Expression) + case ast.KindPropertyAccessExpression, ast.KindParenthesizedExpression, ast.KindNonNullExpression: + return isNarrowableReference(node.Expression()) case ast.KindElementAccessExpression: expr := node.AsElementAccessExpression() return ast.IsStringOrNumericLiteralLike(expr.ArgumentExpression) || @@ -2653,13 +2560,13 @@ func isNarrowableReference(node *ast.Node) bool { func hasNarrowableArgument(expr *ast.Node) bool { call := expr.AsCallExpression() - for _, argument := range call.Arguments.Nodes { + for _, argument := range call.Arguments.Nodes { //nolint:modernize if containsNarrowableReference(argument) { return true } } if ast.IsPropertyAccessExpression(call.Expression) { - if containsNarrowableReference(call.Expression.AsPropertyAccessExpression().Expression) { + if containsNarrowableReference(call.Expression.Expression()) { return true } } @@ -2689,7 +2596,7 @@ func isNarrowingBinaryExpression(expr *ast.BinaryExpression) bool { func isNarrowableOperand(expr *ast.Node) bool { switch expr.Kind { case ast.KindParenthesizedExpression: - return isNarrowableOperand(expr.AsParenthesizedExpression().Expression) + return isNarrowableOperand(expr.Expression()) case ast.KindBinaryExpression: binary := expr.AsBinaryExpression() switch binary.OperatorToken.Kind { @@ -2703,7 +2610,7 @@ func isNarrowableOperand(expr *ast.Node) bool { } func isNarrowingTypeOfOperands(expr1 *ast.Node, expr2 *ast.Node) bool { - return ast.IsTypeOfExpression(expr1) && isNarrowableOperand(expr1.AsTypeOfExpression().Expression) && ast.IsStringLiteralLike(expr2) + return ast.IsTypeOfExpression(expr1) && isNarrowableOperand(expr1.Expression()) && ast.IsStringLiteralLike(expr2) } func (b *Binder) errorOnNode(node *ast.Node, message *diagnostics.Message, args ...any) { @@ -2750,24 +2657,10 @@ func isSignedNumericLiteral(node *ast.Node) bool { } func getOptionalSymbolFlagForNode(node *ast.Node) ast.SymbolFlags { - postfixToken := getPostfixTokenFromNode(node) + postfixToken := node.PostfixToken() return core.IfElse(postfixToken != nil && postfixToken.Kind == ast.KindQuestionToken, ast.SymbolFlagsOptional, ast.SymbolFlagsNone) } -func getPostfixTokenFromNode(node *ast.Node) *ast.Node { - switch node.Kind { - case ast.KindPropertyDeclaration: - return node.AsPropertyDeclaration().PostfixToken - case ast.KindPropertySignature: - return node.AsPropertySignatureDeclaration().PostfixToken - case ast.KindMethodDeclaration: - return node.AsMethodDeclaration().PostfixToken - case ast.KindMethodSignature: - return node.AsMethodSignatureDeclaration().PostfixToken - } - panic("Unhandled case in getPostfixTokenFromNode") -} - func isAsyncFunction(node *ast.Node) bool { switch node.Kind { case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindMethodDeclaration: @@ -2793,22 +2686,10 @@ func isFunctionSymbol(symbol *ast.Symbol) bool { return false } -func unreachableCodeIsError(options core.SourceFileAffectingCompilerOptions) bool { - return options.AllowUnreachableCode == core.TSFalse -} - -func unusedLabelIsError(options core.SourceFileAffectingCompilerOptions) bool { - return options.AllowUnusedLabels == core.TSFalse -} - func isStatementCondition(node *ast.Node) bool { switch node.Parent.Kind { - case ast.KindIfStatement: - return node.Parent.AsIfStatement().Expression == node - case ast.KindWhileStatement: - return node.Parent.AsWhileStatement().Expression == node - case ast.KindDoStatement: - return node.Parent.AsDoStatement().Expression == node + case ast.KindIfStatement, ast.KindWhileStatement, ast.KindDoStatement: + return node.Parent.Expression() == node case ast.KindForStatement: return node.Parent.AsForStatement().Condition == node case ast.KindConditionalExpression: diff --git a/internal/binder/nameresolver.go b/internal/binder/nameresolver.go index 8dfe2aff14..45d9838ade 100644 --- a/internal/binder/nameresolver.go +++ b/internal/binder/nameresolver.go @@ -176,7 +176,7 @@ loop: } } case ast.KindExpressionWithTypeArguments: - if lastLocation == location.AsExpressionWithTypeArguments().Expression && ast.IsHeritageClause(location.Parent) && location.Parent.AsHeritageClause().Token == ast.KindExtendsKeyword { + if lastLocation == location.Expression() && ast.IsHeritageClause(location.Parent) && location.Parent.AsHeritageClause().Token == ast.KindExtendsKeyword { container := location.Parent.Parent if ast.IsClassLike(container) { result = r.lookup(r.getSymbolOfDeclaration(container).Members, name, meaning&ast.SymbolFlagsType) @@ -207,13 +207,6 @@ loop: return nil } } - case ast.KindArrowFunction: - // when targeting ES6 or higher there is no 'arguments' in an arrow function - // for lower compile targets the resolved symbol is used to emit an error - if r.CompilerOptions.GetEmitScriptTarget() >= core.ScriptTargetES2015 { - break - } - fallthrough case ast.KindMethodDeclaration, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionDeclaration: if meaning&ast.SymbolFlagsVariable != 0 && name == "arguments" { result = r.argumentsSymbol() @@ -226,8 +219,8 @@ loop: } if meaning&ast.SymbolFlagsFunction != 0 { functionName := location.AsFunctionExpression().Name() - if functionName != nil && name == functionName.AsIdentifier().Text { - result = location.AsFunctionExpression().Symbol + if functionName != nil && name == functionName.Text() { + result = location.Symbol() break loop } } @@ -276,14 +269,14 @@ loop: case ast.KindInferType: if meaning&ast.SymbolFlagsTypeParameter != 0 { parameterName := location.AsInferTypeNode().TypeParameter.AsTypeParameter().Name() - if parameterName != nil && name == parameterName.AsIdentifier().Text { - result = location.AsInferTypeNode().TypeParameter.AsTypeParameter().Symbol + if parameterName != nil && name == parameterName.Text() { + result = location.AsInferTypeNode().TypeParameter.Symbol() break loop } } case ast.KindExportSpecifier: exportSpecifier := location.AsExportSpecifier() - if lastLocation != nil && lastLocation == exportSpecifier.PropertyName && location.Parent.Parent.AsExportDeclaration().ModuleSpecifier != nil { + if lastLocation != nil && lastLocation == exportSpecifier.PropertyName && location.Parent.Parent.ModuleSpecifier() != nil { location = location.Parent.Parent.Parent } } @@ -361,21 +354,18 @@ func (r *NameResolver) useOuterVariableScopeInParameter(result *ast.Symbol, loca // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - target := r.CompilerOptions.GetEmitScriptTarget() - if target >= core.ScriptTargetES2015 { - functionLocation := location - declarationRequiresScopeChange := core.TSUnknown - if r.GetRequiresScopeChangeCache != nil { - declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation) - } - if declarationRequiresScopeChange == core.TSUnknown { - declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse) - if r.SetRequiresScopeChangeCache != nil { - r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange) - } + functionLocation := location + declarationRequiresScopeChange := core.TSUnknown + if r.GetRequiresScopeChangeCache != nil { + declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation) + } + if declarationRequiresScopeChange == core.TSUnknown { + declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse) + if r.SetRequiresScopeChangeCache != nil { + r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange) } - return declarationRequiresScopeChange != core.TSTrue } + return declarationRequiresScopeChange != core.TSTrue } } return false diff --git a/internal/bundled/embed.go b/internal/bundled/embed.go index 36c00137b2..cf92102db3 100644 --- a/internal/bundled/embed.go +++ b/internal/bundled/embed.go @@ -131,7 +131,7 @@ func (vfs *wrappedFS) walkDir(rest string, walkFn vfs.WalkDirFunc) error { return err } if entry.IsDir() { - if err := vfs.walkDir(name, walkFn); err != nil { + if err := vfs.walkDir(strings.TrimPrefix(name, "/"), walkFn); err != nil { return err } } diff --git a/internal/bundled/generate.go b/internal/bundled/generate.go index c39032bcd9..28b64e3a15 100644 --- a/internal/bundled/generate.go +++ b/internal/bundled/generate.go @@ -14,6 +14,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/repo" "github.com/microsoft/typescript-go/internal/tspath" @@ -150,7 +151,7 @@ func readLibs() []lib { if len(diags) > 0 { for _, diag := range diags { - log.Printf("%s", diag.Message()) + log.Printf("%s", diag.Localize(locale.Default)) } log.Fatalf("failed to parse libs.json") } diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 08284c87be..b8cbb72a85 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -61,6 +61,7 @@ const ( TypeSystemPropertyNameResolvedBaseTypes TypeSystemPropertyNameWriteType TypeSystemPropertyNameInitializerIsUndefined + TypeSystemPropertyNameAliasTarget ) type TypeResolution struct { @@ -624,7 +625,6 @@ type Checker struct { argumentsSymbol *ast.Symbol requireSymbol *ast.Symbol unknownSymbol *ast.Symbol - resolvingSymbol *ast.Symbol unresolvedSymbols map[string]*ast.Symbol errorTypes map[string]*Type denoGlobalThisSymbol *ast.Symbol @@ -854,7 +854,7 @@ type Checker struct { couldContainTypeVariables func(*Type) bool isStringIndexSignatureOnlyType func(*Type) bool markNodeAssignments func(*ast.Node) bool - emitResolver *emitResolver + emitResolver *EmitResolver emitResolverOnce sync.Once _jsxNamespace string _jsxFactoryEntity *ast.Node @@ -867,9 +867,13 @@ type Checker struct { ambientModules []*ast.Symbol nodeAmbientModulesOnce sync.Once nodeAmbientModules []*ast.Symbol + withinUnreachableCode bool + reportedUnreachableNodes collections.Set[*ast.Node] + + mu sync.Mutex } -func NewChecker(program Program) *Checker { +func NewChecker(program Program) (*Checker, *sync.Mutex) { program.BindSourceFiles() c := &Checker{} @@ -926,7 +930,6 @@ func NewChecker(program Program) *Checker { c.argumentsSymbol = c.newSymbol(ast.SymbolFlagsProperty, "arguments") c.requireSymbol = c.newSymbol(ast.SymbolFlagsProperty, "require") c.unknownSymbol = c.newSymbol(ast.SymbolFlagsProperty, "unknown") - c.resolvingSymbol = c.newSymbol(ast.SymbolFlagsNone, ast.InternalSymbolNameResolving) c.unresolvedSymbols = make(map[string]*ast.Symbol) c.errorTypes = make(map[string]*Type) c.denoGlobalThisSymbol = c.newSymbolEx(ast.SymbolFlagsModule, "globalThis", ast.CheckFlagsReadonly) @@ -1088,7 +1091,7 @@ func NewChecker(program Program) *Checker { c.initializeClosures() c.initializeIterationResolvers() c.initializeChecker() - return c + return c, &c.mu } func createFileIndexMap(files []*ast.SourceFile) map[*ast.SourceFile]int { @@ -1560,12 +1563,14 @@ func (c *Checker) onFailedToResolveSymbol(errorLocation *ast.Node, name string, suggestion := c.getSuggestedSymbolForNonexistentSymbol(errorLocation, name, meaning) if suggestion != nil && !(suggestion.ValueDeclaration != nil && ast.IsAmbientModule(suggestion.ValueDeclaration) && ast.IsGlobalScopeAugmentation(suggestion.ValueDeclaration)) { suggestionName := c.symbolToString(suggestion) - message := core.IfElse(meaning == ast.SymbolFlagsNamespace, diagnostics.Cannot_find_namespace_0_Did_you_mean_1, diagnostics.Cannot_find_name_0_Did_you_mean_1) + isUncheckedJS := c.isUncheckedJSSuggestion(errorLocation, suggestion, false /*excludeClasses*/) + message := core.IfElse(meaning == ast.SymbolFlagsNamespace, diagnostics.Cannot_find_namespace_0_Did_you_mean_1, + core.IfElse(isUncheckedJS, diagnostics.Could_not_find_name_0_Did_you_mean_1, diagnostics.Cannot_find_name_0_Did_you_mean_1)) diagnostic := NewDiagnosticForNode(errorLocation, message, name, suggestionName) if suggestion.ValueDeclaration != nil { diagnostic.AddRelatedInfo(NewDiagnosticForNode(suggestion.ValueDeclaration, diagnostics.X_0_is_declared_here, suggestionName)) } - c.diagnostics.Add(diagnostic) + c.addErrorOrSuggestion(!isUncheckedJS, diagnostic) return } // And then fall back to unspecified "not found" @@ -1667,7 +1672,7 @@ func (c *Checker) maybeMappedType(node *ast.Node, symbol *ast.Symbol) bool { for ast.IsComputedPropertyName(node) || ast.IsPropertySignatureDeclaration(node) { node = node.Parent } - if ast.IsTypeLiteralNode(node) && len(node.AsTypeLiteralNode().Members.Nodes) == 1 { + if ast.IsTypeLiteralNode(node) && len(node.Members()) == 1 { t := c.getDeclaredTypeOfSymbol(symbol) return t.flags&TypeFlagsUnion != 0 && c.allTypesAssignableToKind(t, TypeFlagsStringOrNumberLiteral) } @@ -1875,7 +1880,7 @@ func (c *Checker) isBlockScopedNameDeclaredBeforeUse(declaration *ast.Node, usag if usage.Flags&ast.NodeFlagsJSDoc != 0 || IsInTypeQuery(usage) || c.isInAmbientOrTypeNode(usage) { return true } - if declaration.Pos() <= usage.Pos() && !(ast.IsPropertyDeclaration(declaration) && isThisProperty(usage.Parent) && declaration.Initializer() == nil && !isExclamationToken(declaration.AsPropertyDeclaration().PostfixToken)) { + if declaration.Pos() <= usage.Pos() && !(ast.IsPropertyDeclaration(declaration) && isThisProperty(usage.Parent) && declaration.Initializer() == nil && !isExclamationToken(declaration.PostfixToken())) { // declaration is before usage switch { case declaration.Kind == ast.KindBindingElement: @@ -2046,7 +2051,7 @@ func isSameScopeDescendentOf(initial *ast.Node, parent *ast.Node, stopAt *ast.No return false } -// stopAtAnyPropertyDeclaration is used for detecting ES-standard class field use-before-def errors +// isPropertyImmediatelyReferencedWithinDeclaration is used for detecting ES-standard class field use-before-def errors func isPropertyImmediatelyReferencedWithinDeclaration(declaration *ast.Node, usage *ast.Node, stopAtAnyPropertyDeclaration bool) bool { // always legal if usage is after declaration if usage.End() > declaration.End() { @@ -2189,6 +2194,7 @@ func (c *Checker) checkSourceFile(ctx context.Context, sourceFile *ast.SourceFil c.wasCanceled = true } c.ctx = nil + c.reportedUnreachableNodes.Clear() links.typeChecked = true } } @@ -2205,10 +2211,12 @@ func (c *Checker) checkSourceElements(nodes []*ast.Node) { func (c *Checker) checkSourceElement(node *ast.Node) bool { if node != nil { saveCurrentNode := c.currentNode + saveWithinUnreachableCode := c.withinUnreachableCode c.currentNode = node c.instantiationCount = 0 c.checkSourceElementWorker(node) c.currentNode = saveCurrentNode + c.withinUnreachableCode = saveWithinUnreachableCode } return false } @@ -2224,13 +2232,13 @@ func (c *Checker) checkSourceElementWorker(node *ast.Node) { } } } - kind := node.Kind - if kind >= ast.KindFirstStatement && kind <= ast.KindLastStatement { - flowNode := node.FlowNodeData().FlowNode - if flowNode != nil && !c.isReachableFlowNode(flowNode) { - c.errorOrSuggestion(c.compilerOptions.AllowUnreachableCode == core.TSFalse, node, diagnostics.Unreachable_code_detected) + + if !c.withinUnreachableCode && c.compilerOptions.AllowUnreachableCode != core.TSTrue { + if c.checkSourceElementUnreachable(node) { + c.withinUnreachableCode = true } } + switch node.Kind { case ast.KindTypeParameter: c.checkTypeParameter(node) @@ -2353,6 +2361,87 @@ func (c *Checker) checkSourceElementWorker(node *ast.Node) { } } +func (c *Checker) checkSourceElementUnreachable(node *ast.Node) bool { + if !ast.IsPotentiallyExecutableNode(node) { + return false + } + + if c.reportedUnreachableNodes.Has(node) { + return true + } + + if !c.isSourceElementUnreachable(node) { + return false + } + + c.reportedUnreachableNodes.Add(node) + + sourceFile := ast.GetSourceFileOfNode(node) + + start := node.Pos() + end := node.End() + + parent := node.Parent + if parent.CanHaveStatements() { + statements := parent.Statements() + if offset := slices.Index(statements, node); offset >= 0 { + // Scan backwards to find the first unreachable unreported node; + // this may happen when producing region diagnostics where not all nodes + // will have been visited. + // TODO: enable this code once we support region diagnostics again. + first := offset + // for i := offset - 1; i >= 0; i-- { + // prevNode := statements[i] + // if !ast.IsPotentiallyExecutableNode(prevNode) || c.reportedUnreachableNodes.Has(prevNode) || !c.isSourceElementUnreachable(prevNode) { + // break + // } + // firstUnreachableIndex = i + // c.reportedUnreachableNodes.Add(prevNode) + // } + + last := offset + for i := offset + 1; i < len(statements); i++ { + nextNode := statements[i] + if !ast.IsPotentiallyExecutableNode(nextNode) || !c.isSourceElementUnreachable(nextNode) { + break + } + last = i + c.reportedUnreachableNodes.Add(nextNode) + } + + start = statements[first].Pos() + end = statements[last].End() + } + } + + start = scanner.SkipTrivia(sourceFile.Text(), start) + + diagnostic := ast.NewDiagnostic(sourceFile, core.NewTextRange(start, end), diagnostics.Unreachable_code_detected) + c.addErrorOrSuggestion(c.compilerOptions.AllowUnreachableCode == core.TSFalse, diagnostic) + + return true +} + +func (c *Checker) isSourceElementUnreachable(node *ast.Node) bool { + // Precondition: ast.IsPotentiallyExecutableNode is true + if node.Flags&ast.NodeFlagsUnreachable != 0 { + // The binder has determined that this code is unreachable. + // Ignore const enums unless preserveConstEnums is set. + switch node.Kind { + case ast.KindEnumDeclaration: + return !ast.IsEnumConst(node) || c.compilerOptions.ShouldPreserveConstEnums() + case ast.KindModuleDeclaration: + return ast.IsInstantiatedModule(node, c.compilerOptions.ShouldPreserveConstEnums()) + default: + return true + } + } else if flowNode := node.FlowNodeData().FlowNode; flowNode != nil { + // For code the binder doesn't know is unreachable, use control flow / types. + return !c.isReachableFlowNode(flowNode) + } + return false +} + // Function and class expression bodies are checked after all statements in the enclosing body. This is // to ensure constructs like the following are permitted: // @@ -2407,7 +2496,7 @@ func (c *Checker) checkDeferredNode(node *ast.Node) { case ast.KindTypeAssertionExpression, ast.KindAsExpression: c.checkAssertionDeferred(node) case ast.KindVoidExpression: - c.checkExpression(node.AsVoidExpression().Expression) + c.checkExpression(node.Expression()) case ast.KindBinaryExpression: if ast.IsInstanceOfExpression(node) { c.resolveUntypedCall(node) @@ -2524,6 +2613,10 @@ func (c *Checker) checkTypeParameterDeferred(node *ast.Node) { } } +func (c *Checker) shouldCheckErasableSyntax(node *ast.Node) bool { + return c.compilerOptions.ErasableSyntaxOnly.IsTrue() && !ast.IsInJSFile(node) +} + func (c *Checker) checkParameter(node *ast.Node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -2537,7 +2630,7 @@ func (c *Checker) checkParameter(node *ast.Node) { paramName = node.Name().Text() } if ast.HasSyntacticModifier(node, ast.ModifierFlagsParameterPropertyModifier) { - if c.compilerOptions.ErasableSyntaxOnly.IsTrue() { + if c.shouldCheckErasableSyntax(node) { c.error(node, diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled) } if !(ast.IsConstructorDeclaration(fn) && ast.NodeIsPresent(fn.Body())) { @@ -2730,7 +2823,7 @@ func (c *Checker) checkConstructorDeclaration(node *ast.Node) { c.error(superCall, diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers) } else { var superCallStatement *ast.Node - for _, statement := range node.Body().AsBlock().Statements.Nodes { + for _, statement := range node.Body().Statements() { if ast.IsExpressionStatement(statement) && isSuperCall(ast.SkipOuterExpressions(statement.Expression(), ast.OEKAll)) { superCallStatement = statement break @@ -2902,7 +2995,7 @@ func (c *Checker) getDeprecatedSuggestionNode(node *ast.Node) *ast.Node { case ast.KindTaggedTemplateExpression: return c.getDeprecatedSuggestionNode(node.AsTaggedTemplateExpression().Tag) case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: - return c.getDeprecatedSuggestionNode(getTagNameOfNode(node)) + return c.getDeprecatedSuggestionNode(node.TagName()) case ast.KindElementAccessExpression: return node.AsElementAccessExpression().ArgumentExpression case ast.KindPropertyAccessExpression: @@ -2971,7 +3064,7 @@ func (c *Checker) getTypePredicateParent(node *ast.Node) *ast.SignatureDeclarati } func (c *Checker) checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern *ast.Node, predicateVariableNode *ast.Node, predicateVariableName string) bool { - for _, element := range pattern.AsBindingPattern().Elements.Nodes { + for _, element := range pattern.Elements() { name := element.Name() if name == nil { continue @@ -3088,7 +3181,7 @@ func (c *Checker) checkArrayType(node *ast.Node) { func (c *Checker) checkTupleType(node *ast.Node) { seenOptionalElement := false seenRestElement := false - elements := node.AsTupleTypeNode().Elements.Nodes + elements := node.Elements() for _, e := range elements { flags := c.getTupleElementFlags(e) if flags&ElementFlagsVariadic != 0 { @@ -3306,9 +3399,6 @@ func (c *Checker) checkFunctionOrMethodDeclaration(node *ast.Node) { if c.getContextualCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature), node) == nil { c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments) } - if node.Type() != nil || core.Some(node.Parameters(), func(p *ast.Node) bool { return p.Type() != nil }) { - c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_may_not_occur_with_a_param_or_returns_tag) - } } if node.Type() == nil { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -3805,14 +3895,14 @@ func (c *Checker) isSymbolUsedInConditionBody(expr *ast.Node, body *ast.Node, te func (c *Checker) checkDoStatement(node *ast.Node) { c.checkGrammarStatementInAmbientContext(node) - c.checkSourceElement(node.AsDoStatement().Statement) + c.checkSourceElement(node.Statement()) c.checkTruthinessExpression(node.Expression(), CheckModeNormal) } func (c *Checker) checkWhileStatement(node *ast.Node) { c.checkGrammarStatementInAmbientContext(node) c.checkTruthinessExpression(node.Expression(), CheckModeNormal) - c.checkSourceElement(node.AsWhileStatement().Statement) + c.checkSourceElement(node.Statement()) } func (c *Checker) checkForStatement(node *ast.Node) { @@ -4012,8 +4102,8 @@ func (c *Checker) checkWithStatement(node *ast.Node) { c.checkExpression(node.Expression()) sourceFile := ast.GetSourceFileOfNode(node) if !c.hasParseDiagnostics(sourceFile) { - start := scanner.GetRangeOfTokenAtPosition(sourceFile, node.Pos()).Pos() - end := node.AsWithStatement().Statement.Pos() + start := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) + end := node.Statement().Pos() c.grammarErrorAtPos(sourceFile.AsNode(), start, end-start, diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any) } } @@ -4042,7 +4132,7 @@ func (c *Checker) checkSwitchStatement(node *ast.Node) { c.checkTypeComparableTo(caseType, expressionType, clause.Expression(), nil /*headMessage*/) } } - c.checkSourceElements(clause.AsCaseOrDefaultClause().Statements.Nodes) + c.checkSourceElements(clause.Statements()) if c.compilerOptions.NoFallthroughCasesInSwitch.IsTrue() { if flowNode := clause.AsCaseOrDefaultClause().FallthroughFlowNode; flowNode != nil && c.isReachableFlowNode(flowNode) { c.error(clause, diagnostics.Fallthrough_case_in_switch) @@ -4060,17 +4150,20 @@ func (c *Checker) checkLabeledStatement(node *ast.Node) { labelText := labelNode.Text() if !c.checkGrammarStatementInAmbientContext(node) { for current := node.Parent; current != nil && !ast.IsFunctionLike(current); current = current.Parent { - if ast.IsLabeledStatement(current) && current.AsLabeledStatement().Label.Text() == labelText { + if ast.IsLabeledStatement(current) && current.Label().Text() == labelText { c.grammarErrorOnNode(labelNode, diagnostics.Duplicate_label_0, labelText) break } } } + if labelNode.Flags&ast.NodeFlagsUnreachable != 0 && c.compilerOptions.AllowUnusedLabels != core.TSTrue { + c.errorOrSuggestion(c.compilerOptions.AllowUnusedLabels == core.TSFalse, labelNode, diagnostics.Unused_label) + } c.checkSourceElement(labeledStatement.Statement) } func (c *Checker) checkThrowStatement(node *ast.Node) { - throwExpr := node.AsThrowStatement().Expression + throwExpr := node.Expression() if !c.checkGrammarStatementInAmbientContext(node) { if ast.IsIdentifier(throwExpr) && len(throwExpr.Text()) == 0 { c.grammarErrorAtPos(node, throwExpr.Pos(), 0 /*length*/, diagnostics.Line_break_not_permitted_here) @@ -4226,7 +4319,7 @@ func (c *Checker) checkClassLikeDeclaration(node *ast.Node) { } c.checkIndexConstraints(classType, symbol, false /*isStaticIndex*/) c.checkIndexConstraints(staticType, symbol, true /*isStaticIndex*/) - c.checkTypeForDuplicateIndexSignatures(node) + c.checkClassOrInterfaceForDuplicateIndexSignatures(node) c.checkPropertyInitialization(node) } @@ -4457,7 +4550,7 @@ basePropertyCheck: }) { constructor := ast.FindConstructorDeclaration(ast.GetClassLikeDeclarationOfSymbol(t.symbol)) propName := uninitialized.Name() - if isExclamationToken(uninitialized.AsPropertyDeclaration().PostfixToken) || constructor == nil || !ast.IsIdentifier(propName) || !c.strictNullChecks || !c.isPropertyInitializedInConstructor(propName, t, constructor) { + if isExclamationToken(uninitialized.PostfixToken()) || constructor == nil || !ast.IsIdentifier(propName) || !c.strictNullChecks || !c.isPropertyInitializedInConstructor(propName, t, constructor) { errorMessage := diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration c.error(core.OrElse(ast.GetNameOfDeclaration(derived.ValueDeclaration), derived.ValueDeclaration), errorMessage, c.symbolToString(base), c.TypeToString(baseType)) } @@ -4713,14 +4806,15 @@ func (c *Checker) checkIndexConstraintForIndexSignature(t *Type, checkInfo *Inde } } -func (c *Checker) checkTypeForDuplicateIndexSignatures(node *ast.Node) { - if ast.IsInterfaceDeclaration(node) { - // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration - // to prevent this run check only for the first declaration of a given kind - if symbol := c.getSymbolOfDeclaration(node); len(symbol.Declarations) != 0 && symbol.Declarations[0] != node { - return - } +func (c *Checker) checkClassOrInterfaceForDuplicateIndexSignatures(node *ast.Node) { + // Only check the type once + if links := c.declaredTypeLinks.Get(c.getSymbolOfDeclaration(node)); !links.indexSignaturesChecked { + links.indexSignaturesChecked = true + c.checkTypeForDuplicateIndexSignatures(node) } +} + +func (c *Checker) checkTypeForDuplicateIndexSignatures(node *ast.Node) { // TypeScript 1.0 spec (April 2014) // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration @@ -4773,7 +4867,7 @@ func (c *Checker) checkPropertyInitialization(node *ast.Node) { } func (c *Checker) isPropertyWithoutInitializer(node *ast.Node) bool { - return ast.IsPropertyDeclaration(node) && !hasAbstractModifier(node) && !isExclamationToken(node.AsPropertyDeclaration().PostfixToken) && node.Initializer() == nil + return ast.IsPropertyDeclaration(node) && !hasAbstractModifier(node) && !isExclamationToken(node.PostfixToken()) && node.Initializer() == nil } func (c *Checker) isPropertyInitializedInStaticBlocks(propName *ast.Node, propType *Type, staticBlocks []*ast.Node, startPos int, endPos int) bool { @@ -4820,8 +4914,8 @@ func (c *Checker) checkInterfaceDeclaration(node *ast.Node) { symbol := c.getSymbolOfDeclaration(node) c.checkTypeParameterListsIdentical(symbol) // Only check this symbol once - firstInterfaceDecl := ast.GetDeclarationOfKind(symbol, ast.KindInterfaceDeclaration) - if node == firstInterfaceDecl { + if links := c.declaredTypeLinks.Get(symbol); !links.interfaceChecked { + links.interfaceChecked = true t := c.getDeclaredTypeOfSymbol(symbol) typeWithThis := c.getTypeWithThisArgument(t, nil, false) // run subsequent checks only if first set succeeded @@ -4841,7 +4935,7 @@ func (c *Checker) checkInterfaceDeclaration(node *ast.Node) { c.checkTypeReferenceNode(heritageElement) } c.checkSourceElements(node.Members()) - c.checkTypeForDuplicateIndexSignatures(node) + c.checkClassOrInterfaceForDuplicateIndexSignatures(node) c.registerForUnusedIdentifiersCheck(node) } @@ -4892,7 +4986,7 @@ func (c *Checker) checkEnumDeclaration(node *ast.Node) { c.checkExportsOnMergedDeclarations(node) c.checkSourceElements(node.Members()) - if c.compilerOptions.ErasableSyntaxOnly.IsTrue() && node.Flags&ast.NodeFlagsAmbient == 0 { + if c.shouldCheckErasableSyntax(node) && node.Flags&ast.NodeFlagsAmbient == 0 { c.error(node, diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled) } @@ -4982,7 +5076,7 @@ func (c *Checker) checkModuleDeclaration(node *ast.Node) { symbol := c.getSymbolOfDeclaration(node) // The following checks only apply on a non-ambient instantiated module declaration. if symbol.Flags&ast.SymbolFlagsValueModule != 0 && !inAmbientContext && isInstantiatedModule(node, c.compilerOptions.ShouldPreserveConstEnums()) { - if c.compilerOptions.ErasableSyntaxOnly.IsTrue() { + if c.shouldCheckErasableSyntax(node) { c.error(node, diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled) } if c.compilerOptions.GetIsolatedModules() && ast.GetSourceFileOfNode(node).ExternalModuleIndicator == nil { @@ -5015,7 +5109,7 @@ func (c *Checker) checkModuleDeclaration(node *ast.Node) { // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). checkBody := isGlobalAugmentation || c.getSymbolOfDeclaration(node).Flags&ast.SymbolFlagsTransient != 0 if checkBody && node.Body() != nil { - for _, statement := range node.Body().AsModuleBlock().Statements.Nodes { + for _, statement := range node.Body().Statements() { c.checkModuleAugmentationElement(statement) } } @@ -5075,7 +5169,7 @@ func (c *Checker) checkModuleAugmentationElement(node *ast.Node) { case ast.KindBindingElement, ast.KindVariableDeclaration: name := node.Name() if ast.IsBindingPattern(name) { - for _, el := range name.AsBindingPattern().Elements.Nodes { + for _, el := range name.Elements() { // mark individual names in binding pattern c.checkModuleAugmentationElement(el) } @@ -5100,8 +5194,8 @@ func (c *Checker) checkImportDeclaration(node *ast.Node) { } if c.checkExternalImportOrExportDeclaration(node) { var resolvedModule *ast.Symbol - importClause := node.AsImportDeclaration().ImportClause - moduleSpecifier := node.AsImportDeclaration().ModuleSpecifier + importClause := node.ImportClause() + moduleSpecifier := node.ModuleSpecifier() if importClause != nil && !c.checkGrammarImportClause(importClause.AsImportClause()) { if importClause.Name() != nil { c.checkImportBinding(importClause) @@ -5111,9 +5205,9 @@ func (c *Checker) checkImportDeclaration(node *ast.Node) { if ast.IsNamespaceImport(namedBindings) { c.checkImportBinding(namedBindings) } else { - resolvedModule = c.resolveExternalModuleName(node, node.AsImportDeclaration().ModuleSpecifier, false) + resolvedModule = c.resolveExternalModuleName(node, node.ModuleSpecifier(), false) if resolvedModule != nil { - for _, binding := range namedBindings.AsNamedImports().Elements.Nodes { + for _, binding := range namedBindings.Elements() { c.checkImportBinding(binding) } } @@ -5281,7 +5375,7 @@ func (c *Checker) checkImportEqualsDeclaration(node *ast.Node) { return // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. } c.checkGrammarModifiers(node) - if c.compilerOptions.ErasableSyntaxOnly.IsTrue() && node.Flags&ast.NodeFlagsAmbient == 0 { + if c.shouldCheckErasableSyntax(node) && node.Flags&ast.NodeFlagsAmbient == 0 { c.error(node, diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled) } if ast.IsInternalModuleImportEqualsDeclaration(node) || c.checkExternalImportOrExportDeclaration(node) { @@ -5303,11 +5397,11 @@ func (c *Checker) checkImportEqualsDeclaration(node *ast.Node) { c.checkTypeNameIsReserved(node.Name(), diagnostics.Import_name_cannot_be_0) } } - if node.AsImportEqualsDeclaration().IsTypeOnly { + if node.IsTypeOnly() { c.grammarErrorOnNode(node, diagnostics.An_import_alias_cannot_use_import_type) } } else { - if core.ModuleKindES2015 <= c.moduleKind && c.moduleKind <= core.ModuleKindESNext && !node.AsImportEqualsDeclaration().IsTypeOnly && node.Flags&ast.NodeFlagsAmbient == 0 { + if core.ModuleKindES2015 <= c.moduleKind && c.moduleKind <= core.ModuleKindESNext && !node.IsTypeOnly() && node.Flags&ast.NodeFlagsAmbient == 0 { // Import equals declaration cannot be emitted as ESM c.grammarErrorOnNode(node, diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead) } @@ -5331,7 +5425,7 @@ func (c *Checker) checkExportDeclaration(node *ast.Node) { if exportDecl.ExportClause != nil && !ast.IsNamespaceExport(exportDecl.ExportClause) { // export { x, y } // export { x, y } from "foo" - for _, binding := range exportDecl.ExportClause.AsNamedExports().Elements.Nodes { + for _, binding := range exportDecl.ExportClause.Elements() { c.checkExportSpecifier(binding) } inAmbientExternalModule := ast.IsModuleBlock(node.Parent) && ast.IsAmbientModule(node.Parent.Parent) @@ -5356,8 +5450,8 @@ func (c *Checker) checkExportDeclaration(node *ast.Node) { func (c *Checker) checkExportSpecifier(node *ast.Node) { c.checkAliasSymbol(node) - hasModuleSpecifier := node.Parent.Parent.AsExportDeclaration().ModuleSpecifier != nil - c.checkModuleExportName(node.AsExportSpecifier().PropertyName, hasModuleSpecifier) + hasModuleSpecifier := node.Parent.Parent.ModuleSpecifier() != nil + c.checkModuleExportName(node.PropertyName(), hasModuleSpecifier) c.checkModuleExportName(node.Name(), true /*allowStringLiteral*/) if !hasModuleSpecifier { @@ -5383,7 +5477,7 @@ func (c *Checker) checkExportAssignment(node *ast.Node) { if c.checkGrammarModuleElementContext(node, illegalContextMessage) { return // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. } - if c.compilerOptions.ErasableSyntaxOnly.IsTrue() && node.AsExportAssignment().IsExportEquals && node.Flags&ast.NodeFlagsAmbient == 0 { + if c.shouldCheckErasableSyntax(node) && node.AsExportAssignment().IsExportEquals && node.Flags&ast.NodeFlagsAmbient == 0 { c.error(node, diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled) } container := node.Parent @@ -5494,7 +5588,7 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) { links := c.moduleSymbolLinks.Get(moduleSymbol) if !links.exportsChecked { exportEqualsSymbol := moduleSymbol.Exports.Get(ast.InternalSymbolNameExportEquals) - if exportEqualsSymbol != nil && c.hasExportedMembers(moduleSymbol) { + if exportEqualsSymbol != nil && c.hasExportedMembers(moduleSymbol, exportEqualsSymbol.ValueDeclaration.Kind == ast.KindJSExportAssignment) { declaration := core.OrElse(c.getDeclarationOfAliasSymbol(exportEqualsSymbol), exportEqualsSymbol.ValueDeclaration) if declaration != nil && !isTopLevelInExternalModuleAugmentation(declaration) { c.error(declaration, diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements) @@ -5530,10 +5624,17 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) { } } -func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol) bool { +func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol, isCommonJS bool) bool { for id := range moduleSymbol.Exports.Iter() { if id != ast.InternalSymbolNameExportEquals { - return true + if !isCommonJS { + return true + } + for _, declaration := range moduleSymbol.Exports.Get(id).Declarations { + if declaration.Kind != ast.KindJSTypeAliasDeclaration { + return true + } + } } } return false @@ -5621,7 +5722,7 @@ func (c *Checker) checkVariableLikeDeclaration(node *ast.Node) { } // For a binding pattern, check contained binding elements if ast.IsBindingPattern(name) { - c.checkSourceElements(name.AsBindingPattern().Elements.Nodes) + c.checkSourceElements(name.Elements()) } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body if initializer != nil && ast.IsPartOfParameterDeclaration(node) && ast.NodeIsMissing(ast.GetContainingFunction(node).Body()) { @@ -5634,7 +5735,7 @@ func (c *Checker) checkVariableLikeDeclaration(node *ast.Node) { return } needCheckInitializer := initializer != nil && node.Parent.Parent.Kind != ast.KindForInStatement - needCheckWidenedType := !core.Some(name.AsBindingPattern().Elements.Nodes, func(n *ast.Node) bool { return n.Name() != nil }) + needCheckWidenedType := !core.Some(name.Elements(), func(n *ast.Node) bool { return n.Name() != nil }) if needCheckInitializer || needCheckWidenedType { // Don't validate for-in initializer as it is already an error widenedType := c.getWidenedTypeForVariableLikeDeclaration(node, false /*reportErrors*/) @@ -5866,6 +5967,7 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type } return nil } + // TODO: remove ScriptTargetES2015 uplevelIteration := c.languageVersion >= core.ScriptTargetES2015 downlevelIteration := !uplevelIteration && c.compilerOptions.DownlevelIteration == core.TSTrue possibleOutOfBounds := c.compilerOptions.NoUncheckedIndexedAccess == core.TSTrue && use&IterationUsePossiblyOutOfBounds != 0 @@ -6620,7 +6722,7 @@ func (c *Checker) checkTypeAliasDeclaration(node *ast.Node) { } c.checkExportsOnMergedDeclarations(node) - typeNode := node.AsTypeAliasDeclaration().Type + typeNode := node.Type() typeParameters := node.TypeParameters() c.checkTypeParameters(typeParameters) if typeNode != nil && typeNode.Kind == ast.KindIntrinsicKeyword { @@ -6828,10 +6930,26 @@ func (c *Checker) reportUnusedVariable(location *ast.Node, diagnostic *ast.Diagn } func (c *Checker) reportUnused(location *ast.Node, kind UnusedKind, diagnostic *ast.Diagnostic) { - if location.Flags&(ast.NodeFlagsAmbient|ast.NodeFlagsThisNodeOrAnySubNodesHasError) == 0 && - (kind == UnusedKindLocal && c.compilerOptions.NoUnusedLocals.IsTrue() || - (kind == UnusedKindParameter && c.compilerOptions.NoUnusedParameters.IsTrue())) { - c.diagnostics.Add(diagnostic) + if location.Flags&(ast.NodeFlagsAmbient|ast.NodeFlagsThisNodeOrAnySubNodesHasError) == 0 { + isError := c.unusedIsError(kind) + if isError { + c.diagnostics.Add(diagnostic) + } else { + suggestion := *diagnostic + suggestion.SetCategory(diagnostics.CategorySuggestion) + c.suggestionDiagnostics.Add(&suggestion) + } + } +} + +func (c *Checker) unusedIsError(kind UnusedKind) bool { + switch kind { + case UnusedKindLocal: + return c.compilerOptions.NoUnusedLocals.IsTrue() + case UnusedKindParameter: + return c.compilerOptions.NoUnusedParameters.IsTrue() + default: + panic("Unhandled case in unusedIsError") } } @@ -6852,7 +6970,7 @@ func (c *Checker) checkUnusedClassMembers(node *ast.Node) { c.reportUnused(parameter, UnusedKindLocal, NewDiagnosticForNode(parameter.Name(), diagnostics.Property_0_is_declared_but_its_value_is_never_read, ast.SymbolName(parameter.Symbol()))) } } - case ast.KindIndexSignature, ast.KindSemicolonClassElement, ast.KindClassStaticBlockDeclaration: + case ast.KindIndexSignature, ast.KindSemicolonClassElement, ast.KindClassStaticBlockDeclaration, ast.KindJSTypeAliasDeclaration: // Can't be private default: panic("Unhandled case in checkUnusedClassMembers") @@ -6919,7 +7037,7 @@ func (c *Checker) reportUnusedParameters(node *ast.Node) { } func (c *Checker) reportUnusedBindingElements(node *ast.Node) { - declarations := node.AsBindingPattern().Elements.Nodes + declarations := node.Elements() if len(declarations) > 1 && core.Every(declarations, c.isUnreferencedVariableDeclaration) { c.reportUnusedVariable(node, NewDiagnosticForNode(node, diagnostics.All_destructured_elements_are_unused)) } else { @@ -6946,14 +7064,14 @@ func (c *Checker) isUnreferencedVariableDeclaration(node *ast.Node) bool { return true } if ast.IsBindingPattern(name) { - return core.Every(node.Name().AsBindingPattern().Elements.Nodes, c.isUnreferencedVariableDeclaration) + return core.Every(node.Name().Elements(), c.isUnreferencedVariableDeclaration) } if c.symbolReferenceLinks.Get(c.getSymbolOfDeclaration(node)).referenceKinds&ast.SymbolFlagsVariable != 0 { return false } if ast.IsBindingElement(node) && ast.IsObjectBindingPattern(node.Parent) { // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - lastElement := core.LastOrNil(node.Parent.AsBindingPattern().Elements.Nodes) + lastElement := core.LastOrNil(node.Parent.Elements()) if node != lastElement && hasDotDotDotToken(lastElement) { return false } @@ -6974,7 +7092,7 @@ func (c *Checker) reportUnusedImports(node *ast.Node, unuseds []*ast.Node) { if ast.IsNamespaceImport(namedBindings) { declarationCount++ } else { - declarationCount += len(namedBindings.AsNamedImports().Elements.Nodes) + declarationCount += len(namedBindings.Elements()) } } if declarationCount > 1 && declarationCount == len(unuseds) { @@ -7051,7 +7169,7 @@ func (c *Checker) checkUnusedRenamedBindingElements() { func (c *Checker) checkExpressionStatement(node *ast.Node) { // Grammar checking c.checkGrammarStatementInAmbientContext(node) - c.checkExpression(node.AsExpressionStatement().Expression) + c.checkExpression(node.Expression()) } // Returns the type of an expression. Unlike checkExpression, this function is simply concerned @@ -7724,10 +7842,6 @@ func (c *Checker) checkSuperExpression(node *ast.Node) *Type { // c.captureLexicalThis(node.Parent, container) // } if container.Parent.Kind == ast.KindObjectLiteralExpression { - if c.languageVersion < core.ScriptTargetES2015 { - c.error(node, diagnostics.X_super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher) - return c.errorType - } // for object literal assume that type of 'super' is 'any' return c.anyType } @@ -7820,7 +7934,7 @@ func (c *Checker) checkRegularExpressionLiteral(node *ast.Node) *Type { } func (c *Checker) checkArrayLiteral(node *ast.Node, checkMode CheckMode) *Type { - elements := node.AsArrayLiteralExpression().Elements.Nodes + elements := node.Elements() elementTypes := make([]*Type, len(elements)) elementInfos := make([]TupleElementInfo, len(elements)) c.pushCachedContextualType(node) @@ -7834,7 +7948,7 @@ func (c *Checker) checkArrayLiteral(node *ast.Node, checkMode CheckMode) *Type { for i, e := range elements { switch { case ast.IsSpreadElement(e): - spreadType := c.checkExpressionEx(e.AsSpreadElement().Expression, checkMode) + spreadType := c.checkExpressionEx(e.Expression(), checkMode) switch { case c.isArrayLikeType(spreadType): elementTypes[i] = spreadType @@ -8131,7 +8245,7 @@ func (c *Checker) checkCallExpression(node *ast.Node, checkMode CheckMode) *Type } } if ast.IsInJSFile(node) && c.isCommonJSRequire(node) { - return c.resolveExternalModuleTypeByLiteral(node.AsCallExpression().Arguments.Nodes[0]) + return c.resolveExternalModuleTypeByLiteral(node.Arguments()[0]) } returnType := c.getReturnTypeOfSignature(signature) // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property @@ -8139,7 +8253,7 @@ func (c *Checker) checkCallExpression(node *ast.Node, checkMode CheckMode) *Type if returnType.flags&TypeFlagsESSymbolLike != 0 && c.isSymbolOrSymbolForCall(node) { return c.getESSymbolLikeTypeForNode(ast.WalkUpParenthesizedExpressions(node.Parent)) } - if ast.IsCallExpression(node) && node.AsCallExpression().QuestionDotToken == nil && ast.IsExpressionStatement(node.Parent) && returnType.flags&TypeFlagsVoid != 0 && c.getTypePredicateOfSignature(signature) != nil { + if ast.IsCallExpression(node) && node.QuestionDotToken() == nil && ast.IsExpressionStatement(node.Parent) && returnType.flags&TypeFlagsVoid != 0 && c.getTypePredicateOfSignature(signature) != nil { if !ast.IsDottedName(node.Expression()) { c.error(node.Expression(), diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name) } else if c.getEffectsSignature(node) == nil { @@ -9700,10 +9814,8 @@ func (c *Checker) resolveUntypedCall(node *ast.Node) *Signature { switch node.Kind { case ast.KindTaggedTemplateExpression: c.checkExpression(node.AsTaggedTemplateExpression().Template) - case ast.KindJsxOpeningElement: - c.checkExpression(node.AsJsxOpeningElement().Attributes) - case ast.KindJsxSelfClosingElement: - c.checkExpression(node.AsJsxSelfClosingElement().Attributes) + case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: + c.checkExpression(node.Attributes()) case ast.KindBinaryExpression: c.checkExpression(node.AsBinaryExpression().Left) case ast.KindCallExpression, ast.KindNewExpression: @@ -9804,7 +9916,7 @@ func (c *Checker) invocationErrorRecovery(apparentType *Type, kind SignatureKind // Create a diagnostic on the originating import if possible onto which we can attach a quickfix // An import call expression cannot be rewritten into another form to correct the error - the only solution is to use `.default` at the use-site if importNode != nil && !ast.IsImportCall(importNode) { - sigs := c.getSignaturesOfType(c.getTypeOfSymbol(c.valueSymbolLinks.Get(apparentType.symbol).target), kind) + sigs := c.getSignaturesOfType(c.getTypeOfSymbol(c.exportTypeLinks.Get(apparentType.symbol).target), kind) if len(sigs) == 0 { return } @@ -9856,7 +9968,7 @@ func (c *Checker) checkFunctionExpressionOrObjectLiteralMethod(node *ast.Node, c } if checkMode&CheckModeSkipContextSensitive != 0 && c.isContextSensitive(node) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage - if node.Type() == nil && !hasContextSensitiveParameters(node) { + if node.Type() == nil && !ast.HasContextSensitiveParameters(node) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type contextualSignature := c.getContextualSignature(node) if contextualSignature != nil && c.couldContainTypeVariables(c.getReturnTypeOfSignature(contextualSignature)) { @@ -9882,9 +9994,6 @@ func (c *Checker) checkFunctionExpressionOrObjectLiteralMethod(node *ast.Node, c if c.getContextualCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature), node) == nil { c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments) } - if node.Type() != nil || core.Some(node.Parameters(), func(p *ast.Node) bool { return p.Type() != nil }) { - c.error(node.FunctionLikeData().FullSignature, diagnostics.A_JSDoc_type_tag_may_not_occur_with_a_param_or_returns_tag) - } } c.contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) return c.getTypeOfSymbol(c.getSymbolOfDeclaration(node)) @@ -10076,7 +10185,7 @@ func (c *Checker) isAritySmaller(signature *Signature, target *ast.Node) bool { targetParameterCount := 0 for targetParameterCount < len(parameters) { param := parameters[targetParameterCount] - if param.Initializer() != nil || param.AsParameterDeclaration().QuestionToken != nil || hasDotDotDotToken(param) { + if param.Initializer() != nil || param.QuestionToken() != nil || hasDotDotDotToken(param) { break } targetParameterCount++ @@ -10169,7 +10278,7 @@ func (c *Checker) assignParameterType(parameter *ast.Symbol, contextualType *Typ // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push // the destructured type into the contained binding elements. func (c *Checker) assignBindingElementTypes(pattern *ast.Node, parentType *Type) { - for _, element := range pattern.AsBindingPattern().Elements.Nodes { + for _, element := range pattern.Elements() { name := element.Name() if name != nil { t := c.getBindingElementTypeFromParentType(element, parentType, false /*noTupleBoundsCheck*/) @@ -10387,7 +10496,7 @@ func (c *Checker) checkMetaProperty(node *ast.Node) *Type { return c.checkNewTargetMetaProperty(node) case ast.KindImportKeyword: if node.Name().Text() == "defer" { - debug.Assert(!ast.IsCallExpression(node.Parent) || node.Parent.AsCallExpression().Expression != node, "Trying to get the type of `import.defer` in `import.defer(...)`") + debug.Assert(!ast.IsCallExpression(node.Parent) || node.Parent.Expression() != node, "Trying to get the type of `import.defer` in `import.defer(...)`") return c.errorType } return c.checkImportMetaProperty(node) @@ -10911,11 +11020,10 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l if c.checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol) { return c.errorType } - // !!! - // containingClass := getContainingClassExcludingClassDecorators(right) - // if containingClass && isPlainJSFile(ast.GetSourceFileOfNode(containingClass), c.compilerOptions.checkJs) { - // c.grammarErrorOnNode(right, diagnostics.Private_field_0_must_be_declared_in_an_enclosing_class, right.Text()) - // } + containingClass := getContainingClassExcludingClassDecorators(right) + if containingClass != nil && ast.IsPlainJSFile(ast.GetSourceFileOfNode(containingClass), c.compilerOptions.CheckJs) { + c.grammarErrorOnNode(right, diagnostics.Private_field_0_must_be_declared_in_an_enclosing_class, right.Text()) + } } else { isSetonlyAccessor := prop.Flags&ast.SymbolFlagsSetAccessor != 0 && prop.Flags&ast.SymbolFlagsGetAccessor == 0 if isSetonlyAccessor && assignmentKind != AssignmentKindDefinite { @@ -10942,6 +11050,10 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l indexInfo = c.getApplicableIndexInfoForName(apparentType, right.Text()) } if indexInfo == nil { + isUncheckedJS := c.isUncheckedJSSuggestion(node, leftType.symbol, true /*excludeClasses*/) + if !isUncheckedJS && c.isJSLiteralType(leftType) { + return c.anyType + } if leftType.symbol == c.denoGlobalThisSymbol { globalSymbol := c.denoGlobalThisSymbol.Exports.Get(right.Text()) if globalSymbol != nil && globalSymbol.Flags&ast.SymbolFlagsBlockScoped != 0 { @@ -10957,7 +11069,7 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l return c.anyType } if right.Text() != "" && !c.checkAndReportErrorForExtendingInterface(node) { - c.reportNonexistentProperty(right, core.IfElse(isThisTypeParameter(leftType), apparentType, leftType)) + c.reportNonexistentProperty(right, core.IfElse(isThisTypeParameter(leftType), apparentType, leftType), isUncheckedJS) } return c.errorType } @@ -11134,7 +11246,10 @@ func (c *Checker) checkPrivateIdentifierPropertyAccess(leftType *Type, right *as return false } -func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType *Type) { +func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType *Type, isUncheckedJS bool) { + if ast.IsJSDocNameReferenceContext(propNode) { + return + } var diagnostic *ast.Diagnostic if !ast.IsPrivateIdentifier(propNode) && containingType.flags&TypeFlagsUnion != 0 && containingType.flags&TypeFlagsPrimitive == 0 { for _, subtype := range containingType.Types() { @@ -11163,7 +11278,8 @@ func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType * suggestion := c.getSuggestedSymbolForNonexistentProperty(propNode, containingType) if suggestion != nil { suggestedName := ast.SymbolName(suggestion) - diagnostic = NewDiagnosticChainForNode(diagnostic, propNode, diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName) + message := core.IfElse(isUncheckedJS, diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2, diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2) + diagnostic = NewDiagnosticChainForNode(diagnostic, propNode, message, missingProperty, container, suggestedName) if suggestion.ValueDeclaration != nil { diagnostic.AddRelatedInfo(NewDiagnosticForNode(suggestion.ValueDeclaration, diagnostics.X_0_is_declared_here, suggestedName)) } @@ -11180,7 +11296,7 @@ func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType * } } } - c.diagnostics.Add(diagnostic) + c.addErrorOrSuggestion(!isUncheckedJS || diagnostic.Code() != diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.Code(), diagnostic) } func (c *Checker) getSuggestedLibForNonExistentProperty(missingProperty string, containingType *Type) string { @@ -11322,7 +11438,7 @@ func (c *Checker) checkPropertyNotUsedBeforeDeclaration(prop *ast.Symbol, node * } func (c *Checker) isOptionalPropertyDeclaration(node *ast.Node) bool { - return ast.IsPropertyDeclaration(node) && !ast.HasAccessorModifier(node) && ast.IsQuestionToken(node.AsPropertyDeclaration().PostfixToken) + return ast.IsPropertyDeclaration(node) && !ast.HasAccessorModifier(node) && ast.IsQuestionToken(node.PostfixToken()) } func (c *Checker) isPropertyDeclaredInAncestorClass(prop *ast.Symbol) bool { @@ -11394,14 +11510,6 @@ func (c *Checker) checkPropertyAccessibilityAtLocation(location *ast.Node, isSup // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if c.languageVersion < core.ScriptTargetES2015 { - if c.symbolHasNonMethodDeclaration(prop) { - if errorNode != nil { - c.error(errorNode, diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword) - } - return false - } - } if flags&ast.ModifierFlagsAbstract != 0 { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member @@ -11598,8 +11706,8 @@ func (c *Checker) getEnclosingClassFromThisParameter(node *ast.Node) *Type { // 1. The type of a syntactic 'this' parameter in the enclosing function scope thisParameter := getThisParameterFromNodeContext(node) var thisType *Type - if thisParameter != nil && thisParameter.AsParameterDeclaration().Type != nil { - thisType = c.getTypeFromTypeNode(thisParameter.AsParameterDeclaration().Type) + if thisParameter != nil && thisParameter.Type() != nil { + thisType = c.getTypeFromTypeNode(thisParameter.Type()) } if thisType != nil { // 2. The constraint of a type parameter used for an explicit 'this' parameter @@ -11740,12 +11848,11 @@ func (c *Checker) TryGetThisTypeAtEx(node *ast.Node, includeGlobalThis bool, con container = c.getThisContainer(node, false /*includeArrowFunctions*/, false /*includeClassComputedPropertyName*/) } if ast.IsFunctionLike(container) && (!c.isInParameterInitializerBeforeContainingFunction(node) || ast.GetThisParameter(container) != nil) { - thisType := c.getThisTypeOfDeclaration(container) - if thisType == nil && ast.IsInJSFile(container) { - if sig := c.getSignatureOfFullSignatureType(container); sig != nil { - thisType = c.getThisTypeOfSignature(sig) - } + sig := c.getSignatureOfFullSignatureType(container) + if sig == nil { + sig = c.getSignatureFromDeclaration(container) } + thisType := c.getThisTypeOfSignature(sig) // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. if thisType == nil { @@ -11847,10 +11954,6 @@ func (c *Checker) isInParameterInitializerBeforeContainingFunction(node *ast.Nod return false } -func (c *Checker) getThisTypeOfDeclaration(declaration *ast.Node) *Type { - return c.getThisTypeOfSignature(c.getSignatureFromDeclaration(declaration)) -} - func (c *Checker) checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression *ast.Node, container *ast.Node) { if ast.IsPropertyDeclaration(container) && ast.HasStaticModifier(container) && c.legacyDecorators { initializer := container.Initializer() @@ -11886,7 +11989,7 @@ func (c *Checker) classDeclarationExtendsNull(classDecl *ast.Node) bool { func (c *Checker) checkAssertion(node *ast.Node, checkMode CheckMode) *Type { if node.Kind == ast.KindTypeAssertionExpression { - if c.compilerOptions.ErasableSyntaxOnly.IsTrue() { + if c.shouldCheckErasableSyntax(node) { c.diagnostics.Add(ast.NewDiagnostic(ast.GetSourceFileOfNode(node), core.NewTextRange(scanner.SkipTrivia(ast.GetSourceFileOfNode(node).Text(), node.Pos()), node.Expression().Pos()), diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled)) } } @@ -12173,7 +12276,7 @@ func (c *Checker) checkDestructuringAssignment(node *ast.Node, sourceType *Type, } func (c *Checker) checkObjectLiteralAssignment(node *ast.Node, sourceType *Type, rightIsThis bool) *Type { - properties := node.AsObjectLiteralExpression().Properties + properties := node.PropertyList() if c.strictNullChecks && len(properties.Nodes) == 0 { return c.checkNonNullType(sourceType, node) } @@ -12185,7 +12288,7 @@ func (c *Checker) checkObjectLiteralAssignment(node *ast.Node, sourceType *Type, // Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided func (c *Checker) checkObjectLiteralDestructuringPropertyAssignment(node *ast.Node, objectLiteralType *Type, propertyIndex int, allProperties *ast.NodeList, rightIsThis bool) *Type { - properties := node.AsObjectLiteralExpression().Properties.Nodes + properties := node.Properties() property := properties[propertyIndex] if ast.IsPropertyAssignment(property) || ast.IsShorthandPropertyAssignment(property) { name := property.Name() @@ -12228,15 +12331,15 @@ func (c *Checker) checkObjectLiteralDestructuringPropertyAssignment(node *ast.No } func (c *Checker) checkArrayLiteralAssignment(node *ast.Node, sourceType *Type, checkMode CheckMode) *Type { - elements := node.AsArrayLiteralExpression().Elements + elements := node.Elements() // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). possiblyOutOfBoundsType := core.OrElse(c.checkIteratedTypeOrElementType(IterationUseDestructuring|IterationUsePossiblyOutOfBounds, sourceType, c.undefinedType, node), c.errorType) inBoundsType := core.IfElse(c.compilerOptions.NoUncheckedIndexedAccess == core.TSTrue, nil, possiblyOutOfBoundsType) - for i := range elements.Nodes { + for i := range elements { t := possiblyOutOfBoundsType - if elements.Nodes[i].Kind == ast.KindSpreadElement { + if elements[i].Kind == ast.KindSpreadElement { if inBoundsType == nil { inBoundsType = core.OrElse(c.checkIteratedTypeOrElementType(IterationUseDestructuring, sourceType, c.undefinedType, node), c.errorType) } @@ -12248,7 +12351,7 @@ func (c *Checker) checkArrayLiteralAssignment(node *ast.Node, sourceType *Type, } func (c *Checker) checkArrayLiteralDestructuringElementAssignment(node *ast.Node, sourceType *Type, elementIndex int, elementType *Type, checkMode CheckMode) *Type { - elements := node.AsArrayLiteralExpression().Elements + elements := node.ElementList() element := elements.Nodes[elementIndex] if !ast.IsOmittedExpression(element) { if !ast.IsSpreadElement(element) { @@ -12624,7 +12727,7 @@ func (c *Checker) isIndirectCall(node *ast.Node) bool { right := node.AsBinaryExpression().Right return ast.IsParenthesizedExpression(node.Parent) && ast.IsNumericLiteral(left) && left.Text() == "0" && (ast.IsCallExpression(node.Parent.Parent) && node.Parent.Parent.Expression() == node.Parent || - ast.IsTaggedTemplateExpression(node.Parent.Parent) && (ast.IsAccessExpression(right) || ast.IsIdentifier(right) && right.Text() == "eval")) + ast.IsTaggedTemplateExpression(node.Parent.Parent)) && (ast.IsAccessExpression(right) || ast.IsIdentifier(right) && right.Text() == "eval") } func (c *Checker) checkInstanceOfExpression(left *ast.Expression, right *ast.Expression, leftType *Type, rightType *Type, checkMode CheckMode) *Type { @@ -12665,7 +12768,8 @@ func (c *Checker) checkInExpression(left *ast.Expression, right *ast.Expression, // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors if c.symbolNodeLinks.Get(left).resolvedSymbol == nil && ast.GetContainingClass(left) != nil { - c.reportNonexistentProperty(left, rightType) + isUncheckedJS := c.isUncheckedJSSuggestion(left, rightType.symbol, true /*excludeClasses*/) + c.reportNonexistentProperty(left, rightType, isUncheckedJS) } } else { // The type of the left operand must be assignable to string, number, or symbol. @@ -12750,7 +12854,7 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type // Spreads may cause an early bail; ensure computed names are always checked (this is cached) // As otherwise they may not be checked until exports for the type at this position are retrieved, // which may never occur. - for _, elem := range node.AsObjectLiteralExpression().Properties.Nodes { + for _, elem := range node.Properties() { if elem.Name() != nil && ast.IsComputedPropertyName(elem.Name()) { c.checkComputedPropertyName(elem.Name()) } @@ -12770,6 +12874,9 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type } result := c.newAnonymousType(node.Symbol(), propertiesTable, nil, nil, indexInfos) result.objectFlags |= objectFlags | ObjectFlagsObjectLiteral | ObjectFlagsContainsObjectOrArrayLiteral + if contextualType == nil && ast.IsInJSFile(node) && !ast.IsInJsonFile(node) { + result.objectFlags |= ObjectFlagsJSLiteral + } if patternWithComputedProperties { result.objectFlags |= ObjectFlagsObjectLiteralPatternWithComputedProperties } @@ -12779,11 +12886,11 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type return result } // expando object literals have empty properties but filled exports -- skip straight to type creation - if len(node.AsObjectLiteralExpression().Properties.Nodes) == 0 && node.Symbol() != nil && node.Symbol().Exports.Len() > 0 { + if len(node.Properties()) == 0 && node.Symbol() != nil && node.Symbol().Exports.Len() != 0 { propertiesTable = node.Symbol().Exports return createObjectLiteralType() } - for _, memberDecl := range node.AsObjectLiteralExpression().Properties.Nodes { + for _, memberDecl := range node.Properties() { member := c.getSymbolOfDeclaration(memberDecl) var computedNameType *Type if memberDecl.Name() != nil && memberDecl.Name().Kind == ast.KindComputedPropertyName { @@ -13167,7 +13274,7 @@ func (c *Checker) hasDefaultValue(node *ast.Node) bool { func (c *Checker) isConstContext(node *ast.Node) bool { parent := node.Parent - return isConstAssertion(parent) || + return ast.IsConstAssertion(parent) || c.isValidConstAssertionArgument(node) && c.isConstTypeVariable(c.getContextualType(node, ContextFlagsNone), 0) || (ast.IsParenthesizedExpression(parent) || ast.IsArrayLiteralExpression(parent) || ast.IsSpreadElement(parent)) && c.isConstContext(parent) || (ast.IsPropertyAssignment(parent) || ast.IsShorthandPropertyAssignment(parent) || ast.IsTemplateSpan(parent)) && c.isConstContext(parent.Parent) @@ -13300,7 +13407,7 @@ func (c *Checker) getNarrowedTypeOfSymbol(symbol *ast.Symbol, location *ast.Node // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference // as if it occurred in the specified location. We then recompute the narrowed binding element type by // destructuring from the narrowed parent type. - if ast.IsBindingElement(declaration) && declaration.Initializer() == nil && !hasDotDotDotToken(declaration) && len(declaration.Parent.AsBindingPattern().Elements.Nodes) >= 2 { + if ast.IsBindingElement(declaration) && declaration.Initializer() == nil && !hasDotDotDotToken(declaration) && len(declaration.Parent.Elements()) >= 2 { parent := declaration.Parent.Parent rootDeclaration := ast.GetRootDeclaration(parent) if ast.IsVariableDeclaration(rootDeclaration) && c.getCombinedNodeFlagsCached(rootDeclaration)&ast.NodeFlagsConstant != 0 || ast.IsParameter(rootDeclaration) { @@ -13415,7 +13522,7 @@ func (c *Checker) getResolvedSymbol(node *ast.Node) *ast.Symbol { if links.resolvedSymbol == nil { var symbol *ast.Symbol if !ast.NodeIsMissing(node) { - symbol = c.resolveName(node, node.AsIdentifier().Text, ast.SymbolFlagsValue|ast.SymbolFlagsExportValue, + symbol = c.resolveName(node, node.Text(), ast.SymbolFlagsValue|ast.SymbolFlagsExportValue, c.getCannotFindNameDiagnosticForName(node), !ast.IsWriteOnlyAccess(node), false /*excludeGlobals*/) } links.resolvedSymbol = core.OrElse(symbol, c.unknownSymbol) @@ -13428,7 +13535,7 @@ func (c *Checker) getResolvedSymbolOrNil(node *ast.Node) *ast.Symbol { } func (c *Checker) getCannotFindNameDiagnosticForName(node *ast.Node) *diagnostics.Message { - switch node.AsIdentifier().Text { + switch node.Text() { case "document", "console": return diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom case "$": @@ -13473,18 +13580,30 @@ func (c *Checker) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast. func (c *Checker) getDiagnostics(ctx context.Context, sourceFile *ast.SourceFile, collection *ast.DiagnosticsCollection) []*ast.Diagnostic { c.checkNotCanceled() + isSuggestionDiagnostics := collection == &c.suggestionDiagnostics + + files := c.files if sourceFile != nil { - c.CheckSourceFile(ctx, sourceFile) - if c.wasCanceled { - return nil - } - return collection.GetDiagnosticsForFile(sourceFile.FileName()) + files = []*ast.SourceFile{sourceFile} } - for _, file := range c.files { + + for _, file := range files { c.CheckSourceFile(ctx, file) if c.wasCanceled { return nil } + + // Check unused identifiers as suggestions if we're collecting suggestion diagnostics + // and they are not configured as errors + if isSuggestionDiagnostics && !file.IsDeclarationFile && + !(c.compilerOptions.NoUnusedLocals.IsTrue() || c.compilerOptions.NoUnusedParameters.IsTrue()) { + links := c.sourceFileLinks.Get(file) + c.checkUnusedIdentifiers(links.identifierCheckNodes) + } + } + + if sourceFile != nil { + return collection.GetDiagnosticsForFile(sourceFile.FileName()) } return collection.GetDiagnostics() } @@ -14070,7 +14189,7 @@ func (c *Checker) checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(nod // TODO: how to get name for export *? name := "*" if !ast.IsExportDeclaration(typeOnlyDeclaration) { - name = getNameFromImportDeclaration(typeOnlyDeclaration).Text() + name = typeOnlyDeclaration.Name().Text() } c.error(decl.ModuleReference, message).AddRelatedInfo(createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name)) } @@ -14170,10 +14289,10 @@ func (c *Checker) reportNonDefaultExport(moduleSymbol *ast.Symbol, node *ast.Nod } if exportStar != nil { defaultExport := core.Find(exportStar.Declarations, func(decl *ast.Declaration) bool { - if !(ast.IsExportDeclaration(decl) && decl.AsExportDeclaration().ModuleSpecifier != nil) { + if !(ast.IsExportDeclaration(decl) && decl.ModuleSpecifier() != nil) { return false } - resolvedExternalModuleName := c.resolveExternalModuleName(decl, decl.AsExportDeclaration().ModuleSpecifier, false /*ignoreErrors*/) + resolvedExternalModuleName := c.resolveExternalModuleName(decl, decl.ModuleSpecifier(), false /*ignoreErrors*/) return resolvedExternalModuleName != nil && resolvedExternalModuleName.Exports.Get(ast.InternalSymbolNameDefault) != nil }) if defaultExport != nil { @@ -14304,7 +14423,7 @@ func (c *Checker) getExternalModuleMember(node *ast.Node, specifier *ast.Node, d func (c *Checker) getPropertyOfVariable(symbol *ast.Symbol, name string) *ast.Symbol { if symbol.Flags&ast.SymbolFlagsVariable != 0 { - typeAnnotation := symbol.ValueDeclaration.AsVariableDeclaration().Type + typeAnnotation := symbol.ValueDeclaration.Type() if typeAnnotation != nil { return c.resolveSymbol(c.getPropertyOfType(c.getTypeFromTypeNode(typeAnnotation), name)) } @@ -14425,7 +14544,7 @@ func (c *Checker) canHaveSyntheticDefault(file *ast.Node, moduleSymbol *ast.Symb } // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker - return !ast.IsExternalModule(file.AsSourceFile()) && c.resolveExportByName(moduleSymbol, "__esModule", nil /*sourceNode*/, dontResolveAlias) == nil + return (file.AsSourceFile().ExternalModuleIndicator == nil || file.AsSourceFile().ExternalModuleIndicator == file) && c.resolveExportByName(moduleSymbol, "__esModule", nil /*sourceNode*/, dontResolveAlias) == nil } func (c *Checker) getEmitSyntaxForModuleSpecifierExpression(usage *ast.Node) core.ResolutionMode { @@ -14517,7 +14636,7 @@ func (c *Checker) getTargetOfExportSpecifier(node *ast.Node, meaning ast.SymbolF exportDeclaration := node.Parent.Parent var resolved *ast.Symbol switch { - case exportDeclaration.AsExportDeclaration().ModuleSpecifier != nil: + case exportDeclaration.ModuleSpecifier() != nil: resolved = c.getExternalModuleMember(exportDeclaration, node, dontResolveAlias) case ast.IsStringLiteral(name): resolved = nil @@ -14529,7 +14648,7 @@ func (c *Checker) getTargetOfExportSpecifier(node *ast.Node, meaning ast.SymbolF } func (c *Checker) getTargetOfExportAssignment(node *ast.Node, dontResolveAlias bool) *ast.Symbol { - resolved := c.getTargetOfAliasLikeExpression(node.AsExportAssignment().Expression, dontResolveAlias) + resolved := c.getTargetOfAliasLikeExpression(node.Expression(), dontResolveAlias) c.markSymbolOfAliasDeclarationIfTypeOnly(node, nil /*immediateTarget*/, resolved, false /*overwriteEmpty*/, nil, "") return resolved } @@ -14580,7 +14699,7 @@ func (c *Checker) getModuleSpecifierForImportOrExport(node *ast.Node) *ast.Node return getModuleSpecifierFromNode(node.Parent) case ast.KindImportEqualsDeclaration: if ast.IsExternalModuleReference(node.AsImportEqualsDeclaration().ModuleReference) { - return node.AsImportEqualsDeclaration().ModuleReference.AsExternalModuleReference().Expression + return node.AsImportEqualsDeclaration().ModuleReference.Expression() } else { return nil } @@ -14599,9 +14718,9 @@ func (c *Checker) getModuleSpecifierForImportOrExport(node *ast.Node) *ast.Node func getModuleSpecifierFromNode(node *ast.Node) *ast.Node { switch node.Kind { case ast.KindImportDeclaration, ast.KindJSImportDeclaration: - return node.AsImportDeclaration().ModuleSpecifier + return node.ModuleSpecifier() case ast.KindExportDeclaration: - return node.AsExportDeclaration().ModuleSpecifier + return node.ModuleSpecifier() } panic("Unhandled case in getModuleSpecifierFromNode") } @@ -14697,31 +14816,31 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri contextSpecifier = location.AsModuleDeclaration().Name() } else if ast.IsLiteralImportTypeNode(location) { contextSpecifier = location.AsImportTypeNode().Argument.AsLiteralTypeNode().Literal - } else if ast.IsVariableDeclaration(location) && location.AsVariableDeclaration().Initializer != nil && ast.IsRequireCall(location.AsVariableDeclaration().Initializer, true /*requireStringLiteralLikeArgument*/) { - contextSpecifier = location.AsVariableDeclaration().Initializer.AsCallExpression().Arguments.Nodes[0] + } else if ast.IsVariableDeclaration(location) && location.Initializer() != nil && ast.IsRequireCall(location.Initializer(), true /*requireStringLiteralLikeArgument*/) { + contextSpecifier = location.Initializer().Arguments()[0] } else { ancestor := ast.FindAncestor(location, ast.IsImportCall) if ancestor != nil { - contextSpecifier = ancestor.AsCallExpression().Arguments.Nodes[0] + contextSpecifier = ancestor.Arguments()[0] } if ancestor == nil { ancestor = ast.FindAncestor(location, ast.IsImportDeclarationOrJSImportDeclaration) if ancestor != nil { - contextSpecifier = ancestor.AsImportDeclaration().ModuleSpecifier + contextSpecifier = ancestor.ModuleSpecifier() } } if ancestor == nil { ancestor = ast.FindAncestor(location, ast.IsExportDeclaration) if ancestor != nil { - contextSpecifier = ancestor.AsExportDeclaration().ModuleSpecifier + contextSpecifier = ancestor.ModuleSpecifier() } } if ancestor == nil { ancestor = ast.FindAncestor(location, ast.IsImportEqualsDeclaration) if ancestor != nil { if moduleRefrence := ancestor.AsImportEqualsDeclaration().ModuleReference; moduleRefrence.Kind == ast.KindExternalModuleReference { - contextSpecifier = moduleRefrence.AsExternalModuleReference().Expression + contextSpecifier = moduleRefrence.Expression() } } } @@ -14858,7 +14977,7 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri } var message *diagnostics.Message - if overrideHost != nil && overrideHost.Kind == ast.KindImportDeclaration && overrideHost.AsImportDeclaration().ImportClause != nil && overrideHost.AsImportDeclaration().ImportClause.IsTypeOnly() { + if overrideHost != nil && overrideHost.Kind == ast.KindImportDeclaration && overrideHost.ImportClause() != nil && overrideHost.ImportClause().IsTypeOnly() { message = diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute } else if overrideHost != nil && overrideHost.Kind == ast.KindImportType { message = diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute @@ -15123,9 +15242,9 @@ func (c *Checker) resolveESModuleSymbol(moduleSymbol *ast.Symbol, referencingLoc if namespaceImport != nil || ast.IsImportCall(referenceParent) { var reference *ast.Node if ast.IsImportCall(referenceParent) { - reference = referenceParent.AsCallExpression().Arguments.Nodes[0] + reference = referenceParent.Arguments()[0] } else { - reference = referenceParent.AsImportDeclaration().ModuleSpecifier + reference = referenceParent.ModuleSpecifier() } typ := c.getTypeOfSymbol(symbol) defaultOnlyType := c.getTypeWithSyntheticDefaultOnly(typ, symbol, moduleSymbol, reference) @@ -15331,13 +15450,27 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign if resolveLocation == nil { resolveLocation = name } - symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.AsIdentifier().Text, meaning, message, true /*isUse*/, false /*excludeGlobals*/)) + if meaning == ast.SymbolFlagsNamespace { + symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, nil, true /*isUse*/, false /*excludeGlobals*/)) + if symbol == nil { + alias := c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), ast.SymbolFlagsAlias, nil, true /*isUse*/, false /*excludeGlobals*/)) + if alias != nil && alias.Name == ast.InternalSymbolNameExportEquals { + // resolve typedefs exported from commonjs, stored on the module symbol + symbol = alias.Parent + } + } + if symbol == nil && message != nil { + c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/) + } + } else { + symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/)) + } case ast.KindQualifiedName: qualified := name.AsQualifiedName() - symbol = c.resolveQualifiedName(name, qualified.Left, qualified.Right, meaning, ignoreErrors, dontResolveAlias, location) + symbol = c.resolveQualifiedName(name, qualified.Left, qualified.Right, meaning, ignoreErrors, location) case ast.KindPropertyAccessExpression: access := name.AsPropertyAccessExpression() - symbol = c.resolveQualifiedName(name, access.Expression, access.Name(), meaning, ignoreErrors, dontResolveAlias, location) + symbol = c.resolveQualifiedName(name, access.Expression, access.Name(), meaning, ignoreErrors, location) default: panic("Unknown entity name kind") } @@ -15355,7 +15488,7 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign return symbol } -func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *ast.Node, meaning ast.SymbolFlags, ignoreErrors bool, dontResolveAlias bool, location *ast.Node) *ast.Symbol { +func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *ast.Node, meaning ast.SymbolFlags, ignoreErrors bool, location *ast.Node) *ast.Symbol { namespace := c.resolveEntityName(left, ast.SymbolFlagsNamespace, ignoreErrors, false /*dontResolveAlias*/, location) if namespace == nil || ast.NodeIsMissing(right) { return nil @@ -15367,9 +15500,9 @@ func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *as ast.IsInJSFile(namespace.ValueDeclaration) && c.compilerOptions.GetModuleResolutionKind() != core.ModuleResolutionKindBundler && ast.IsVariableDeclaration(namespace.ValueDeclaration) && - namespace.ValueDeclaration.AsVariableDeclaration().Initializer != nil && - c.isCommonJSRequire(namespace.ValueDeclaration.AsVariableDeclaration().Initializer) { - moduleName := namespace.ValueDeclaration.AsVariableDeclaration().Initializer.AsCallExpression().Arguments.Nodes[0] + namespace.ValueDeclaration.Initializer() != nil && + c.isCommonJSRequire(namespace.ValueDeclaration.Initializer()) { + moduleName := namespace.ValueDeclaration.Initializer().Arguments()[0] moduleSym := c.resolveExternalModuleName(moduleName, moduleName, false /*ignoreErrors*/) if moduleSym != nil { resolvedModuleSymbol := c.resolveExternalModuleSymbol(moduleSym, false /*dontResolveAlias*/) @@ -15378,7 +15511,7 @@ func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *as } } } - text := right.AsIdentifier().Text + text := right.Text() symbol := c.getMergedSymbol(c.getSymbol(c.getExportsOfSymbol(namespace), text, meaning)) if symbol == nil && namespace.Flags&ast.SymbolFlagsAlias != 0 { // `namespace` can be resolved further if there was a symbol merge with a re-export @@ -15407,7 +15540,7 @@ func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *as exportedTypeSymbol := c.getMergedSymbol(c.getSymbol(c.getExportsOfSymbol(namespace), text, ast.SymbolFlagsType)) if exportedTypeSymbol != nil { qualified := name.Parent.AsQualifiedName() - c.error(qualified.Right, diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, c.symbolToString(exportedTypeSymbol), qualified.Right.AsIdentifier().Text) + c.error(qualified.Right, diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, c.symbolToString(exportedTypeSymbol), qualified.Right.Text()) return nil } } @@ -15420,14 +15553,14 @@ func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *as func (c *Checker) tryGetQualifiedNameAsValue(node *ast.Node) *ast.Symbol { id := ast.GetFirstIdentifier(node) - symbol := c.resolveName(id, id.AsIdentifier().Text, ast.SymbolFlagsValue, nil /*nameNotFoundMessage*/, true /*isUse*/, false /*excludeGlobals*/) + symbol := c.resolveName(id, id.Text(), ast.SymbolFlagsValue, nil /*nameNotFoundMessage*/, true /*isUse*/, false /*excludeGlobals*/) if symbol == nil { return nil } n := id for ast.IsQualifiedName(n.Parent) { t := c.getTypeOfSymbol(symbol) - symbol = c.getPropertyOfType(t, n.Parent.AsQualifiedName().Right.AsIdentifier().Text) + symbol = c.getPropertyOfType(t, n.Parent.AsQualifiedName().Right.Text()) if symbol == nil { return nil } @@ -15686,9 +15819,9 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as nestedSymbols := ast.NewSymbolTable() lookupTable := make(ExportCollisionTable) for _, node := range exportStars.Declarations { - resolvedModule := c.resolveExternalModuleName(node, node.AsExportDeclaration().ModuleSpecifier, false /*ignoreErrors*/) - exportedSymbols := visit(resolvedModule, node, isTypeOnly || node.AsExportDeclaration().IsTypeOnly) - c.extendExportSymbols(nestedSymbols, ast.GetSymbolTable(&exportedSymbols), lookupTable, node) + resolvedModule := c.resolveExternalModuleName(node, node.ModuleSpecifier(), false /*ignoreErrors*/) + exportedSymbols := visit(resolvedModule, node, isTypeOnly || node.IsTypeOnly()) + c.extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node) } for id, s := range lookupTable { // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself @@ -15701,7 +15834,7 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as } c.extendExportSymbols(symbols, nestedSymbols, nil, nil) } - if exportStar != nil && exportStar.AsExportDeclaration().IsTypeOnly { + if exportStar != nil && exportStar.IsTypeOnly() { if typeOnlyExportStarMap == nil { typeOnlyExportStarMap = make(map[string]*ast.Node) } @@ -15711,12 +15844,26 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as } return symbols } + var originalModule *ast.Symbol + if moduleSymbol != nil { + if c.resolveSymbolEx(moduleSymbol.Exports.Get(ast.InternalSymbolNameExportEquals), false /*dontResolveAlias*/) != nil { + originalModule = moduleSymbol + } + } // A module defined by an 'export=' consists of one export that needs to be resolved moduleSymbol = c.resolveExternalModuleSymbol(moduleSymbol, false /*dontResolveAlias*/) exports = visit(moduleSymbol, nil, false) if exports == nil { exports = ast.NewSymbolTable() } + // A CommonJS module defined by an 'export=' might also export typedefs, stored on the original module + if originalModule != nil && originalModule.Exports.Len() > 1 { + for _, symbol := range originalModule.Exports.Iter() { + if symbol.Flags&ast.SymbolFlagsType != 0 && symbol.Name != ast.InternalSymbolNameExportEquals && exports.Get(symbol.Name) == nil { + exports.Set(symbol.Name, symbol) + } + } + } for name := range nonTypeOnlyNames.Keys() { delete(typeOnlyExportStarMap, name) } @@ -15737,7 +15884,7 @@ func (c *Checker) extendExportSymbols(target ast.SymbolTable, source ast.SymbolT target.Set(id, sourceSymbol) if lookupTable != nil && exportNode != nil { lookupTable[id] = &ExportCollision{ - specifierText: scanner.GetTextOfNode(exportNode.AsExportDeclaration().ModuleSpecifier), + specifierText: scanner.GetTextOfNode(exportNode.ModuleSpecifier()), } } } else if lookupTable != nil && exportNode != nil && c.resolveSymbol(targetSymbol) != c.resolveSymbol(sourceSymbol) { @@ -15761,29 +15908,25 @@ func (c *Checker) resolveAlias(symbol *ast.Symbol) *ast.Symbol { } links := c.aliasSymbolLinks.Get(symbol) if links.aliasTarget == nil { - links.aliasTarget = c.resolvingSymbol + if !c.pushTypeResolution(symbol, TypeSystemPropertyNameAliasTarget) { + return c.unknownSymbol + } node := c.getDeclarationOfAliasSymbol(symbol) if node == nil { panic("Unexpected nil in resolveAlias for symbol: " + c.symbolToString(symbol)) } - target := c.getTargetOfAliasDeclaration(node, false /*dontRecursivelyResolve*/) - if links.aliasTarget == c.resolvingSymbol { - if target == nil { - target = c.unknownSymbol - } - links.aliasTarget = target - } else { + links.aliasTarget = core.OrElse(c.getTargetOfAliasDeclaration(node, false /*dontRecursivelyResolve*/), c.unknownSymbol) + if !c.popTypeResolution() { c.error(node, diagnostics.Circular_definition_of_import_alias_0, c.symbolToString(symbol)) + links.aliasTarget = c.unknownSymbol } - } else if links.aliasTarget == c.resolvingSymbol { - links.aliasTarget = c.unknownSymbol } return links.aliasTarget } func (c *Checker) tryResolveAlias(symbol *ast.Symbol) *ast.Symbol { links := c.aliasSymbolLinks.Get(symbol) - if links.aliasTarget != c.resolvingSymbol { + if links.aliasTarget != nil || c.findResolutionCycleStartIndex(symbol, TypeSystemPropertyNameAliasTarget) < 0 { return c.resolveAlias(symbol) } return nil @@ -15854,7 +15997,7 @@ func (c *Checker) getSymbolFlagsEx(symbol *ast.Symbol, excludeTypeOnlyMeanings b var typeOnlyResolution *ast.Symbol if typeOnlyDeclaration != nil { if typeOnlyDeclarationIsExportStar { - moduleSpecifier := typeOnlyDeclaration.AsExportDeclaration().ModuleSpecifier + moduleSpecifier := typeOnlyDeclaration.ModuleSpecifier() typeOnlyResolution = c.resolveExternalModuleName(moduleSpecifier, moduleSpecifier /*ignoreErrors*/, true) } else { typeOnlyResolution = c.resolveAlias(typeOnlyDeclaration.Symbol()) @@ -16092,7 +16235,7 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo debug.AssertIsDefined(symbol.ValueDeclaration) declaration := symbol.ValueDeclaration if ast.IsSourceFile(declaration) && ast.IsJsonSourceFile(declaration.AsSourceFile()) { - statements := declaration.AsSourceFile().Statements.Nodes + statements := declaration.Statements() if len(statements) == 0 { return c.emptyObjectType } @@ -16117,7 +16260,7 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo if declaration.Type() != nil { result = c.getTypeFromTypeNode(declaration.Type()) } else { - result = c.widenTypeForVariableLikeDeclaration(c.checkExpressionCached(declaration.AsExportAssignment().Expression), declaration, false /*reportErrors*/) + result = c.widenTypeForVariableLikeDeclaration(c.checkExpressionCached(declaration.Expression()), declaration, false /*reportErrors*/) } case ast.KindBinaryExpression: result = c.getWidenedTypeForAssignmentDeclaration(symbol) @@ -16126,7 +16269,7 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo case ast.KindEnumMember: result = c.getTypeOfEnumMember(symbol) case ast.KindCommonJSExport: - result = c.checkExpression(declaration.AsCommonJSExport().Initializer) + result = c.checkExpression(declaration.Initializer()) default: panic("Unhandled case in getTypeOfVariableOrParameterOrPropertyWorker: " + declaration.Kind.String()) } @@ -16319,7 +16462,7 @@ func (c *Checker) checkDeclarationInitializer(declaration *ast.Node, checkMode C func (c *Checker) padObjectLiteralType(t *Type, pattern *ast.Node) *Type { var missingElements []*ast.Node - for _, e := range pattern.AsBindingPattern().Elements.Nodes { + for _, e := range pattern.Elements() { if e.Initializer() != nil { name := c.getPropertyNameFromBindingElement(e) if name != ast.InternalSymbolNameMissing && c.getPropertyOfType(t, name) == nil { @@ -16353,7 +16496,7 @@ func (c *Checker) getPropertyNameFromBindingElement(e *ast.Node) string { } func (c *Checker) padTupleType(t *Type, pattern *ast.Node) *Type { - patternElements := pattern.AsBindingPattern().Elements.Nodes + patternElements := pattern.Elements() if t.TargetTupleType().combinedFlags&ElementFlagsVariable != 0 || c.getTypeReferenceArity(t) >= len(patternElements) { return t } @@ -16651,14 +16794,14 @@ func (c *Checker) getInferredTypeParameterConstraint(t *Type, omitTypeReferences inferences = append(inferences, c.stringType) case ast.IsTypeParameterDeclaration(parent) && ast.IsMappedTypeNode(parent.Parent): inferences = append(inferences, c.stringNumberSymbolType) - case ast.IsMappedTypeNode(parent) && parent.AsMappedTypeNode().Type != nil && - ast.SkipParentheses(parent.AsMappedTypeNode().Type) == declaration.Parent && + case ast.IsMappedTypeNode(parent) && parent.Type() != nil && + ast.SkipParentheses(parent.Type()) == declaration.Parent && ast.IsConditionalTypeNode(parent.Parent) && parent.Parent.AsConditionalTypeNode().ExtendsType == parent && ast.IsMappedTypeNode(parent.Parent.AsConditionalTypeNode().CheckType) && - parent.Parent.AsConditionalTypeNode().CheckType.AsMappedTypeNode().Type != nil: + parent.Parent.AsConditionalTypeNode().CheckType.Type() != nil: checkMappedType := parent.Parent.AsConditionalTypeNode().CheckType - nodeType := c.getTypeFromTypeNode(checkMappedType.AsMappedTypeNode().Type) + nodeType := c.getTypeFromTypeNode(checkMappedType.Type()) checkMappedTypeParameter := checkMappedType.AsMappedTypeNode().TypeParameter mapper := newSimpleTypeMapper(c.getDeclaredTypeOfTypeParameter(c.getSymbolOfDeclaration(checkMappedTypeParameter)), core.IfElse(checkMappedTypeParameter.AsTypeParameter().Constraint != nil, @@ -17231,7 +17374,7 @@ func (c *Checker) getBindingElementTypeFromParentType(declaration *ast.Node, par c.error(declaration, diagnostics.Rest_types_may_only_be_created_from_object_types) return c.errorType } - elements := pattern.AsBindingPattern().Elements.Nodes + elements := pattern.Elements() literalMembers := make([]*ast.Node, 0, len(elements)) for _, element := range elements { if !hasDotDotDotToken(element) { @@ -17252,7 +17395,7 @@ func (c *Checker) getBindingElementTypeFromParentType(declaration *ast.Node, par // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). elementType := c.checkIteratedTypeOrElementType(IterationUseDestructuring|core.IfElse(hasDotDotDotToken(declaration), 0, IterationUsePossiblyOutOfBounds), parentType, c.undefinedType, pattern) - index := slices.Index(pattern.AsBindingPattern().Elements.Nodes, declaration) + index := slices.Index(pattern.Elements(), declaration) if hasDotDotDotToken(declaration) { // If the parent is a tuple type, the rest element has a tuple type of the // remaining tuple element types. Otherwise, the rest element has an array type with same @@ -17427,7 +17570,7 @@ func (c *Checker) getTypeFromObjectBindingPattern(pattern *ast.Node, includePatt members := ast.NewSymbolTable() var stringIndexInfo *IndexInfo objectFlags := ObjectFlagsObjectLiteral | ObjectFlagsContainsObjectOrArrayLiteral - for _, e := range pattern.AsBindingPattern().Elements.Nodes { + for _, e := range pattern.Elements() { name := e.PropertyNameOrName() if hasDotDotDotToken(e) { stringIndexInfo = c.newIndexInfo(c.stringType, c.anyType, false /*isReadonly*/, nil, nil) @@ -17460,13 +17603,14 @@ func (c *Checker) getTypeFromObjectBindingPattern(pattern *ast.Node, includePatt // Return the type implied by an array binding pattern func (c *Checker) getTypeFromArrayBindingPattern(pattern *ast.Node, includePatternInType bool, reportErrors bool) *Type { - elements := pattern.AsBindingPattern().Elements.Nodes + elements := pattern.Elements() lastElement := core.LastOrNil(elements) var restElement *ast.Node if lastElement != nil && ast.IsBindingElement(lastElement) && hasDotDotDotToken(lastElement) { restElement = lastElement } if len(elements) == 0 || len(elements) == 1 && restElement != nil { + // TODO: remove ScriptTargetES2015 if c.languageVersion >= core.ScriptTargetES2015 { return c.createIterableType(c.anyType) } @@ -17698,6 +17842,10 @@ func (c *Checker) widenTypeForVariableLikeDeclaration(t *Type, declaration *ast. } func (c *Checker) reportImplicitAny(declaration *ast.Node, t *Type, wideningKind WideningKind) { + if ast.IsInJSFile(declaration) && !ast.IsCheckJSEnabledForFile(ast.GetSourceFileOfNode(declaration), c.compilerOptions) { + // Only report implicit any errors/suggestions in TS and ts-check JS files + return + } typeAsString := c.TypeToString(c.getWidenedType(t)) var diagnostic *diagnostics.Message switch declaration.Kind { @@ -18206,6 +18354,8 @@ func (c *Checker) typeResolutionHasProperty(r *TypeResolution) bool { return c.nodeLinks.Get(r.target.(*ast.Node)).flags&NodeCheckFlagsInitializerIsUndefinedComputed != 0 case TypeSystemPropertyNameWriteType: return c.valueSymbolLinks.Get(r.target.(*ast.Symbol)).writeType != nil + case TypeSystemPropertyNameAliasTarget: + return c.aliasSymbolLinks.Get(r.target.(*ast.Symbol)).aliasTarget != nil } panic("Unhandled case in typeResolutionHasProperty") } @@ -19038,7 +19188,7 @@ func (c *Checker) getIndexInfosOfIndexSymbol(indexSymbol *ast.Symbol, siblingSym parameters := declaration.Parameters() returnTypeNode := declaration.Type() if len(parameters) == 1 { - typeNode := parameters[0].AsParameterDeclaration().Type + typeNode := parameters[0].Type() if typeNode != nil { valueType := c.anyType if returnTypeNode != nil { @@ -19217,13 +19367,11 @@ func (c *Checker) getSignaturesOfSymbol(symbol *ast.Symbol) []*Signature { } // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters. // Exclude contextually-typed kinds because we already apply the @type tag to the context, plus applying it here to the initializer would suppress checks that the two are compatible. - if ast.IsFunctionExpressionOrArrowFunction(decl) || ast.IsObjectLiteralMethod(decl) { - if sig := c.getSignatureOfFullSignatureType(decl); sig != nil { - result = append(result, sig) - continue - } + sig := c.getSignatureOfFullSignatureType(decl) + if sig == nil { + sig = c.getSignatureFromDeclaration(decl) } - result = append(result, c.getSignatureFromDeclaration(decl)) + result = append(result, sig) } return result } @@ -19239,6 +19387,14 @@ func (c *Checker) getSignatureFromDeclaration(declaration *ast.Node) *Signature minArgumentCount := 0 hasThisParameter := false iife := ast.GetImmediatelyInvokedFunctionExpression(declaration) + isUntypedSignatureInJSFile := iife == nil && + ast.IsInJSFile(declaration) && + (ast.IsFunctionExpression(declaration) || ast.IsArrowFunction(declaration) || ast.IsMethodOrAccessor(declaration) || ast.IsFunctionDeclaration(declaration) || ast.IsConstructorDeclaration(declaration)) && + core.Every(declaration.Parameters(), func(param *ast.Node) bool { return param.Type() == nil }) && + c.getContextualType(declaration, ContextFlagsSignature) == nil + if isUntypedSignatureInJSFile { + flags |= SignatureFlagsIsUntypedSignatureInJSFile + } for i, param := range declaration.Parameters() { paramSymbol := param.Symbol() typeNode := param.Type() @@ -19260,7 +19416,7 @@ func (c *Checker) getSignatureFromDeclaration(declaration *ast.Node) *Signature isOptionalParameter := isOptionalDeclaration(param) || param.Initializer() != nil || isRestParameter(param) || - iife != nil && len(parameters) > len(iife.AsCallExpression().Arguments.Nodes) && typeNode == nil + iife != nil && len(parameters) > len(iife.Arguments()) && typeNode == nil if !isOptionalParameter { minArgumentCount = len(parameters) } @@ -19297,15 +19453,13 @@ func (c *Checker) getSignatureFromDeclaration(declaration *ast.Node) *Signature } func (c *Checker) getTypeParametersFromDeclaration(declaration *ast.Node) []*Type { + if sig := c.getSignatureOfFullSignatureType(declaration); sig != nil { + return sig.TypeParameters() + } var result []*Type for _, node := range declaration.TypeParameters() { result = core.AppendIfUnique(result, c.getDeclaredTypeOfTypeParameter(node.Symbol())) } - if len(result) == 0 && ast.IsFunctionDeclaration(declaration) { - if sig := c.getSignatureOfFullSignatureType(declaration); sig != nil { - return sig.TypeParameters() - } - } return result } @@ -19380,7 +19534,7 @@ func isLateBindableAST(node *ast.Node) bool { var expr *ast.Node switch { case ast.IsComputedPropertyName(node): - expr = node.AsComputedPropertyName().Expression + expr = node.Expression() case ast.IsElementAccessExpression(node): expr = node.AsElementAccessExpression().ArgumentExpression } @@ -19459,7 +19613,7 @@ func (c *Checker) getReturnTypeFromAnnotation(declaration *ast.Node) *Type { } func (c *Checker) getSignatureOfFullSignatureType(node *ast.Node) *Signature { - if ast.IsInJSFile(node) && ast.IsFunctionLike(node) && node.FunctionLikeData().FullSignature != nil { + if ast.IsInJSFile(node) && (ast.IsFunctionDeclaration(node) || ast.IsMethodDeclaration(node) || ast.IsFunctionExpressionOrArrowFunction(node)) && node.FunctionLikeData().FullSignature != nil { return c.getSingleCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature)) } return nil @@ -21347,7 +21501,7 @@ func (c *Checker) getTypeArguments(t *Type) []*Type { case ast.KindArrayType: typeArguments = []*Type{c.getTypeFromTypeNode(node.AsArrayTypeNode().ElementType)} case ast.KindTupleType: - typeArguments = core.Map(node.AsTupleTypeNode().Elements.Nodes, c.getTypeFromTypeNode) + typeArguments = core.Map(node.Elements(), c.getTypeFromTypeNode) default: panic("Unhandled case in getTypeArguments") } @@ -21487,20 +21641,44 @@ func (c *Checker) getDefaultOrUnknownFromTypeParameter(t *Type) *Type { return core.IfElse(result != nil, result, c.unknownType) } -func (c *Checker) getNamedMembers(members ast.SymbolTable) []*ast.Symbol { - if members == nil || members.Len() == 0 { +func (c *Checker) getNamedMembers(members ast.SymbolTable, container *ast.Symbol) []*ast.Symbol { + if members.Len() == 0 { return nil } + // For classes and interfaces, we store explicitly declared members ahead of inherited members. This ensures we process + // explicitly declared members first in type relations, which is beneficial because explicitly declared members are more + // likely to contain discriminating differences. See for example https://github.com/microsoft/typescript-go/issues/1968. result := make([]*ast.Symbol, 0, members.Len()) + var containedCount int + if container != nil && container.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) != 0 { + for id, symbol := range members.Iter() { + if c.isNamedMember(symbol, id) && c.isDeclarationContainedBy(symbol, container) { + result = append(result, symbol) + } + } + containedCount = len(result) + } for id, symbol := range members.Iter() { - if c.isNamedMember(symbol, id) { + if c.isNamedMember(symbol, id) && (container == nil || container.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) == 0 || !c.isDeclarationContainedBy(symbol, container)) { result = append(result, symbol) } } - c.sortSymbols(result) + c.sortSymbols(result[:containedCount]) + c.sortSymbols(result[containedCount:]) return result } +func (c *Checker) isDeclarationContainedBy(symbol *ast.Symbol, container *ast.Symbol) bool { + if declaration := symbol.ValueDeclaration; declaration != nil { + for _, d := range container.Declarations { + if declaration.Loc.ContainedBy(d.Loc) { + return true + } + } + } + return false +} + func (c *Checker) isNamedMember(symbol *ast.Symbol, id string) bool { return !isReservedMemberName(id) && c.symbolIsValue(symbol) } @@ -22228,9 +22406,9 @@ func (c *Checker) getTypeFromTypeNodeWorker(node *ast.Node) *Type { case ast.KindAnyKeyword, ast.KindJSDocAllType: return c.anyType case ast.KindJSDocNonNullableType: - return c.getTypeFromTypeNode(node.AsJSDocNonNullableType().Type) + return c.getTypeFromTypeNode(node.Type()) case ast.KindJSDocNullableType: - t := c.getTypeFromTypeNode(node.AsJSDocNullableType().Type) + t := c.getTypeFromTypeNode(node.Type()) if c.strictNullChecks { return c.getNullableType(t, TypeFlagsNull) } else { @@ -22239,7 +22417,7 @@ func (c *Checker) getTypeFromTypeNodeWorker(node *ast.Node) *Type { case ast.KindJSDocVariadicType: return c.createArrayType(c.getTypeFromTypeNode(node.AsJSDocVariadicType().Type)) case ast.KindJSDocOptionalType: - return c.addOptionality(c.getTypeFromTypeNode(node.AsJSDocOptionalType().Type)) + return c.addOptionality(c.getTypeFromTypeNode(node.Type())) case ast.KindUnknownKeyword: return c.unknownType case ast.KindStringKeyword: @@ -22288,7 +22466,7 @@ func (c *Checker) getTypeFromTypeNodeWorker(node *ast.Node) *Type { case ast.KindNamedTupleMember: return c.getTypeFromNamedTupleTypeNode(node) case ast.KindParenthesizedType: - return c.getTypeFromTypeNode(node.AsParenthesizedTypeNode().Type) + return c.getTypeFromTypeNode(node.Type()) case ast.KindRestType: return c.getTypeFromRestTypeNode(node) case ast.KindFunctionType, ast.KindConstructorType, ast.KindTypeLiteral: @@ -22375,7 +22553,7 @@ func (c *Checker) getTypeFromIndexedAccessTypeNode(node *ast.Node) *Type { func (c *Checker) getTypeFromTypeOperatorNode(node *ast.Node) *Type { links := c.typeNodeLinks.Get(node) if links.resolvedType == nil { - argType := node.AsTypeOperatorNode().Type + argType := node.Type() switch node.AsTypeOperatorNode().Operator { case ast.KindKeyOfKeyword: links.resolvedType = c.getIndexType(c.getTypeFromTypeNode(argType)) @@ -22595,7 +22773,7 @@ func (c *Checker) isDeferredTypeReferenceNode(node *ast.Node, hasDefaultTypeArgu case ast.KindArrayType: return c.mayResolveTypeAlias(node.AsArrayTypeNode().ElementType) case ast.KindTupleType: - return core.Some(node.AsTupleTypeNode().Elements.Nodes, c.mayResolveTypeAlias) + return core.Some(node.Elements(), c.mayResolveTypeAlias) case ast.KindTypeReference: return hasDefaultTypeArguments || core.Some(node.TypeArguments(), c.mayResolveTypeAlias) } @@ -22628,15 +22806,11 @@ func (c *Checker) mayResolveTypeAlias(node *ast.Node) bool { case ast.KindTypeQuery: return true case ast.KindTypeOperator: - return node.AsTypeOperatorNode().Operator != ast.KindUniqueKeyword && c.mayResolveTypeAlias(node.AsTypeOperatorNode().Type) - case ast.KindParenthesizedType: - return c.mayResolveTypeAlias(node.AsParenthesizedTypeNode().Type) - case ast.KindOptionalType: - return c.mayResolveTypeAlias(node.AsOptionalTypeNode().Type) - case ast.KindNamedTupleMember: - return c.mayResolveTypeAlias(node.AsNamedTupleMember().Type) + return node.AsTypeOperatorNode().Operator != ast.KindUniqueKeyword && c.mayResolveTypeAlias(node.Type()) + case ast.KindParenthesizedType, ast.KindOptionalType, ast.KindNamedTupleMember: + return c.mayResolveTypeAlias(node.Type()) case ast.KindRestType: - return node.AsRestTypeNode().Type.Kind != ast.KindArrayType || c.mayResolveTypeAlias(node.AsRestTypeNode().Type.AsArrayTypeNode().ElementType) + return node.Type().Kind != ast.KindArrayType || c.mayResolveTypeAlias(node.Type().AsArrayTypeNode().ElementType) case ast.KindUnionType: return core.Some(node.AsUnionTypeNode().Types.Nodes, c.mayResolveTypeAlias) case ast.KindIntersectionType: @@ -23048,7 +23222,7 @@ func getTypeReferenceName(node *ast.Node) *ast.Node { case ast.KindExpressionWithTypeArguments: // We only support expressions that are simple qualified names. For other // expressions this produces nil - expr := node.AsExpressionWithTypeArguments().Expression + expr := node.Expression() if ast.IsEntityNameExpression(expr) { return expr } @@ -23191,7 +23365,7 @@ func (c *Checker) getDeclaredTypeOfTypeAlias(symbol *ast.Symbol) *Type { return c.errorType } declaration := core.Find(symbol.Declarations, ast.IsTypeOrJSTypeAliasDeclaration) - typeNode := declaration.AsTypeAliasDeclaration().Type + typeNode := declaration.Type() t := c.getTypeFromTypeNode(typeNode) if c.popTypeResolution() { typeParameters := c.getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) @@ -23309,7 +23483,7 @@ func (c *Checker) computeEnumMemberValue(member *ast.Node, autoValue jsnum.Numbe c.error(member.Name(), diagnostics.An_enum_member_cannot_have_a_numeric_name) } else { text := ast.GetTextOfPropertyName(member.Name()) - if isNumericLiteralName(text) && !isInfinityOrNaNString(text) { + if isNumericLiteralName(text) && !ast.IsInfinityOrNaNString(text) { c.error(member.Name(), diagnostics.An_enum_member_cannot_have_a_numeric_name) } } @@ -23329,7 +23503,7 @@ func (c *Checker) computeEnumMemberValue(member *ast.Node, autoValue jsnum.Numbe c.error(member.Name(), diagnostics.Enum_member_must_have_initializer) return evaluator.NewResult(nil, false, false, false) } - if c.compilerOptions.GetIsolatedModules() && previous != nil && previous.AsEnumMember().Initializer != nil { + if c.compilerOptions.GetIsolatedModules() && previous != nil && previous.Initializer() != nil { prevValue := c.getEnumMemberValue(previous) _, prevIsNum := prevValue.Value.(jsnum.Number) if !prevIsNum || prevValue.ResolvedOtherFiles { @@ -23376,7 +23550,7 @@ func (c *Checker) evaluateEntity(expr *ast.Node, location *ast.Node) evaluator.R return evaluator.NewResult(nil, false, false, false) } if expr.Kind == ast.KindIdentifier { - if isInfinityOrNaNString(expr.Text()) && (symbol == c.getGlobalSymbol(expr.Text(), ast.SymbolFlagsValue, nil /*diagnostic*/)) { + if ast.IsInfinityOrNaNString(expr.Text()) && (symbol == c.getGlobalSymbol(expr.Text(), ast.SymbolFlagsValue, nil /*diagnostic*/)) { // Technically we resolved a global lib file here, but the decision to treat this as numeric // is more predicated on the fact that the single-file resolution *didn't* resolve to a // different meaning of `Infinity` or `NaN`. Transpilers handle this no problem. @@ -23466,8 +23640,8 @@ func (c *Checker) getTypeFromArrayOrTupleTypeNode(node *ast.Node) *Type { target := c.getArrayOrTupleTargetType(node) if target == c.emptyGenericType { links.resolvedType = c.emptyObjectType - } else if !(node.Kind == ast.KindTupleType && core.Some(node.AsTupleTypeNode().Elements.Nodes, c.isVariadicTupleElement)) && c.isDeferredTypeReferenceNode(node, false) { - if node.Kind == ast.KindTupleType && len(node.AsTupleTypeNode().Elements.Nodes) == 0 { + } else if !(node.Kind == ast.KindTupleType && core.Some(node.Elements(), c.isVariadicTupleElement)) && c.isDeferredTypeReferenceNode(node, false) { + if node.Kind == ast.KindTupleType && len(node.Elements()) == 0 { links.resolvedType = target } else { links.resolvedType = c.createDeferredTypeReference(target, node, nil /*mapper*/, nil /*alias*/) @@ -23477,7 +23651,7 @@ func (c *Checker) getTypeFromArrayOrTupleTypeNode(node *ast.Node) *Type { if node.Kind == ast.KindArrayType { elementTypes = []*Type{c.getTypeFromTypeNode(node.AsArrayTypeNode().ElementType)} } else { - elementTypes = core.Map(node.AsTupleTypeNode().Elements.Nodes, c.getTypeFromTypeNode) + elementTypes = core.Map(node.Elements(), c.getTypeFromTypeNode) } links.resolvedType = c.createNormalizedTypeReference(target, elementTypes) } @@ -23498,7 +23672,7 @@ func (c *Checker) getArrayOrTupleTargetType(node *ast.Node) *Type { } return c.globalArrayType } - return c.getTupleTargetType(core.Map(node.AsTupleTypeNode().Elements.Nodes, c.getTupleElementInfo), readonly) + return c.getTupleTargetType(core.Map(node.Elements(), c.getTupleElementInfo), readonly) } func (c *Checker) isReadonlyTypeOperator(node *ast.Node) bool { @@ -23511,7 +23685,7 @@ func (c *Checker) getTypeFromNamedTupleTypeNode(node *ast.Node) *Type { if node.AsNamedTupleMember().DotDotDotToken != nil { links.resolvedType = c.getTypeFromRestTypeNode(node) } else { - links.resolvedType = c.addOptionalityEx(c.getTypeFromTypeNode(node.Type()), true /*isProperty*/, node.AsNamedTupleMember().QuestionToken != nil) + links.resolvedType = c.addOptionalityEx(c.getTypeFromTypeNode(node.Type()), true /*isProperty*/, node.QuestionToken() != nil) } } return links.resolvedType @@ -23529,15 +23703,15 @@ func (c *Checker) getTypeFromRestTypeNode(node *ast.Node) *Type { func (c *Checker) getArrayElementTypeNode(node *ast.Node) *ast.Node { switch node.Kind { case ast.KindParenthesizedType: - return c.getArrayElementTypeNode(node.AsParenthesizedTypeNode().Type) + return c.getArrayElementTypeNode(node.Type()) case ast.KindTupleType: - if len(node.AsTupleTypeNode().Elements.Nodes) == 1 { - node = node.AsTupleTypeNode().Elements.Nodes[0] + if len(node.Elements()) == 1 { + node = node.Elements()[0] if node.Kind == ast.KindRestType { - return c.getArrayElementTypeNode(node.AsRestTypeNode().Type) + return c.getArrayElementTypeNode(node.Type()) } if node.Kind == ast.KindNamedTupleMember && node.AsNamedTupleMember().DotDotDotToken != nil { - return c.getArrayElementTypeNode(node.AsNamedTupleMember().Type) + return c.getArrayElementTypeNode(node.Type()) } } case ast.KindArrayType: @@ -23547,7 +23721,7 @@ func (c *Checker) getArrayElementTypeNode(node *ast.Node) *ast.Node { } func (c *Checker) getTypeFromOptionalTypeNode(node *ast.Node) *Type { - return c.addOptionalityEx(c.getTypeFromTypeNode(node.AsOptionalTypeNode().Type), true /*isProperty*/, true /*isOptional*/) + return c.addOptionalityEx(c.getTypeFromTypeNode(node.Type()), true /*isProperty*/, true /*isOptional*/) } func (c *Checker) getTypeFromUnionTypeNode(node *ast.Node) *Type { @@ -23589,7 +23763,7 @@ func (c *Checker) getTypeFromTemplateTypeNode(node *ast.Node) *Type { texts[0] = node.AsTemplateLiteralTypeNode().Head.Text() for i, span := range spans.Nodes { texts[i+1] = span.AsTemplateLiteralTypeSpan().Literal.Text() - types[i] = c.getTypeFromTypeNode(span.AsTemplateLiteralTypeSpan().Type) + types[i] = c.getTypeFromTypeNode(span.Type()) } links.resolvedType = c.getTemplateLiteralType(texts, types) } @@ -23668,7 +23842,7 @@ func (c *Checker) getConditionalType(root *ConditionalRoot, mapper *TypeMapper, // When the check and extends types are simple tuple types of the same arity, we defer resolution of the // conditional type when any tuple elements are generic. This is such that non-distributable conditional // types can be written `[X] extends [Y] ? ...` and be deferred similarly to `X extends Y ? ...`. - checkTuples := c.isSimpleTupleType(checkTypeNode) && c.isSimpleTupleType(extendsTypeNode) && len(checkTypeNode.AsTupleTypeNode().Elements.Nodes) == len(extendsTypeNode.AsTupleTypeNode().Elements.Nodes) + checkTuples := c.isSimpleTupleType(checkTypeNode) && c.isSimpleTupleType(extendsTypeNode) && len(checkTypeNode.Elements()) == len(extendsTypeNode.Elements()) checkTypeDeferred := c.isDeferredType(checkType, checkTuples) var combinedMapper *TypeMapper if len(root.inferTypeParameters) != 0 { @@ -23811,8 +23985,8 @@ func (c *Checker) getTailRecursionRoot(newType *Type, newMapper *TypeMapper) (*C } func (c *Checker) isSimpleTupleType(node *ast.Node) bool { - return ast.IsTupleTypeNode(node) && len(node.AsTupleTypeNode().Elements.Nodes) > 0 && !core.Some(node.AsTupleTypeNode().Elements.Nodes, func(e *ast.Node) bool { - return ast.IsOptionalTypeNode(e) || ast.IsRestTypeNode(e) || ast.IsNamedTupleMember(e) && (e.AsNamedTupleMember().QuestionToken != nil || e.AsNamedTupleMember().DotDotDotToken != nil) + return ast.IsTupleTypeNode(node) && len(node.Elements()) > 0 && !core.Some(node.Elements(), func(e *ast.Node) bool { + return ast.IsOptionalTypeNode(e) || ast.IsRestTypeNode(e) || ast.IsNamedTupleMember(e) && (e.QuestionToken() != nil || e.AsNamedTupleMember().DotDotDotToken != nil) }) } @@ -23953,6 +24127,13 @@ func (c *Checker) getTypeFromImportTypeNode(node *ast.Node) *Type { symbolFromVariable = c.getPropertyOfTypeEx(c.getTypeOfSymbol(mergedResolvedSymbol), current.Text(), false /*skipObjectFunctionPropertyAugment*/, true /*includeTypeOnlyMembers*/) } else { symbolFromModule = c.getSymbol(c.getExportsOfSymbol(mergedResolvedSymbol), current.Text(), meaning) + if symbolFromModule == nil { + // a CommonJS module might have typedefs exported alongside an export= + immediateModuleSymbol := c.resolveExternalModuleSymbol(innerModuleSymbol, true /*dontResolveAlias*/) + if immediateModuleSymbol != nil && core.Some(immediateModuleSymbol.Declarations, func(d *ast.Node) bool { return d.Kind == ast.KindJSExportAssignment }) { + symbolFromModule = c.getSymbol(c.getExportsOfSymbol(immediateModuleSymbol.Parent), current.Text(), meaning) + } + } } next := core.OrElse(symbolFromModule, symbolFromVariable) if next == nil { @@ -24045,7 +24226,7 @@ func (c *Checker) getTupleElementFlags(node *ast.Node) ElementFlags { case ast.KindOptionalType: return ElementFlagsOptional case ast.KindRestType: - return core.IfElse(c.getArrayElementTypeNode(node.AsRestTypeNode().Type) != nil, ElementFlagsRest, ElementFlagsVariadic) + return core.IfElse(c.getArrayElementTypeNode(node.Type()) != nil, ElementFlagsRest, ElementFlagsVariadic) case ast.KindNamedTupleMember: named := node.AsNamedTupleMember() switch { @@ -24300,7 +24481,7 @@ func (c *Checker) getConditionalFlowTypeOfType(t *Type, node *ast.Node) *Type { if constraint != nil { constraints = append(constraints, constraint) } - } else if t.flags&TypeFlagsTypeParameter != 0 && ast.IsMappedTypeNode(parent) && parent.AsMappedTypeNode().NameType == nil && node == parent.AsMappedTypeNode().Type { + } else if t.flags&TypeFlagsTypeParameter != 0 && ast.IsMappedTypeNode(parent) && parent.AsMappedTypeNode().NameType == nil && node == parent.Type() { mappedType := c.getTypeFromTypeNode(parent) if c.getTypeParameterFromMappedType(mappedType) == c.getActualTypeVariable(t) { typeParameter := c.getHomomorphicTypeVariable(mappedType) @@ -24323,7 +24504,7 @@ func (c *Checker) getConditionalFlowTypeOfType(t *Type, node *ast.Node) *Type { func (c *Checker) getImpliedConstraint(t *Type, checkNode *ast.Node, extendsNode *ast.Node) *Type { switch { case isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode): - return c.getImpliedConstraint(t, checkNode.AsTupleTypeNode().Elements.Nodes[0], extendsNode.AsTupleTypeNode().Elements.Nodes[0]) + return c.getImpliedConstraint(t, checkNode.Elements()[0], extendsNode.Elements()[0]) case c.getActualTypeVariable(c.getTypeFromTypeNode(checkNode)) == c.getActualTypeVariable(t): return c.getTypeFromTypeNode(extendsNode) } @@ -24331,7 +24512,7 @@ func (c *Checker) getImpliedConstraint(t *Type, checkNode *ast.Node, extendsNode } func isUnaryTupleTypeNode(node *ast.Node) bool { - return ast.IsTupleTypeNode(node) && len(node.AsTupleTypeNode().Elements.Nodes) == 1 + return ast.IsTupleTypeNode(node) && len(node.Elements()) == 1 } func (c *Checker) newType(flags TypeFlags, objectFlags ObjectFlags, data TypeData) *Type { @@ -24473,8 +24654,11 @@ func (c *Checker) cloneTypeReference(source *Type) *Type { func (c *Checker) setStructuredTypeMembers(t *Type, members ast.SymbolTable, callSignatures []*Signature, constructSignatures []*Signature, indexInfos []*IndexInfo) { t.objectFlags |= ObjectFlagsMembersResolved data := t.AsStructuredType() + if members == nil { + members = ast.NewSymbolTable() + } data.members = members - data.properties = c.getNamedMembers(members) + data.properties = c.getNamedMembers(members, t.symbol) if len(callSignatures) != 0 { if len(constructSignatures) != 0 { data.signatures = core.Concatenate(callSignatures, constructSignatures) @@ -26401,6 +26585,9 @@ func (c *Checker) getPropertyTypeForIndexType(originalObjectType *Type, objectTy if indexType.flags&TypeFlagsNever != 0 { return c.neverType } + if c.isJSLiteralType(objectType) { + return c.anyType + } if accessExpression != nil && !isConstEnumObjectType(objectType) { if isObjectLiteralType(objectType) { if c.noImplicitAny && indexType.flags&(TypeFlagsStringLiteral|TypeFlagsNumberLiteral) != 0 { @@ -26460,6 +26647,9 @@ func (c *Checker) getPropertyTypeForIndexType(originalObjectType *Type, objectTy if accessFlags&AccessFlagsAllowMissing != 0 && isObjectLiteralType(objectType) { return c.undefinedType } + if c.isJSLiteralType(objectType) { + return c.anyType + } if accessNode != nil { indexNode := getIndexNodeForAccessExpression(accessNode) if indexNode.Kind != ast.KindBigIntLiteral && indexType.flags&(TypeFlagsStringLiteral|TypeFlagsNumberLiteral) != 0 { @@ -26531,7 +26721,7 @@ func getIndexNodeForAccessExpression(accessNode *ast.Node) *ast.Node { case ast.KindIndexedAccessType: return accessNode.AsIndexedAccessTypeNode().IndexType case ast.KindComputedPropertyName: - return accessNode.AsComputedPropertyName().Expression + return accessNode.Expression() } return accessNode } @@ -27344,7 +27534,7 @@ func (c *Checker) getModifiersTypeFromMappedType(t *Type) *Type { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. - m.modifiersType = c.instantiateType(c.getTypeFromTypeNode(c.getConstraintDeclarationForMappedType(t).AsTypeOperatorNode().Type), m.mapper) + m.modifiersType = c.instantiateType(c.getTypeFromTypeNode(c.getConstraintDeclarationForMappedType(t).Type()), m.mapper) } else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', @@ -27496,10 +27686,10 @@ func isExportOrExportExpression(location *ast.Node) bool { parent := n.Parent if parent != nil { if ast.IsAnyExportAssignment(parent) { - return parent.AsExportAssignment().Expression == n && ast.IsEntityNameExpression(n) + return parent.Expression() == n && ast.IsEntityNameExpression(n) } if ast.IsExportSpecifier(parent) { - return parent.AsExportSpecifier().Name() == n || parent.AsExportSpecifier().PropertyName == n + return parent.AsExportSpecifier().Name() == n || parent.PropertyName() == n } } return false @@ -27514,12 +27704,12 @@ func shouldMarkIdentifierAliasReferenced(node *ast.IdentifierNode) bool { return false } // Next two check for an identifier inside a type only export. - if ast.IsExportSpecifier(parent) && parent.AsExportSpecifier().IsTypeOnly { + if ast.IsExportSpecifier(parent) && parent.IsTypeOnly() { return false } if parent.Parent != nil { greatGrandparent := parent.Parent.Parent - if greatGrandparent != nil && ast.IsExportDeclaration(greatGrandparent) && greatGrandparent.AsExportDeclaration().IsTypeOnly { + if greatGrandparent != nil && ast.IsExportDeclaration(greatGrandparent) && greatGrandparent.IsTypeOnly() { return false } } @@ -27542,7 +27732,7 @@ func (c *Checker) markIdentifierAliasReferenced(location *ast.IdentifierNode) { func (c *Checker) markPropertyAliasReferenced(location *ast.Node /*PropertyAccessExpression | QualifiedName*/, propSymbol *ast.Symbol, parentType *Type) { var left *ast.Node if ast.IsPropertyAccessExpression(location) { - left = location.AsPropertyAccessExpression().Expression + left = location.Expression() } else { left = location.AsQualifiedName().Left } @@ -27671,11 +27861,8 @@ func (c *Checker) markImportEqualsAliasReferenced(location *ast.Node /*ImportEqu } func (c *Checker) markExportSpecifierAliasReferenced(location *ast.ExportSpecifierNode) { - if location.Parent.Parent.AsExportDeclaration().ModuleSpecifier == nil && !location.AsExportSpecifier().IsTypeOnly && !location.Parent.Parent.AsExportDeclaration().IsTypeOnly { - exportedName := location.PropertyName() - if exportedName == nil { - exportedName = location.Name() - } + if location.Parent.Parent.ModuleSpecifier() == nil && !location.IsTypeOnly() && !location.Parent.Parent.IsTypeOnly() { + exportedName := location.PropertyNameOrName() if exportedName.Kind == ast.KindStringLiteral { return // Skip for invalid syntax like this: export { "x" } } @@ -28266,10 +28453,10 @@ func (c *Checker) getContextualType(node *ast.Node, contextFlags ContextFlags) * case ast.KindDecorator: return c.getContextualTypeForDecorator(parent) case ast.KindTypeAssertionExpression, ast.KindAsExpression: - if isConstAssertion(parent) { + if ast.IsConstAssertion(parent) { return c.getContextualType(parent, contextFlags) } - return c.getTypeFromTypeNode(getAssertedTypeNode(parent)) + return c.getTypeFromTypeNode(parent.Type()) case ast.KindBinaryExpression: return c.getContextualTypeForBinaryOperand(node, contextFlags) case ast.KindPropertyAssignment, @@ -28279,9 +28466,9 @@ func (c *Checker) getContextualType(node *ast.Node, contextFlags ContextFlags) * return c.getContextualType(parent.Parent, contextFlags) case ast.KindArrayLiteralExpression: t := c.getApparentTypeOfContextualType(parent, contextFlags) - elementIndex := ast.IndexOfNode(parent.AsArrayLiteralExpression().Elements.Nodes, node) + elementIndex := ast.IndexOfNode(parent.Elements(), node) firstSpreadIndex, lastSpreadIndex := c.getSpreadIndices(parent) - return c.getContextualTypeForElementExpression(t, elementIndex, len(parent.AsArrayLiteralExpression().Elements.Nodes), firstSpreadIndex, lastSpreadIndex) + return c.getContextualTypeForElementExpression(t, elementIndex, len(parent.Elements()), firstSpreadIndex, lastSpreadIndex) case ast.KindConditionalExpression: return c.getContextualTypeForConditionalOperand(node, contextFlags) case ast.KindTemplateSpan: @@ -28291,7 +28478,7 @@ func (c *Checker) getContextualType(node *ast.Node, contextFlags ContextFlags) * case ast.KindNonNullExpression: return c.getContextualType(parent, contextFlags) case ast.KindSatisfiesExpression: - return c.getTypeFromTypeNode(parent.AsSatisfiesExpression().Type) + return c.getTypeFromTypeNode(parent.Type()) case ast.KindExportAssignment, ast.KindJSExportAssignment, ast.KindCommonJSExport: return c.tryGetTypeFromTypeNode(parent) case ast.KindJsxExpression: @@ -28325,7 +28512,7 @@ func (c *Checker) getContextualTypeForInitializerExpression(node *ast.Node, cont if result != nil { return result } - if contextFlags&ContextFlagsSkipBindingPatterns == 0 && ast.IsBindingPattern(declaration.Name()) && len(declaration.Name().AsBindingPattern().Elements.Nodes) > 0 { + if contextFlags&ContextFlagsSkipBindingPatterns == 0 && ast.IsBindingPattern(declaration.Name()) && len(declaration.Name().Elements()) > 0 { return c.getTypeFromBindingPattern(declaration.Name(), true /*includePatternInType*/, false /*reportErrors*/) } } @@ -28493,7 +28680,7 @@ func (c *Checker) getContextualTypeForBindingElement(declaration *ast.Node, cont return nil } if ast.IsArrayBindingPattern(parent.Name()) { - index := slices.Index(declaration.Parent.AsBindingPattern().Elements.Nodes, declaration) + index := slices.Index(declaration.Parent.Elements(), declaration) if index < 0 { return nil } @@ -28953,7 +29140,7 @@ func (c *Checker) getEffectiveCallArguments(node *ast.Node) []*ast.Node { // Handles instanceof operator return []*ast.Node{node.AsBinaryExpression().Left} case ast.IsJsxOpeningLikeElement(node): - if len(node.Attributes().AsJsxAttributes().Properties.Nodes) != 0 || (ast.IsJsxOpeningElement(node) && len(node.Parent.Children().Nodes) != 0) { + if len(node.Attributes().Properties()) != 0 || (ast.IsJsxOpeningElement(node) && len(node.Parent.Children().Nodes) != 0) { return []*ast.Node{node.Attributes()} } return nil @@ -29014,7 +29201,7 @@ func (c *Checker) getSpreadIndices(node *ast.Node) (int, int) { links := c.arrayLiteralLinks.Get(node) if !links.indicesComputed { first, last := -1, -1 - for i, element := range node.AsArrayLiteralExpression().Elements.Nodes { + for i, element := range node.Elements() { if ast.IsSpreadElement(element) { if first < 0 { first = i @@ -29648,7 +29835,7 @@ func (c *Checker) discriminateContextualTypeByObjectMembers(node *ast.Node, cont } discriminated := c.getMatchingUnionConstituentForObjectLiteral(contextualType, node) if discriminated == nil { - discriminantProperties := core.Filter(node.AsObjectLiteralExpression().Properties.Nodes, func(p *ast.Node) bool { + discriminantProperties := core.Filter(node.Properties(), func(p *ast.Node) bool { symbol := p.Symbol() if symbol == nil { return false @@ -29674,7 +29861,7 @@ func (c *Checker) discriminateContextualTypeByObjectMembers(node *ast.Node, cont func (c *Checker) getMatchingUnionConstituentForObjectLiteral(unionType *Type, node *ast.Node) *Type { keyPropertyName := c.getKeyPropertyName(unionType) if keyPropertyName != "" { - propNode := core.Find(node.AsObjectLiteralExpression().Properties.Nodes, func(p *ast.Node) bool { + propNode := core.Find(node.Properties(), func(p *ast.Node) bool { return p.Symbol() != nil && ast.IsPropertyAssignment(p) && p.Symbol().Name == keyPropertyName && c.isPossiblyDiscriminantValue(p.Initializer()) }) if propNode != nil { @@ -29696,7 +29883,7 @@ func (c *Checker) isPossiblyDiscriminantValue(node *ast.Node) bool { case ast.KindPropertyAccessExpression, ast.KindParenthesizedExpression: return c.isPossiblyDiscriminantValue(node.Expression()) case ast.KindJsxExpression: - return node.AsJsxExpression().Expression == nil || c.isPossiblyDiscriminantValue(node.AsJsxExpression().Expression) + return node.Expression() == nil || c.isPossiblyDiscriminantValue(node.Expression()) } return false } @@ -29783,9 +29970,9 @@ func (c *Checker) isContextSensitive(node *ast.Node) bool { case ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: return c.isContextSensitiveFunctionLikeDeclaration(node) case ast.KindObjectLiteralExpression: - return core.Some(node.AsObjectLiteralExpression().Properties.Nodes, c.isContextSensitive) + return core.Some(node.Properties(), c.isContextSensitive) case ast.KindArrayLiteralExpression: - return core.Some(node.AsArrayLiteralExpression().Elements.Nodes, c.isContextSensitive) + return core.Some(node.Elements(), c.isContextSensitive) case ast.KindConditionalExpression: return c.isContextSensitive(node.AsConditionalExpression().WhenTrue) || c.isContextSensitive(node.AsConditionalExpression().WhenFalse) case ast.KindBinaryExpression: @@ -29796,7 +29983,7 @@ func (c *Checker) isContextSensitive(node *ast.Node) bool { case ast.KindParenthesizedExpression: return c.isContextSensitive(node.Expression()) case ast.KindJsxAttributes: - return core.Some(node.AsJsxAttributes().Properties.Nodes, c.isContextSensitive) || ast.IsJsxOpeningElement(node.Parent) && core.Some(node.Parent.Parent.Children().Nodes, c.isContextSensitive) + return core.Some(node.Properties(), c.isContextSensitive) || ast.IsJsxOpeningElement(node.Parent) && core.Some(node.Parent.Parent.Children().Nodes, c.isContextSensitive) case ast.KindJsxAttribute: // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. initializer := node.Initializer() @@ -29810,7 +29997,7 @@ func (c *Checker) isContextSensitive(node *ast.Node) bool { } func (c *Checker) isContextSensitiveFunctionLikeDeclaration(node *ast.Node) bool { - return hasContextSensitiveParameters(node) || c.hasContextSensitiveReturnExpression(node) + return ast.HasContextSensitiveParameters(node) || c.hasContextSensitiveReturnExpression(node) } func (c *Checker) hasContextSensitiveReturnExpression(node *ast.Node) bool { @@ -30353,7 +30540,7 @@ func (c *Checker) isSomeSymbolAssignedWorker(node *ast.Node) bool { if node.Kind == ast.KindIdentifier { return c.isSymbolAssigned(c.getSymbolOfDeclaration(node.Parent)) } - return core.Some(node.AsBindingPattern().Elements.Nodes, func(e *ast.Node) bool { + return core.Some(node.Elements(), func(e *ast.Node) bool { return e.Name() != nil && c.isSomeSymbolAssignedWorker(e.Name()) }) } @@ -30413,7 +30600,7 @@ func (c *Checker) hasContextualTypeWithNoGenericTypes(node *ast.Node, checkMode // If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types, // as we want the type of a rest element to be generic when possible. if (ast.IsIdentifier(node) || ast.IsPropertyAccessExpression(node) || ast.IsElementAccessExpression(node)) && - !((ast.IsJsxOpeningElement(node.Parent) || ast.IsJsxSelfClosingElement(node.Parent)) && getTagNameOfNode(node.Parent) == node) { + !((ast.IsJsxOpeningElement(node.Parent) || ast.IsJsxSelfClosingElement(node.Parent)) && node.Parent.TagName() == node) { contextualType := c.getContextualType(node, core.IfElse(checkMode&CheckModeRestBindingElement != 0, ContextFlagsSkipBindingPatterns, ContextFlagsNone)) if contextualType != nil { return !c.isGenericType(contextualType) @@ -30523,7 +30710,7 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy } else if ast.IsJSDocParameterTag(parent) && parent.Name() == node { if fn := ast.GetNodeAtPosition(ast.GetSourceFileOfNode(node), node.Pos(), false); fn != nil && ast.IsFunctionLike(fn) { for _, param := range fn.Parameters() { - if param.Name().Text() == node.Text() { + if ast.IsIdentifier(param.Name()) && param.Name().Text() == node.Text() { return c.getSymbolOfNode(param) } } @@ -30589,7 +30776,7 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy } return nil case ast.KindDefaultKeyword, ast.KindFunctionKeyword, ast.KindEqualsGreaterThanToken, ast.KindClassKeyword: - return c.getSymbolOfNode(node) + return c.getSymbolOfNode(node.Parent) case ast.KindImportType: if ast.IsLiteralImportTypeNode(node) { return c.getSymbolAtLocation(node.AsImportTypeNode().Argument.AsLiteralTypeNode().Literal, ignoreErrors) @@ -30729,6 +30916,9 @@ func (c *Checker) getSymbolOfNameOrPropertyAccessExpression(name *ast.Node) *ast } meaning := core.IfElse(isJSDoc, ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace, ast.SymbolFlagsValue) result := c.resolveEntityName(name, meaning, true /*ignoreErrors*/, true /*dontResolveAlias*/, nil /*location*/) + if result != nil && result.Flags&ast.SymbolFlagsModuleExports != 0 { + result = result.ValueDeclaration.Symbol() // Symbol of the module source file + } if result == nil && isJSDoc { if container := ast.FindAncestor(name, ast.IsClassOrInterfaceLike); container != nil { symbol := c.getSymbolOfDeclaration(container) @@ -30784,7 +30974,7 @@ func (c *Checker) getSymbolOfNameOrPropertyAccessExpression(name *ast.Node) *ast } func (c *Checker) isThisPropertyAndThisTyped(node *ast.Node) bool { - if node.AsPropertyAccessExpression().Expression.Kind == ast.KindThisKeyword { + if node.Expression().Kind == ast.KindThisKeyword { container := c.getThisContainer(node, false /*includeArrowFunctions*/, false /*includeClassComputedPropertyName*/) if ast.IsFunctionLike(container) { containingLiteral := getContainingObjectLiteral(container) @@ -31016,7 +31206,7 @@ func (c *Checker) containsArgumentsReference(node *ast.Node) bool { case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression: return visit(node.Expression()) case ast.KindPropertyAssignment: - return visit(node.AsPropertyAssignment().Initializer) + return visit(node.Initializer()) } if nodeStartsNewLexicalEnvironment(node) || ast.IsPartOfTypeNode(node) { return false @@ -31033,7 +31223,7 @@ func (c *Checker) GetTypeAtLocation(node *ast.Node) *Type { return c.getTypeOfNode(node) } -func (c *Checker) GetEmitResolver() *emitResolver { +func (c *Checker) GetEmitResolver() *EmitResolver { c.emitResolverOnce.Do(func() { c.emitResolver = newEmitResolver(c) }) diff --git a/internal/checker/checker_test.go b/internal/checker/checker_test.go index c5029ecbc9..2dcda5d528 100644 --- a/internal/checker/checker_test.go +++ b/internal/checker/checker_test.go @@ -51,7 +51,7 @@ foo.bar;` file := p.GetSourceFile("/foo.ts") interfaceId := file.Statements.Nodes[0].Name() varId := file.Statements.Nodes[1].AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes[0].Name() - propAccess := file.Statements.Nodes[2].AsExpressionStatement().Expression + propAccess := file.Statements.Nodes[2].Expression() nodes := []*ast.Node{interfaceId, varId, propAccess} for _, node := range nodes { symbol := c.GetSymbolAtLocation(node) diff --git a/internal/checker/emitresolver.go b/internal/checker/emitresolver.go index 287ceeeb12..17c8e5fec6 100644 --- a/internal/checker/emitresolver.go +++ b/internal/checker/emitresolver.go @@ -15,7 +15,7 @@ import ( "github.com/microsoft/typescript-go/internal/printer" ) -var _ printer.EmitResolver = (*emitResolver)(nil) +var _ printer.EmitResolver = (*EmitResolver)(nil) // Links for jsx type JSXLinks struct { @@ -32,9 +32,9 @@ type DeclarationFileLinks struct { aliasesMarked bool // if file has had alias visibility marked } -type emitResolver struct { +type EmitResolver struct { checker *Checker - checkerMu sync.Mutex + checkerMu *sync.Mutex isValueAliasDeclaration func(node *ast.Node) bool aliasMarkingVisitor func(node *ast.Node) bool referenceResolver binder.ReferenceResolver @@ -43,32 +43,33 @@ type emitResolver struct { declarationFileLinks core.LinkStore[*ast.Node, DeclarationFileLinks] } -func newEmitResolver(checker *Checker) *emitResolver { - e := &emitResolver{checker: checker} +func newEmitResolver(checker *Checker) *EmitResolver { + e := &EmitResolver{checker: checker} e.isValueAliasDeclaration = e.isValueAliasDeclarationWorker e.aliasMarkingVisitor = e.aliasMarkingVisitorWorker + e.checkerMu = &checker.mu return e } -func (r *emitResolver) GetJsxFactoryEntity(location *ast.Node) *ast.Node { +func (r *EmitResolver) GetJsxFactoryEntity(location *ast.Node) *ast.Node { r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.checker.getJsxFactoryEntity(location) } -func (r *emitResolver) GetJsxFragmentFactoryEntity(location *ast.Node) *ast.Node { +func (r *EmitResolver) GetJsxFragmentFactoryEntity(location *ast.Node) *ast.Node { r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.checker.getJsxFragmentFactoryEntity(location) } -func (r *emitResolver) IsOptionalParameter(node *ast.Node) bool { +func (r *EmitResolver) IsOptionalParameter(node *ast.Node) bool { r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.isOptionalParameter(node) } -func (r *emitResolver) IsLateBound(node *ast.Node) bool { +func (r *EmitResolver) IsLateBound(node *ast.Node) bool { // TODO: Require an emitContext to construct an EmitResolver, remove all emitContext arguments // node = r.emitContext.ParseNode(node) if node == nil { @@ -86,7 +87,7 @@ func (r *emitResolver) IsLateBound(node *ast.Node) bool { return symbol.CheckFlags&ast.CheckFlagsLate != 0 } -func (r *emitResolver) GetEnumMemberValue(node *ast.Node) evaluator.Result { +func (r *EmitResolver) GetEnumMemberValue(node *ast.Node) evaluator.Result { // node = r.emitContext.ParseNode(node) if !ast.IsParseTreeNode(node) { return evaluator.NewResult(nil, false, false, false) @@ -101,14 +102,14 @@ func (r *emitResolver) GetEnumMemberValue(node *ast.Node) evaluator.Result { return r.checker.enumMemberLinks.Get(node).value } -func (r *emitResolver) IsDeclarationVisible(node *ast.Node) bool { +func (r *EmitResolver) IsDeclarationVisible(node *ast.Node) bool { // Only lock on external API func to prevent deadlocks r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.isDeclarationVisible(node) } -func (r *emitResolver) isDeclarationVisible(node *ast.Node) bool { +func (r *EmitResolver) isDeclarationVisible(node *ast.Node) bool { // node = r.emitContext.ParseNode(node) if !ast.IsParseTreeNode(node) { return false @@ -128,7 +129,7 @@ func (r *emitResolver) isDeclarationVisible(node *ast.Node) bool { return links.isVisible == core.TSTrue } -func (r *emitResolver) determineIfDeclarationIsVisible(node *ast.Node) bool { +func (r *EmitResolver) determineIfDeclarationIsVisible(node *ast.Node) bool { switch node.Kind { case ast.KindJSDocCallbackTag, // ast.KindJSDocEnumTag, // !!! TODO: JSDoc @enum support? @@ -149,14 +150,15 @@ func (r *emitResolver) determineIfDeclarationIsVisible(node *ast.Node) bool { ast.KindImportEqualsDeclaration: if ast.IsVariableDeclaration(node) { if ast.IsBindingPattern(node.Name()) && - len(node.Name().AsBindingPattern().Elements.Nodes) == 0 { + len(node.Name().Elements()) == 0 { // If the binding pattern is empty, this variable declaration is not visible return false } // falls through } - // external module augmentation is always visible - if ast.IsExternalModuleAugmentation(node) { + // External module augmentation is always visible + // A @typedef at top-level in an external module is always visible + if ast.IsExternalModuleAugmentation(node) || ast.IsImplicitlyExportedJSTypeAlias(node) { return true } parent := ast.GetDeclarationContainer(node) @@ -223,7 +225,7 @@ func (r *emitResolver) determineIfDeclarationIsVisible(node *ast.Node) bool { } } -func (r *emitResolver) PrecalculateDeclarationEmitVisibility(file *ast.SourceFile) { +func (r *EmitResolver) PrecalculateDeclarationEmitVisibility(file *ast.SourceFile) { r.checkerMu.Lock() defer r.checkerMu.Unlock() if r.declarationFileLinks.Get(file.AsNode()).aliasesMarked { @@ -236,10 +238,10 @@ func (r *emitResolver) PrecalculateDeclarationEmitVisibility(file *ast.SourceFil file.AsNode().ForEachChild(r.aliasMarkingVisitor) } -func (r *emitResolver) aliasMarkingVisitorWorker(node *ast.Node) bool { +func (r *EmitResolver) aliasMarkingVisitorWorker(node *ast.Node) bool { switch node.Kind { case ast.KindExportAssignment, ast.KindJSExportAssignment: - if node.AsExportAssignment().Expression.Kind == ast.KindIdentifier { + if node.Expression().Kind == ast.KindIdentifier { r.markLinkedAliases(node.Expression()) } case ast.KindExportSpecifier: @@ -250,10 +252,10 @@ func (r *emitResolver) aliasMarkingVisitorWorker(node *ast.Node) bool { // Sets the isVisible link on statements the Identifier or ExportName node points at // Follows chains of import d = a.b.c -func (r *emitResolver) markLinkedAliases(node *ast.Node) { +func (r *EmitResolver) markLinkedAliases(node *ast.Node) { var exportSymbol *ast.Symbol if node.Kind != ast.KindStringLiteral && node.Parent != nil && node.Parent.Kind == ast.KindExportAssignment { - exportSymbol = r.checker.resolveName(node, node.AsIdentifier().Text, ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace|ast.SymbolFlagsAlias /*nameNotFoundMessage*/, nil /*isUse*/, false, false) + exportSymbol = r.checker.resolveName(node, node.Text(), ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace|ast.SymbolFlagsAlias /*nameNotFoundMessage*/, nil /*isUse*/, false, false) } else if node.Parent.Kind == ast.KindExportSpecifier { exportSymbol = r.checker.getTargetOfExportSpecifier(node.Parent, ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace|ast.SymbolFlagsAlias, false) } @@ -274,7 +276,7 @@ func (r *emitResolver) markLinkedAliases(node *ast.Node) { // Add the referenced top container visible internalModuleReference := declaration.AsImportEqualsDeclaration().ModuleReference firstIdentifier := ast.GetFirstIdentifier(internalModuleReference) - importSymbol := r.checker.resolveName(declaration, firstIdentifier.AsIdentifier().Text, ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace|ast.SymbolFlagsAlias /*nameNotFoundMessage*/, nil /*isUse*/, false, false) + importSymbol := r.checker.resolveName(declaration, firstIdentifier.Text(), ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace|ast.SymbolFlagsAlias /*nameNotFoundMessage*/, nil /*isUse*/, false, false) nextSymbol = importSymbol } } @@ -295,8 +297,8 @@ func getMeaningOfEntityNameReference(entityName *ast.Node) ast.SymbolFlags { if entityName.Kind == ast.KindQualifiedName || entityName.Kind == ast.KindPropertyAccessExpression || entityName.Parent.Kind == ast.KindImportEqualsDeclaration || (entityName.Parent.Kind == ast.KindQualifiedName && entityName.Parent.AsQualifiedName().Left == entityName) || - (entityName.Parent.Kind == ast.KindPropertyAccessExpression && (entityName.Parent.AsPropertyAccessExpression()).Expression == entityName) || - (entityName.Parent.Kind == ast.KindElementAccessExpression && (entityName.Parent.AsElementAccessExpression()).Expression == entityName) { + (entityName.Parent.Kind == ast.KindPropertyAccessExpression && entityName.Parent.Expression() == entityName) || + (entityName.Parent.Kind == ast.KindElementAccessExpression && entityName.Parent.Expression() == entityName) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration return ast.SymbolFlagsNamespace @@ -305,13 +307,13 @@ func getMeaningOfEntityNameReference(entityName *ast.Node) ast.SymbolFlags { return ast.SymbolFlagsType } -func (r *emitResolver) IsEntityNameVisible(entityName *ast.Node, enclosingDeclaration *ast.Node) printer.SymbolAccessibilityResult { +func (r *EmitResolver) IsEntityNameVisible(entityName *ast.Node, enclosingDeclaration *ast.Node) printer.SymbolAccessibilityResult { r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.isEntityNameVisible(entityName, enclosingDeclaration, true) } -func (r *emitResolver) isEntityNameVisible(entityName *ast.Node, enclosingDeclaration *ast.Node, shouldComputeAliasToMakeVisible bool) printer.SymbolAccessibilityResult { +func (r *EmitResolver) isEntityNameVisible(entityName *ast.Node, enclosingDeclaration *ast.Node, shouldComputeAliasToMakeVisible bool) printer.SymbolAccessibilityResult { // node = r.emitContext.ParseNode(entityName) if !ast.IsParseTreeNode(entityName) { return printer.SymbolAccessibilityResult{Accessibility: printer.SymbolAccessibilityNotAccessible} @@ -355,7 +357,7 @@ func (r *emitResolver) isEntityNameVisible(entityName *ast.Node, enclosingDeclar func noopAddVisibleAlias(declaration *ast.Node, aliasingStatement *ast.Node) {} -func (r *emitResolver) hasVisibleDeclarations(symbol *ast.Symbol, shouldComputeAliasToMakeVisible bool) *printer.SymbolAccessibilityResult { +func (r *EmitResolver) hasVisibleDeclarations(symbol *ast.Symbol, shouldComputeAliasToMakeVisible bool) *printer.SymbolAccessibilityResult { var aliasesToMakeVisibleSet map[ast.NodeId]*ast.Node var addVisibleAlias func(declaration *ast.Node, aliasingStatement *ast.Node) @@ -439,7 +441,7 @@ func (r *emitResolver) hasVisibleDeclarations(symbol *ast.Symbol, shouldComputeA } } -func (r *emitResolver) IsImplementationOfOverload(node *ast.SignatureDeclaration) bool { +func (r *EmitResolver) IsImplementationOfOverload(node *ast.SignatureDeclaration) bool { // node = r.emitContext.ParseNode(node) if !ast.IsParseTreeNode(node) { return false @@ -458,18 +460,25 @@ func (r *emitResolver) IsImplementationOfOverload(node *ast.SignatureDeclaration // function foo(a: any) { // This is implementation of the overloads // return a; // } - return len(signaturesOfSymbol) > 1 || - // If there is single signature for the symbol, it is overload if that signature isn't coming from the node - // e.g.: function foo(a: string): string; - // function foo(a: any) { // This is implementation of the overloads - // return a; - // } - (len(signaturesOfSymbol) == 1 && signaturesOfSymbol[0].declaration != node) + if len(signaturesOfSymbol) > 1 { + return true + } + // If there is single signature for the symbol, it is overload if that signature isn't coming from the node + // e.g.: function foo(a: string): string; + // function foo(a: any) { // This is implementation of the overloads + // return a; + // } + if len(signaturesOfSymbol) == 1 { + declaration := signaturesOfSymbol[0].declaration + if declaration != node && declaration.Flags&ast.NodeFlagsJSDoc == 0 { + return true + } + } } return false } -func (r *emitResolver) IsImportRequiredByAugmentation(decl *ast.ImportDeclaration) bool { +func (r *EmitResolver) IsImportRequiredByAugmentation(decl *ast.ImportDeclaration) bool { // node = r.emitContext.ParseNode(node) if !ast.IsParseTreeNode(decl.AsNode()) { return false @@ -505,14 +514,14 @@ func (r *emitResolver) IsImportRequiredByAugmentation(decl *ast.ImportDeclaratio return false } -func (r *emitResolver) IsDefinitelyReferenceToGlobalSymbolObject(node *ast.Node) bool { +func (r *EmitResolver) IsDefinitelyReferenceToGlobalSymbolObject(node *ast.Node) bool { if !ast.IsPropertyAccessExpression(node) || !ast.IsIdentifier(node.Name()) || !ast.IsPropertyAccessExpression(node.Expression()) && !ast.IsIdentifier(node.Expression()) { return false } if node.Expression().Kind == ast.KindIdentifier { - if node.Expression().AsIdentifier().Text != "Symbol" { + if node.Expression().Text() != "Symbol" { return false } r.checkerMu.Lock() @@ -520,7 +529,7 @@ func (r *emitResolver) IsDefinitelyReferenceToGlobalSymbolObject(node *ast.Node) // Exactly `Symbol.something` and `Symbol` either does not resolve or definitely resolves to the global Symbol return r.checker.getResolvedSymbol(node.Expression()) == r.checker.getGlobalSymbol("Symbol", ast.SymbolFlagsValue|ast.SymbolFlagsExportValue, nil /*diagnostic*/) } - if node.Expression().Expression().Kind != ast.KindIdentifier || node.Expression().Expression().AsIdentifier().Text != "globalThis" || node.Expression().Name().Text() != "Symbol" { + if node.Expression().Expression().Kind != ast.KindIdentifier || node.Expression().Expression().Text() != "globalThis" || node.Expression().Name().Text() != "Symbol" { return false } r.checkerMu.Lock() @@ -530,7 +539,7 @@ func (r *emitResolver) IsDefinitelyReferenceToGlobalSymbolObject(node *ast.Node) return resolved == r.checker.denoGlobalThisSymbol || resolved == r.checker.nodeGlobalThisSymbol } -func (r *emitResolver) RequiresAddingImplicitUndefined(declaration *ast.Node, symbol *ast.Symbol, enclosingDeclaration *ast.Node) bool { +func (r *EmitResolver) RequiresAddingImplicitUndefined(declaration *ast.Node, symbol *ast.Symbol, enclosingDeclaration *ast.Node) bool { if !ast.IsParseTreeNode(declaration) { return false } @@ -539,7 +548,7 @@ func (r *emitResolver) RequiresAddingImplicitUndefined(declaration *ast.Node, sy return r.requiresAddingImplicitUndefined(declaration, symbol, enclosingDeclaration) } -func (r *emitResolver) requiresAddingImplicitUndefined(declaration *ast.Node, symbol *ast.Symbol, enclosingDeclaration *ast.Node) bool { +func (r *EmitResolver) requiresAddingImplicitUndefined(declaration *ast.Node, symbol *ast.Symbol, enclosingDeclaration *ast.Node) bool { // node = r.emitContext.ParseNode(node) if !ast.IsParseTreeNode(declaration) { return false @@ -559,11 +568,11 @@ func (r *emitResolver) requiresAddingImplicitUndefined(declaration *ast.Node, sy } } -func (r *emitResolver) requiresAddingImplicitUndefinedWorker(parameter *ast.Node, enclosingDeclaration *ast.Node) bool { +func (r *EmitResolver) requiresAddingImplicitUndefinedWorker(parameter *ast.Node, enclosingDeclaration *ast.Node) bool { return (r.isRequiredInitializedParameter(parameter, enclosingDeclaration) || r.isOptionalUninitializedParameterProperty(parameter)) && !r.declaredParameterTypeContainsUndefined(parameter) } -func (r *emitResolver) declaredParameterTypeContainsUndefined(parameter *ast.Node) bool { +func (r *EmitResolver) declaredParameterTypeContainsUndefined(parameter *ast.Node) bool { // typeNode := getNonlocalEffectiveTypeAnnotationNode(parameter); // !!! JSDoc Support typeNode := parameter.Type() if typeNode == nil { @@ -576,14 +585,14 @@ func (r *emitResolver) declaredParameterTypeContainsUndefined(parameter *ast.Nod return r.checker.isErrorType(t) || r.checker.containsUndefinedType(t) } -func (r *emitResolver) isOptionalUninitializedParameterProperty(parameter *ast.Node) bool { +func (r *EmitResolver) isOptionalUninitializedParameterProperty(parameter *ast.Node) bool { return r.checker.strictNullChecks && r.isOptionalParameter(parameter) && ( /*isJSDocParameterTag(parameter) ||*/ parameter.Initializer() == nil) && // !!! TODO: JSDoc support ast.HasSyntacticModifier(parameter, ast.ModifierFlagsParameterPropertyModifier) } -func (r *emitResolver) isRequiredInitializedParameter(parameter *ast.Node, enclosingDeclaration *ast.Node) bool { +func (r *EmitResolver) isRequiredInitializedParameter(parameter *ast.Node, enclosingDeclaration *ast.Node) bool { if !r.checker.strictNullChecks || r.isOptionalParameter(parameter) || /*isJSDocParameterTag(parameter) ||*/ parameter.Initializer() == nil { // !!! TODO: JSDoc Support return false } @@ -593,12 +602,12 @@ func (r *emitResolver) isRequiredInitializedParameter(parameter *ast.Node, enclo return true } -func (r *emitResolver) isOptionalParameter(node *ast.Node) bool { +func (r *EmitResolver) isOptionalParameter(node *ast.Node) bool { // !!! TODO: JSDoc support // if (hasEffectiveQuestionToken(node)) { // return true; // } - if ast.IsParameter(node) && node.AsParameterDeclaration().QuestionToken != nil { + if ast.IsParameter(node) && node.QuestionToken() != nil { return true } if !ast.IsParameter(node) { @@ -624,7 +633,7 @@ func (r *emitResolver) isOptionalParameter(node *ast.Node) bool { return false } -func (r *emitResolver) IsLiteralConstDeclaration(node *ast.Node) bool { +func (r *EmitResolver) IsLiteralConstDeclaration(node *ast.Node) bool { // node = r.emitContext.ParseNode(node) if !ast.IsParseTreeNode(node) { return false @@ -637,17 +646,17 @@ func (r *emitResolver) IsLiteralConstDeclaration(node *ast.Node) bool { return false } -func (r *emitResolver) IsExpandoFunctionDeclaration(node *ast.Node) bool { +func (r *EmitResolver) IsExpandoFunctionDeclaration(node *ast.Node) bool { // node = r.emitContext.ParseNode(node) // !!! TODO: expando function support return false } -func (r *emitResolver) isSymbolAccessible(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags, shouldComputeAliasToMarkVisible bool) printer.SymbolAccessibilityResult { +func (r *EmitResolver) isSymbolAccessible(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags, shouldComputeAliasToMarkVisible bool) printer.SymbolAccessibilityResult { return r.checker.IsSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasToMarkVisible) } -func (r *emitResolver) IsSymbolAccessible(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags, shouldComputeAliasToMarkVisible bool) printer.SymbolAccessibilityResult { +func (r *EmitResolver) IsSymbolAccessible(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags, shouldComputeAliasToMarkVisible bool) printer.SymbolAccessibilityResult { // TODO: Split into locking and non-locking API methods - only current usage is the symbol tracker, which is non-locking, // as all tracker calls happen within a CreateX call below, which already holds a lock // r.checkerMu.Lock() @@ -659,7 +668,7 @@ func isConstEnumOrConstEnumOnlyModule(s *ast.Symbol) bool { return isConstEnumSymbol(s) || s.Flags&ast.SymbolFlagsConstEnumOnlyModule != 0 } -func (r *emitResolver) IsReferencedAliasDeclaration(node *ast.Node) bool { +func (r *EmitResolver) IsReferencedAliasDeclaration(node *ast.Node) bool { c := r.checker if !c.canCollectSymbolAliasAccessibilityData || !ast.IsParseTreeNode(node) { return true @@ -685,7 +694,7 @@ func (r *emitResolver) IsReferencedAliasDeclaration(node *ast.Node) bool { return false } -func (r *emitResolver) IsValueAliasDeclaration(node *ast.Node) bool { +func (r *EmitResolver) IsValueAliasDeclaration(node *ast.Node) bool { c := r.checker if !c.canCollectSymbolAliasAccessibilityData || !ast.IsParseTreeNode(node) { return true @@ -697,7 +706,7 @@ func (r *emitResolver) IsValueAliasDeclaration(node *ast.Node) bool { return r.isValueAliasDeclarationWorker(node) } -func (r *emitResolver) isValueAliasDeclarationWorker(node *ast.Node) bool { +func (r *EmitResolver) isValueAliasDeclarationWorker(node *ast.Node) bool { c := r.checker switch node.Kind { @@ -712,9 +721,9 @@ func (r *emitResolver) isValueAliasDeclarationWorker(node *ast.Node) bool { case ast.KindExportDeclaration: exportClause := node.AsExportDeclaration().ExportClause return exportClause != nil && (ast.IsNamespaceExport(exportClause) || - core.Some(exportClause.AsNamedExports().Elements.Nodes, r.isValueAliasDeclaration)) + core.Some(exportClause.Elements(), r.isValueAliasDeclaration)) case ast.KindExportAssignment, ast.KindJSExportAssignment: - if node.AsExportAssignment().Expression != nil && node.AsExportAssignment().Expression.Kind == ast.KindIdentifier { + if node.Expression() != nil && node.Expression().Kind == ast.KindIdentifier { return r.isAliasResolvedToValue(c.getSymbolOfDeclaration(node), true /*excludeTypeOnlyValues*/) } return true @@ -722,7 +731,7 @@ func (r *emitResolver) isValueAliasDeclarationWorker(node *ast.Node) bool { return false } -func (r *emitResolver) isAliasResolvedToValue(symbol *ast.Symbol, excludeTypeOnlyValues bool) bool { +func (r *EmitResolver) isAliasResolvedToValue(symbol *ast.Symbol, excludeTypeOnlyValues bool) bool { c := r.checker if symbol == nil { return false @@ -747,7 +756,7 @@ func (r *emitResolver) isAliasResolvedToValue(symbol *ast.Symbol, excludeTypeOnl !isConstEnumOrConstEnumOnlyModule(target)) } -func (r *emitResolver) IsTopLevelValueImportEqualsWithEntityName(node *ast.Node) bool { +func (r *EmitResolver) IsTopLevelValueImportEqualsWithEntityName(node *ast.Node) bool { c := r.checker if !c.canCollectSymbolAliasAccessibilityData { return true @@ -766,7 +775,7 @@ func (r *emitResolver) IsTopLevelValueImportEqualsWithEntityName(node *ast.Node) return r.isAliasResolvedToValue(c.getSymbolOfDeclaration(node), false /*excludeTypeOnlyValues*/) } -func (r *emitResolver) MarkLinkedReferencesRecursively(file *ast.SourceFile) { +func (r *EmitResolver) MarkLinkedReferencesRecursively(file *ast.SourceFile) { r.checkerMu.Lock() defer r.checkerMu.Unlock() @@ -790,7 +799,7 @@ func (r *emitResolver) MarkLinkedReferencesRecursively(file *ast.SourceFile) { } } -func (r *emitResolver) GetExternalModuleFileFromDeclaration(declaration *ast.Node) *ast.SourceFile { +func (r *EmitResolver) GetExternalModuleFileFromDeclaration(declaration *ast.Node) *ast.SourceFile { if !ast.IsParseTreeNode(declaration) { return nil } @@ -816,7 +825,7 @@ func (r *emitResolver) GetExternalModuleFileFromDeclaration(declaration *ast.Nod return decl.AsSourceFile() } -func (r *emitResolver) getReferenceResolver() binder.ReferenceResolver { +func (r *EmitResolver) getReferenceResolver() binder.ReferenceResolver { if r.referenceResolver == nil { r.referenceResolver = binder.NewReferenceResolver(r.checker.compilerOptions, binder.ReferenceResolverHooks{ ResolveName: r.checker.resolveName, @@ -832,7 +841,7 @@ func (r *emitResolver) getReferenceResolver() binder.ReferenceResolver { return r.referenceResolver } -func (r *emitResolver) GetReferencedExportContainer(node *ast.IdentifierNode, prefixLocals bool) *ast.Node /*SourceFile|ModuleDeclaration|EnumDeclaration*/ { +func (r *EmitResolver) GetReferencedExportContainer(node *ast.IdentifierNode, prefixLocals bool) *ast.Node /*SourceFile|ModuleDeclaration|EnumDeclaration*/ { if !ast.IsParseTreeNode(node) { return nil } @@ -843,13 +852,13 @@ func (r *emitResolver) GetReferencedExportContainer(node *ast.IdentifierNode, pr return r.getReferenceResolver().GetReferencedExportContainer(node, prefixLocals) } -func (r *emitResolver) SetReferencedImportDeclaration(node *ast.IdentifierNode, ref *ast.Declaration) { +func (r *EmitResolver) SetReferencedImportDeclaration(node *ast.IdentifierNode, ref *ast.Declaration) { r.checkerMu.Lock() defer r.checkerMu.Unlock() r.jsxLinks.Get(node).importRef = ref } -func (r *emitResolver) GetReferencedImportDeclaration(node *ast.IdentifierNode) *ast.Declaration { +func (r *EmitResolver) GetReferencedImportDeclaration(node *ast.IdentifierNode) *ast.Declaration { r.checkerMu.Lock() defer r.checkerMu.Unlock() if !ast.IsParseTreeNode(node) { @@ -859,7 +868,7 @@ func (r *emitResolver) GetReferencedImportDeclaration(node *ast.IdentifierNode) return r.getReferenceResolver().GetReferencedImportDeclaration(node) } -func (r *emitResolver) GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration { +func (r *EmitResolver) GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration { if !ast.IsParseTreeNode(node) { return nil } @@ -870,7 +879,7 @@ func (r *emitResolver) GetReferencedValueDeclaration(node *ast.IdentifierNode) * return r.getReferenceResolver().GetReferencedValueDeclaration(node) } -func (r *emitResolver) GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration { +func (r *EmitResolver) GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration { if !ast.IsParseTreeNode(node) { return nil } @@ -881,7 +890,7 @@ func (r *emitResolver) GetReferencedValueDeclarations(node *ast.IdentifierNode) return r.getReferenceResolver().GetReferencedValueDeclarations(node) } -func (r *emitResolver) GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string { +func (r *EmitResolver) GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string { if !ast.IsParseTreeNode(expression.AsNode()) { return "" } @@ -896,7 +905,7 @@ func (r *emitResolver) GetElementAccessExpressionName(expression *ast.ElementAcc // and requires giving it access to a lot of context it's otherwise not required to have, which also further complicates the API // and likely reduces performance. There's probably some refactoring that could be done here to simplify this. -func (r *emitResolver) CreateReturnTypeOfSignatureDeclaration(emitContext *printer.EmitContext, signatureDeclaration *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) *ast.Node { +func (r *EmitResolver) CreateReturnTypeOfSignatureDeclaration(emitContext *printer.EmitContext, signatureDeclaration *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) *ast.Node { original := emitContext.ParseNode(signatureDeclaration) if original == nil { return emitContext.Factory.NewKeywordTypeNode(ast.KindAnyKeyword) @@ -908,7 +917,7 @@ func (r *emitResolver) CreateReturnTypeOfSignatureDeclaration(emitContext *print return requestNodeBuilder.SerializeReturnTypeForSignature(original, enclosingDeclaration, flags, internalFlags, tracker) } -func (r *emitResolver) CreateTypeParametersOfSignatureDeclaration(emitContext *printer.EmitContext, signatureDeclaration *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) []*ast.Node { +func (r *EmitResolver) CreateTypeParametersOfSignatureDeclaration(emitContext *printer.EmitContext, signatureDeclaration *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) []*ast.Node { original := emitContext.ParseNode(signatureDeclaration) if original == nil { return nil @@ -920,7 +929,7 @@ func (r *emitResolver) CreateTypeParametersOfSignatureDeclaration(emitContext *p return requestNodeBuilder.SerializeTypeParametersForSignature(original, enclosingDeclaration, flags, internalFlags, tracker) } -func (r *emitResolver) CreateTypeOfDeclaration(emitContext *printer.EmitContext, declaration *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) *ast.Node { +func (r *EmitResolver) CreateTypeOfDeclaration(emitContext *printer.EmitContext, declaration *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) *ast.Node { original := emitContext.ParseNode(declaration) if original == nil { return emitContext.Factory.NewKeywordTypeNode(ast.KindAnyKeyword) @@ -934,7 +943,7 @@ func (r *emitResolver) CreateTypeOfDeclaration(emitContext *printer.EmitContext, return requestNodeBuilder.SerializeTypeForDeclaration(declaration, symbol, enclosingDeclaration, flags|nodebuilder.FlagsMultilineObjectLiterals, internalFlags, tracker) } -func (r *emitResolver) CreateLiteralConstValue(emitContext *printer.EmitContext, node *ast.Node, tracker nodebuilder.SymbolTracker) *ast.Node { +func (r *EmitResolver) CreateLiteralConstValue(emitContext *printer.EmitContext, node *ast.Node, tracker nodebuilder.SymbolTracker) *ast.Node { node = emitContext.ParseNode(node) r.checkerMu.Lock() t := r.checker.getTypeOfSymbol(r.checker.getSymbolOfDeclaration(node)) @@ -986,7 +995,7 @@ func (r *emitResolver) CreateLiteralConstValue(emitContext *printer.EmitContext, panic("unhandled literal const value kind") } -func (r *emitResolver) CreateTypeOfExpression(emitContext *printer.EmitContext, expression *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) *ast.Node { +func (r *EmitResolver) CreateTypeOfExpression(emitContext *printer.EmitContext, expression *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) *ast.Node { expression = emitContext.ParseNode(expression) if expression == nil { return emitContext.Factory.NewKeywordTypeNode(ast.KindAnyKeyword) @@ -998,7 +1007,7 @@ func (r *emitResolver) CreateTypeOfExpression(emitContext *printer.EmitContext, return requestNodeBuilder.SerializeTypeForExpression(expression, enclosingDeclaration, flags|nodebuilder.FlagsMultilineObjectLiterals, internalFlags, tracker) } -func (r *emitResolver) CreateLateBoundIndexSignatures(emitContext *printer.EmitContext, container *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) []*ast.Node { +func (r *EmitResolver) CreateLateBoundIndexSignatures(emitContext *printer.EmitContext, container *ast.Node, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) []*ast.Node { container = emitContext.ParseNode(container) r.checkerMu.Lock() defer r.checkerMu.Unlock() @@ -1038,8 +1047,8 @@ func (r *emitResolver) CreateLateBoundIndexSignatures(emitContext *printer.EmitC allComponentComputedNamesSerializable := enclosingDeclaration != nil && core.Every(info.components, func(c *ast.Node) bool { return c.Name() != nil && ast.IsComputedPropertyName(c.Name()) && - ast.IsEntityNameExpression(c.Name().AsComputedPropertyName().Expression) && - r.isEntityNameVisible(c.Name().AsComputedPropertyName().Expression, enclosingDeclaration, false).Accessibility == printer.SymbolAccessibilityAccessible + ast.IsEntityNameExpression(c.Name().Expression()) && + r.isEntityNameVisible(c.Name().Expression(), enclosingDeclaration, false).Accessibility == printer.SymbolAccessibilityAccessible }) if allComponentComputedNamesSerializable { for _, c := range info.components { @@ -1074,11 +1083,8 @@ func (r *emitResolver) CreateLateBoundIndexSignatures(emitContext *printer.EmitC node := requestNodeBuilder.IndexInfoToIndexSignatureDeclaration(info, enclosingDeclaration, flags, internalFlags, tracker) if node != nil && isStatic { modNodes := []*ast.Node{emitContext.Factory.NewModifier(ast.KindStaticKeyword)} - mods := node.Modifiers() - if mods != nil { - modNodes = append(modNodes, mods.Nodes...) - } - mods = emitContext.Factory.NewModifierList(modNodes) + modNodes = append(modNodes, node.ModifierNodes()...) + mods := emitContext.Factory.NewModifierList(modNodes) node = emitContext.Factory.UpdateIndexSignatureDeclaration( node.AsIndexSignatureDeclaration(), mods, @@ -1094,21 +1100,21 @@ func (r *emitResolver) CreateLateBoundIndexSignatures(emitContext *printer.EmitC return result } -func (r *emitResolver) GetEffectiveDeclarationFlags(node *ast.Node, flags ast.ModifierFlags) ast.ModifierFlags { +func (r *EmitResolver) GetEffectiveDeclarationFlags(node *ast.Node, flags ast.ModifierFlags) ast.ModifierFlags { // node = emitContext.ParseNode(node) r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.checker.GetEffectiveDeclarationFlags(node, flags) } -func (r *emitResolver) GetResolutionModeOverride(node *ast.Node) core.ResolutionMode { +func (r *EmitResolver) GetResolutionModeOverride(node *ast.Node) core.ResolutionMode { // node = emitContext.ParseNode(node) r.checkerMu.Lock() defer r.checkerMu.Unlock() return r.checker.GetResolutionModeOverride(node.AsImportAttributes(), false) } -func (r *emitResolver) GetConstantValue(node *ast.Node) any { +func (r *EmitResolver) GetConstantValue(node *ast.Node) any { // node = emitContext.ParseNode(node) r.checkerMu.Lock() defer r.checkerMu.Unlock() diff --git a/internal/checker/exports.go b/internal/checker/exports.go index dc61a4a547..332a72569e 100644 --- a/internal/checker/exports.go +++ b/internal/checker/exports.go @@ -170,3 +170,19 @@ func (c *Checker) GetIndexSignaturesAtLocation(node *ast.Node) []*ast.Node { func (c *Checker) GetResolvedSymbol(node *ast.Node) *ast.Symbol { return c.getResolvedSymbol(node) } + +func (c *Checker) GetJsxNamespace(location *ast.Node) string { + return c.getJsxNamespace(location) +} + +func (c *Checker) ResolveName(name string, location *ast.Node, meaning ast.SymbolFlags, excludeGlobals bool) *ast.Symbol { + return c.resolveName(location, name, meaning, nil, true, excludeGlobals) +} + +func (c *Checker) GetSymbolFlags(symbol *ast.Symbol) ast.SymbolFlags { + return c.getSymbolFlags(symbol) +} + +func (c *Checker) GetBaseTypes(t *Type) []*Type { + return c.getBaseTypes(t) +} diff --git a/internal/checker/flow.go b/internal/checker/flow.go index eafd7fde95..8df30cad40 100644 --- a/internal/checker/flow.go +++ b/internal/checker/flow.go @@ -1549,7 +1549,7 @@ func (c *Checker) createFinalArrayType(elementType *Type) *Type { func (c *Checker) reportFlowControlError(node *ast.Node) { block := ast.FindAncestor(node, ast.IsFunctionOrModuleBlock) sourceFile := ast.GetSourceFileOfNode(node) - span := scanner.GetRangeOfTokenAtPosition(sourceFile, ast.GetStatementsOfBlock(block).Pos()) + span := scanner.GetRangeOfTokenAtPosition(sourceFile, block.StatementList().Pos()) c.diagnostics.Add(ast.NewDiagnostic(sourceFile, span, diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)) } @@ -1759,11 +1759,8 @@ func (c *Checker) getDestructuringPropertyName(node *ast.Node) (string, bool) { if ast.IsPropertyAssignment(node) || ast.IsShorthandPropertyAssignment(node) { return c.getLiteralPropertyNameText(node.Name()) } - if ast.IsArrayBindingPattern(parent) { - return strconv.Itoa(slices.Index(parent.AsBindingPattern().Elements.Nodes, node)), true - } - if ast.IsArrayLiteralExpression(parent) { - return strconv.Itoa(slices.Index(parent.AsArrayLiteralExpression().Elements.Nodes, node)), true + if ast.IsArrayLiteralExpression(parent) || ast.IsArrayBindingPattern(parent) { + return strconv.Itoa(slices.Index(parent.Elements(), node)), true } return "", false } @@ -2099,7 +2096,7 @@ func (c *Checker) getTypeOfDottedName(node *ast.Node, diagnostic *ast.Diagnostic case ast.KindSuperKeyword: return c.checkSuperExpression(node) case ast.KindPropertyAccessExpression: - t := c.getTypeOfDottedName(node.AsPropertyAccessExpression().Expression, diagnostic) + t := c.getTypeOfDottedName(node.Expression(), diagnostic) if t != nil { name := node.Name() var prop *ast.Symbol @@ -2115,7 +2112,7 @@ func (c *Checker) getTypeOfDottedName(node *ast.Node, diagnostic *ast.Diagnostic } } case ast.KindParenthesizedExpression: - return c.getTypeOfDottedName(node.AsParenthesizedExpression().Expression, diagnostic) + return c.getTypeOfDottedName(node.Expression(), diagnostic) } } return nil @@ -2243,7 +2240,7 @@ func (c *Checker) getInitialTypeOfBindingElement(node *ast.Node) *Type { case ast.IsObjectBindingPattern(pattern): t = c.getTypeOfDestructuredProperty(parentType, getBindingElementPropertyName(node)) case !hasDotDotDotToken(node): - t = c.getTypeOfDestructuredArrayElement(parentType, slices.Index(pattern.AsBindingPattern().Elements.Nodes, node)) + t = c.getTypeOfDestructuredArrayElement(parentType, slices.Index(pattern.Elements(), node)) default: t = c.getTypeOfDestructuredSpreadExpression(parentType) } @@ -2286,7 +2283,7 @@ func (c *Checker) getAssignedTypeOfBinaryExpression(node *ast.Node) *Type { } func (c *Checker) getAssignedTypeOfArrayLiteralElement(node *ast.Node, element *ast.Node) *Type { - return c.getTypeOfDestructuredArrayElement(c.getAssignedType(node), slices.Index(node.AsArrayLiteralExpression().Elements.Nodes, element)) + return c.getTypeOfDestructuredArrayElement(c.getAssignedType(node), slices.Index(node.Elements(), element)) } func (c *Checker) getTypeOfDestructuredArrayElement(t *Type, index int) *Type { @@ -2408,7 +2405,7 @@ func (c *Checker) typeMaybeAssignableTo(source *Type, target *Type) bool { func (c *Checker) getTypePredicateArgument(predicate *TypePredicate, callExpression *ast.Node) *ast.Node { if predicate.kind == TypePredicateKindIdentifier || predicate.kind == TypePredicateKindAssertsIdentifier { arguments := callExpression.Arguments() - if int(predicate.parameterIndex) < len(arguments) { + if predicate.parameterIndex >= 0 && int(predicate.parameterIndex) < len(arguments) { return arguments[predicate.parameterIndex] } } else { @@ -2499,7 +2496,7 @@ func (c *Checker) isReachableFlowNodeWorker(f *FlowState, flow *ast.FlowNode, no case flags&ast.FlowFlagsCall != 0: if signature := c.getEffectsSignature(flow.Node); signature != nil { if predicate := c.getTypePredicateOfSignature(signature); predicate != nil && predicate.kind == TypePredicateKindAssertsIdentifier && predicate.t == nil { - if arguments := flow.Node.Arguments(); int(predicate.parameterIndex) < len(arguments) && c.isFalseExpression(arguments[predicate.parameterIndex]) { + if arguments := flow.Node.Arguments(); predicate.parameterIndex >= 0 && int(predicate.parameterIndex) < len(arguments) && c.isFalseExpression(arguments[predicate.parameterIndex]) { return false } } @@ -2682,11 +2679,8 @@ func (c *Checker) markNodeAssignmentsWorker(node *ast.Node) bool { return false case ast.KindExportSpecifier: exportDeclaration := node.AsExportSpecifier().Parent.Parent.AsExportDeclaration() - name := node.AsExportSpecifier().PropertyName - if name == nil { - name = node.Name() - } - if !node.AsExportSpecifier().IsTypeOnly && !exportDeclaration.IsTypeOnly && exportDeclaration.ModuleSpecifier == nil && !ast.IsStringLiteral(name) { + name := node.PropertyNameOrName() + if !node.IsTypeOnly() && !exportDeclaration.IsTypeOnly && exportDeclaration.ModuleSpecifier == nil && !ast.IsStringLiteral(name) { symbol := c.resolveEntityName(name, ast.SymbolFlagsValue, true /*ignoreErrors*/, true /*dontResolveAlias*/, nil) if symbol != nil && c.isParameterOrMutableLocalVariable(symbol) { links := c.markedAssignmentSymbolLinks.Get(symbol) diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index 28a18ed053..dafbd9f413 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -214,7 +214,7 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has if c.reportObviousDecoratorErrors(node) || c.reportObviousModifierErrors(node) { return true } - if ast.IsParameter(node) && ast.IsThisParameter(node) { + if ast.IsThisParameter(node) { return c.grammarErrorOnFirstToken(node, diagnostics.Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters) } blockScopeKind := ast.NodeFlagsNone @@ -232,10 +232,7 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has // [...leadingDecorators, ...leadingModifiers, ...trailingDecorators, ...trailingModifiers]. It is an error to // have both leading and trailing decorators. hasLeadingDecorators := false - var modifiers []*ast.Node - if node.Modifiers() != nil { - modifiers = node.Modifiers().Nodes - } + modifiers := node.ModifierNodes() for _, modifier := range modifiers { if ast.IsDecorator(modifier) { if !nodeCanBeDecorated(c.legacyDecorators, node, node.Parent, node.Parent.Parent) { @@ -587,16 +584,11 @@ func (c *Checker) reportObviousModifierErrors(node *ast.Node) bool { } func (c *Checker) findFirstModifierExcept(node *ast.Node, allowedModifier ast.Kind) *ast.Node { - modifiers := node.Modifiers() - if modifiers == nil { - return nil - } - modifier := core.Find(modifiers.Nodes, ast.IsModifier) + modifier := core.Find(node.ModifierNodes(), ast.IsModifier) if modifier != nil && modifier.Kind != allowedModifier { return modifier - } else { - return nil } + return nil } func (c *Checker) findFirstIllegalModifier(node *ast.Node) *ast.Node { @@ -627,10 +619,7 @@ func (c *Checker) findFirstIllegalModifier(node *ast.Node) *ast.Node { ast.KindShorthandPropertyAssignment, ast.KindNamespaceExportDeclaration, ast.KindMissingDeclaration: - if modifiers := node.Modifiers(); modifiers != nil { - return core.Find(modifiers.Nodes, ast.IsModifier) - } - return nil + return core.Find(node.ModifierNodes(), ast.IsModifier) default: if node.Parent.Kind == ast.KindModuleBlock || node.Parent.Kind == ast.KindSourceFile { return nil @@ -644,17 +633,12 @@ func (c *Checker) findFirstIllegalModifier(node *ast.Node) *ast.Node { case ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration: - if modifiers := node.Modifiers(); modifiers != nil { - return core.Find(modifiers.Nodes, ast.IsModifier) - } - return nil + return core.Find(node.ModifierNodes(), ast.IsModifier) case ast.KindVariableStatement: if node.AsVariableStatement().DeclarationList.Flags&ast.NodeFlagsUsing != 0 { return c.findFirstModifierExcept(node, ast.KindAwaitKeyword) - } else if modifiers := node.Modifiers(); modifiers != nil { - return core.Find(modifiers.Nodes, ast.IsModifier) } - return nil + return core.Find(node.ModifierNodes(), ast.IsModifier) case ast.KindEnumDeclaration: return c.findFirstModifierExcept(node, ast.KindConstKeyword) default: @@ -673,7 +657,7 @@ func (c *Checker) reportObviousDecoratorErrors(node *ast.Node) bool { func (c *Checker) findFirstIllegalDecorator(node *ast.Node) *ast.Node { if ast.CanHaveIllegalDecorators(node) { - decorator := core.Find(node.Modifiers().Nodes, ast.IsDecorator) + decorator := core.Find(node.ModifierNodes(), ast.IsDecorator) return decorator } else { return nil @@ -749,7 +733,7 @@ func (c *Checker) checkGrammarForUseStrictSimpleParameterList(node *ast.Node) bo body := node.Body() var useStrictDirective *ast.Node if body != nil && ast.IsBlock(body) { - useStrictDirective = binder.FindUseStrictPrologue(ast.GetSourceFileOfNode(node), body.AsBlock().Statements.Nodes) + useStrictDirective = binder.FindUseStrictPrologue(ast.GetSourceFileOfNode(node), body.Statements()) } if useStrictDirective != nil { nonSimpleParameters := core.Filter(node.Parameters(), func(n *ast.Node) bool { @@ -791,7 +775,7 @@ func (c *Checker) checkGrammarFunctionLikeDeclaration(node *ast.Node) bool { func (c *Checker) checkGrammarClassLikeDeclaration(node *ast.Node) bool { file := ast.GetSourceFileOfNode(node) - return c.checkGrammarClassDeclarationHeritageClauses(node, file) || c.checkGrammarTypeParameterList(node.ClassLikeData().TypeParameters, file) + return c.checkGrammarClassDeclarationHeritageClauses(node, file) || c.checkGrammarTypeParameterList(node.TypeParameterList(), file) } func (c *Checker) checkGrammarArrowFunction(node *ast.Node, file *ast.SourceFile) bool { @@ -814,8 +798,8 @@ func (c *Checker) checkGrammarArrowFunction(node *ast.Node, file *ast.SourceFile } equalsGreaterThanToken := arrowFunc.EqualsGreaterThanToken - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, equalsGreaterThanToken.Pos()) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, equalsGreaterThanToken.End()) + startLine := scanner.GetECMALineOfPosition(file, equalsGreaterThanToken.Pos()) + endLine := scanner.GetECMALineOfPosition(file, equalsGreaterThanToken.End()) return startLine != endLine && c.grammarErrorOnNode(equalsGreaterThanToken, diagnostics.Line_terminator_not_permitted_before_arrow) } @@ -900,7 +884,7 @@ func (c *Checker) checkGrammarHeritageClause(node *ast.HeritageClause) bool { return c.grammarErrorAtPos(node.AsNode(), types.Pos(), 0, diagnostics.X_0_list_cannot_be_empty, listType) } - for _, node := range types.Nodes { + for _, node := range types.Nodes { //nolint:modernize if c.checkGrammarExpressionWithTypeArguments(node) { return true } @@ -949,11 +933,11 @@ func (c *Checker) checkGrammarClassDeclarationHeritageClauses(node *ast.ClassLik for _, tag := range j.AsJSDoc().Tags.Nodes { if tag.Kind == ast.KindJSDocAugmentsTag { target := typeNodes[0].AsExpressionWithTypeArguments() - source := tag.AsJSDocAugmentsTag().ClassName.AsExpressionWithTypeArguments() + source := tag.ClassName().AsExpressionWithTypeArguments() if !ast.HasSamePropertyAccessName(target.Expression, source.Expression) && target.Expression.Kind == ast.KindIdentifier && source.Expression.Kind == ast.KindIdentifier { - return c.grammarErrorOnNode(tag.AsJSDocAugmentsTag().ClassName, diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, tag.AsJSDocAugmentsTag().TagName.Text(), source.Expression.Text(), target.Expression.Text()) + return c.grammarErrorOnNode(tag.ClassName(), diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, tag.TagName().Text(), source.Expression.Text(), target.Expression.Text()) } } } @@ -1092,15 +1076,15 @@ func (c *Checker) checkGrammarObjectLiteralExpression(node *ast.ObjectLiteralExp } // Modifiers are never allowed on properties except for 'async' on a method declaration - if modifiers := prop.Modifiers(); modifiers != nil { + if modifiers := prop.ModifierNodes(); len(modifiers) != 0 { if ast.CanHaveModifiers(prop) { - for _, mod := range modifiers.Nodes { + for _, mod := range modifiers { if ast.IsModifier(mod) && (mod.Kind != ast.KindAsyncKeyword || prop.Kind != ast.KindMethodDeclaration) { c.grammarErrorOnNode(mod, diagnostics.X_0_modifier_cannot_be_used_here, scanner.GetTextOfNode(mod)) } } } else if ast.CanHaveIllegalModifiers(prop) { - for _, mod := range modifiers.Nodes { + for _, mod := range modifiers { if ast.IsModifier(mod) { c.grammarErrorOnNode(mod, diagnostics.X_0_modifier_cannot_be_used_here, scanner.GetTextOfNode(mod)) } @@ -1185,7 +1169,7 @@ func (c *Checker) checkGrammarJsxElement(node *ast.Node) bool { c.checkGrammarJsxName(node.TagName()) c.checkGrammarTypeArguments(node, node.TypeArgumentList()) var seen collections.Set[string] - for _, attrNode := range node.Attributes().AsJsxAttributes().Properties.Nodes { + for _, attrNode := range node.Attributes().Properties() { if attrNode.Kind == ast.KindJsxSpreadAttribute { continue } @@ -1338,9 +1322,6 @@ func (c *Checker) checkGrammarForInOrForOfStatement(forInOrOfStatement *ast.ForI func (c *Checker) checkGrammarAccessor(accessor *ast.AccessorDeclaration) bool { body := accessor.Body() if accessor.Flags&ast.NodeFlagsAmbient == 0 && (accessor.Parent.Kind != ast.KindTypeLiteral) && (accessor.Parent.Kind != ast.KindInterfaceDeclaration) { - if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(accessor.Name()) { - return c.grammarErrorOnNode(accessor.Name(), diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher) - } if body == nil && !ast.HasSyntacticModifier(accessor, ast.ModifierFlagsAbstract) { return c.grammarErrorAtPos(accessor, accessor.End()-1, len(";"), diagnostics.X_0_expected, "{") } @@ -1402,7 +1383,7 @@ func (c *Checker) doesAccessorHaveCorrectParameterCount(accessor *ast.AccessorDe func (c *Checker) checkGrammarTypeOperatorNode(node *ast.TypeOperatorNode) bool { if node.Operator == ast.KindUniqueKeyword { - innerType := node.AsTypeOperatorNode().Type + innerType := node.Type if innerType.Kind != ast.KindSymbolKeyword { return c.grammarErrorOnNode(innerType, diagnostics.X_0_expected, scanner.TokenToString(ast.KindSymbolKeyword)) } @@ -1431,7 +1412,7 @@ func (c *Checker) checkGrammarTypeOperatorNode(node *ast.TypeOperatorNode) bool return c.grammarErrorOnNode(node.AsNode(), diagnostics.X_unique_symbol_types_are_not_allowed_here) } } else if node.Operator == ast.KindReadonlyKeyword { - innerType := node.AsTypeOperatorNode().Type + innerType := node.Type if innerType.Kind != ast.KindArrayType && innerType.Kind != ast.KindTupleType { return c.grammarErrorOnFirstToken(node.AsNode(), diagnostics.X_readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, scanner.TokenToString(ast.KindSymbolKeyword)) } @@ -1492,9 +1473,6 @@ func (c *Checker) checkGrammarMethod(node *ast.Node /*Union[MethodDeclaration, M } if ast.IsClassLike(node.Parent) { - if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(node.Name()) { - return c.grammarErrorOnNode(node.Name(), diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher) - } // Technically, computed properties in ambient contexts is disallowed // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -1515,16 +1493,7 @@ func (c *Checker) checkGrammarMethod(node *ast.Node /*Union[MethodDeclaration, M } func (c *Checker) checkGrammarBreakOrContinueStatement(node *ast.Node) bool { - var targetLabel *ast.IdentifierNode - switch node.Kind { - case ast.KindBreakStatement: - targetLabel = node.AsBreakStatement().Label - case ast.KindContinueStatement: - targetLabel = node.AsContinueStatement().Label - default: - panic(fmt.Sprintf("Unexpected node kind %q", node.Kind)) - } - + targetLabel := node.Label() var current *ast.Node = node for current != nil { if ast.IsFunctionLikeOrClassStaticBlockDeclaration(current) { @@ -1533,10 +1502,10 @@ func (c *Checker) checkGrammarBreakOrContinueStatement(node *ast.Node) bool { switch current.Kind { case ast.KindLabeledStatement: - if targetLabel != nil && (current.AsLabeledStatement()).Label.Text() == targetLabel.Text() { + if targetLabel != nil && current.Label().Text() == targetLabel.Text() { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - isMisplacedContinueLabel := node.Kind == ast.KindContinueStatement && !ast.IsIterationStatement((current.AsLabeledStatement()).Statement, true /*lookInLabeledStatements*/) + isMisplacedContinueLabel := node.Kind == ast.KindContinueStatement && !ast.IsIterationStatement(current.Statement(), true /*lookInLabeledStatements*/) if isMisplacedContinueLabel { return c.grammarErrorOnNode(node, diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement) @@ -1581,7 +1550,7 @@ func (c *Checker) checkGrammarBreakOrContinueStatement(node *ast.Node) bool { func (c *Checker) checkGrammarBindingElement(node *ast.BindingElement) bool { if node.DotDotDotToken != nil { - elements := node.Parent.AsBindingPattern().Elements + elements := node.Parent.ElementList() if node.AsNode() != core.LastOrNil(elements.Nodes) { return c.grammarErrorOnNode(&node.Node, diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern) } @@ -1663,7 +1632,7 @@ func (c *Checker) checkGrammarForEsModuleMarkerInBindingName(name *ast.Node) boo return c.grammarErrorOnNodeSkippedOnNoEmit(name, diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules) } } else { - for _, element := range name.AsBindingPattern().Elements.Nodes { + for _, element := range name.Elements() { if element.Name() != nil { return c.checkGrammarForEsModuleMarkerInBindingName(element.Name()) } @@ -1674,11 +1643,11 @@ func (c *Checker) checkGrammarForEsModuleMarkerInBindingName(name *ast.Node) boo func (c *Checker) checkGrammarNameInLetOrConstDeclarations(name *ast.Node /*Union[Identifier, BindingPattern]*/) bool { if name.Kind == ast.KindIdentifier { - if name.AsIdentifier().Text == "let" { + if name.Text() == "let" { return c.grammarErrorOnNode(name, diagnostics.X_let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations) } } else { - elements := name.AsBindingPattern().Elements.Nodes + elements := name.Elements() for _, element := range elements { bindingElement := element.AsBindingElement() if bindingElement.Name() != nil { @@ -1882,7 +1851,7 @@ func (c *Checker) checkGrammarMetaProperty(node *ast.MetaProperty) bool { } case ast.KindImportKeyword: if nameText != "meta" { - isCallee := ast.IsCallExpression(node.Parent) && node.Parent.AsCallExpression().Expression == node.AsNode() + isCallee := ast.IsCallExpression(node.Parent) && node.Parent.Expression() == node.AsNode() if nameText == "defer" { if !isCallee { return c.grammarErrorAtPos(node.AsNode(), node.AsNode().End(), 0, diagnostics.X_0_expected, "(") @@ -1934,13 +1903,7 @@ func (c *Checker) checkGrammarProperty(node *ast.Node /*Union[PropertyDeclaratio if c.checkGrammarForInvalidDynamicName(propertyName, diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type) { return true } - if c.languageVersion < core.ScriptTargetES2015 && ast.IsPrivateIdentifier(propertyName) { - return c.grammarErrorOnNode(propertyName, diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher) - } - if c.languageVersion < core.ScriptTargetES2015 && ast.IsAutoAccessorPropertyDeclaration(node) && node.Flags&ast.NodeFlagsAmbient == 0 { - return c.grammarErrorOnNode(propertyName, diagnostics.Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher) - } - if ast.IsAutoAccessorPropertyDeclaration(node) && c.checkGrammarForInvalidQuestionMark(node.AsPropertyDeclaration().PostfixToken, diagnostics.An_accessor_property_cannot_be_declared_optional) { + if ast.IsAutoAccessorPropertyDeclaration(node) && c.checkGrammarForInvalidQuestionMark(node.PostfixToken(), diagnostics.An_accessor_property_cannot_be_declared_optional) { return true } } else if ast.IsInterfaceDeclaration(node.Parent) { @@ -1951,7 +1914,7 @@ func (c *Checker) checkGrammarProperty(node *ast.Node /*Union[PropertyDeclaratio // Interfaces cannot contain property declarations panic(fmt.Sprintf("Unexpected node kind %q", node.Kind)) } - if initializer := node.AsPropertySignatureDeclaration().Initializer; initializer != nil { + if initializer := node.Initializer(); initializer != nil { return c.grammarErrorOnNode(initializer, diagnostics.An_interface_property_cannot_have_an_initializer) } } else if ast.IsTypeLiteralNode(node.Parent) { @@ -1962,7 +1925,7 @@ func (c *Checker) checkGrammarProperty(node *ast.Node /*Union[PropertyDeclaratio // Type literals cannot contain property declarations panic(fmt.Sprintf("Unexpected node kind %q", node.Kind)) } - if initializer := node.AsPropertySignatureDeclaration().Initializer; initializer != nil { + if initializer := node.Initializer(); initializer != nil { return c.grammarErrorOnNode(initializer, diagnostics.A_type_literal_property_cannot_have_an_initializer) } } @@ -2130,9 +2093,7 @@ func (c *Checker) checkGrammarNumericLiteral(node *ast.NumericLiteral) { // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. isFractional := strings.ContainsRune(nodeText, '.') - // !!! - // isScientific := node.NumericLiteralFlags & ast.TokenFlagsScientific - isScientific := strings.ContainsRune(nodeText, 'e') + isScientific := node.TokenFlags&ast.TokenFlagsScientific != 0 // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway @@ -2190,21 +2151,15 @@ func (c *Checker) checkGrammarImportClause(node *ast.ImportClause) bool { } func (c *Checker) checkGrammarTypeOnlyNamedImportsOrExports(namedBindings *ast.Node) bool { - var nodeList *ast.NodeList - if namedBindings.Kind == ast.KindNamedImports { - nodeList = namedBindings.AsNamedImports().Elements - } else { - nodeList = namedBindings.AsNamedExports().Elements - } - + nodeList := namedBindings.ElementList() for _, specifier := range nodeList.Nodes { var specifierIsTypeOnly bool var message *diagnostics.Message if specifier.Kind == ast.KindImportSpecifier { - specifierIsTypeOnly = specifier.AsImportSpecifier().IsTypeOnly + specifierIsTypeOnly = specifier.IsTypeOnly() message = diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement } else { - specifierIsTypeOnly = specifier.AsExportSpecifier().IsTypeOnly + specifierIsTypeOnly = specifier.IsTypeOnly() message = diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement } @@ -2236,7 +2191,7 @@ func (c *Checker) checkGrammarImportCallExpression(node *ast.Node) bool { nodeArguments := nodeAsCall.Arguments argumentNodes := nodeArguments.Nodes - if c.moduleKind != core.ModuleKindESNext && c.moduleKind != core.ModuleKindNodeNext && c.moduleKind != core.ModuleKindNode16 && c.moduleKind != core.ModuleKindPreserve { + if !(core.ModuleKindNode16 <= c.moduleKind && c.moduleKind <= core.ModuleKindNodeNext) && c.moduleKind != core.ModuleKindESNext && c.moduleKind != core.ModuleKindPreserve { // We are allowed trailing comma after proposal-import-assertions. c.checkGrammarForDisallowedTrailingComma(nodeArguments, diagnostics.Trailing_comma_not_allowed) diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index 20df4ac300..a18cc67097 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -267,7 +267,7 @@ func (c *Checker) discriminateContextualTypeByJSXAttributes(node *ast.Node, cont return discriminated } jsxChildrenPropertyName := c.getJsxElementChildrenPropertyName(c.getJsxNamespaceAt(node)) - discriminantProperties := core.Filter(node.AsJsxAttributes().Properties.Nodes, func(p *ast.Node) bool { + discriminantProperties := core.Filter(node.Properties(), func(p *ast.Node) bool { symbol := p.Symbol() if symbol == nil || !ast.IsJsxAttribute(p) { return false @@ -293,11 +293,11 @@ func (c *Checker) discriminateContextualTypeByJSXAttributes(node *ast.Node, cont func (c *Checker) elaborateJsxComponents(node *ast.Node, source *Type, target *Type, relation *Relation, diagnosticOutput *[]*ast.Diagnostic) bool { reportedError := false - for _, prop := range node.AsJsxAttributes().Properties.Nodes { + for _, prop := range node.Properties() { if !ast.IsJsxSpreadAttribute(prop) && !isHyphenatedJsxName(prop.Name().Text()) { nameType := c.getStringLiteralType(prop.Name().Text()) if nameType != nil && nameType.flags&TypeFlagsNever == 0 { - reportedError = c.elaborateElement(source, target, relation, prop.Name(), prop.Initializer(), nameType, nil, diagnosticOutput) || reportedError + reportedError = c.elaborateElement(source, target, relation, prop.Name(), prop.Initializer(), nameType, nil, nil, diagnosticOutput) || reportedError } } } @@ -326,13 +326,14 @@ func (c *Checker) elaborateJsxComponents(node *ast.Node, source *Type, target *T nonArrayLikeTargetParts = c.filterType(childrenTargetType, func(t *Type) bool { return !c.isArrayOrTupleLikeType(t) }) } var invalidTextDiagnostic *diagnostics.Message - getInvalidTextualChildDiagnostic := func() *diagnostics.Message { + var invalidTextDiagnosticArgs []any + getInvalidTextualChildDiagnostic := func() (*diagnostics.Message, []any) { if invalidTextDiagnostic == nil { tagNameText := scanner.GetTextOfNode(node.Parent.TagName()) - diagnostic := diagnostics.X_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2 - invalidTextDiagnostic = diagnostics.FormatMessage(diagnostic, tagNameText, childrenPropName, c.TypeToString(childrenTargetType)) + invalidTextDiagnostic = diagnostics.X_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2 + invalidTextDiagnosticArgs = []any{tagNameText, childrenPropName, c.TypeToString(childrenTargetType)} } - return invalidTextDiagnostic + return invalidTextDiagnostic, invalidTextDiagnosticArgs } if moreThanOneRealChildren { if arrayLikeTargetParts != c.neverType { @@ -350,7 +351,7 @@ func (c *Checker) elaborateJsxComponents(node *ast.Node, source *Type, target *T child := validChildren[0] e := c.getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic) if e.errorNode != nil { - reportedError = c.elaborateElement(source, target, relation, e.errorNode, e.innerExpression, e.nameType, e.errorMessage, diagnosticOutput) || reportedError + reportedError = c.elaborateElement(source, target, relation, e.errorNode, e.innerExpression, e.nameType, nil, e.createDiagnostic, diagnosticOutput) || reportedError } } else if !c.isTypeRelatedTo(c.getIndexedAccessType(source, childrenNameType), childrenTargetType, relation) { // arity mismatch @@ -364,13 +365,13 @@ func (c *Checker) elaborateJsxComponents(node *ast.Node, source *Type, target *T } type JsxElaborationElement struct { - errorNode *ast.Node - innerExpression *ast.Node - nameType *Type - errorMessage *diagnostics.Message + errorNode *ast.Node + innerExpression *ast.Node + nameType *Type + createDiagnostic func(prop *ast.Node) *ast.Diagnostic // Optional: creates a custom diagnostic for this element } -func (c *Checker) generateJsxChildren(node *ast.Node, getInvalidTextDiagnostic func() *diagnostics.Message) iter.Seq[JsxElaborationElement] { +func (c *Checker) generateJsxChildren(node *ast.Node, getInvalidTextDiagnostic func() (*diagnostics.Message, []any)) iter.Seq[JsxElaborationElement] { return func(yield func(JsxElaborationElement) bool) { memberOffset := 0 for i, child := range node.Children().Nodes { @@ -387,7 +388,7 @@ func (c *Checker) generateJsxChildren(node *ast.Node, getInvalidTextDiagnostic f } } -func (c *Checker) getElaborationElementForJsxChild(child *ast.Node, nameType *Type, getInvalidTextDiagnostic func() *diagnostics.Message) JsxElaborationElement { +func (c *Checker) getElaborationElementForJsxChild(child *ast.Node, nameType *Type, getInvalidTextDiagnostic func() (*diagnostics.Message, []any)) JsxElaborationElement { switch child.Kind { case ast.KindJsxExpression: // child is of the type of the expression @@ -398,7 +399,15 @@ func (c *Checker) getElaborationElementForJsxChild(child *ast.Node, nameType *Ty return JsxElaborationElement{} } // child is a string - return JsxElaborationElement{errorNode: child, innerExpression: nil, nameType: nameType, errorMessage: getInvalidTextDiagnostic()} + return JsxElaborationElement{ + errorNode: child, + innerExpression: nil, + nameType: nameType, + createDiagnostic: func(prop *ast.Node) *ast.Diagnostic { + errorMessage, errorArgs := getInvalidTextDiagnostic() + return NewDiagnosticForNode(prop, errorMessage, errorArgs...) + }, + } case ast.KindJsxElement, ast.KindJsxSelfClosingElement, ast.KindJsxFragment: // child is of type JSX.Element return JsxElaborationElement{errorNode: child, innerExpression: child, nameType: nameType} @@ -448,7 +457,10 @@ func (c *Checker) elaborateIterableOrArrayLikeTargetElementwise(iterator iter.Se if next != nil { specificSource = c.checkExpressionForMutableLocationWithContextualType(next, sourcePropType) } - if c.exactOptionalPropertyTypes && c.isExactOptionalPropertyMismatch(specificSource, targetPropType) { + if e.createDiagnostic != nil { + // Use the custom diagnostic factory if provided (e.g., for JSX text children with dynamic error messages) + c.reportDiagnostic(e.createDiagnostic(prop), diagnosticOutput) + } else if c.exactOptionalPropertyTypes && c.isExactOptionalPropertyMismatch(specificSource, targetPropType) { diag := createDiagnosticForNode(prop, diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target, c.TypeToString(specificSource), c.TypeToString(targetPropType)) c.reportDiagnostic(diag, diagnosticOutput) } else { @@ -456,10 +468,10 @@ func (c *Checker) elaborateIterableOrArrayLikeTargetElementwise(iterator iter.Se sourceIsOptional := propName != ast.InternalSymbolNameMissing && core.OrElse(c.getPropertyOfType(source, propName), c.unknownSymbol).Flags&ast.SymbolFlagsOptional != 0 targetPropType = c.removeMissingType(targetPropType, targetIsOptional) sourcePropType = c.removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional) - result := c.checkTypeRelatedToEx(specificSource, targetPropType, relation, prop, e.errorMessage, diagnosticOutput) + result := c.checkTypeRelatedToEx(specificSource, targetPropType, relation, prop, nil, diagnosticOutput) if result && specificSource != sourcePropType { // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType - c.checkTypeRelatedToEx(sourcePropType, targetPropType, relation, prop, e.errorMessage, diagnosticOutput) + c.checkTypeRelatedToEx(sourcePropType, targetPropType, relation, prop, nil, diagnosticOutput) } } } @@ -719,7 +731,7 @@ func (c *Checker) createJsxAttributesTypeFromAttributesProperty(openingLikeEleme // Create anonymous type from given attributes symbol table. // @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable // @param attributesTable a symbol table of attributes property - for _, attributeDecl := range attributes.AsJsxAttributes().Properties.Nodes { + for _, attributeDecl := range attributes.Properties() { member := attributeDecl.Symbol() if ast.IsJsxAttribute(attributeDecl) { exprType := c.checkJsxAttribute(attributeDecl, checkMode) @@ -796,11 +808,11 @@ func (c *Checker) createJsxAttributesTypeFromAttributesProperty(openingLikeEleme case ast.IsJsxElement(parent): // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if parent.AsJsxElement().OpeningElement == openingLikeElement { - children = parent.AsJsxElement().Children.Nodes + children = parent.Children().Nodes } case ast.IsJsxFragment(parent): if parent.AsJsxFragment().OpeningFragment == openingLikeElement { - children = parent.AsJsxFragment().Children.Nodes + children = parent.Children().Nodes } } return len(ast.GetSemanticJsxChildren(children)) != 0 @@ -939,7 +951,7 @@ func (c *Checker) getJsxPropsTypeFromClassType(sig *Signature, context *ast.Node attributesType = c.getReturnTypeOfSignature(sig) default: attributesType = c.getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) - if attributesType == nil && len(context.Attributes().AsJsxAttributes().Properties.Nodes) != 0 { + if attributesType == nil && len(context.Attributes().Properties()) != 0 { // There is no property named 'props' on this instance type c.error(context, diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, forcedLookupLocation) } diff --git a/internal/checker/mapper.go b/internal/checker/mapper.go index da13ffafb4..bc9bd9b00f 100644 --- a/internal/checker/mapper.go +++ b/internal/checker/mapper.go @@ -1,6 +1,10 @@ package checker -import "github.com/microsoft/typescript-go/internal/core" +import ( + "slices" + + "github.com/microsoft/typescript-go/internal/core" +) // TypeMapperKind @@ -158,10 +162,8 @@ func newArrayToSingleTypeMapper(sources []*Type, target *Type) *TypeMapper { } func (m *ArrayToSingleTypeMapper) Map(t *Type) *Type { - for _, s := range m.sources { - if t == s { - return m.target - } + if slices.Contains(m.sources, t) { + return m.target } return t } diff --git a/internal/checker/nodebuilder.go b/internal/checker/nodebuilder.go index bd629596c7..484c5abfc5 100644 --- a/internal/checker/nodebuilder.go +++ b/internal/checker/nodebuilder.go @@ -9,7 +9,7 @@ import ( type NodeBuilder struct { ctxStack []*NodeBuilderContext basicHost Host - impl *nodeBuilderImpl + impl *NodeBuilderImpl } // EmitContext implements NodeBuilderInterface. diff --git a/internal/checker/nodebuilderimpl.go b/internal/checker/nodebuilderimpl.go index 0f09e8cdad..f4a0906013 100644 --- a/internal/checker/nodebuilderimpl.go +++ b/internal/checker/nodebuilderimpl.go @@ -83,7 +83,7 @@ type NodeBuilderContext struct { typeParameterSymbolList map[ast.SymbolId]struct{} } -type nodeBuilderImpl struct { +type NodeBuilderImpl struct { // host members f *ast.NodeFactory ch *Checker @@ -107,13 +107,13 @@ const ( // Node builder utility functions -func newNodeBuilderImpl(ch *Checker, e *printer.EmitContext) *nodeBuilderImpl { - b := &nodeBuilderImpl{f: e.Factory.AsNodeFactory(), ch: ch, e: e} +func newNodeBuilderImpl(ch *Checker, e *printer.EmitContext) *NodeBuilderImpl { + b := &NodeBuilderImpl{f: e.Factory.AsNodeFactory(), ch: ch, e: e} b.cloneBindingNameVisitor = ast.NewNodeVisitor(b.cloneBindingName, b.f, ast.NodeVisitorHooks{}) return b } -func (b *nodeBuilderImpl) saveRestoreFlags() func() { +func (b *NodeBuilderImpl) saveRestoreFlags() func() { flags := b.ctx.flags internalFlags := b.ctx.internalFlags depth := b.ctx.depth @@ -125,7 +125,7 @@ func (b *nodeBuilderImpl) saveRestoreFlags() func() { } } -func (b *nodeBuilderImpl) checkTruncationLength() bool { +func (b *NodeBuilderImpl) checkTruncationLength() bool { if b.ctx.truncating { return b.ctx.truncating } @@ -133,7 +133,7 @@ func (b *nodeBuilderImpl) checkTruncationLength() bool { return b.ctx.truncating } -func (b *nodeBuilderImpl) appendReferenceToType(root *ast.TypeNode, ref *ast.TypeNode) *ast.TypeNode { +func (b *NodeBuilderImpl) appendReferenceToType(root *ast.TypeNode, ref *ast.TypeNode) *ast.TypeNode { if ast.IsImportTypeNode(root) { // first shift type arguments @@ -163,7 +163,7 @@ func (b *nodeBuilderImpl) appendReferenceToType(root *ast.TypeNode, ref *ast.Typ qualifier = id } } - return b.f.UpdateImportTypeNode(imprt, imprt.IsTypeOf, imprt.Argument, imprt.Attributes, qualifier, ref.AsTypeReferenceNode().TypeArguments) + return b.f.UpdateImportTypeNode(imprt, imprt.IsTypeOf, imprt.Argument, imprt.Attributes, qualifier, ref.TypeArgumentList()) } else { // first shift type arguments // !!! In the old emitter, an Identifier could have type arguments for use with quickinfo: @@ -185,7 +185,7 @@ func (b *nodeBuilderImpl) appendReferenceToType(root *ast.TypeNode, ref *ast.Typ for _, id := range ids { typeName = b.f.NewQualifiedName(typeName, id) } - return b.f.UpdateTypeReferenceNode(root.AsTypeReferenceNode(), typeName, ref.AsTypeReferenceNode().TypeArguments) + return b.f.UpdateTypeReferenceNode(root.AsTypeReferenceNode(), typeName, ref.TypeArgumentList()) } } @@ -205,7 +205,7 @@ func isClassInstanceSide(c *Checker, t *Type) bool { return t.symbol != nil && t.symbol.Flags&ast.SymbolFlagsClass != 0 && (t == c.getDeclaredTypeOfClassOrInterface(t.symbol) || (t.flags&TypeFlagsObject != 0 && t.objectFlags&ObjectFlagsIsClassInstanceClone != 0)) } -func (b *nodeBuilderImpl) createElidedInformationPlaceholder() *ast.TypeNode { +func (b *NodeBuilderImpl) createElidedInformationPlaceholder() *ast.TypeNode { b.ctx.approximateLength += 3 if b.ctx.flags&nodebuilder.FlagsNoTruncation == 0 { return b.f.NewTypeReferenceNode(b.f.NewIdentifier("..."), nil /*typeArguments*/) @@ -213,7 +213,7 @@ func (b *nodeBuilderImpl) createElidedInformationPlaceholder() *ast.TypeNode { return b.e.AddSyntheticLeadingComment(b.f.NewKeywordTypeNode(ast.KindAnyKeyword), ast.KindMultiLineCommentTrivia, "elided", false /*hasTrailingNewLine*/) } -func (b *nodeBuilderImpl) mapToTypeNodes(list []*Type, isBareList bool) *ast.NodeList { +func (b *NodeBuilderImpl) mapToTypeNodes(list []*Type, isBareList bool) *ast.NodeList { if len(list) == 0 { return nil } @@ -327,18 +327,18 @@ func typesAreSameReference(a, b *Type) bool { return a == b || a.symbol != nil && a.symbol == b.symbol || a.alias != nil && a.alias == b.alias } -func (b *nodeBuilderImpl) setCommentRange(node *ast.Node, range_ *ast.Node) { +func (b *NodeBuilderImpl) setCommentRange(node *ast.Node, range_ *ast.Node) { if range_ != nil && b.ctx.enclosingFile != nil && b.ctx.enclosingFile == ast.GetSourceFileOfNode(range_) { // Copy comments to node for declaration emit b.e.AssignCommentRange(node, range_) } } -func (b *nodeBuilderImpl) tryReuseExistingTypeNodeHelper(existing *ast.TypeNode) *ast.TypeNode { +func (b *NodeBuilderImpl) tryReuseExistingTypeNodeHelper(existing *ast.TypeNode) *ast.TypeNode { return nil // !!! } -func (b *nodeBuilderImpl) tryReuseExistingTypeNode(typeNode *ast.TypeNode, t *Type, host *ast.Node, addUndefined bool) *ast.TypeNode { +func (b *NodeBuilderImpl) tryReuseExistingTypeNode(typeNode *ast.TypeNode, t *Type, host *ast.Node, addUndefined bool) *ast.TypeNode { originalType := t if addUndefined { t = b.ch.getOptionalType(t, !ast.IsParameter(host)) @@ -362,7 +362,7 @@ func (b *nodeBuilderImpl) tryReuseExistingTypeNode(typeNode *ast.TypeNode, t *Ty return nil } -func (b *nodeBuilderImpl) typeNodeIsEquivalentToType(annotatedDeclaration *ast.Node, t *Type, typeFromTypeNode *Type) bool { +func (b *NodeBuilderImpl) typeNodeIsEquivalentToType(annotatedDeclaration *ast.Node, t *Type, typeFromTypeNode *Type) bool { if typeFromTypeNode == t { return true } @@ -377,7 +377,7 @@ func (b *nodeBuilderImpl) typeNodeIsEquivalentToType(annotatedDeclaration *ast.N return false } -func (b *nodeBuilderImpl) existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing *ast.TypeNode, t *Type) bool { +func (b *NodeBuilderImpl) existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing *ast.TypeNode, t *Type) bool { // In JS, you can say something like `Foo` and get a `Foo` implicitly - we don't want to preserve that original `Foo` in these cases, though. if t.objectFlags&ObjectFlagsReference == 0 { return true @@ -404,7 +404,7 @@ func (b *nodeBuilderImpl) existingTypeNodeIsNotReferenceOrIsReferenceWithCompati return len(existing.TypeArguments()) >= b.ch.getMinTypeArgumentCount(t.AsTypeReference().target.AsInterfaceType().TypeParameters()) } -func (b *nodeBuilderImpl) tryReuseExistingNonParameterTypeNode(existing *ast.TypeNode, t *Type, host *ast.Node, annotationType *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) tryReuseExistingNonParameterTypeNode(existing *ast.TypeNode, t *Type, host *ast.Node, annotationType *Type) *ast.TypeNode { if host == nil { host = b.ctx.enclosingDeclaration } @@ -420,7 +420,7 @@ func (b *nodeBuilderImpl) tryReuseExistingNonParameterTypeNode(existing *ast.Typ return nil } -func (b *nodeBuilderImpl) getResolvedTypeWithoutAbstractConstructSignatures(t *StructuredType) *Type { +func (b *NodeBuilderImpl) getResolvedTypeWithoutAbstractConstructSignatures(t *StructuredType) *Type { if len(t.ConstructSignatures()) == 0 { return t.AsType() } @@ -440,7 +440,7 @@ func (b *nodeBuilderImpl) getResolvedTypeWithoutAbstractConstructSignatures(t *S return typeCopy } -func (b *nodeBuilderImpl) symbolToNode(symbol *ast.Symbol, meaning ast.SymbolFlags) *ast.Node { +func (b *NodeBuilderImpl) symbolToNode(symbol *ast.Symbol, meaning ast.SymbolFlags) *ast.Node { if b.ctx.internalFlags&nodebuilder.InternalFlagsWriteComputedProps != 0 { if symbol.ValueDeclaration != nil { name := ast.GetNameOfDeclaration(symbol.ValueDeclaration) @@ -462,7 +462,7 @@ func (b *nodeBuilderImpl) symbolToNode(symbol *ast.Symbol, meaning ast.SymbolFla return b.symbolToExpression(symbol, meaning) } -func (b *nodeBuilderImpl) symbolToName(symbol *ast.Symbol, meaning ast.SymbolFlags, expectsIdentifier bool) *ast.Node { +func (b *NodeBuilderImpl) symbolToName(symbol *ast.Symbol, meaning ast.SymbolFlags, expectsIdentifier bool) *ast.Node { chain := b.lookupSymbolChain(symbol, meaning, false) if expectsIdentifier && len(chain) != 1 && !b.ctx.encounteredError && (b.ctx.flags&nodebuilder.FlagsAllowQualifiedNameInPlaceOfIdentifier != 0) { b.ctx.encounteredError = true @@ -470,7 +470,7 @@ func (b *nodeBuilderImpl) symbolToName(symbol *ast.Symbol, meaning ast.SymbolFla return b.createEntityNameFromSymbolChain(chain, len(chain)-1) } -func (b *nodeBuilderImpl) createEntityNameFromSymbolChain(chain []*ast.Symbol, index int) *ast.Node { +func (b *NodeBuilderImpl) createEntityNameFromSymbolChain(chain []*ast.Symbol, index int) *ast.Node { // typeParameterNodes := b.lookupTypeParameterNodes(chain, index) symbol := chain[index] @@ -498,7 +498,7 @@ func (b *nodeBuilderImpl) createEntityNameFromSymbolChain(chain []*ast.Symbol, i } // TODO: Audit usages of symbolToEntityNameNode - they should probably all be symbolToName -func (b *nodeBuilderImpl) symbolToEntityNameNode(symbol *ast.Symbol) *ast.EntityName { +func (b *NodeBuilderImpl) symbolToEntityNameNode(symbol *ast.Symbol) *ast.EntityName { identifier := b.f.NewIdentifier(symbol.Name) if symbol.Parent != nil { return b.f.NewQualifiedName(b.symbolToEntityNameNode(symbol.Parent), identifier) @@ -506,7 +506,7 @@ func (b *nodeBuilderImpl) symbolToEntityNameNode(symbol *ast.Symbol) *ast.Entity return identifier } -func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFlags, typeArguments *ast.NodeList) *ast.TypeNode { +func (b *NodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFlags, typeArguments *ast.NodeList) *ast.TypeNode { chain := b.lookupSymbolChain(symbol, mask, (b.ctx.flags&nodebuilder.FlagsUseAliasDefinedOutsideCurrentScope == 0)) // If we're using aliases outside the current scope, dont bother with the module if len(chain) == 0 { return nil // TODO: shouldn't be possible, `lookupSymbolChain` should always at least return the input symbol and issue an error @@ -532,7 +532,7 @@ func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl specifier = b.getSpecifierForModuleSymbol(chain[0], core.ModuleKindESNext) attributes = b.f.NewImportAttributes( ast.KindWithKeyword, - b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.f.NewStringLiteral("resolution-mode"), b.f.NewStringLiteral("import"))}), + b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.newStringLiteral("resolution-mode"), b.newStringLiteral("import"))}), false, ) } @@ -561,7 +561,7 @@ func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl } attributes = b.f.NewImportAttributes( ast.KindWithKeyword, - b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.f.NewStringLiteral("resolution-mode"), b.f.NewStringLiteral(modeStr))}), + b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.newStringLiteral("resolution-mode"), b.newStringLiteral(modeStr))}), false, ) } @@ -575,7 +575,7 @@ func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl } } - lit := b.f.NewLiteralTypeNode(b.f.NewStringLiteral(specifier)) + lit := b.f.NewLiteralTypeNode(b.newStringLiteral(specifier)) b.ctx.approximateLength += len(specifier) + 10 // specifier + import("") if nonRootParts == nil || ast.IsEntityName(nonRootParts) { if nonRootParts != nil { @@ -617,7 +617,7 @@ func getTopmostIndexedAccessType(node *ast.IndexedAccessTypeNode) *ast.IndexedAc return node } -func (b *nodeBuilderImpl) createAccessFromSymbolChain(chain []*ast.Symbol, index int, stopper int, overrideTypeArguments *ast.NodeList) *ast.Node { +func (b *NodeBuilderImpl) createAccessFromSymbolChain(chain []*ast.Symbol, index int, stopper int, overrideTypeArguments *ast.NodeList) *ast.Node { // !!! TODO: smuggle type arguments out typeParameterNodes := overrideTypeArguments if index != (len(chain) - 1) { @@ -670,7 +670,7 @@ func (b *nodeBuilderImpl) createAccessFromSymbolChain(chain []*ast.Symbol, index break } } - if name != nil && ast.IsComputedPropertyName(name) && ast.IsEntityName(name.AsComputedPropertyName().Expression) { + if name != nil && ast.IsComputedPropertyName(name) && ast.IsEntityName(name.Expression()) { lhs := b.createAccessFromSymbolChain(chain, index-1, stopper, overrideTypeArguments) if ast.IsEntityName(lhs) { return b.f.NewIndexedAccessTypeNode( @@ -692,12 +692,12 @@ func (b *nodeBuilderImpl) createAccessFromSymbolChain(chain []*ast.Symbol, index if ast.IsIndexedAccessTypeNode(lhs) { return b.f.NewIndexedAccessTypeNode( lhs, - b.f.NewLiteralTypeNode(b.f.NewStringLiteral(symbolName)), + b.f.NewLiteralTypeNode(b.newStringLiteral(symbolName)), ) } return b.f.NewIndexedAccessTypeNode( b.f.NewTypeReferenceNode(lhs, typeParameterNodes), - b.f.NewLiteralTypeNode(b.f.NewStringLiteral(symbolName)), + b.f.NewLiteralTypeNode(b.newStringLiteral(symbolName)), ) } @@ -718,12 +718,12 @@ func (b *nodeBuilderImpl) createAccessFromSymbolChain(chain []*ast.Symbol, index return identifier } -func (b *nodeBuilderImpl) symbolToExpression(symbol *ast.Symbol, mask ast.SymbolFlags) *ast.Expression { +func (b *NodeBuilderImpl) symbolToExpression(symbol *ast.Symbol, mask ast.SymbolFlags) *ast.Expression { chain := b.lookupSymbolChain(symbol, mask, false) return b.createExpressionFromSymbolChain(chain, len(chain)-1) } -func (b *nodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, index int) *ast.Expression { +func (b *NodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, index int) *ast.Expression { // typeParameterNodes := b.lookupTypeParameterNodes(chain, index) symbol := chain[index] @@ -736,7 +736,7 @@ func (b *nodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, i } if startsWithSingleOrDoubleQuote(symbolName) && core.Some(symbol.Declarations, hasNonGlobalAugmentationExternalModuleSymbol) { - return b.f.NewStringLiteral(b.getSpecifierForModuleSymbol(symbol, core.ResolutionModeNone)) + return b.newStringLiteral(b.getSpecifierForModuleSymbol(symbol, core.ResolutionModeNone)) } if index == 0 || canUsePropertyAccess(symbolName) { @@ -757,7 +757,7 @@ func (b *nodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, i var expression *ast.Expression if startsWithSingleOrDoubleQuote(symbolName) && symbol.Flags&ast.SymbolFlagsEnumMember == 0 { - expression = b.f.NewStringLiteral(stringutil.UnquoteString(symbolName)) + expression = b.newStringLiteral(stringutil.UnquoteString(symbolName)) } else if jsnum.FromString(symbolName).String() == symbolName { // TODO: the follwing in strada would assert if the number is negative, but no such assertion exists here // Moreover, what's even guaranteeing the name *isn't* -1 here anyway? Needs double-checking. @@ -798,7 +798,7 @@ func isDefaultBindingContext(location *ast.Node) bool { return location.Kind == ast.KindSourceFile || ast.IsAmbientModule(location) } -func (b *nodeBuilderImpl) getNameOfSymbolFromNameType(symbol *ast.Symbol) string { +func (b *NodeBuilderImpl) getNameOfSymbolFromNameType(symbol *ast.Symbol) string { if b.ch.valueSymbolLinks.Has(symbol) { nameType := b.ch.valueSymbolLinks.Get(symbol).nameType if nameType == nil { @@ -835,7 +835,7 @@ func (b *nodeBuilderImpl) getNameOfSymbolFromNameType(symbol *ast.Symbol) string * Unlike `symbolName(symbol)`, this will include quotes if the name is from a string literal. * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ -func (b *nodeBuilderImpl) getNameOfSymbolAsWritten(symbol *ast.Symbol) string { +func (b *NodeBuilderImpl) getNameOfSymbolAsWritten(symbol *ast.Symbol) string { result, ok := b.ctx.remappedSymbolReferences[ast.GetSymbolId(symbol)] if ok { symbol = result @@ -886,19 +886,22 @@ func (b *nodeBuilderImpl) getNameOfSymbolAsWritten(symbol *ast.Symbol) string { if len(name) > 0 { return name } + if symbol.Name == ast.InternalSymbolNameMissing { + return "__missing" + } return symbol.Name } // The full set of type parameters for a generic class or interface type consists of its outer type parameters plus // its locally declared type parameters. -func (b *nodeBuilderImpl) getTypeParametersOfClassOrInterface(symbol *ast.Symbol) []*Type { +func (b *NodeBuilderImpl) getTypeParametersOfClassOrInterface(symbol *ast.Symbol) []*Type { result := make([]*Type, 0) result = append(result, b.ch.getOuterTypeParametersOfClassOrInterface(symbol)...) result = append(result, b.ch.getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)...) return result } -func (b *nodeBuilderImpl) lookupTypeParameterNodes(chain []*ast.Symbol, index int) *ast.TypeParameterList { +func (b *NodeBuilderImpl) lookupTypeParameterNodes(chain []*ast.Symbol, index int) *ast.TypeParameterList { debug.Assert(chain != nil && 0 <= index && index < len(chain)) symbol := chain[index] symbolId := ast.GetSymbolId(symbol) @@ -940,12 +943,12 @@ func (b *nodeBuilderImpl) lookupTypeParameterNodes(chain []*ast.Symbol, index in } // TODO: move `lookupSymbolChain` and co to `symbolaccessibility.go` (but getSpecifierForModuleSymbol uses much context which makes that hard?) -func (b *nodeBuilderImpl) lookupSymbolChain(symbol *ast.Symbol, meaning ast.SymbolFlags, yieldModuleSymbol bool) []*ast.Symbol { +func (b *NodeBuilderImpl) lookupSymbolChain(symbol *ast.Symbol, meaning ast.SymbolFlags, yieldModuleSymbol bool) []*ast.Symbol { b.ctx.tracker.TrackSymbol(symbol, b.ctx.enclosingDeclaration, meaning) return b.lookupSymbolChainWorker(symbol, meaning, yieldModuleSymbol) } -func (b *nodeBuilderImpl) lookupSymbolChainWorker(symbol *ast.Symbol, meaning ast.SymbolFlags, yieldModuleSymbol bool) []*ast.Symbol { +func (b *NodeBuilderImpl) lookupSymbolChainWorker(symbol *ast.Symbol, meaning ast.SymbolFlags, yieldModuleSymbol bool) []*ast.Symbol { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain []*ast.Symbol isTypeParameter := symbol.Flags&ast.SymbolFlagsTypeParameter != 0 @@ -966,7 +969,7 @@ type sortedSymbolNamePair struct { } /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ -func (b *nodeBuilderImpl) getSymbolChain(symbol *ast.Symbol, meaning ast.SymbolFlags, endOfChain bool, yieldModuleSymbol bool) []*ast.Symbol { +func (b *NodeBuilderImpl) getSymbolChain(symbol *ast.Symbol, meaning ast.SymbolFlags, endOfChain bool, yieldModuleSymbol bool) []*ast.Symbol { accessibleSymbolChain := b.ch.getAccessibleSymbolChain(symbol, b.ctx.enclosingDeclaration, meaning, b.ctx.flags&nodebuilder.FlagsUseOnlyExternalAliasing != 0) qualifierMeaning := meaning if len(accessibleSymbolChain) > 1 { @@ -1032,7 +1035,7 @@ func (b *nodeBuilderImpl) getSymbolChain(symbol *ast.Symbol, meaning ast.SymbolF return nil } -func (b_ *nodeBuilderImpl) sortByBestName(a sortedSymbolNamePair, b sortedSymbolNamePair) int { +func (b_ *NodeBuilderImpl) sortByBestName(a sortedSymbolNamePair, b sortedSymbolNamePair) int { specifierA := a.name specifierB := b.name if len(specifierA) > 0 && len(specifierB) > 0 { @@ -1093,38 +1096,34 @@ func tryGetModuleSpecifierFromDeclarationWorker(node *ast.Node) *ast.Node { if requireCall == nil { return nil } - return requireCall.AsCallExpression().Arguments.Nodes[0] - case ast.KindImportDeclaration: - return node.AsImportDeclaration().ModuleSpecifier - case ast.KindExportDeclaration: - return node.AsExportDeclaration().ModuleSpecifier - case ast.KindJSDocImportTag: - return node.AsJSDocImportTag().ModuleSpecifier + return requireCall.Arguments()[0] + case ast.KindImportDeclaration, ast.KindExportDeclaration, ast.KindJSDocImportTag: + return node.ModuleSpecifier() case ast.KindImportEqualsDeclaration: ref := node.AsImportEqualsDeclaration().ModuleReference if ref.Kind != ast.KindExternalModuleReference { return nil } - return ref.AsExternalModuleReference().Expression + return ref.Expression() case ast.KindImportClause: if ast.IsImportDeclaration(node.Parent) { - return node.Parent.AsImportDeclaration().ModuleSpecifier + return node.Parent.ModuleSpecifier() } - return node.Parent.AsJSDocImportTag().ModuleSpecifier + return node.Parent.ModuleSpecifier() case ast.KindNamespaceExport: - return node.Parent.AsExportDeclaration().ModuleSpecifier + return node.Parent.ModuleSpecifier() case ast.KindNamespaceImport: if ast.IsImportDeclaration(node.Parent.Parent) { - return node.Parent.Parent.AsImportDeclaration().ModuleSpecifier + return node.Parent.Parent.ModuleSpecifier() } - return node.Parent.Parent.AsJSDocImportTag().ModuleSpecifier + return node.Parent.Parent.ModuleSpecifier() case ast.KindExportSpecifier: - return node.Parent.Parent.AsExportDeclaration().ModuleSpecifier + return node.Parent.Parent.ModuleSpecifier() case ast.KindImportSpecifier: if ast.IsImportDeclaration(node.Parent.Parent.Parent) { - return node.Parent.Parent.Parent.AsImportDeclaration().ModuleSpecifier + return node.Parent.Parent.Parent.ModuleSpecifier() } - return node.Parent.Parent.Parent.AsJSDocImportTag().ModuleSpecifier + return node.Parent.Parent.Parent.ModuleSpecifier() case ast.KindImportType: if ast.IsLiteralImportTypeNode(node) { return node.AsImportTypeNode().Argument.AsLiteralTypeNode().Literal @@ -1136,7 +1135,7 @@ func tryGetModuleSpecifierFromDeclarationWorker(node *ast.Node) *ast.Node { } } -func (b *nodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overrideImportMode core.ResolutionMode) string { +func (b *NodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overrideImportMode core.ResolutionMode) string { file := ast.GetDeclarationOfKind(symbol, ast.KindSourceFile) if file == nil { equivalentSymbol := core.FirstNonNil(symbol.Declarations, func(d *ast.Node) *ast.Symbol { @@ -1180,7 +1179,6 @@ func (b *nodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri if ok { return result } - isBundle := false // !!! remove me // For declaration bundles, we need to generate absolute paths relative to the common source dir for imports, // just like how the declaration emitter does for the ambient module declarations - we can easily accomplish this // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative @@ -1192,13 +1190,6 @@ func (b *nodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri if resolutionMode == core.ResolutionModeESM { endingPref = modulespecifiers.ImportModuleSpecifierEndingPreferenceJs } - if isBundle { - // !!! relies on option cloning and specifier host implementation - // specifierCompilerOptions = &core.CompilerOptions{BaseUrl: host.CommonSourceDirectory()} - // TODO: merge with b.ch.compilerOptions - specifierPref = modulespecifiers.ImportModuleSpecifierPreferenceNonRelative - endingPref = modulespecifiers.ImportModuleSpecifierEndingPreferenceMinimal - } allSpecifiers := modulespecifiers.GetModuleSpecifiers( symbol, @@ -1220,7 +1211,7 @@ func (b *nodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri return specifier } -func (b *nodeBuilderImpl) typeParameterToDeclarationWithConstraint(typeParameter *Type, constraintNode *ast.TypeNode) *ast.TypeParameterDeclarationNode { +func (b *NodeBuilderImpl) typeParameterToDeclarationWithConstraint(typeParameter *Type, constraintNode *ast.TypeNode) *ast.TypeParameterDeclarationNode { restoreFlags := b.saveRestoreFlags() b.ctx.flags &= ^nodebuilder.FlagsWriteTypeParametersInQualifiedName // Avoids potential infinite loop when building for a claimspace with a generic modifiers := ast.CreateModifiersFromModifierFlags(b.ch.getTypeParameterModifiers(typeParameter), b.f.NewModifier) @@ -1252,7 +1243,7 @@ func (b *nodeBuilderImpl) typeParameterToDeclarationWithConstraint(typeParameter * * It also calls `setOriginalNode` to setup a `.original` pointer, since you basically *always* want these in the node builder. */ -func (b *nodeBuilderImpl) setTextRange(range_ *ast.Node, location *ast.Node) *ast.Node { +func (b *NodeBuilderImpl) setTextRange(range_ *ast.Node, location *ast.Node) *ast.Node { if range_ == nil { return range_ } @@ -1279,7 +1270,7 @@ func (b *nodeBuilderImpl) setTextRange(range_ *ast.Node, location *ast.Node) *as return range_ } -func (b *nodeBuilderImpl) typeParameterShadowsOtherTypeParameterInScope(name string, typeParameter *Type) bool { +func (b *NodeBuilderImpl) typeParameterShadowsOtherTypeParameterInScope(name string, typeParameter *Type) bool { result := b.ch.resolveName(b.ctx.enclosingDeclaration, name, ast.SymbolFlagsType, nil, false, false) if result != nil && result.Flags&ast.SymbolFlagsTypeParameter != 0 { return result != typeParameter.symbol @@ -1287,7 +1278,7 @@ func (b *nodeBuilderImpl) typeParameterShadowsOtherTypeParameterInScope(name str return false } -func (b *nodeBuilderImpl) typeParameterToName(typeParameter *Type) *ast.Identifier { +func (b *NodeBuilderImpl) typeParameterToName(typeParameter *Type) *ast.Identifier { if b.ctx.flags&nodebuilder.FlagsGenerateNamesForShadowedTypeParams != 0 && b.ctx.typeParameterNames != nil { cached, ok := b.ctx.typeParameterNames[typeParameter.id] if ok { @@ -1312,7 +1303,7 @@ func (b *nodeBuilderImpl) typeParameterToName(typeParameter *Type) *ast.Identifi b.ctx.typeParameterNamesByTextNextNameCount = make(map[string]int) } - rawText := result.AsIdentifier().Text + rawText := result.Text() i := 0 cached, ok := b.ctx.typeParameterNamesByTextNextNameCount[rawText] if ok { @@ -1346,15 +1337,15 @@ func (b *nodeBuilderImpl) typeParameterToName(typeParameter *Type) *ast.Identifi return result.AsIdentifier() } -func (b *nodeBuilderImpl) isMappedTypeHomomorphic(mapped *Type) bool { +func (b *NodeBuilderImpl) isMappedTypeHomomorphic(mapped *Type) bool { return b.ch.getHomomorphicTypeVariable(mapped) != nil } -func (b *nodeBuilderImpl) isHomomorphicMappedTypeWithNonHomomorphicInstantiation(mapped *MappedType) bool { +func (b *NodeBuilderImpl) isHomomorphicMappedTypeWithNonHomomorphicInstantiation(mapped *MappedType) bool { return mapped.target != nil && !b.isMappedTypeHomomorphic(mapped.AsType()) && b.isMappedTypeHomomorphic(mapped.target) } -func (b *nodeBuilderImpl) createMappedTypeNodeFromType(t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) createMappedTypeNodeFromType(t *Type) *ast.TypeNode { debug.Assert(t.Flags()&TypeFlagsObject != 0) mapped := t.AsMappedType() var readonlyToken *ast.Node @@ -1434,7 +1425,7 @@ func (b *nodeBuilderImpl) createMappedTypeNodeFromType(t *Type) *ast.TypeNode { // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - rawConstraintTypeFromDeclaration := b.getTypeFromTypeNode(mapped.declaration.TypeParameter.AsTypeParameter().Constraint.AsTypeOperatorNode().Type, false) + rawConstraintTypeFromDeclaration := b.getTypeFromTypeNode(mapped.declaration.TypeParameter.AsTypeParameter().Constraint.Type(), false) if rawConstraintTypeFromDeclaration != nil { rawConstraintTypeFromDeclaration = b.ch.getConstraintOfTypeParameter(rawConstraintTypeFromDeclaration) } @@ -1470,7 +1461,7 @@ func (b *nodeBuilderImpl) createMappedTypeNodeFromType(t *Type) *ast.TypeNode { return result } -func (b *nodeBuilderImpl) typePredicateToTypePredicateNode(predicate *TypePredicate) *ast.Node { +func (b *NodeBuilderImpl) typePredicateToTypePredicateNode(predicate *TypePredicate) *ast.Node { var assertsModifier *ast.Node if predicate.kind == TypePredicateKindAssertsIdentifier || predicate.kind == TypePredicateKindAssertsThis { assertsModifier = b.f.NewToken(ast.KindAssertsKeyword) @@ -1493,7 +1484,7 @@ func (b *nodeBuilderImpl) typePredicateToTypePredicateNode(predicate *TypePredic ) } -func (b *nodeBuilderImpl) typeToTypeNodeHelperWithPossibleReusableTypeNode(t *Type, typeNode *ast.TypeNode) *ast.TypeNode { +func (b *NodeBuilderImpl) typeToTypeNodeHelperWithPossibleReusableTypeNode(t *Type, typeNode *ast.TypeNode) *ast.TypeNode { if t == nil { return b.f.NewKeywordTypeNode(ast.KindAnyKeyword) } @@ -1506,7 +1497,7 @@ func (b *nodeBuilderImpl) typeToTypeNodeHelperWithPossibleReusableTypeNode(t *Ty return b.typeToTypeNode(t) } -func (b *nodeBuilderImpl) typeParameterToDeclaration(parameter *Type) *ast.Node { +func (b *NodeBuilderImpl) typeParameterToDeclaration(parameter *Type) *ast.Node { constraint := b.ch.getConstraintOfTypeParameter(parameter) var constraintNode *ast.Node if constraint != nil { @@ -1515,11 +1506,11 @@ func (b *nodeBuilderImpl) typeParameterToDeclaration(parameter *Type) *ast.Node return b.typeParameterToDeclarationWithConstraint(parameter, constraintNode) } -func (b *nodeBuilderImpl) symbolToTypeParameterDeclarations(symbol *ast.Symbol) []*ast.Node { +func (b *NodeBuilderImpl) symbolToTypeParameterDeclarations(symbol *ast.Symbol) []*ast.Node { return b.typeParametersToTypeParameterDeclarations(symbol) } -func (b *nodeBuilderImpl) typeParametersToTypeParameterDeclarations(symbol *ast.Symbol) []*ast.Node { +func (b *NodeBuilderImpl) typeParametersToTypeParameterDeclarations(symbol *ast.Symbol) []*ast.Node { targetSymbol := b.ch.getTargetSymbol(symbol) if targetSymbol.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface|ast.SymbolFlagsAlias) != 0 { var results []*ast.Node @@ -1549,14 +1540,14 @@ func getEffectiveParameterDeclaration(symbol *ast.Symbol) *ast.Node { return nil } -func (b *nodeBuilderImpl) symbolToParameterDeclaration(parameterSymbol *ast.Symbol, preserveModifierFlags bool) *ast.Node { +func (b *NodeBuilderImpl) symbolToParameterDeclaration(parameterSymbol *ast.Symbol, preserveModifierFlags bool) *ast.Node { parameterDeclaration := getEffectiveParameterDeclaration(parameterSymbol) parameterType := b.ch.getTypeOfSymbol(parameterSymbol) parameterTypeNode := b.serializeTypeForDeclaration(parameterDeclaration, parameterType, parameterSymbol) var modifiers *ast.ModifierList if b.ctx.flags&nodebuilder.FlagsOmitParameterModifiers == 0 && preserveModifierFlags && parameterDeclaration != nil && ast.CanHaveModifiers(parameterDeclaration) { - originals := core.Filter(parameterDeclaration.Modifiers().Nodes, ast.IsModifier) + originals := core.Filter(parameterDeclaration.ModifierNodes(), ast.IsModifier) clones := core.Map(originals, func(node *ast.Node) *ast.Node { return node.Clone(b.f) }) if len(clones) > 0 { modifiers = b.f.NewModifierList(clones) @@ -1587,7 +1578,7 @@ func (b *nodeBuilderImpl) symbolToParameterDeclaration(parameterSymbol *ast.Symb return parameterNode } -func (b *nodeBuilderImpl) parameterToParameterDeclarationName(parameterSymbol *ast.Symbol, parameterDeclaration *ast.Node) *ast.Node { +func (b *NodeBuilderImpl) parameterToParameterDeclarationName(parameterSymbol *ast.Symbol, parameterDeclaration *ast.Node) *ast.Node { if parameterDeclaration == nil || parameterDeclaration.Name() == nil { return b.f.NewIdentifier(parameterSymbol.Name) } @@ -1607,7 +1598,7 @@ func (b *nodeBuilderImpl) parameterToParameterDeclarationName(parameterSymbol *a } } -func (b *nodeBuilderImpl) cloneBindingName(node *ast.Node) *ast.Node { +func (b *NodeBuilderImpl) cloneBindingName(node *ast.Node) *ast.Node { if ast.IsComputedPropertyName(node) && b.ch.isLateBindableName(node) { b.trackComputedName(node.Expression(), b.ctx.enclosingDeclaration) } @@ -1633,17 +1624,17 @@ func (b *nodeBuilderImpl) cloneBindingName(node *ast.Node) *ast.Node { return visited } -func (b *nodeBuilderImpl) symbolTableToDeclarationStatements(symbolTable *ast.SymbolTable) []*ast.Node { +func (b *NodeBuilderImpl) symbolTableToDeclarationStatements(symbolTable *ast.SymbolTable) []*ast.Node { panic("unimplemented") // !!! } -func (b *nodeBuilderImpl) serializeTypeForExpression(expr *ast.Node) *ast.Node { +func (b *NodeBuilderImpl) serializeTypeForExpression(expr *ast.Node) *ast.Node { // !!! TODO: shim, add node reuse t := b.ch.instantiateType(b.ch.getWidenedType(b.ch.getRegularTypeOfExpression(expr)), b.ctx.mapper) return b.typeToTypeNode(t) } -func (b *nodeBuilderImpl) serializeInferredReturnTypeForSignature(signature *Signature, returnType *Type) *ast.Node { +func (b *NodeBuilderImpl) serializeInferredReturnTypeForSignature(signature *Signature, returnType *Type) *ast.Node { oldSuppressReportInferenceFallback := b.ctx.suppressReportInferenceFallback b.ctx.suppressReportInferenceFallback = true typePredicate := b.ch.getTypePredicateOfSignature(signature) @@ -1663,7 +1654,7 @@ func (b *nodeBuilderImpl) serializeInferredReturnTypeForSignature(signature *Sig return returnTypeNode } -func (b *nodeBuilderImpl) typePredicateToTypePredicateNodeHelper(typePredicate *TypePredicate) *ast.Node { +func (b *NodeBuilderImpl) typePredicateToTypePredicateNodeHelper(typePredicate *TypePredicate) *ast.Node { var assertsModifier *ast.Node if typePredicate.kind == TypePredicateKindAssertsThis || typePredicate.kind == TypePredicateKindAssertsIdentifier { assertsModifier = b.f.NewToken(ast.KindAssertsKeyword) @@ -1690,7 +1681,7 @@ type SignatureToSignatureDeclarationOptions struct { questionToken *ast.Node } -func (b *nodeBuilderImpl) signatureToSignatureDeclarationHelper(signature *Signature, kind ast.Kind, options *SignatureToSignatureDeclarationOptions) *ast.Node { +func (b *NodeBuilderImpl) signatureToSignatureDeclarationHelper(signature *Signature, kind ast.Kind, options *SignatureToSignatureDeclarationOptions) *ast.Node { var typeParameters []*ast.Node expandedParams := b.ch.getExpandedParameters(signature, true /*skipUnionExpanding*/)[0] @@ -1899,7 +1890,7 @@ func (c *Checker) getExpandedParameters(sig *Signature, skipUnionExpanding bool) return [][]*ast.Symbol{sig.parameters} } -func (b *nodeBuilderImpl) tryGetThisParameterDeclaration(signature *Signature) *ast.Node { +func (b *NodeBuilderImpl) tryGetThisParameterDeclaration(signature *Signature) *ast.Node { if signature.thisParameter != nil { return b.symbolToParameterDeclaration(signature.thisParameter, false) } @@ -1922,7 +1913,7 @@ func (b *nodeBuilderImpl) tryGetThisParameterDeclaration(signature *Signature) * /** * Serializes the return type of the signature by first trying to use the syntactic printer if possible and falling back to the checker type if not. */ -func (b *nodeBuilderImpl) serializeReturnTypeForSignature(signature *Signature) *ast.Node { +func (b *NodeBuilderImpl) serializeReturnTypeForSignature(signature *Signature) *ast.Node { suppressAny := b.ctx.flags&nodebuilder.FlagsSuppressAnyReturnType != 0 restoreFlags := b.saveRestoreFlags() if suppressAny { @@ -1951,7 +1942,7 @@ func (b *nodeBuilderImpl) serializeReturnTypeForSignature(signature *Signature) return returnTypeNode } -func (b *nodeBuilderImpl) indexInfoToIndexSignatureDeclarationHelper(indexInfo *IndexInfo, typeNode *ast.TypeNode) *ast.Node { +func (b *NodeBuilderImpl) indexInfoToIndexSignatureDeclarationHelper(indexInfo *IndexInfo, typeNode *ast.TypeNode) *ast.Node { name := getNameFromIndexInfo(indexInfo) indexerTypeNode := b.typeToTypeNode(indexInfo.keyType) @@ -1982,7 +1973,7 @@ func (b *nodeBuilderImpl) indexInfoToIndexSignatureDeclarationHelper(indexInfo * * @param type - The type to write; an existing annotation must match this type if it's used, otherwise this is the type serialized as a new type node * @param symbol - The symbol is used both to find an existing annotation if declaration is not provided, and to determine if `unique symbol` should be printed */ -func (b *nodeBuilderImpl) serializeTypeForDeclaration(declaration *ast.Declaration, t *Type, symbol *ast.Symbol) *ast.Node { +func (b *NodeBuilderImpl) serializeTypeForDeclaration(declaration *ast.Declaration, t *Type, symbol *ast.Symbol) *ast.Node { // !!! node reuse logic if symbol == nil { symbol = b.ch.getSymbolOfDeclaration(declaration) @@ -2019,7 +2010,7 @@ func (b *nodeBuilderImpl) serializeTypeForDeclaration(declaration *ast.Declarati const MAX_REVERSE_MAPPED_NESTING_INSPECTION_DEPTH = 3 -func (b *nodeBuilderImpl) shouldUsePlaceholderForProperty(propertySymbol *ast.Symbol) bool { +func (b *NodeBuilderImpl) shouldUsePlaceholderForProperty(propertySymbol *ast.Symbol) bool { // Use placeholders for reverse mapped types we've either // (1) already descended into, or // (2) are nested reverse mappings within a mapping over a non-anonymous type, or @@ -2034,10 +2025,8 @@ func (b *nodeBuilderImpl) shouldUsePlaceholderForProperty(propertySymbol *ast.Sy return false } // (1) - for _, elem := range b.ctx.reverseMappedStack { - if elem == propertySymbol { - return true - } + if slices.Contains(b.ctx.reverseMappedStack, propertySymbol) { + return true } // (2) if len(b.ctx.reverseMappedStack) > 0 { @@ -2080,7 +2069,7 @@ func (b *nodeBuilderImpl) shouldUsePlaceholderForProperty(propertySymbol *ast.Sy return false } -func (b *nodeBuilderImpl) trackComputedName(accessExpression *ast.Node, enclosingDeclaration *ast.Node) { +func (b *NodeBuilderImpl) trackComputedName(accessExpression *ast.Node, enclosingDeclaration *ast.Node) { // get symbol of the first identifier of the entityName firstIdentifier := ast.GetFirstIdentifier(accessExpression) name := b.ch.resolveName(firstIdentifier, firstIdentifier.Text(), ast.SymbolFlagsValue|ast.SymbolFlagsExportValue, nil /*nameNotFoundMessage*/, true /*isUse*/, false) @@ -2089,7 +2078,7 @@ func (b *nodeBuilderImpl) trackComputedName(accessExpression *ast.Node, enclosin } } -func (b *nodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name string, _singleQuote bool, stringNamed bool, isMethod bool) *ast.Node { +func (b *NodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name string, singleQuote bool, stringNamed bool, isMethod bool) *ast.Node { isMethodNamedNew := isMethod && name == "new" if !isMethodNamedNew && scanner.IsIdentifierText(name, core.LanguageVariantStandard) { return b.f.NewIdentifier(name) @@ -2098,17 +2087,19 @@ func (b *nodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name stri return b.f.NewNumericLiteral(name) } result := b.f.NewStringLiteral(name) - // !!! TODO: set singleQuote + if singleQuote { + result.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } return result } -func (b *nodeBuilderImpl) isStringNamed(d *ast.Declaration) bool { +func (b *NodeBuilderImpl) isStringNamed(d *ast.Declaration) bool { name := ast.GetNameOfDeclaration(d) if name == nil { return false } if ast.IsComputedPropertyName(name) { - t := b.ch.checkExpression(name.AsComputedPropertyName().Expression) + t := b.ch.checkExpression(name.Expression()) return t.flags&TypeFlagsStringLike != 0 } if ast.IsElementAccessExpression(name) { @@ -2118,14 +2109,12 @@ func (b *nodeBuilderImpl) isStringNamed(d *ast.Declaration) bool { return ast.IsStringLiteral(name) } -func (b *nodeBuilderImpl) isSingleQuotedStringNamed(d *ast.Declaration) bool { - return false // !!! - // TODO: actually support single-quote-style-maintenance - // name := ast.GetNameOfDeclaration(d) - // return name != nil && ast.IsStringLiteral(name) && (name.AsStringLiteral().SingleQuote || !nodeIsSynthesized(name) && startsWith(getTextOfNode(name, false /*includeTrivia*/), "'")) +func (b *NodeBuilderImpl) isSingleQuotedStringNamed(d *ast.Declaration) bool { + name := ast.GetNameOfDeclaration(d) + return name != nil && ast.IsStringLiteral(name) && name.AsStringLiteral().TokenFlags&ast.TokenFlagsSingleQuote != 0 } -func (b *nodeBuilderImpl) getPropertyNameNodeForSymbol(symbol *ast.Symbol) *ast.Node { +func (b *NodeBuilderImpl) getPropertyNameNodeForSymbol(symbol *ast.Symbol) *ast.Node { stringNamed := len(symbol.Declarations) != 0 && core.Every(symbol.Declarations, b.isStringNamed) singleQuote := len(symbol.Declarations) != 0 && core.Every(symbol.Declarations, b.isSingleQuotedStringNamed) isMethod := symbol.Flags&ast.SymbolFlagsMethod != 0 @@ -2147,7 +2136,7 @@ func (b *nodeBuilderImpl) getPropertyNameNodeForSymbol(symbol *ast.Symbol) *ast. } // See getNameForSymbolFromNameType for a stringy equivalent -func (b *nodeBuilderImpl) getPropertyNameNodeForSymbolFromNameType(symbol *ast.Symbol, singleQuote bool, stringNamed bool, isMethod bool) *ast.Node { +func (b *NodeBuilderImpl) getPropertyNameNodeForSymbolFromNameType(symbol *ast.Symbol, singleQuote bool, stringNamed bool, isMethod bool) *ast.Node { if !b.ch.valueSymbolLinks.Has(symbol) { return nil } @@ -2164,8 +2153,11 @@ func (b *nodeBuilderImpl) getPropertyNameNodeForSymbolFromNameType(symbol *ast.S name = nameType.AsLiteralType().value.(string) } if !scanner.IsIdentifierText(name, core.LanguageVariantStandard) && (stringNamed || !isNumericLiteralName(name)) { - // !!! TODO: set singleQuote - return b.f.NewStringLiteral(name) + node := b.f.NewStringLiteral(name) + if singleQuote { + node.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } + return node } if isNumericLiteralName(name) && name[0] == '-' { return b.f.NewComputedPropertyName(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(name[1:]))) @@ -2178,7 +2170,7 @@ func (b *nodeBuilderImpl) getPropertyNameNodeForSymbolFromNameType(symbol *ast.S return nil } -func (b *nodeBuilderImpl) addPropertyToElementList(propertySymbol *ast.Symbol, typeElements []*ast.TypeElement) []*ast.TypeElement { +func (b *NodeBuilderImpl) addPropertyToElementList(propertySymbol *ast.Symbol, typeElements []*ast.TypeElement) []*ast.TypeElement { propertyIsReverseMapped := propertySymbol.CheckFlags&ast.CheckFlagsReverseMapped != 0 var propertyType *Type if b.shouldUsePlaceholderForProperty(propertySymbol) { @@ -2312,7 +2304,7 @@ func (b *nodeBuilderImpl) addPropertyToElementList(propertySymbol *ast.Symbol, t return typeElements } -func (b *nodeBuilderImpl) createTypeNodesFromResolvedType(resolvedType *StructuredType) *ast.NodeList { +func (b *NodeBuilderImpl) createTypeNodesFromResolvedType(resolvedType *StructuredType) *ast.NodeList { if b.checkTruncationLength() { if b.ctx.flags&nodebuilder.FlagsNoTruncation != 0 { elem := b.f.NewNotEmittedTypeElement() @@ -2369,7 +2361,7 @@ func (b *nodeBuilderImpl) createTypeNodesFromResolvedType(resolvedType *Structur } } -func (b *nodeBuilderImpl) createTypeNodeFromObjectType(t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) createTypeNodeFromObjectType(t *Type) *ast.TypeNode { if b.ch.isGenericMappedType(t) || (t.objectFlags&ObjectFlagsMapped != 0 && t.AsMappedType().containsError) { return b.createMappedTypeNodeFromType(t) } @@ -2439,7 +2431,7 @@ func getTypeAliasForTypeLiteral(c *Checker, t *Type) *ast.Symbol { return nil } -func (b *nodeBuilderImpl) shouldWriteTypeOfFunctionSymbol(symbol *ast.Symbol, typeId TypeId) bool { +func (b *NodeBuilderImpl) shouldWriteTypeOfFunctionSymbol(symbol *ast.Symbol, typeId TypeId) bool { isStaticMethodSymbol := symbol.Flags&ast.SymbolFlagsMethod != 0 && core.Some(symbol.Declarations, func(declaration *ast.Node) bool { return ast.IsStatic(declaration) && !b.ch.isLateBindableIndexSignature(ast.GetNameOfDeclaration(declaration)) }) @@ -2464,7 +2456,7 @@ func (b *nodeBuilderImpl) shouldWriteTypeOfFunctionSymbol(symbol *ast.Symbol, ty return false } -func (b *nodeBuilderImpl) createAnonymousTypeNode(t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) createAnonymousTypeNode(t *Type) *ast.TypeNode { typeId := t.id symbol := t.symbol if symbol != nil { @@ -2481,7 +2473,7 @@ func (b *nodeBuilderImpl) createAnonymousTypeNode(t *Type) *ast.TypeNode { if b.ctx.visitedTypes.Has(typeId) { return b.createElidedInformationPlaceholder() } - return b.visitAndTransformType(t, (*nodeBuilderImpl).createTypeNodeFromObjectType) + return b.visitAndTransformType(t, (*NodeBuilderImpl).createTypeNodeFromObjectType) } var isInstanceType ast.SymbolFlags if isClassInstanceSide(b.ch, t) { @@ -2507,7 +2499,7 @@ func (b *nodeBuilderImpl) createAnonymousTypeNode(t *Type) *ast.TypeNode { return b.createElidedInformationPlaceholder() } } else { - return b.visitAndTransformType(t, (*nodeBuilderImpl).createTypeNodeFromObjectType) + return b.visitAndTransformType(t, (*NodeBuilderImpl).createTypeNodeFromObjectType) } } else { // Anonymous types without a symbol are never circular. @@ -2515,7 +2507,7 @@ func (b *nodeBuilderImpl) createAnonymousTypeNode(t *Type) *ast.TypeNode { } } -func (b *nodeBuilderImpl) getTypeFromTypeNode(node *ast.TypeNode, noMappedTypes bool) *Type { +func (b *NodeBuilderImpl) getTypeFromTypeNode(node *ast.TypeNode, noMappedTypes bool) *Type { // !!! noMappedTypes optional param support t := b.ch.getTypeFromTypeNode(node) if b.ctx.mapper == nil { @@ -2529,7 +2521,7 @@ func (b *nodeBuilderImpl) getTypeFromTypeNode(node *ast.TypeNode, noMappedTypes return instantiated } -func (b *nodeBuilderImpl) typeToTypeNodeOrCircularityElision(t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) typeToTypeNodeOrCircularityElision(t *Type) *ast.TypeNode { if t.flags&TypeFlagsUnion != 0 { if b.ctx.visitedTypes.Has(t.id) { if b.ctx.flags&nodebuilder.FlagsAllowAnonymousIdentifier == 0 { @@ -2538,12 +2530,12 @@ func (b *nodeBuilderImpl) typeToTypeNodeOrCircularityElision(t *Type) *ast.TypeN } return b.createElidedInformationPlaceholder() } - return b.visitAndTransformType(t, (*nodeBuilderImpl).typeToTypeNode) + return b.visitAndTransformType(t, (*NodeBuilderImpl).typeToTypeNode) } return b.typeToTypeNode(t) } -func (b *nodeBuilderImpl) conditionalTypeToTypeNode(_t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) conditionalTypeToTypeNode(_t *Type) *ast.TypeNode { t := _t.AsConditionalType() checkTypeNode := b.typeToTypeNode(t.checkType) b.ctx.approximateLength += 15 @@ -2586,7 +2578,7 @@ func (b *nodeBuilderImpl) conditionalTypeToTypeNode(_t *Type) *ast.TypeNode { return b.f.NewConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode) } -func (b *nodeBuilderImpl) getParentSymbolOfTypeParameter(typeParameter *TypeParameter) *ast.Symbol { +func (b *NodeBuilderImpl) getParentSymbolOfTypeParameter(typeParameter *TypeParameter) *ast.Symbol { tp := ast.GetDeclarationOfKind(typeParameter.symbol, ast.KindTypeParameter) var host *ast.Node // !!! JSDoc support @@ -2601,7 +2593,7 @@ func (b *nodeBuilderImpl) getParentSymbolOfTypeParameter(typeParameter *TypePara return b.ch.getSymbolOfNode(host) } -func (b *nodeBuilderImpl) typeReferenceToTypeNode(t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) typeReferenceToTypeNode(t *Type) *ast.TypeNode { var typeArguments []*Type = b.ch.getTypeArguments(t) if t.Target() == b.ch.globalArrayType || t.Target() == b.ch.globalReadonlyArrayType { if b.ctx.flags&nodebuilder.FlagsWriteArrayAsGenericType != 0 { @@ -2735,7 +2727,7 @@ func (b *nodeBuilderImpl) typeReferenceToTypeNode(t *Type) *ast.TypeNode { } } -func (b *nodeBuilderImpl) visitAndTransformType(t *Type, transform func(b *nodeBuilderImpl, t *Type) *ast.TypeNode) *ast.TypeNode { +func (b *NodeBuilderImpl) visitAndTransformType(t *Type, transform func(b *NodeBuilderImpl, t *Type) *ast.TypeNode) *ast.TypeNode { typeId := t.id isConstructorObject := t.objectFlags&ObjectFlagsAnonymous != 0 && t.symbol != nil && t.symbol.Flags&ast.SymbolFlagsClass != 0 var id *CompositeSymbolIdentity @@ -2820,7 +2812,7 @@ func (b *nodeBuilderImpl) visitAndTransformType(t *Type, transform func(b *nodeB // } } -func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { +func (b *NodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { inTypeAlias := b.ctx.flags & nodebuilder.FlagsInTypeAlias b.ctx.flags &^= nodebuilder.FlagsInTypeAlias @@ -2881,9 +2873,9 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { if ast.IsImportTypeNode(parentName) { parentName.AsImportTypeNode().IsTypeOf = true // mutably update, node is freshly manufactured anyhow - return b.f.NewIndexedAccessTypeNode(parentName, b.f.NewLiteralTypeNode(b.f.NewStringLiteral(memberName))) + return b.f.NewIndexedAccessTypeNode(parentName, b.f.NewLiteralTypeNode(b.newStringLiteral(memberName))) } else if ast.IsTypeReferenceNode(parentName) { - return b.f.NewIndexedAccessTypeNode(b.f.NewTypeQueryNode(parentName.AsTypeReferenceNode().TypeName, nil), b.f.NewLiteralTypeNode(b.f.NewStringLiteral(memberName))) + return b.f.NewIndexedAccessTypeNode(b.f.NewTypeQueryNode(parentName.AsTypeReferenceNode().TypeName, nil), b.f.NewLiteralTypeNode(b.newStringLiteral(memberName))) } else { panic("Unhandled type node kind returned from `symbolToTypeNode`.") } @@ -2892,7 +2884,7 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { } if t.flags&TypeFlagsStringLiteral != 0 { b.ctx.approximateLength += len(t.AsLiteralType().value.(string)) + 2 - lit := b.f.NewStringLiteral(t.AsLiteralType().value.(string) /*, b.flags&nodebuilder.FlagsUseSingleQuotesForStringLiteralType != 0*/) + lit := b.newStringLiteral(t.AsLiteralType().value.(string)) b.e.AddEmitFlags(lit, printer.EFNoAsciiEscaping) return b.f.NewLiteralTypeNode(lit) } @@ -2981,7 +2973,7 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { if objectFlags&ObjectFlagsReference != 0 { debug.Assert(t.Flags()&TypeFlagsObject != 0) if t.AsTypeReference().node != nil { - return b.visitAndTransformType(t, (*nodeBuilderImpl).typeReferenceToTypeNode) + return b.visitAndTransformType(t, (*NodeBuilderImpl).typeReferenceToTypeNode) } else { return b.typeReferenceToTypeNode(t) } @@ -3063,13 +3055,13 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { if t.flags&TypeFlagsTemplateLiteral != 0 { texts := t.AsTemplateLiteralType().texts types := t.AsTemplateLiteralType().types - templateHead := b.f.NewTemplateHead(texts[0], texts[0], ast.TokenFlagsNone) + templateHead := b.f.NewTemplateHead(texts[0], "", ast.TokenFlagsNone) templateSpans := b.f.NewNodeList(core.MapIndex(types, func(t *Type, i int) *ast.Node { var res *ast.TemplateMiddleOrTail if i < len(types)-1 { - res = b.f.NewTemplateMiddle(texts[i+1], texts[i+1], ast.TokenFlagsNone) + res = b.f.NewTemplateMiddle(texts[i+1], "", ast.TokenFlagsNone) } else { - res = b.f.NewTemplateTail(texts[i+1], texts[i+1], ast.TokenFlagsNone) + res = b.f.NewTemplateTail(texts[i+1], "", ast.TokenFlagsNone) } return b.f.NewTemplateLiteralTypeSpan(b.typeToTypeNode(t), res) })) @@ -3087,7 +3079,7 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { return b.f.NewIndexedAccessTypeNode(objectTypeNode, indexTypeNode) } if t.flags&TypeFlagsConditional != 0 { - return b.visitAndTransformType(t, (*nodeBuilderImpl).conditionalTypeToTypeNode) + return b.visitAndTransformType(t, (*NodeBuilderImpl).conditionalTypeToTypeNode) } if t.flags&TypeFlagsSubstitution != 0 { typeNode := b.typeToTypeNode(t.AsSubstitutionType().baseType) @@ -3105,8 +3097,16 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { panic("Should be unreachable.") } +func (b *NodeBuilderImpl) newStringLiteral(text string) *ast.Node { + node := b.f.NewStringLiteral(text) + if b.ctx.flags&nodebuilder.FlagsUseSingleQuotesForStringLiteralType != 0 { + node.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } + return node +} + // Direct serialization core functions for types, type aliases, and symbols -func (t *TypeAlias) ToTypeReferenceNode(b *nodeBuilderImpl) *ast.Node { +func (t *TypeAlias) ToTypeReferenceNode(b *NodeBuilderImpl) *ast.Node { return b.f.NewTypeReferenceNode(b.symbolToEntityNameNode(t.Symbol()), b.mapToTypeNodes(t.TypeArguments(), false /*isBareList*/)) } diff --git a/internal/checker/nodebuilderscopes.go b/internal/checker/nodebuilderscopes.go index fa35bd7f31..7fb2ed46aa 100644 --- a/internal/checker/nodebuilderscopes.go +++ b/internal/checker/nodebuilderscopes.go @@ -49,7 +49,7 @@ type localsRecord struct { oldSymbol *ast.Symbol } -func (b *nodeBuilderImpl) enterNewScope(declaration *ast.Node, expandedParams []*ast.Symbol, typeParameters []*Type, originalParameters []*ast.Symbol, mapper *TypeMapper) func() { +func (b *NodeBuilderImpl) enterNewScope(declaration *ast.Node, expandedParams []*ast.Symbol, typeParameters []*Type, originalParameters []*ast.Symbol, mapper *TypeMapper) func() { cleanupContext := cloneNodeBuilderContext(b.ctx) // For regular function/method declarations, the enclosing declaration will already be signature.declaration, // so this is a no-op, but for arrow functions and function expressions, the enclosing declaration will be diff --git a/internal/checker/printer.go b/internal/checker/printer.go index 8e82a2350f..f7c231650a 100644 --- a/internal/checker/printer.go +++ b/internal/checker/printer.go @@ -377,3 +377,8 @@ func (c *Checker) TypeToTypeNode(t *Type, enclosingDeclaration *ast.Node, flags nodeBuilder := c.getNodeBuilder() return nodeBuilder.TypeToTypeNode(t, enclosingDeclaration, flags, nodebuilder.InternalFlagsNone, nil) } + +func (c *Checker) TypePredicateToTypePredicateNode(t *TypePredicate, enclosingDeclaration *ast.Node, flags nodebuilder.Flags) *ast.TypePredicateNodeNode { + nodeBuilder := c.getNodeBuilder() + return nodeBuilder.TypePredicateToTypePredicateNode(t, enclosingDeclaration, flags, nodebuilder.InternalFlagsNone, nil) +} diff --git a/internal/checker/relater.go b/internal/checker/relater.go index 4f101352ff..db83af0745 100644 --- a/internal/checker/relater.go +++ b/internal/checker/relater.go @@ -443,7 +443,7 @@ func (c *Checker) elaborateError(node *ast.Node, source *Type, target *Type, rel } switch node.Kind { case ast.KindAsExpression: - if !isConstAssertion(node) { + if !ast.IsConstAssertion(node) { break } fallthrough @@ -493,7 +493,7 @@ func (c *Checker) elaborateObjectLiteral(node *ast.Node, source *Type, target *T return false } reportedError := false - for _, prop := range node.AsObjectLiteralExpression().Properties.Nodes { + for _, prop := range node.Properties() { if ast.IsSpreadAssignment(prop) { continue } @@ -503,10 +503,10 @@ func (c *Checker) elaborateObjectLiteral(node *ast.Node, source *Type, target *T } switch prop.Kind { case ast.KindSetAccessor, ast.KindGetAccessor, ast.KindMethodDeclaration, ast.KindShorthandPropertyAssignment: - reportedError = c.elaborateElement(source, target, relation, prop.Name(), nil, nameType, nil, diagnosticOutput) || reportedError + reportedError = c.elaborateElement(source, target, relation, prop.Name(), nil, nameType, nil, nil, diagnosticOutput) || reportedError case ast.KindPropertyAssignment: message := core.IfElse(ast.IsComputedNonLiteralName(prop.Name()), diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1, nil) - reportedError = c.elaborateElement(source, target, relation, prop.Name(), prop.Initializer(), nameType, message, diagnosticOutput) || reportedError + reportedError = c.elaborateElement(source, target, relation, prop.Name(), prop.Initializer(), nameType, message, nil, diagnosticOutput) || reportedError } } return reportedError @@ -525,18 +525,18 @@ func (c *Checker) elaborateArrayLiteral(node *ast.Node, source *Type, target *Ty } } reportedError := false - for i, element := range node.AsArrayLiteralExpression().Elements.Nodes { + for i, element := range node.Elements() { if ast.IsOmittedExpression(element) || c.isTupleLikeType(target) && c.getPropertyOfType(target, jsnum.Number(i).String()) == nil { continue } nameType := c.getNumberLiteralType(jsnum.Number(i)) checkNode := c.getEffectiveCheckNode(element) - reportedError = c.elaborateElement(source, target, relation, checkNode, checkNode, nameType, nil, diagnosticOutput) || reportedError + reportedError = c.elaborateElement(source, target, relation, checkNode, checkNode, nameType, nil, nil, diagnosticOutput) || reportedError } return reportedError } -func (c *Checker) elaborateElement(source *Type, target *Type, relation *Relation, prop *ast.Node, next *ast.Node, nameType *Type, errorMessage *diagnostics.Message, diagnosticOutput *[]*ast.Diagnostic) bool { +func (c *Checker) elaborateElement(source *Type, target *Type, relation *Relation, prop *ast.Node, next *ast.Node, nameType *Type, errorMessage *diagnostics.Message, diagnosticFactory func(prop *ast.Node) *ast.Diagnostic, diagnosticOutput *[]*ast.Diagnostic) bool { targetPropType := c.getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) if targetPropType == nil || targetPropType.flags&TypeFlagsIndexedAccess != 0 { // Don't elaborate on indexes on generic variables @@ -557,7 +557,10 @@ func (c *Checker) elaborateElement(source *Type, target *Type, relation *Relatio if next != nil { specificSource = c.checkExpressionForMutableLocationWithContextualType(next, sourcePropType) } - if c.exactOptionalPropertyTypes && c.isExactOptionalPropertyMismatch(specificSource, targetPropType) { + if diagnosticFactory != nil { + // Use the custom diagnostic factory if provided (e.g., for JSX text children with dynamic error messages) + diags = append(diags, diagnosticFactory(prop)) + } else if c.exactOptionalPropertyTypes && c.isExactOptionalPropertyMismatch(specificSource, targetPropType) { diags = append(diags, createDiagnosticForNode(prop, diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target, c.TypeToString(specificSource), c.TypeToString(targetPropType))) } else { propName := c.getPropertyNameFromIndex(nameType, nil /*accessNode*/) @@ -1963,7 +1966,7 @@ func (c *Checker) getTupleElementLabelFromBindingElement(node *ast.Node, index i return name + "_n" case ast.KindArrayBindingPattern: if hasDotDotDotToken(node) { - elements := node.Name().AsBindingPattern().Elements.Nodes + elements := node.Name().Elements() lastElement := core.LastOrNil(elements) lastElementIsBindingElementRest := lastElement != nil && ast.IsBindingElement(lastElement) && hasDotDotDotToken(lastElement) elementCount := len(elements) - core.IfElse(lastElementIsBindingElementRest, 1, 0) @@ -1994,19 +1997,11 @@ func (c *Checker) getTypePredicateOfSignature(sig *Signature) *TypePredicate { default: if sig.declaration != nil { typeNode := sig.declaration.Type() - var jsdocTypePredicate *TypePredicate - if typeNode == nil { - if jsdocSignature := c.getSignatureOfFullSignatureType(sig.declaration); jsdocSignature != nil { - jsdocTypePredicate = c.getTypePredicateOfSignature(jsdocSignature) - } - } switch { case typeNode != nil: if ast.IsTypePredicateNode(typeNode) { sig.resolvedTypePredicate = c.createTypePredicateFromTypePredicateNode(typeNode, sig) } - case jsdocTypePredicate != nil: - sig.resolvedTypePredicate = jsdocTypePredicate case ast.IsFunctionLikeDeclaration(sig.declaration) && (sig.resolvedReturnType == nil || sig.resolvedReturnType.flags&TypeFlagsBoolean != 0) && c.getParameterCount(sig) > 0: sig.resolvedTypePredicate = c.noTypePredicate // avoid infinite loop sig.resolvedTypePredicate = c.getTypePredicateFromBody(sig.declaration) @@ -3878,26 +3873,32 @@ func (r *Relater) typeArgumentsRelatedTo(sources []*Type, targets []*Type, varia } else { related = r.c.compareTypesIdentical(s, t) } - } else if variance == VarianceFlagsCovariant { - related = r.isRelatedToEx(s, t, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) - } else if variance == VarianceFlagsContravariant { - related = r.isRelatedToEx(t, s, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) - } else if variance == VarianceFlagsBivariant { - // In the bivariant case we first compare contravariantly without reporting - // errors. Then, if that doesn't succeed, we compare covariantly with error - // reporting. Thus, error elaboration will be based on the covariant check, - // which is generally easier to reason about. - related = r.isRelatedTo(t, s, RecursionFlagsBoth, false /*reportErrors*/) - if related == TernaryFalse { - related = r.isRelatedToEx(s, t, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) - } } else { - // In the invariant case we first compare covariantly, and only when that - // succeeds do we proceed to compare contravariantly. Thus, error elaboration - // will typically be based on the covariant check. - related = r.isRelatedToEx(s, t, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) - if related != TernaryFalse { - related &= r.isRelatedToEx(t, s, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) + // Propagate unreliable variance flag + if r.c.inVarianceComputation && varianceFlags&VarianceFlagsUnreliable != 0 { + r.c.instantiateType(s, r.c.reportUnreliableMapper) + } + if variance == VarianceFlagsCovariant { + related = r.isRelatedToEx(s, t, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) + } else if variance == VarianceFlagsContravariant { + related = r.isRelatedToEx(t, s, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) + } else if variance == VarianceFlagsBivariant { + // In the bivariant case we first compare contravariantly without reporting + // errors. Then, if that doesn't succeed, we compare covariantly with error + // reporting. Thus, error elaboration will be based on the covariant check, + // which is generally easier to reason about. + related = r.isRelatedTo(t, s, RecursionFlagsBoth, false /*reportErrors*/) + if related == TernaryFalse { + related = r.isRelatedToEx(s, t, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) + } + } else { + // In the invariant case we first compare covariantly, and only when that + // succeeds do we proceed to compare contravariantly. Thus, error elaboration + // will typically be based on the covariant check. + related = r.isRelatedToEx(s, t, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) + if related != TernaryFalse { + related &= r.isRelatedToEx(t, s, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState) + } } } if related == TernaryFalse { diff --git a/internal/checker/services.go b/internal/checker/services.go index 5282377107..fd2f15ee6c 100644 --- a/internal/checker/services.go +++ b/internal/checker/services.go @@ -277,7 +277,7 @@ func (c *Checker) getAugmentedPropertiesOfType(t *Type) []*ast.Symbol { } } } - return c.getNamedMembers(propsByName) + return c.getNamedMembers(propsByName, nil) } func (c *Checker) TryGetMemberInModuleExportsAndProperties(memberName string, moduleSymbol *ast.Symbol) *ast.Symbol { @@ -456,7 +456,7 @@ func (c *Checker) GetExportSpecifierLocalTargetSymbol(node *ast.Node) *ast.Symbo // node should be ExportSpecifier | Identifier switch node.Kind { case ast.KindExportSpecifier: - if node.Parent.Parent.AsExportDeclaration().ModuleSpecifier != nil { + if node.Parent.Parent.ModuleSpecifier() != nil { return c.getExternalModuleMember(node.Parent.Parent, node, false /*dontResolveAlias*/) } name := node.PropertyNameOrName() @@ -805,7 +805,7 @@ func (c *Checker) getTypeOfAssignmentPattern(expr *ast.Node) *Type { if ast.IsPropertyAssignment(expr.Parent) { node := expr.Parent.Parent typeOfParentObjectLiteral := core.OrElse(c.getTypeOfAssignmentPattern(node), c.errorType) - propertyIndex := slices.Index(node.AsObjectLiteralExpression().Properties.Nodes, expr.Parent) + propertyIndex := slices.Index(node.Properties(), expr.Parent) return c.checkObjectLiteralDestructuringPropertyAssignment(node, typeOfParentObjectLiteral, propertyIndex, nil, false) } // Array literal assignment - array destructuring pattern @@ -813,5 +813,9 @@ func (c *Checker) getTypeOfAssignmentPattern(expr *ast.Node) *Type { // [{ property1: p1, property2 }] = elems; typeOfArrayLiteral := core.OrElse(c.getTypeOfAssignmentPattern(node), c.errorType) elementType := core.OrElse(c.checkIteratedTypeOrElementType(IterationUseDestructuring, typeOfArrayLiteral, c.undefinedType, expr.Parent), c.errorType) - return c.checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, slices.Index(node.AsArrayLiteralExpression().Elements.Nodes, expr), elementType, CheckModeNormal) + return c.checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, slices.Index(node.Elements(), expr), elementType, CheckModeNormal) +} + +func (c *Checker) GetSignatureFromDeclaration(node *ast.Node) *Signature { + return c.getSignatureFromDeclaration(node) } diff --git a/internal/checker/stringer_generated.go b/internal/checker/stringer_generated.go index b910ac0979..36a9211dc2 100644 --- a/internal/checker/stringer_generated.go +++ b/internal/checker/stringer_generated.go @@ -17,8 +17,9 @@ const _SignatureKind_name = "SignatureKindCallSignatureKindConstruct" var _SignatureKind_index = [...]uint8{0, 17, 39} func (i SignatureKind) String() string { - if i < 0 || i >= SignatureKind(len(_SignatureKind_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_SignatureKind_index)-1 { return "SignatureKind(" + strconv.FormatInt(int64(i), 10) + ")" } - return _SignatureKind_name[_SignatureKind_index[i]:_SignatureKind_index[i+1]] + return _SignatureKind_name[_SignatureKind_index[idx]:_SignatureKind_index[idx+1]] } diff --git a/internal/checker/symbolaccessibility.go b/internal/checker/symbolaccessibility.go index 92532474aa..a681a5de38 100644 --- a/internal/checker/symbolaccessibility.go +++ b/internal/checker/symbolaccessibility.go @@ -538,7 +538,7 @@ func isUMDExportSymbol(symbol *ast.Symbol) bool { } func isNamespaceReexportDeclaration(node *ast.Node) bool { - return ast.IsNamespaceExport(node) && node.Parent.AsExportDeclaration().ModuleSpecifier != nil + return ast.IsNamespaceExport(node) && node.Parent.ModuleSpecifier() != nil } func (ch *Checker) getCandidateListForSymbol( diff --git a/internal/checker/types.go b/internal/checker/types.go index f9b6f642e1..e7f57e076d 100644 --- a/internal/checker/types.go +++ b/internal/checker/types.go @@ -82,7 +82,7 @@ const TypeFormatFlagsNodeBuilderFlagsMask = TypeFormatFlagsNoTruncation | TypeFo TypeFormatFlagsUseTypeOfFunction | TypeFormatFlagsOmitParameterModifiers | TypeFormatFlagsUseAliasDefinedOutsideCurrentScope | TypeFormatFlagsAllowUniqueESSymbolType | TypeFormatFlagsInTypeAlias | TypeFormatFlagsUseSingleQuotesForStringLiteralType | TypeFormatFlagsNoTypeReduction | TypeFormatFlagsOmitThisParameter -type SymbolFormatFlags int32 +type SymbolFormatFlags uint32 const ( SymbolFormatFlagsNone SymbolFormatFlags = 0 @@ -193,8 +193,10 @@ type TypeAliasLinks struct { // Links for declared types (type parameters, class types, interface types, enums) type DeclaredTypeLinks struct { - declaredType *Type - typeParametersChecked bool + declaredType *Type + interfaceChecked bool + indexSignaturesChecked bool + typeParametersChecked bool } // Links for switch clauses @@ -715,6 +717,10 @@ func (t *Type) IsIndex() bool { return t.flags&TypeFlagsIndex != 0 } +func (t *Type) IsTupleType() bool { + return isTupleType(t) +} + // TypeData type TypeData interface { @@ -924,6 +930,7 @@ type TupleElementInfo struct { } func (t *TupleElementInfo) TupleElementFlags() ElementFlags { return t.flags } +func (t *TupleElementInfo) LabeledDeclaration() *ast.Node { return t.labeledDeclaration } type TupleType struct { InterfaceType @@ -942,6 +949,7 @@ func (t *TupleType) ElementFlags() []ElementFlags { } return elementFlags } +func (t *TupleType) ElementInfos() []TupleElementInfo { return t.elementInfos } // InstantiationExpressionType @@ -1180,6 +1188,10 @@ type TypePredicate struct { t *Type } +func (typePredicate *TypePredicate) Type() *Type { + return typePredicate.t +} + // IndexInfo type IndexInfo struct { @@ -1210,20 +1222,6 @@ const ( type TypeComparer func(s *Type, t *Type, reportErrors bool) Ternary type LanguageFeatureMinimumTargetMap struct { - Classes core.ScriptTarget - ForOf core.ScriptTarget - Generators core.ScriptTarget - Iteration core.ScriptTarget - SpreadElements core.ScriptTarget - RestElements core.ScriptTarget - TaggedTemplates core.ScriptTarget - DestructuringAssignment core.ScriptTarget - BindingPatterns core.ScriptTarget - ArrowFunctions core.ScriptTarget - BlockScopedVariables core.ScriptTarget - ObjectAssign core.ScriptTarget - RegularExpressionFlagsUnicode core.ScriptTarget - RegularExpressionFlagsSticky core.ScriptTarget Exponentiation core.ScriptTarget AsyncFunctions core.ScriptTarget ForAwaitOf core.ScriptTarget @@ -1247,20 +1245,6 @@ type LanguageFeatureMinimumTargetMap struct { } var LanguageFeatureMinimumTarget = LanguageFeatureMinimumTargetMap{ - Classes: core.ScriptTargetES2015, - ForOf: core.ScriptTargetES2015, - Generators: core.ScriptTargetES2015, - Iteration: core.ScriptTargetES2015, - SpreadElements: core.ScriptTargetES2015, - RestElements: core.ScriptTargetES2015, - TaggedTemplates: core.ScriptTargetES2015, - DestructuringAssignment: core.ScriptTargetES2015, - BindingPatterns: core.ScriptTargetES2015, - ArrowFunctions: core.ScriptTargetES2015, - BlockScopedVariables: core.ScriptTargetES2015, - ObjectAssign: core.ScriptTargetES2015, - RegularExpressionFlagsUnicode: core.ScriptTargetES2015, - RegularExpressionFlagsSticky: core.ScriptTargetES2015, Exponentiation: core.ScriptTargetES2016, AsyncFunctions: core.ScriptTargetES2017, ForAwaitOf: core.ScriptTargetES2018, diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index db441acbb2..4008c8219d 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -85,7 +85,7 @@ func isStaticPrivateIdentifierProperty(s *ast.Symbol) bool { } func isEmptyObjectLiteral(expression *ast.Node) bool { - return expression.Kind == ast.KindObjectLiteralExpression && len(expression.AsObjectLiteralExpression().Properties.Nodes) == 0 + return ast.IsObjectLiteralExpression(expression) && len(expression.Properties()) == 0 } type AssignmentKind int32 @@ -136,26 +136,6 @@ func isCompoundLikeAssignment(assignment *ast.Node) bool { return right.Kind == ast.KindBinaryExpression && isShiftOperatorOrHigher(right.AsBinaryExpression().OperatorToken.Kind) } -func getAssertedTypeNode(node *ast.Node) *ast.Node { - switch node.Kind { - case ast.KindAsExpression: - return node.AsAsExpression().Type - case ast.KindSatisfiesExpression: - return node.AsSatisfiesExpression().Type - case ast.KindTypeAssertionExpression: - return node.AsTypeAssertion().Type - } - panic("Unhandled case in getAssertedTypeNode") -} - -func isConstAssertion(node *ast.Node) bool { - switch node.Kind { - case ast.KindAsExpression, ast.KindTypeAssertionExpression: - return isConstTypeReference(getAssertedTypeNode(node)) - } - return false -} - func isConstTypeReference(node *ast.Node) bool { return ast.IsTypeReferenceNode(node) && len(node.TypeArguments()) == 0 && ast.IsIdentifier(node.AsTypeReferenceNode().TypeName) && node.AsTypeReferenceNode().TypeName.Text() == "const" } @@ -189,20 +169,6 @@ func IsInTypeQuery(node *ast.Node) bool { }) != nil } -func getNameFromImportDeclaration(node *ast.Node) *ast.Node { - switch node.Kind { - case ast.KindImportSpecifier: - return node.AsImportSpecifier().Name() - case ast.KindNamespaceImport: - return node.AsNamespaceImport().Name() - case ast.KindImportClause: - return node.AsImportClause().Name() - case ast.KindImportEqualsDeclaration: - return node.AsImportEqualsDeclaration().Name() - } - return nil -} - func nodeCanBeDecorated(useLegacyDecorators bool, node *ast.Node, parent *ast.Node, grandparent *ast.Node) bool { // private names cannot be used with decorators yet if useLegacyDecorators && node.Name() != nil && ast.IsPrivateIdentifier(node.Name()) { @@ -257,7 +223,7 @@ func isShorthandAmbientModuleSymbol(moduleSymbol *ast.Symbol) bool { func isShorthandAmbientModule(node *ast.Node) bool { // The only kind of module that can be missing a body is a shorthand ambient module. - return node != nil && node.Kind == ast.KindModuleDeclaration && node.AsModuleDeclaration().Body == nil + return node != nil && node.Kind == ast.KindModuleDeclaration && node.Body() == nil } func getAliasDeclarationFromName(node *ast.Node) *ast.Node { @@ -283,7 +249,7 @@ func entityNameToString(name *ast.Node) string { case ast.KindQualifiedName: return entityNameToString(name.AsQualifiedName().Left) + "." + entityNameToString(name.AsQualifiedName().Right) case ast.KindPropertyAccessExpression: - return entityNameToString(name.AsPropertyAccessExpression().Expression) + "." + entityNameToString(name.AsPropertyAccessExpression().Name()) + return entityNameToString(name.Expression()) + "." + entityNameToString(name.AsPropertyAccessExpression().Name()) case ast.KindJsxNamespacedName: return entityNameToString(name.AsJsxNamespacedName().Namespace) + ":" + entityNameToString(name.AsJsxNamespacedName().Name()) } @@ -299,12 +265,12 @@ func getContainingQualifiedNameNode(node *ast.Node) *ast.Node { func isSideEffectImport(node *ast.Node) bool { ancestor := ast.FindAncestor(node, ast.IsImportDeclaration) - return ancestor != nil && ancestor.AsImportDeclaration().ImportClause == nil + return ancestor != nil && ancestor.ImportClause() == nil } func getExternalModuleRequireArgument(node *ast.Node) *ast.Node { if ast.IsVariableDeclarationInitializedToRequire(node) { - return node.AsVariableDeclaration().Initializer.AsCallExpression().Arguments.Nodes[0] + return node.Initializer().Arguments()[0] } return nil } @@ -368,27 +334,11 @@ func isExclamationToken(node *ast.Node) bool { } func isOptionalDeclaration(declaration *ast.Node) bool { - switch declaration.Kind { - case ast.KindParameter: - return declaration.AsParameterDeclaration().QuestionToken != nil - case ast.KindPropertyDeclaration: - return ast.IsQuestionToken(declaration.AsPropertyDeclaration().PostfixToken) - case ast.KindPropertySignature: - return ast.IsQuestionToken(declaration.AsPropertySignatureDeclaration().PostfixToken) - case ast.KindMethodDeclaration: - return ast.IsQuestionToken(declaration.AsMethodDeclaration().PostfixToken) - case ast.KindMethodSignature: - return ast.IsQuestionToken(declaration.AsMethodSignatureDeclaration().PostfixToken) - case ast.KindPropertyAssignment: - return ast.IsQuestionToken(declaration.AsPropertyAssignment().PostfixToken) - case ast.KindShorthandPropertyAssignment: - return ast.IsQuestionToken(declaration.AsShorthandPropertyAssignment().PostfixToken) - } - return false + return ast.HasQuestionToken(declaration) } func isEmptyArrayLiteral(expression *ast.Node) bool { - return ast.IsArrayLiteralExpression(expression) && len(expression.AsArrayLiteralExpression().Elements.Nodes) == 0 + return ast.IsArrayLiteralExpression(expression) && len(expression.Elements()) == 0 } func declarationBelongsToPrivateAmbientMember(declaration *ast.Node) bool { @@ -1021,6 +971,13 @@ func IsKnownSymbol(symbol *ast.Symbol) bool { return isLateBoundName(symbol.Name) } +func IsPrivateIdentifierSymbol(symbol *ast.Symbol) bool { + if symbol == nil { + return false + } + return strings.HasPrefix(symbol.Name, ast.InternalSymbolNamePrefix+"#") +} + func isLateBoundName(name string) bool { return len(name) >= 2 && name[0] == '\xfe' && name[1] == '@' } @@ -1063,7 +1020,7 @@ func isThisInitializedObjectBindingExpression(node *ast.Node) bool { } func isThisInitializedDeclaration(node *ast.Node) bool { - return node != nil && ast.IsVariableDeclaration(node) && node.AsVariableDeclaration().Initializer != nil && node.AsVariableDeclaration().Initializer.Kind == ast.KindThisKeyword + return node != nil && ast.IsVariableDeclaration(node) && node.Initializer() != nil && node.Initializer().Kind == ast.KindThisKeyword } func isInfinityOrNaNString(name string) bool { @@ -1111,43 +1068,8 @@ func isNonNullAccess(node *ast.Node) bool { return ast.IsAccessExpression(node) && ast.IsNonNullExpression(node.Expression()) } -func getTagNameOfNode(node *ast.Node) *ast.Node { - switch node.Kind { - case ast.KindJsxOpeningElement: - return node.AsJsxOpeningElement().TagName - case ast.KindJsxClosingElement: - return node.AsJsxClosingElement().TagName - case ast.KindJsxSelfClosingElement: - return node.AsJsxSelfClosingElement().TagName - } - panic("Unhandled case in getTagNameOfNode") -} - func getBindingElementPropertyName(node *ast.Node) *ast.Node { - name := node.AsBindingElement().PropertyName - if name != nil { - return name - } - return node.Name() -} - -func hasContextSensitiveParameters(node *ast.Node) bool { - // Functions with type parameters are not context sensitive. - if node.TypeParameters() == nil { - // Functions with any parameters that lack type annotations are context sensitive. - if core.Some(node.Parameters(), func(p *ast.Node) bool { return p.Type() == nil }) { - return true - } - if !ast.IsArrowFunction(node) { - // If the first parameter is not an explicit 'this' parameter, then the function has - // an implicit 'this' parameter which is subject to contextual typing. - parameter := core.FirstOrNil(node.Parameters()) - if parameter == nil || !ast.IsThisParameter(parameter) { - return true - } - } - } - return false + return node.PropertyNameOrName() } func isCallChain(node *ast.Node) bool { @@ -1173,16 +1095,10 @@ func isSuperProperty(node *ast.Node) bool { func getMembersOfDeclaration(node *ast.Node) []*ast.Node { switch node.Kind { - case ast.KindInterfaceDeclaration: - return node.AsInterfaceDeclaration().Members.Nodes - case ast.KindClassDeclaration: - return node.AsClassDeclaration().Members.Nodes - case ast.KindClassExpression: - return node.AsClassExpression().Members.Nodes - case ast.KindTypeLiteral: - return node.AsTypeLiteralNode().Members.Nodes + case ast.KindInterfaceDeclaration, ast.KindClassDeclaration, ast.KindClassExpression, ast.KindTypeLiteral: + return node.Members() case ast.KindObjectLiteralExpression: - return node.AsObjectLiteralExpression().Properties.Nodes + return node.Properties() } return nil } @@ -1229,7 +1145,7 @@ func isInRightSideOfImportOrExportAssignment(node *ast.EntityName) bool { } return node.Parent.Kind == ast.KindImportEqualsDeclaration && node.Parent.AsImportEqualsDeclaration().ModuleReference == node || - (node.Parent.Kind == ast.KindExportAssignment || node.Parent.Kind == ast.KindJSExportAssignment) && node.Parent.AsExportAssignment().Expression == node + (node.Parent.Kind == ast.KindExportAssignment || node.Parent.Kind == ast.KindJSExportAssignment) && node.Parent.Expression() == node } func isJsxIntrinsicTagName(tagName *ast.Node) bool { @@ -1430,10 +1346,8 @@ func minAndMax[T any](slice []T, getValue func(value T) int) (int, int) { func getNonModifierTokenRangeOfNode(node *ast.Node) core.TextRange { pos := node.Pos() - if node.Modifiers() != nil { - if last := ast.FindLastVisibleNode(node.Modifiers().Nodes); last != nil { - pos = last.Pos() - } + if last := ast.FindLastVisibleNode(node.ModifierNodes()); last != nil { + pos = last.Pos() } return scanner.GetRangeOfTokenAtPosition(ast.GetSourceFileOfNode(node), pos) } @@ -1858,3 +1772,92 @@ func nodeStartsNewLexicalEnvironment(node *ast.Node) bool { } return false } + +// Determines whether a did-you-mean error should be a suggestion in an unchecked JS file. +// Only applies to unchecked JS files without checkJS, // @ts-check or // @ts-nocheck +// It does not suggest when the suggestion: +// - Is from a global file that is different from the reference file, or +// - (optionally) Is a class, or is a this.x property access expression +func (c *Checker) isUncheckedJSSuggestion(node *ast.Node, suggestion *ast.Symbol, excludeClasses bool) bool { + file := ast.GetSourceFileOfNode(node) + if file != nil { + if c.compilerOptions.CheckJs.IsUnknown() && file.CheckJsDirective == nil && (file.ScriptKind == core.ScriptKindJS || file.ScriptKind == core.ScriptKindJSX) { + var declarationFile *ast.SourceFile + if suggestion != nil { + if firstDeclaration := core.FirstOrNil(suggestion.Declarations); firstDeclaration != nil { + declarationFile = ast.GetSourceFileOfNode(firstDeclaration) + } + } + suggestionHasNoExtendsOrDecorators := suggestion == nil || + suggestion.ValueDeclaration == nil || + !ast.IsClassLike(suggestion.ValueDeclaration) || + len(ast.GetExtendsHeritageClauseElements(suggestion.ValueDeclaration)) != 0 || + classOrConstructorParameterIsDecorated(suggestion.ValueDeclaration) + return !(file != declarationFile && declarationFile != nil && ast.IsGlobalSourceFile(declarationFile.AsNode())) && + !(excludeClasses && suggestion != nil && suggestion.Flags&ast.SymbolFlagsClass != 0 && suggestionHasNoExtendsOrDecorators) && + !(node != nil && excludeClasses && ast.IsPropertyAccessExpression(node) && node.Expression().Kind == ast.KindThisKeyword && suggestionHasNoExtendsOrDecorators) + } + } + return false +} + +func classOrConstructorParameterIsDecorated(node *ast.Node) bool { + if nodeIsDecorated(node, nil, nil) { + return true + } + constructor := ast.GetFirstConstructorWithBody(node) + return constructor != nil && childIsDecorated(constructor, node) +} + +func nodeIsDecorated(node *ast.Node, parent *ast.Node, grandparent *ast.Node) bool { + return ast.HasDecorators(node) && nodeCanBeDecorated(false, node, parent, grandparent) +} + +func nodeOrChildIsDecorated(node *ast.Node, parent *ast.Node, grandparent *ast.Node) bool { + return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent) +} + +func childIsDecorated(node *ast.Node, parent *ast.Node) bool { + switch node.Kind { + case ast.KindClassDeclaration, ast.KindClassExpression: + return core.Some(node.Members(), func(m *ast.Node) bool { + return nodeOrChildIsDecorated(m, node, parent) + }) + case ast.KindMethodDeclaration, + ast.KindSetAccessor, + ast.KindConstructor: + return core.Some(node.Parameters(), func(p *ast.Node) bool { + return nodeIsDecorated(p, node, parent) + }) + default: + return false + } +} + +// Returns if a type is or consists of a JSLiteral object type +// In addition to objects which are directly literals, +// * unions where every element is a jsliteral +// * intersections where at least one element is a jsliteral +// * and instantiable types constrained to a jsliteral +// Should all count as literals and not print errors on access or assignment of possibly existing properties. +// This mirrors the behavior of the index signature propagation, to which this behaves similarly (but doesn't affect assignability or inference). +func (c *Checker) isJSLiteralType(t *Type) bool { + if c.noImplicitAny { + return false + // Flag is meaningless under `noImplicitAny` mode + } + if t.objectFlags&ObjectFlagsJSLiteral != 0 { + return true + } + if t.flags&TypeFlagsUnion != 0 { + return core.Every(t.AsUnionType().types, c.isJSLiteralType) + } + if t.flags&TypeFlagsIntersection != 0 { + return core.Some(t.AsIntersectionType().types, c.isJSLiteralType) + } + if t.flags&TypeFlagsInstantiable != 0 { + constraint := c.getResolvedBaseConstraint(t, nil) + return constraint != t && c.isJSLiteralType(constraint) + } + return false +} diff --git a/internal/collections/syncmap.go b/internal/collections/syncmap.go index 9a020bc23e..c191430535 100644 --- a/internal/collections/syncmap.go +++ b/internal/collections/syncmap.go @@ -13,7 +13,7 @@ type SyncMap[K comparable, V any] struct { func (s *SyncMap[K, V]) Load(key K) (value V, ok bool) { val, ok := s.m.Load(key) - if !ok { + if !ok || val == nil { return value, ok } return val.(V), true @@ -25,6 +25,10 @@ func (s *SyncMap[K, V]) Store(key K, value V) { func (s *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) { actualAny, loaded := s.m.LoadOrStore(key, value) + if actualAny == nil { + return actual, loaded + } + return actualAny.(V), loaded } @@ -38,7 +42,17 @@ func (s *SyncMap[K, V]) Clear() { func (s *SyncMap[K, V]) Range(f func(key K, value V) bool) { s.m.Range(func(key, value any) bool { - return f(key.(K), value.(V)) + var k K + if key != nil { + k = key.(K) + } + + var v V + if value != nil { + v = value.(V) + } + + return f(k, v) }) } diff --git a/internal/collections/syncmap_test.go b/internal/collections/syncmap_test.go new file mode 100644 index 0000000000..5fe7c578f4 --- /dev/null +++ b/internal/collections/syncmap_test.go @@ -0,0 +1,32 @@ +package collections_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/collections" + "gotest.tools/v3/assert" +) + +func TestSyncMapWithNil(t *testing.T) { + t.Parallel() + + var m collections.SyncMap[string, any] + + got1, ok := m.Load("foo") + assert.Assert(t, !ok) + assert.Equal(t, got1, nil) + + m.Store("foo", nil) + + got2, ok := m.Load("foo") + assert.Assert(t, ok) + assert.Equal(t, got2, nil) + + too, loaded := m.LoadOrStore("too", nil) + assert.Assert(t, !loaded) + assert.Equal(t, too, nil) + + m.Range(func(k string, v any) bool { + return true + }) +} diff --git a/internal/compiler/checkerpool.go b/internal/compiler/checkerpool.go index 9b32992f20..50025dd7ed 100644 --- a/internal/compiler/checkerpool.go +++ b/internal/compiler/checkerpool.go @@ -12,9 +12,11 @@ import ( ) type CheckerPool interface { + Count() int GetChecker(ctx context.Context) (*checker.Checker, func()) GetCheckerForFile(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) - GetAllCheckers(ctx context.Context) ([]*checker.Checker, func()) + GetCheckerForFileExclusive(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) + ForEachCheckerParallel(ctx context.Context, cb func(idx int, c *checker.Checker)) Files(checker *checker.Checker) iter.Seq[*ast.SourceFile] } @@ -24,6 +26,7 @@ type checkerPool struct { createCheckersOnce sync.Once checkers []*checker.Checker + locks []*sync.Mutex fileAssociations map[*ast.SourceFile]*checker.Checker } @@ -34,17 +37,32 @@ func newCheckerPool(checkerCount int, program *Program) *checkerPool { program: program, checkerCount: checkerCount, checkers: make([]*checker.Checker, checkerCount), + locks: make([]*sync.Mutex, checkerCount), } return pool } +func (p *checkerPool) Count() int { + return p.checkerCount +} + func (p *checkerPool) GetCheckerForFile(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) { p.createCheckers() checker := p.fileAssociations[file] return checker, noop } +func (p *checkerPool) GetCheckerForFileExclusive(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) { + c, done := p.GetCheckerForFile(ctx, file) + idx := slices.Index(p.checkers, c) + p.locks[idx].Lock() + return c, sync.OnceFunc(func() { + p.locks[idx].Unlock() + done() + }) +} + func (p *checkerPool) GetChecker(ctx context.Context) (*checker.Checker, func()) { p.createCheckers() checker := p.checkers[0] @@ -56,7 +74,7 @@ func (p *checkerPool) createCheckers() { wg := core.NewWorkGroup(p.program.SingleThreaded()) for i := range p.checkerCount { wg.Queue(func() { - p.checkers[i] = checker.NewChecker(p.program) + p.checkers[i], p.locks[i] = checker.NewChecker(p.program) }) } @@ -69,9 +87,19 @@ func (p *checkerPool) createCheckers() { }) } -func (p *checkerPool) GetAllCheckers(ctx context.Context) ([]*checker.Checker, func()) { +// Runs `cb` for each checker in the pool concurrently, locking and unlocking checker mutexes as it goes, +// making it safe to call `ForEachCheckerParallel` from many threads simultaneously. +func (p *checkerPool) ForEachCheckerParallel(ctx context.Context, cb func(idx int, c *checker.Checker)) { p.createCheckers() - return p.checkers, noop + wg := core.NewWorkGroup(p.program.SingleThreaded()) + for idx, checker := range p.checkers { + wg.Queue(func() { + p.locks[idx].Lock() + defer p.locks[idx].Unlock() + cb(idx, checker) + }) + } + wg.RunAndWait() } func (p *checkerPool) Files(checker *checker.Checker) iter.Seq[*ast.SourceFile] { diff --git a/internal/compiler/emitter.go b/internal/compiler/emitter.go index 62f3e16285..51fd655120 100644 --- a/internal/compiler/emitter.go +++ b/internal/compiler/emitter.go @@ -125,6 +125,8 @@ func getScriptTransformers(emitContext *printer.EmitContext, host printer.EmitHo tx = append(tx, downleveler) } + tx = append(tx, estransforms.NewUseStrictTransformer(&opts)) + // transform module syntax tx = append(tx, getModuleTransformer(&opts)) diff --git a/internal/compiler/fileInclude.go b/internal/compiler/fileInclude.go index 68687e5e03..13aeba9cd8 100644 --- a/internal/compiler/fileInclude.go +++ b/internal/compiler/fileInclude.go @@ -29,7 +29,7 @@ const ( fileIncludeKindAutomaticTypeDirectiveFile ) -type fileIncludeReason struct { +type FileIncludeReason struct { kind fileIncludeKind data any @@ -81,28 +81,28 @@ type automaticTypeDirectiveFileData struct { packageId module.PackageId } -func (r *fileIncludeReason) asIndex() int { +func (r *FileIncludeReason) asIndex() int { return r.data.(int) } -func (r *fileIncludeReason) asLibFileIndex() (int, bool) { +func (r *FileIncludeReason) asLibFileIndex() (int, bool) { index, ok := r.data.(int) return index, ok } -func (r *fileIncludeReason) isReferencedFile() bool { +func (r *FileIncludeReason) isReferencedFile() bool { return r != nil && r.kind <= fileIncludeKindLibReferenceDirective } -func (r *fileIncludeReason) asReferencedFileData() *referencedFileData { +func (r *FileIncludeReason) asReferencedFileData() *referencedFileData { return r.data.(*referencedFileData) } -func (r *fileIncludeReason) asAutomaticTypeDirectiveFileData() *automaticTypeDirectiveFileData { +func (r *FileIncludeReason) asAutomaticTypeDirectiveFileData() *automaticTypeDirectiveFileData { return r.data.(*automaticTypeDirectiveFileData) } -func (r *fileIncludeReason) getReferencedLocation(program *Program) *referenceFileLocation { +func (r *FileIncludeReason) getReferencedLocation(program *Program) *referenceFileLocation { ref := r.asReferencedFileData() file := program.GetSourceFileByPath(ref.file) switch r.kind { @@ -153,7 +153,7 @@ func (r *fileIncludeReason) getReferencedLocation(program *Program) *referenceFi } } -func (r *fileIncludeReason) toDiagnostic(program *Program, relativeFileName bool) *ast.Diagnostic { +func (r *FileIncludeReason) toDiagnostic(program *Program, relativeFileName bool) *ast.Diagnostic { if relativeFileName { r.relativeFileNameDiagOnce.Do(func() { r.relativeFileNameDiag = r.computeDiagnostic(program, func(fileName string) string { @@ -169,7 +169,7 @@ func (r *fileIncludeReason) toDiagnostic(program *Program, relativeFileName bool } } -func (r *fileIncludeReason) computeDiagnostic(program *Program, toFileName func(string) string) *ast.Diagnostic { +func (r *FileIncludeReason) computeDiagnostic(program *Program, toFileName func(string) string) *ast.Diagnostic { if r.isReferencedFile() { return r.computeReferenceFileDiagnostic(program, toFileName) } @@ -229,7 +229,7 @@ func (r *fileIncludeReason) computeDiagnostic(program *Program, toFileName func( } } -func (r *fileIncludeReason) computeReferenceFileDiagnostic(program *Program, toFileName func(string) string) *ast.Diagnostic { +func (r *FileIncludeReason) computeReferenceFileDiagnostic(program *Program, toFileName func(string) string) *ast.Diagnostic { referenceLocation := program.includeProcessor.getReferenceLocation(r, program) referenceText := referenceLocation.text() switch r.kind { @@ -268,7 +268,7 @@ func (r *fileIncludeReason) computeReferenceFileDiagnostic(program *Program, toF } } -func (r *fileIncludeReason) toRelatedInfo(program *Program) *ast.Diagnostic { +func (r *FileIncludeReason) toRelatedInfo(program *Program) *ast.Diagnostic { if r.isReferencedFile() { return r.computeReferenceFileRelatedInfo(program) } @@ -321,7 +321,7 @@ func (r *fileIncludeReason) toRelatedInfo(program *Program) *ast.Diagnostic { return nil } -func (r *fileIncludeReason) computeReferenceFileRelatedInfo(program *Program) *ast.Diagnostic { +func (r *FileIncludeReason) computeReferenceFileRelatedInfo(program *Program) *ast.Diagnostic { referenceLocation := program.includeProcessor.getReferenceLocation(r, program) if referenceLocation.isSynthetic { return nil diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index b369c2bdaf..d82f7d3aef 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -18,7 +18,7 @@ import ( type libResolution struct { libraryName string resolution *module.ResolvedModule - trace []string + trace []module.DiagAndArgs } type LibFile struct { @@ -64,7 +64,6 @@ type processedFiles struct { importHelpersImportSpecifiers map[tspath.Path]*ast.Node libFiles map[tspath.Path]*LibFile // List of present unsupported extensions - unsupportedExtensions []string sourceFilesFoundSearchingNodeModules collections.Set[tspath.Path] includeProcessor *includeProcessor // if file was included using source file and its output is actually part of program @@ -106,19 +105,19 @@ func processAllProgramFiles( loader.addProjectReferenceTasks(singleThreaded) loader.resolver = loader.opts.Host.MakeResolver(loader.projectReferenceFileMapper.host, compilerOptions, opts.TypingsLocation, opts.ProjectName) for index, rootFile := range rootFiles { - loader.addRootTask(rootFile, nil, &fileIncludeReason{kind: fileIncludeKindRootFile, data: index}) + loader.addRootTask(rootFile, nil, &FileIncludeReason{kind: fileIncludeKindRootFile, data: index}) } if len(rootFiles) > 0 && compilerOptions.NoLib.IsFalseOrUnknown() { if compilerOptions.Lib == nil { name := tsoptions.GetDefaultLibFileName(compilerOptions) libFile := loader.pathForLibFile(name) - loader.addRootTask(libFile.path, libFile, &fileIncludeReason{kind: fileIncludeKindLibFile}) + loader.addRootTask(libFile.path, libFile, &FileIncludeReason{kind: fileIncludeKindLibFile}) } else { for index, lib := range compilerOptions.Lib { if name, ok := tsoptions.GetLibFileName(lib); ok { libFile := loader.pathForLibFile(name) - loader.addRootTask(libFile.path, libFile, &fileIncludeReason{kind: fileIncludeKindLibFile, data: index}) + loader.addRootTask(libFile.path, libFile, &FileIncludeReason{kind: fileIncludeKindLibFile, data: index}) } // !!! error on unknown name } @@ -142,7 +141,7 @@ func processAllProgramFiles( libFiles := make([]*ast.SourceFile, 0, totalFileCount) // totalFileCount here since we append files to it later to construct the final list filesByPath := make(map[tspath.Path]*ast.SourceFile, totalFileCount) - loader.includeProcessor.fileIncludeReasons = make(map[tspath.Path][]*fileIncludeReason, totalFileCount) + loader.includeProcessor.fileIncludeReasons = make(map[tspath.Path][]*FileIncludeReason, totalFileCount) var outputFileToProjectReferenceSource map[tspath.Path]string if !opts.canUseProjectReferenceSource() { outputFileToProjectReferenceSource = make(map[tspath.Path]string, totalFileCount) @@ -152,7 +151,6 @@ func processAllProgramFiles( sourceFileMetaDatas := make(map[tspath.Path]ast.SourceFileMetaData, totalFileCount) var jsxRuntimeImportSpecifiers map[tspath.Path]*jsxRuntimeImportSpecifier var importHelpersImportSpecifiers map[tspath.Path]*ast.Node - var unsupportedExtensions []string var sourceFilesFoundSearchingNodeModules collections.Set[tspath.Path] libFilesMap := make(map[tspath.Path]*LibFile, libFileCount) @@ -217,10 +215,6 @@ func processAllProgramFiles( } importHelpersImportSpecifiers[path] = task.importHelpersImportSpecifier } - extension := tspath.TryGetExtensionFromPath(file.FileName()) - if slices.Contains(tspath.SupportedJSExtensionsFlat, extension) { - unsupportedExtensions = core.AppendIfUnique(unsupportedExtensions, extension) - } if task.fromExternalLibrary { sourceFilesFoundSearchingNodeModules.Add(path) } @@ -237,7 +231,7 @@ func processAllProgramFiles( module.ModeAwareCacheKey{Name: value.libraryName, Mode: core.ModuleKindCommonJS}: value.resolution, } for _, trace := range value.trace { - opts.Host.Trace(trace) + opts.Host.Trace(trace.Message, trace.Args...) } } @@ -251,7 +245,6 @@ func processAllProgramFiles( sourceFileMetaDatas: sourceFileMetaDatas, jsxRuntimeImportSpecifiers: jsxRuntimeImportSpecifiers, importHelpersImportSpecifiers: importHelpersImportSpecifiers, - unsupportedExtensions: unsupportedExtensions, sourceFilesFoundSearchingNodeModules: sourceFilesFoundSearchingNodeModules, libFiles: libFilesMap, missingFiles: missingFiles, @@ -264,7 +257,7 @@ func (p *fileLoader) toPath(file string) tspath.Path { return tspath.ToPath(file, p.opts.Host.GetCurrentDirectory(), p.opts.Host.FS().UseCaseSensitiveFileNames()) } -func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReason *fileIncludeReason) { +func (p *fileLoader) addRootTask(fileName string, libFile *LibFile, includeReason *FileIncludeReason) { absPath := tspath.GetNormalizedAbsolutePath(fileName, p.opts.Host.GetCurrentDirectory()) if core.Tristate.IsTrue(p.opts.Config.CompilerOptions().AllowNonTsExtensions) || slices.Contains(p.supportedExtensions, tspath.TryGetExtensionFromPath(absPath)) { p.rootTasks = append(p.rootTasks, &parseTask{ @@ -293,7 +286,7 @@ func (p *fileLoader) addAutomaticTypeDirectiveTasks() { func (p *fileLoader) resolveAutomaticTypeDirectives(containingFileName string) ( toParse []resolvedRef, typeResolutionsInFile module.ModeAwareCache[*module.ResolvedTypeReferenceDirective], - typeResolutionsTrace []string, + typeResolutionsTrace []module.DiagAndArgs, ) { automaticTypeDirectiveNames := module.GetAutomaticTypeDirectiveNames(p.opts.Config.CompilerOptions(), p.opts.Host) if len(automaticTypeDirectiveNames) != 0 { @@ -309,7 +302,7 @@ func (p *fileLoader) resolveAutomaticTypeDirectives(containingFileName string) ( fileName: resolved.ResolvedFileName, increaseDepth: resolved.IsExternalLibraryImport, elideOnDepth: false, - includeReason: &fileIncludeReason{ + includeReason: &FileIncludeReason{ kind: fileIncludeKindAutomaticTypeDirectiveFile, data: &automaticTypeDirectiveFileData{name, resolved.PackageId}, }, @@ -350,7 +343,7 @@ func (p *fileLoader) addProjectReferenceTasks(singleThreaded bool) { for _, fileName := range resolved.FileNames() { p.rootTasks = append(p.rootTasks, &parseTask{ normalizedFilePath: fileName, - includeReason: &fileIncludeReason{ + includeReason: &FileIncludeReason{ kind: fileIncludeKindSourceFromProjectReference, data: index, }, @@ -361,7 +354,7 @@ func (p *fileLoader) addProjectReferenceTasks(singleThreaded bool) { if outputDts != "" { p.rootTasks = append(p.rootTasks, &parseTask{ normalizedFilePath: outputDts, - includeReason: &fileIncludeReason{ + includeReason: &FileIncludeReason{ kind: fileIncludeKindOutputFromProjectReference, data: index, }, @@ -438,7 +431,7 @@ func (p *fileLoader) resolveTripleslashPathReference(moduleName string, containi } return resolvedRef{ fileName: tspath.NormalizePath(referencedFileName), - includeReason: &fileIncludeReason{ + includeReason: &FileIncludeReason{ kind: fileIncludeKindReferenceFile, data: &referencedFileData{ file: p.toPath(containingFile), @@ -456,13 +449,13 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) { meta := t.metadata typeResolutionsInFile := make(module.ModeAwareCache[*module.ResolvedTypeReferenceDirective], len(file.TypeReferenceDirectives)) - var typeResolutionsTrace []string + var typeResolutionsTrace []module.DiagAndArgs for index, ref := range file.TypeReferenceDirectives { redirect, fileName := p.projectReferenceFileMapper.getRedirectForResolution(file) resolutionMode := getModeForTypeReferenceDirectiveInFile(ref, file, meta, module.GetCompilerOptionsWithRedirect(p.opts.Config.CompilerOptions(), redirect)) resolved, trace := p.resolver.ResolveTypeReferenceDirective(ref.FileName, fileName, resolutionMode, redirect) typeResolutionsInFile[module.ModeAwareCacheKey{Name: ref.FileName, Mode: resolutionMode}] = resolved - includeReason := &fileIncludeReason{ + includeReason := &FileIncludeReason{ kind: fileIncludeKindTypeReferenceDirective, data: &referencedFileData{ file: t.path, @@ -534,7 +527,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) { if len(moduleNames) != 0 { resolutionsInFile := make(module.ModeAwareCache[*module.ResolvedModule], len(moduleNames)) - var resolutionsTrace []string + var resolutionsTrace []module.DiagAndArgs for index, entry := range moduleNames { moduleName := entry.Text() @@ -585,7 +578,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) { increaseDepth: resolvedModule.IsExternalLibraryImport, elideOnDepth: isJsFileFromNodeModules, isFromExternalLibrary: resolvedModule.IsExternalLibraryImport, - includeReason: &fileIncludeReason{ + includeReason: &FileIncludeReason{ kind: fileIncludeKindImport, data: &referencedFileData{ file: t.path, @@ -654,16 +647,22 @@ func getLibraryNameFromLibFileName(libFileName string) string { // lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable // lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown components := strings.Split(libFileName, ".") - var path string + var path strings.Builder + path.WriteString("@typescript/lib-") if len(components) > 1 { - path = components[1] + path.WriteString(components[1]) } i := 2 for i < len(components) && components[i] != "" && components[i] != "d" { - path += core.IfElse(i == 2, "/", "-") + components[i] + if i == 2 { + path.WriteByte('/') + } else { + path.WriteByte('-') + } + path.WriteString(components[i]) i++ } - return "@typescript/lib-" + path + return path.String() } func getInferredLibraryNameResolveFrom(options *core.CompilerOptions, currentDirectory string, libFileName string) string { diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index d0fb499a67..554ca47327 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -21,13 +21,13 @@ type parseTask struct { subTasks []*parseTask loaded bool isForAutomaticTypeDirective bool - includeReason *fileIncludeReason + includeReason *FileIncludeReason metadata ast.SourceFileMetaData resolutionsInFile module.ModeAwareCache[*module.ResolvedModule] - resolutionsTrace []string + resolutionsTrace []module.DiagAndArgs typeResolutionsInFile module.ModeAwareCache[*module.ResolvedTypeReferenceDirective] - typeResolutionsTrace []string + typeResolutionsTrace []module.DiagAndArgs resolutionDiagnostics []*ast.Diagnostic importHelpersImportSpecifier *ast.Node jsxRuntimeImportSpecifier *jsxRuntimeImportSpecifier @@ -39,7 +39,7 @@ type parseTask struct { fromExternalLibrary bool loadedTask *parseTask - allIncludeReasons []*fileIncludeReason + allIncludeReasons []*FileIncludeReason } func (t *parseTask) FileName() string { @@ -92,7 +92,7 @@ func (t *parseTask) load(loader *fileLoader) { if compilerOptions.NoLib != core.TSTrue { for index, lib := range file.LibReferenceDirectives { - includeReason := &fileIncludeReason{ + includeReason := &FileIncludeReason{ kind: fileIncludeKindLibReferenceDirective, data: &referencedFileData{ file: t.path, @@ -142,7 +142,7 @@ type resolvedRef struct { increaseDepth bool elideOnDepth bool isFromExternalLibrary bool - includeReason *fileIncludeReason + includeReason *FileIncludeReason } func (t *parseTask) addSubTask(ref resolvedRef, libFile *LibFile) { @@ -255,10 +255,10 @@ func (w *filesParser) collectWorker(loader *fileLoader, tasks []*parseTask, iter continue } for _, trace := range task.typeResolutionsTrace { - loader.opts.Host.Trace(trace) + loader.opts.Host.Trace(trace.Message, trace.Args...) } for _, trace := range task.resolutionsTrace { - loader.opts.Host.Trace(trace) + loader.opts.Host.Trace(trace.Message, trace.Args...) } if subTasks := task.subTasks; len(subTasks) > 0 { w.collectWorker(loader, subTasks, iterate, seen) @@ -267,14 +267,14 @@ func (w *filesParser) collectWorker(loader *fileLoader, tasks []*parseTask, iter } } -func (w *filesParser) addIncludeReason(loader *fileLoader, task *parseTask, reason *fileIncludeReason) { +func (w *filesParser) addIncludeReason(loader *fileLoader, task *parseTask, reason *FileIncludeReason) { if task.redirectedParseTask != nil { w.addIncludeReason(loader, task.redirectedParseTask, reason) } else if task.loaded { if existing, ok := loader.includeProcessor.fileIncludeReasons[task.path]; ok { loader.includeProcessor.fileIncludeReasons[task.path] = append(existing, reason) } else { - loader.includeProcessor.fileIncludeReasons[task.path] = []*fileIncludeReason{reason} + loader.includeProcessor.fileIncludeReasons[task.path] = []*FileIncludeReason{reason} } } } diff --git a/internal/compiler/host.go b/internal/compiler/host.go index 0817caeae9..516889830b 100644 --- a/internal/compiler/host.go +++ b/internal/compiler/host.go @@ -3,6 +3,7 @@ package compiler import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -15,7 +16,7 @@ type CompilerHost interface { FS() vfs.FS DefaultLibraryPath() string GetCurrentDirectory() string - Trace(msg string) + Trace(msg *diagnostics.Message, args ...any) GetSourceFile(opts ast.SourceFileParseOptions) *ast.SourceFile GetResolvedProjectReference(fileName string, path tspath.Path) *tsoptions.ParsedCommandLine MakeResolver(host module.ResolutionHost, options *core.CompilerOptions, typingsLocation string, projectName string) module.ResolverInterface @@ -30,7 +31,7 @@ type compilerHost struct { fs vfs.FS defaultLibraryPath string extendedConfigCache tsoptions.ExtendedConfigCache - trace func(msg string) + trace func(msg *diagnostics.Message, args ...any) } func NewCachedFSCompilerHost( @@ -38,7 +39,7 @@ func NewCachedFSCompilerHost( fs vfs.FS, defaultLibraryPath string, extendedConfigCache tsoptions.ExtendedConfigCache, - trace func(msg string), + trace func(msg *diagnostics.Message, args ...any), ) CompilerHost { return NewCompilerHost(currentDirectory, cachedvfs.From(fs), defaultLibraryPath, extendedConfigCache, trace) } @@ -48,10 +49,10 @@ func NewCompilerHost( fs vfs.FS, defaultLibraryPath string, extendedConfigCache tsoptions.ExtendedConfigCache, - trace func(msg string), + trace func(msg *diagnostics.Message, args ...any), ) CompilerHost { if trace == nil { - trace = func(msg string) {} + trace = func(msg *diagnostics.Message, args ...any) {} } return &compilerHost{ currentDirectory: currentDirectory, @@ -74,8 +75,8 @@ func (h *compilerHost) GetCurrentDirectory() string { return h.currentDirectory } -func (h *compilerHost) Trace(msg string) { - h.trace(msg) +func (h *compilerHost) Trace(msg *diagnostics.Message, args ...any) { + h.trace(msg, args...) } func (h *compilerHost) IsNodeSourceFile(path tspath.Path) bool { diff --git a/internal/compiler/includeprocessor.go b/internal/compiler/includeprocessor.go index d865d74fbb..83691f45a1 100644 --- a/internal/compiler/includeprocessor.go +++ b/internal/compiler/includeprocessor.go @@ -12,11 +12,11 @@ import ( ) type includeProcessor struct { - fileIncludeReasons map[tspath.Path][]*fileIncludeReason + fileIncludeReasons map[tspath.Path][]*FileIncludeReason processingDiagnostics []*processingDiagnostic - reasonToReferenceLocation collections.SyncMap[*fileIncludeReason, *referenceFileLocation] - includeReasonToRelatedInfo collections.SyncMap[*fileIncludeReason, *ast.Diagnostic] + reasonToReferenceLocation collections.SyncMap[*FileIncludeReason, *referenceFileLocation] + includeReasonToRelatedInfo collections.SyncMap[*FileIncludeReason, *ast.Diagnostic] redirectAndFileFormat collections.SyncMap[tspath.Path, []*ast.Diagnostic] computedDiagnostics *ast.DiagnosticsCollection computedDiagnosticsOnce sync.Once @@ -59,7 +59,7 @@ func (i *includeProcessor) addProcessingDiagnostic(d ...*processingDiagnostic) { i.processingDiagnostics = append(i.processingDiagnostics, d...) } -func (i *includeProcessor) getReferenceLocation(r *fileIncludeReason, program *Program) *referenceFileLocation { +func (i *includeProcessor) getReferenceLocation(r *FileIncludeReason, program *Program) *referenceFileLocation { if existing, ok := i.reasonToReferenceLocation.Load(r); ok { return existing } @@ -84,7 +84,7 @@ func (i *includeProcessor) getCompilerOptionsObjectLiteralSyntax(program *Progra return i.compilerOptionsSyntax } -func (i *includeProcessor) getRelatedInfo(r *fileIncludeReason, program *Program) *ast.Diagnostic { +func (i *includeProcessor) getRelatedInfo(r *FileIncludeReason, program *Program) *ast.Diagnostic { if existing, ok := i.includeReasonToRelatedInfo.Load(r); ok { return existing } diff --git a/internal/compiler/processingDiagnostic.go b/internal/compiler/processingDiagnostic.go index 83bac967ab..20e5c8d18c 100644 --- a/internal/compiler/processingDiagnostic.go +++ b/internal/compiler/processingDiagnostic.go @@ -23,13 +23,13 @@ type processingDiagnostic struct { data any } -func (d *processingDiagnostic) asFileIncludeReason() *fileIncludeReason { - return d.data.(*fileIncludeReason) +func (d *processingDiagnostic) asFileIncludeReason() *FileIncludeReason { + return d.data.(*FileIncludeReason) } type includeExplainingDiagnostic struct { file tspath.Path - diagnosticReason *fileIncludeReason + diagnosticReason *FileIncludeReason message *diagnostics.Message args []any } @@ -70,13 +70,13 @@ func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program) var includeDetails []*ast.Diagnostic var relatedInfo []*ast.Diagnostic var redirectInfo []*ast.Diagnostic - var preferredLocation *fileIncludeReason - var seenReasons collections.Set[*fileIncludeReason] + var preferredLocation *FileIncludeReason + var seenReasons collections.Set[*FileIncludeReason] if diag.diagnosticReason.isReferencedFile() && !program.includeProcessor.getReferenceLocation(diag.diagnosticReason, program).isSynthetic { preferredLocation = diag.diagnosticReason } - processRelatedInfo := func(includeReason *fileIncludeReason) { + processRelatedInfo := func(includeReason *FileIncludeReason) { if preferredLocation == nil && includeReason.isReferencedFile() && !program.includeProcessor.getReferenceLocation(includeReason, program).isSynthetic { preferredLocation = includeReason } else { @@ -86,7 +86,7 @@ func (d *processingDiagnostic) createDiagnosticExplainingFile(program *Program) } } } - processInclude := func(includeReason *fileIncludeReason) { + processInclude := func(includeReason *FileIncludeReason) { if !seenReasons.AddIfAbsent(includeReason) { return } diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 80cc841a69..086c9ac144 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -8,6 +8,7 @@ import ( "slices" "strings" "sync" + "sync/atomic" "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/ast" @@ -16,6 +17,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/modulespecifiers" "github.com/microsoft/typescript-go/internal/outputpaths" @@ -66,6 +68,10 @@ type Program struct { // Cached unresolved imports for ATA unresolvedImportsOnce sync.Once unresolvedImports *collections.Set[string] + + // Used by workspace/symbol + hasTSFileOnce sync.Once + hasTSFile bool } // FileExists implements checker.Program. @@ -144,10 +150,19 @@ func (p *Program) GetParseFileRedirect(fileName string) string { return p.projectReferenceFileMapper.getParseFileRedirect(ast.NewHasFileName(fileName, p.toPath(fileName))) } -func (p *Program) ForEachResolvedProjectReference( - fn func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int), -) { - p.projectReferenceFileMapper.forEachResolvedProjectReference(fn) +func (p *Program) GetResolvedProjectReferences() []*tsoptions.ParsedCommandLine { + return p.projectReferenceFileMapper.getResolvedProjectReferences() +} + +func (p *Program) RangeResolvedProjectReference(f func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool) bool { + return p.projectReferenceFileMapper.rangeResolvedProjectReference(f) +} + +func (p *Program) RangeResolvedProjectReferenceInChildConfig( + childConfig *tsoptions.ParsedCommandLine, + f func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool, +) bool { + return p.projectReferenceFileMapper.rangeResolvedProjectReferenceInChildConfig(childConfig, f) } // UseCaseSensitiveFileNames implements checker.Program. @@ -263,7 +278,13 @@ func (p *Program) initCheckerPool() { if p.opts.CreateCheckerPool != nil { p.checkerPool = p.opts.CreateCheckerPool(p) } else { - p.checkerPool = newCheckerPool(core.IfElse(p.SingleThreaded(), 1, 4), p) + checkers := 4 + if p.SingleThreaded() { + checkers = 1 + } else if p.Options().Checkers != nil { + checkers = min(max(*p.Options().Checkers, 1), 256) + } + p.checkerPool = newCheckerPool(checkers, p) } } @@ -361,19 +382,13 @@ func (p *Program) BindSourceFiles() { } func (p *Program) CheckSourceFiles(ctx context.Context, files []*ast.SourceFile) { - wg := core.NewWorkGroup(p.SingleThreaded()) - checkers, done := p.checkerPool.GetAllCheckers(ctx) - defer done() - for _, checker := range checkers { - wg.Queue(func() { - for file := range p.checkerPool.Files(checker) { - if files == nil || slices.Contains(files, file) { - checker.CheckSourceFile(ctx, file) - } + p.checkerPool.ForEachCheckerParallel(ctx, func(_ int, checker *checker.Checker) { + for file := range p.checkerPool.Files(checker) { + if files == nil || slices.Contains(files, file) { + checker.CheckSourceFile(ctx, file) } - }) - } - wg.RunAndWait() + } + }) } // Return the type checker associated with the program. @@ -381,8 +396,8 @@ func (p *Program) GetTypeChecker(ctx context.Context) (*checker.Checker, func()) return p.checkerPool.GetChecker(ctx) } -func (p *Program) GetTypeCheckers(ctx context.Context) ([]*checker.Checker, func()) { - return p.checkerPool.GetAllCheckers(ctx) +func (p *Program) ForEachCheckerParallel(ctx context.Context, cb func(idx int, c *checker.Checker)) { + p.checkerPool.ForEachCheckerParallel(ctx, cb) } // Return a checker for the given file. We may have multiple checkers in concurrent scenarios and this @@ -393,6 +408,12 @@ func (p *Program) GetTypeCheckerForFile(ctx context.Context, file *ast.SourceFil return p.checkerPool.GetCheckerForFile(ctx, file) } +// Return a checker for the given file, locked to the current thread to prevent data races from multiple threads +// accessing the same checker. The lock will be released when the `done` function is called. +func (p *Program) GetTypeCheckerForFileExclusive(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) { + return p.checkerPool.GetCheckerForFileExclusive(ctx, file) +} + func (p *Program) GetResolvedModule(file ast.HasFileName, moduleReference string, mode core.ResolutionMode, importAttributeType string) *module.ResolvedModule { if resolutions, ok := p.resolvedModules[file.Path()]; ok { if resolved, ok := resolutions[module.ModeAwareCacheKey{Name: moduleReference, Mode: mode, ImportAttributeType: importAttributeType}]; ok { @@ -674,7 +695,7 @@ func (p *Program) verifyCompilerOptions() { return tsoptions.ForEachPropertyAssignment(pathProp.Initializer.AsObjectLiteralExpression(), key, func(keyProps *ast.PropertyAssignment) *ast.Diagnostic { initializer := keyProps.Initializer if ast.IsArrayLiteralExpression(initializer) { - elements := initializer.AsArrayLiteralExpression().Elements + elements := initializer.ElementList() if elements != nil && len(elements.Nodes) > valueIndex { diag := tsoptions.CreateDiagnosticForNodeInSourceFile(sourceFile(), elements.Nodes[valueIndex], message, args...) p.programDiagnostics = append(p.programDiagnostics, diag) @@ -741,20 +762,10 @@ func (p *Program) verifyCompilerOptions() { createDiagnosticForOptionName(diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib") } - languageVersion := options.GetEmitScriptTarget() - - firstNonAmbientExternalModuleSourceFile := core.Find(p.files, func(f *ast.SourceFile) bool { return ast.IsExternalModule(f) && !f.IsDeclarationFile }) if options.IsolatedModules.IsTrue() || options.VerbatimModuleSyntax.IsTrue() { - if options.Module == core.ModuleKindNone && languageVersion < core.ScriptTargetES2015 && options.IsolatedModules.IsTrue() { - // !!! - // createDiagnosticForOptionName(diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target") - } - if options.PreserveConstEnums.IsFalse() { createDiagnosticForOptionName(diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_0_is_enabled, core.IfElse(options.VerbatimModuleSyntax.IsTrue(), "verbatimModuleSyntax", "isolatedModules"), "preserveConstEnums") } - } else if firstNonAmbientExternalModuleSourceFile != nil && languageVersion < core.ScriptTargetES2015 && options.Module == core.ModuleKindNone { - // !!! } if options.OutDir != "" || @@ -924,13 +935,13 @@ func (p *Program) verifyProjectReferences() { p.programDiagnostics = append(p.programDiagnostics, diag) } - p.ForEachResolvedProjectReference(func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) { + p.RangeResolvedProjectReference(func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool { ref := parent.ProjectReferences()[index] // !!! Deprecated in 5.0 and removed since 5.5 // verifyRemovedProjectReference(ref, parent, index); if config == nil { createDiagnosticForReference(parent, index, diagnostics.File_0_not_found, ref.Path) - return + return true } refOptions := config.CompilerOptions() if !refOptions.Composite.IsTrue() || refOptions.NoEmit.IsTrue() { @@ -947,6 +958,7 @@ func (p *Program) verifyProjectReferences() { createDiagnosticForReference(parent, index, diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoFileName, ref.Path) p.hasEmitBlockingDiagnostics.Add(p.toPath(buildInfoFileName)) } + return true }) } @@ -979,14 +991,12 @@ func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic { return nil } - var globalDiagnostics []*ast.Diagnostic - checkers, done := p.checkerPool.GetAllCheckers(ctx) - defer done() - for _, checker := range checkers { - globalDiagnostics = append(globalDiagnostics, checker.GetGlobalDiagnostics()...) - } + globalDiagnostics := make([][]*ast.Diagnostic, p.checkerPool.Count()) + p.checkerPool.ForEachCheckerParallel(ctx, func(idx int, checker *checker.Checker) { + globalDiagnostics[idx] = checker.GetGlobalDiagnostics() + }) - return SortAndDeduplicateDiagnostics(globalDiagnostics) + return SortAndDeduplicateDiagnostics(slices.Concat(globalDiagnostics...)) } func (p *Program) GetDeclarationDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { @@ -1047,22 +1057,23 @@ func (p *Program) getSemanticDiagnosticsForFileNotFilter(ctx context.Context, so defer done() } diags := slices.Clip(sourceFile.BindDiagnostics()) - checkers, closeCheckers := p.checkerPool.GetAllCheckers(ctx) - defer closeCheckers() // Ask for diags from all checkers; checking one file may add diagnostics to other files. // These are deduplicated later. - for _, checker := range checkers { + checkerDiags := make([][]*ast.Diagnostic, p.checkerPool.Count()) + p.checkerPool.ForEachCheckerParallel(ctx, func(idx int, checker *checker.Checker) { if sourceFile == nil || checker == fileChecker { - diags = append(diags, checker.GetDiagnostics(ctx, sourceFile)...) + checkerDiags[idx] = checker.GetDiagnostics(ctx, sourceFile) } else { - diags = append(diags, checker.GetDiagnosticsWithoutCheck(sourceFile)...) + checkerDiags[idx] = checker.GetDiagnosticsWithoutCheck(sourceFile) } - } + }) if ctx.Err() != nil { return nil } + diags = append(diags, slices.Concat(checkerDiags...)...) + // !!! This should be rewritten to work like getBindAndCheckDiagnosticsForFileNoCache. isPlainJS := ast.IsPlainJSFile(sourceFile, compilerOptions.CheckJs) @@ -1072,6 +1083,12 @@ func (p *Program) getSemanticDiagnosticsForFileNotFilter(ctx context.Context, so }) } + isJS := sourceFile.ScriptKind == core.ScriptKindJS || sourceFile.ScriptKind == core.ScriptKindJSX + isCheckJS := isJS && ast.IsCheckJSEnabledForFile(sourceFile, compilerOptions) + if isCheckJS { + diags = append(diags, sourceFile.JSDocDiagnostics()...) + } + filtered, directivesByLine := p.getDiagnosticsWithPrecedingDirectives(sourceFile, diags) for _, directive := range directivesByLine { // Above we changed all used directive kinds to @ts-ignore, so any @ts-expect-error directives that @@ -1090,7 +1107,7 @@ func (p *Program) getDiagnosticsWithPrecedingDirectives(sourceFile *ast.SourceFi // Build map of directives by line number directivesByLine := make(map[int]ast.CommentDirective) for _, directive := range sourceFile.CommentDirectives { - line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, directive.Loc.Pos()) + line := scanner.GetECMALineOfPosition(sourceFile, directive.Loc.Pos()) directivesByLine[line] = directive } lineStarts := scanner.GetECMALineStarts(sourceFile) @@ -1148,22 +1165,20 @@ func (p *Program) getSuggestionDiagnosticsForFile(ctx context.Context, sourceFil diags := slices.Clip(sourceFile.BindSuggestionDiagnostics) - checkers, closeCheckers := p.checkerPool.GetAllCheckers(ctx) - defer closeCheckers() - - // Ask for diags from all checkers; checking one file may add diagnostics to other files. - // These are deduplicated later. - for _, checker := range checkers { + checkerDiags := make([][]*ast.Diagnostic, p.checkerPool.Count()) + p.checkerPool.ForEachCheckerParallel(ctx, func(idx int, checker *checker.Checker) { if sourceFile == nil || checker == fileChecker { - diags = append(diags, checker.GetSuggestionDiagnostics(ctx, sourceFile)...) + checkerDiags[idx] = checker.GetSuggestionDiagnostics(ctx, sourceFile) } else { // !!! is there any case where suggestion diagnostics are produced in other checkers? } - } + }) if ctx.Err() != nil { return nil } + diags = append(diags, slices.Concat(checkerDiags...)...) + return diags } @@ -1259,32 +1274,32 @@ func (p *Program) SymbolCount() int { for _, file := range p.files { count += file.SymbolCount } - checkers, done := p.checkerPool.GetAllCheckers(context.Background()) - defer done() - for _, checker := range checkers { - count += int(checker.SymbolCount) - } - return count + var val atomic.Uint32 + val.Store(uint32(count)) + p.checkerPool.ForEachCheckerParallel(context.Background(), func(idx int, c *checker.Checker) { + val.Add(c.SymbolCount) + }) + return int(val.Load()) } func (p *Program) TypeCount() int { - var count int - checkers, done := p.checkerPool.GetAllCheckers(context.Background()) - defer done() - for _, checker := range checkers { - count += int(checker.TypeCount) - } - return count + var val atomic.Uint32 + p.checkerPool.ForEachCheckerParallel(context.Background(), func(idx int, c *checker.Checker) { + val.Add(c.TypeCount) + }) + return int(val.Load()) } func (p *Program) InstantiationCount() int { - var count int - checkers, done := p.checkerPool.GetAllCheckers(context.Background()) - defer done() - for _, checker := range checkers { - count += int(checker.TotalInstantiationCount) - } - return count + var val atomic.Uint32 + p.checkerPool.ForEachCheckerParallel(context.Background(), func(idx int, c *checker.Checker) { + val.Add(c.TotalInstantiationCount) + }) + return int(val.Load()) +} + +func (p *Program) Program() *Program { + return p } func (p *Program) GetSourceFileMetaData(path tspath.Path) ast.SourceFileMetaData { @@ -1451,6 +1466,7 @@ func CombineEmitResults(results []*EmitResult) *EmitResult { type ProgramLike interface { Options() *core.CompilerOptions + GetSourceFile(path string) *ast.SourceFile GetSourceFiles() []*ast.SourceFile GetConfigFileParsingDiagnostics() []*ast.Diagnostic GetSyntacticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic @@ -1460,7 +1476,11 @@ type ProgramLike interface { GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic GetDeclarationDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic + GetSuggestionDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic Emit(ctx context.Context, options EmitOptions) *EmitResult + CommonSourceDirectory() string + IsSourceFileDefaultLibrary(path tspath.Path) bool + Program() *Program } func HandleNoEmitOnError(ctx context.Context, program ProgramLike, file *ast.SourceFile) *EmitResult { @@ -1558,7 +1578,7 @@ func (p *Program) GetSourceFiles() []*ast.SourceFile { } // Testing only -func (p *Program) GetIncludeReasons() map[tspath.Path][]*fileIncludeReason { +func (p *Program) GetIncludeReasons() map[tspath.Path][]*FileIncludeReason { return p.includeProcessor.fileIncludeReasons } @@ -1569,17 +1589,17 @@ func (p *Program) IsMissingPath(path tspath.Path) bool { }) } -func (p *Program) ExplainFiles(w io.Writer) { +func (p *Program) ExplainFiles(w io.Writer, locale locale.Locale) { toRelativeFileName := func(fileName string) string { return tspath.GetRelativePathFromDirectory(p.GetCurrentDirectory(), fileName, p.comparePathsOptions) } for _, file := range p.GetSourceFiles() { fmt.Fprintln(w, toRelativeFileName(file.FileName())) for _, reason := range p.includeProcessor.fileIncludeReasons[file.Path()] { - fmt.Fprintln(w, " ", reason.toDiagnostic(p, true).Message()) + fmt.Fprintln(w, " ", reason.toDiagnostic(p, true).Localize(locale)) } for _, diag := range p.includeProcessor.explainRedirectAndImpliedFormat(p, file, toRelativeFileName) { - fmt.Fprintln(w, " ", diag.Message()) + fmt.Fprintln(w, " ", diag.Localize(locale)) } } } @@ -1619,12 +1639,6 @@ func (p *Program) IsSourceFileFromExternalLibrary(file *ast.SourceFile) bool { return p.sourceFilesFoundSearchingNodeModules.Has(file.Path()) } -// UnsupportedExtensions returns a list of all present "unsupported" extensions, -// e.g. extensions that are not yet supported by the port. -func (p *Program) UnsupportedExtensions() []string { - return p.unsupportedExtensions -} - func (p *Program) GetJSXRuntimeImportSpecifier(path tspath.Path) (moduleReference string, specifier *ast.Node) { if result := p.jsxRuntimeImportSpecifiers[path]; result != nil { return result.moduleReference, result.specifier @@ -1640,6 +1654,23 @@ func (p *Program) SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmi return sourceFileMayBeEmitted(sourceFile, p, forceDtsEmit) } +func (p *Program) IsLibFile(sourceFile *ast.SourceFile) bool { + _, ok := p.libFiles[sourceFile.Path()] + return ok +} + +func (p *Program) HasTSFile() bool { + p.hasTSFileOnce.Do(func() { + for _, file := range p.files { + if tspath.HasImplementationTSFileExtension(file.FileName()) { + p.hasTSFile = true + break + } + } + }) + return p.hasTSFile +} + var plainJSErrors = collections.NewSetFromItems( // binder errors diagnostics.Cannot_redeclare_block_scoped_variable_0.Code(), diff --git a/internal/compiler/projectreferencefilemapper.go b/internal/compiler/projectreferencefilemapper.go index 17649ec3e0..58fd18251e 100644 --- a/internal/compiler/projectreferencefilemapper.go +++ b/internal/compiler/projectreferencefilemapper.go @@ -46,6 +46,9 @@ func (mapper *projectReferenceFileMapper) getParseFileRedirect(file ast.HasFileN } func (mapper *projectReferenceFileMapper) getResolvedProjectReferences() []*tsoptions.ParsedCommandLine { + if mapper.opts.Config.ConfigFile == nil { + return nil + } refs, ok := mapper.referencesInConfigFile[mapper.opts.Config.ConfigFile.SourceFile.Path()] var result []*tsoptions.ParsedCommandLine if ok { @@ -106,32 +109,50 @@ func (mapper *projectReferenceFileMapper) getResolvedReferenceFor(path tspath.Pa return config, ok } -func (mapper *projectReferenceFileMapper) forEachResolvedProjectReference( - fn func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int), -) { +func (mapper *projectReferenceFileMapper) rangeResolvedProjectReference( + f func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool, +) bool { if mapper.opts.Config.ConfigFile == nil { - return + return false } seenRef := collections.NewSetWithSizeHint[tspath.Path](len(mapper.referencesInConfigFile)) seenRef.Add(mapper.opts.Config.ConfigFile.SourceFile.Path()) refs := mapper.referencesInConfigFile[mapper.opts.Config.ConfigFile.SourceFile.Path()] - mapper.forEachResolvedReferenceWorker(refs, fn, mapper.opts.Config, seenRef) + return mapper.rangeResolvedReferenceWorker(refs, f, mapper.opts.Config, seenRef) } -func (mapper *projectReferenceFileMapper) forEachResolvedReferenceWorker( +func (mapper *projectReferenceFileMapper) rangeResolvedReferenceWorker( references []tspath.Path, - fn func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int), + f func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool, parent *tsoptions.ParsedCommandLine, seenRef *collections.Set[tspath.Path], -) { +) bool { for index, path := range references { if !seenRef.AddIfAbsent(path) { continue } config, _ := mapper.configToProjectReference[path] - fn(path, config, parent, index) - mapper.forEachResolvedReferenceWorker(mapper.referencesInConfigFile[path], fn, config, seenRef) + if !f(path, config, parent, index) { + return false + } + if !mapper.rangeResolvedReferenceWorker(mapper.referencesInConfigFile[path], f, config, seenRef) { + return false + } } + return true +} + +func (mapper *projectReferenceFileMapper) rangeResolvedProjectReferenceInChildConfig( + childConfig *tsoptions.ParsedCommandLine, + f func(path tspath.Path, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool, +) bool { + if childConfig == nil || childConfig.ConfigFile == nil { + return false + } + seenRef := collections.NewSetWithSizeHint[tspath.Path](len(mapper.referencesInConfigFile)) + seenRef.Add(childConfig.ConfigFile.SourceFile.Path()) + refs := mapper.referencesInConfigFile[childConfig.ConfigFile.SourceFile.Path()] + return mapper.rangeResolvedReferenceWorker(refs, f, mapper.opts.Config, seenRef) } func (mapper *projectReferenceFileMapper) getSourceToDtsIfSymlink(file ast.HasFileName) *tsoptions.SourceOutputAndProjectReference { diff --git a/internal/compiler/projectreferenceparser.go b/internal/compiler/projectreferenceparser.go index f6dd57b4af..482644805c 100644 --- a/internal/compiler/projectreferenceparser.go +++ b/internal/compiler/projectreferenceparser.go @@ -1,6 +1,8 @@ package compiler import ( + "maps" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -91,12 +93,8 @@ func (p *projectReferenceParser) initMapperWorker(tasks []*projectReferenceParse if task.resolved == nil || p.loader.projectReferenceFileMapper.opts.Config.ConfigFile == task.resolved.ConfigFile { continue } - for key, value := range task.resolved.SourceToProjectReference() { - p.loader.projectReferenceFileMapper.sourceToProjectReference[key] = value - } - for key, value := range task.resolved.OutputDtsToProjectReference() { - p.loader.projectReferenceFileMapper.outputDtsToProjectReference[key] = value - } + maps.Copy(p.loader.projectReferenceFileMapper.sourceToProjectReference, task.resolved.SourceToProjectReference()) + maps.Copy(p.loader.projectReferenceFileMapper.outputDtsToProjectReference, task.resolved.OutputDtsToProjectReference()) if p.loader.projectReferenceFileMapper.opts.canUseProjectReferenceSource() { declDir := task.resolved.CompilerOptions().DeclarationDir if declDir == "" { diff --git a/internal/core/compileroptions.go b/internal/core/compileroptions.go index aae6fed160..ad6a4ceeca 100644 --- a/internal/core/compileroptions.go +++ b/internal/core/compileroptions.go @@ -47,6 +47,7 @@ type CompilerOptions struct { ForceConsistentCasingInFileNames Tristate `json:"forceConsistentCasingInFileNames,omitzero"` IsolatedModules Tristate `json:"isolatedModules,omitzero"` IsolatedDeclarations Tristate `json:"isolatedDeclarations,omitzero"` + IgnoreConfig Tristate `json:"ignoreConfig,omitzero"` IgnoreDeprecations string `json:"ignoreDeprecations,omitzero"` ImportHelpers Tristate `json:"importHelpers,omitzero"` InlineSourceMap Tristate `json:"inlineSourceMap,omitzero"` @@ -148,6 +149,7 @@ type CompilerOptions struct { PprofDir string `json:"pprofDir,omitzero"` SingleThreaded Tristate `json:"singleThreaded,omitzero"` Quiet Tristate `json:"quiet,omitzero"` + Checkers *int `json:"checkers,omitzero"` sourceFileAffectingCompilerOptionsOnce sync.Once sourceFileAffectingCompilerOptions SourceFileAffectingCompilerOptions @@ -200,26 +202,30 @@ func (options *CompilerOptions) GetEmitScriptTarget() ScriptTarget { } func (options *CompilerOptions) GetEmitModuleKind() ModuleKind { - if options.Module != ModuleKindNone { + switch options.Module { + case ModuleKindNone, ModuleKindAMD, ModuleKindUMD, ModuleKindSystem: + if options.Target >= ScriptTargetES2015 { + return ModuleKindES2015 + } + return ModuleKindCommonJS + default: return options.Module } - if options.Target >= ScriptTargetES2015 { - return ModuleKindES2015 - } - return ModuleKindCommonJS } func (options *CompilerOptions) GetModuleResolutionKind() ModuleResolutionKind { - if options.ModuleResolution != ModuleResolutionKindUnknown { - return options.ModuleResolution - } - switch options.GetEmitModuleKind() { - case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20: - return ModuleResolutionKindNode16 - case ModuleKindNodeNext: - return ModuleResolutionKindNodeNext + switch options.ModuleResolution { + case ModuleResolutionKindUnknown, ModuleResolutionKindClassic, ModuleResolutionKindNode10: + switch options.GetEmitModuleKind() { + case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20: + return ModuleResolutionKindNode16 + case ModuleKindNodeNext: + return ModuleResolutionKindNodeNext + default: + return ModuleResolutionKindBundler + } default: - return ModuleResolutionKindBundler + return options.ModuleResolution } } @@ -227,12 +233,11 @@ func (options *CompilerOptions) GetEmitModuleDetectionKind() ModuleDetectionKind if options.ModuleDetection != ModuleDetectionKindNone { return options.ModuleDetection } - switch options.GetEmitModuleKind() { - case ModuleKindNode16, ModuleKindNode20, ModuleKindNodeNext: + moduleKind := options.GetEmitModuleKind() + if ModuleKindNode16 <= moduleKind && moduleKind <= ModuleKindNodeNext { return ModuleDetectionKindForce - default: - return ModuleDetectionKindAuto } + return ModuleDetectionKindAuto } func (options *CompilerOptions) GetResolvePackageJsonExports() bool { @@ -251,24 +256,14 @@ func (options *CompilerOptions) AllowImportingTsExtensionsFrom(fileName string) return options.GetAllowImportingTsExtensions() || tspath.IsDeclarationFileName(fileName) } +// Deprecated: always returns true func (options *CompilerOptions) GetESModuleInterop() bool { - if options.ESModuleInterop != TSUnknown { - return options.ESModuleInterop == TSTrue - } - switch options.GetEmitModuleKind() { - case ModuleKindNode16, ModuleKindNode18, ModuleKindNode20, ModuleKindNodeNext, ModuleKindPreserve: - return true - } - return false + return true } +// Deprecated: always returns true func (options *CompilerOptions) GetAllowSyntheticDefaultImports() bool { - if options.AllowSyntheticDefaultImports != TSUnknown { - return options.AllowSyntheticDefaultImports == TSTrue - } - return options.GetESModuleInterop() || - options.GetEmitModuleKind() == ModuleKindSystem || - options.GetModuleResolutionKind() == ModuleResolutionKindBundler + return true } func (options *CompilerOptions) GetResolveJsonModule() bool { @@ -371,19 +366,13 @@ func (options *CompilerOptions) GetPathsBasePath(currentDirectory string) string // SourceFileAffectingCompilerOptions are the precomputed CompilerOptions values which // affect the parse and bind of a source file. type SourceFileAffectingCompilerOptions struct { - AllowUnreachableCode Tristate - AllowUnusedLabels Tristate - BindInStrictMode bool - ShouldPreserveConstEnums bool + BindInStrictMode bool } func (options *CompilerOptions) SourceFileAffecting() SourceFileAffectingCompilerOptions { options.sourceFileAffectingCompilerOptionsOnce.Do(func() { options.sourceFileAffectingCompilerOptions = SourceFileAffectingCompilerOptions{ - AllowUnreachableCode: options.AllowUnreachableCode, - AllowUnusedLabels: options.AllowUnusedLabels, - BindInStrictMode: options.AlwaysStrict.IsTrue() || options.Strict.IsTrue(), - ShouldPreserveConstEnums: options.ShouldPreserveConstEnums(), + BindInStrictMode: options.AlwaysStrict.IsTrue() || options.Strict.IsTrue(), } }) return options.sourceFileAffectingCompilerOptions @@ -401,6 +390,7 @@ const ( type ModuleKind int32 const ( + // Deprecated: Do not use outside of options parsing and validation. ModuleKindNone ModuleKind = 0 ModuleKindCommonJS ModuleKind = 1 // Deprecated: Do not use outside of options parsing and validation. @@ -447,6 +437,10 @@ type ModuleResolutionKind int32 const ( ModuleResolutionKindUnknown ModuleResolutionKind = 0 + // Deprecated: Do not use outside of options parsing and validation. + ModuleResolutionKindClassic ModuleResolutionKind = 1 + // Deprecated: Do not use outside of options parsing and validation. + ModuleResolutionKindNode10 ModuleResolutionKind = 2 // Starting with node16, node's module resolver has significant departures from traditional cjs resolution // to better support ECMAScript modules and their use within node - however more features are still being added. // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable diff --git a/internal/core/context.go b/internal/core/context.go index ddd019208f..394fcf4561 100644 --- a/internal/core/context.go +++ b/internal/core/context.go @@ -2,15 +2,12 @@ package core import ( "context" - - "golang.org/x/text/language" ) type key int const ( requestIDKey key = iota - localeKey ) func WithRequestID(ctx context.Context, id string) context.Context { @@ -23,14 +20,3 @@ func GetRequestID(ctx context.Context) string { } return "" } - -func WithLocale(ctx context.Context, locale language.Tag) context.Context { - return context.WithValue(ctx, localeKey, locale) -} - -func GetLocale(ctx context.Context) language.Tag { - if locale, ok := ctx.Value(localeKey).(language.Tag); ok { - return locale - } - return language.Und -} diff --git a/internal/core/core.go b/internal/core/core.go index f284826eda..6c075d488d 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -7,6 +7,7 @@ import ( "slices" "sort" "strings" + "sync" "unicode" "unicode/utf8" @@ -159,7 +160,7 @@ func Same[T any](s1 []T, s2 []T) bool { } func Some[T any](slice []T, f func(T) bool) bool { - for _, value := range slice { + for _, value := range slice { //nolint:modernize if f(value) { return true } @@ -406,12 +407,9 @@ func ComputeECMALineStartsSeq(text string) iter.Seq[TextPos] { } func PositionToLineAndCharacter(position int, lineStarts []TextPos) (line int, character int) { - line = sort.Search(len(lineStarts), func(i int) bool { + line = max(sort.Search(len(lineStarts), func(i int) bool { return int(lineStarts[i]) > position - }) - 1 - if line < 0 { - line = 0 - } + })-1, 0) return line, position - int(lineStarts[line]) } @@ -476,6 +474,8 @@ func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) s maximumLengthDifference := max(2, int(float64(len(name))*0.34)) bestDistance := math.Floor(float64(len(name))*0.4) + 1 // If the best result is worse than this, don't bother. runeName := []rune(name) + buffers := levenshteinBuffersPool.Get().(*levenshteinBuffers) + defer levenshteinBuffersPool.Put(buffers) var bestCandidate T for _, candidate := range candidates { candidateName := getName(candidate) @@ -490,7 +490,7 @@ func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) s if len(candidateName) < 3 && !strings.EqualFold(candidateName, name) { continue } - distance := levenshteinWithMax(runeName, []rune(candidateName), bestDistance-0.1) + distance := levenshteinWithMax(buffers, runeName, []rune(candidateName), bestDistance-0.1) if distance < 0 { continue } @@ -502,9 +502,25 @@ func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) s return bestCandidate } -func levenshteinWithMax(s1 []rune, s2 []rune, maxValue float64) float64 { - previous := make([]float64, len(s2)+1) - current := make([]float64, len(s2)+1) +type levenshteinBuffers struct { + previous []float64 + current []float64 +} + +var levenshteinBuffersPool = sync.Pool{ + New: func() any { + return &levenshteinBuffers{} + }, +} + +func levenshteinWithMax(buffers *levenshteinBuffers, s1 []rune, s2 []rune, maxValue float64) float64 { + bufferSize := len(s2) + 1 + buffers.previous = slices.Grow(buffers.previous[:0], bufferSize)[:bufferSize] + buffers.current = slices.Grow(buffers.current[:0], bufferSize)[:bufferSize] + + previous := buffers.previous + current := buffers.current + big := maxValue + 0.01 for i := range previous { previous[i] = float64(i) @@ -668,3 +684,13 @@ func DeduplicateSorted[T any](slice []T, isEqual func(a, b T) bool) []T { return deduplicated } + +// CompareBooleans treats true as greater than false. +func CompareBooleans(a, b bool) int { + if a && !b { + return -1 + } else if !a && b { + return 1 + } + return 0 +} diff --git a/internal/core/languagevariant_stringer_generated.go b/internal/core/languagevariant_stringer_generated.go index ae5cca5e6b..7f4303104c 100644 --- a/internal/core/languagevariant_stringer_generated.go +++ b/internal/core/languagevariant_stringer_generated.go @@ -17,8 +17,9 @@ const _LanguageVariant_name = "LanguageVariantStandardLanguageVariantJSX" var _LanguageVariant_index = [...]uint8{0, 23, 41} func (i LanguageVariant) String() string { - if i < 0 || i >= LanguageVariant(len(_LanguageVariant_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_LanguageVariant_index)-1 { return "LanguageVariant(" + strconv.FormatInt(int64(i), 10) + ")" } - return _LanguageVariant_name[_LanguageVariant_index[i]:_LanguageVariant_index[i+1]] + return _LanguageVariant_name[_LanguageVariant_index[idx]:_LanguageVariant_index[idx+1]] } diff --git a/internal/core/scriptkind_stringer_generated.go b/internal/core/scriptkind_stringer_generated.go index ba50779558..97de80e4ca 100644 --- a/internal/core/scriptkind_stringer_generated.go +++ b/internal/core/scriptkind_stringer_generated.go @@ -23,8 +23,9 @@ const _ScriptKind_name = "ScriptKindUnknownScriptKindJSScriptKindJSXScriptKindTS var _ScriptKind_index = [...]uint8{0, 17, 29, 42, 54, 67, 85, 99, 117} func (i ScriptKind) String() string { - if i < 0 || i >= ScriptKind(len(_ScriptKind_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_ScriptKind_index)-1 { return "ScriptKind(" + strconv.FormatInt(int64(i), 10) + ")" } - return _ScriptKind_name[_ScriptKind_index[i]:_ScriptKind_index[i+1]] + return _ScriptKind_name[_ScriptKind_index[idx]:_ScriptKind_index[idx+1]] } diff --git a/internal/core/text.go b/internal/core/text.go index d911b839b1..e6762da38e 100644 --- a/internal/core/text.go +++ b/internal/core/text.go @@ -64,3 +64,11 @@ func (t TextRange) Overlaps(t2 TextRange) bool { end := min(t.end, t2.end) return start < end } + +// Similar to Overlaps, but treats touching ranges as intersecting. +// For example, [0, 5) intersects [5, 10). +func (t TextRange) Intersects(t2 TextRange) bool { + start := max(t.pos, t2.pos) + end := min(t.end, t2.end) + return start <= end +} diff --git a/internal/core/tristate_stringer_generated.go b/internal/core/tristate_stringer_generated.go index 05db2d7778..af1d2d9759 100644 --- a/internal/core/tristate_stringer_generated.go +++ b/internal/core/tristate_stringer_generated.go @@ -18,8 +18,9 @@ const _Tristate_name = "TSUnknownTSFalseTSTrue" var _Tristate_index = [...]uint8{0, 9, 16, 22} func (i Tristate) String() string { - if i >= Tristate(len(_Tristate_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_Tristate_index)-1 { return "Tristate(" + strconv.FormatInt(int64(i), 10) + ")" } - return _Tristate_name[_Tristate_index[i]:_Tristate_index[i+1]] + return _Tristate_name[_Tristate_index[idx]:_Tristate_index[idx+1]] } diff --git a/internal/core/workgroup.go b/internal/core/workgroup.go index fcdd133226..73618a1a19 100644 --- a/internal/core/workgroup.go +++ b/internal/core/workgroup.go @@ -36,11 +36,9 @@ func (w *parallelWorkGroup) Queue(fn func()) { panic("Queue called after RunAndWait returned") } - w.wg.Add(1) - go func() { - defer w.wg.Done() + w.wg.Go(func() { fn() - }() + }) } func (w *parallelWorkGroup) RunAndWait() { diff --git a/internal/diagnostics/diagnostics.go b/internal/diagnostics/diagnostics.go index df6e05de49..aaf238680b 100644 --- a/internal/diagnostics/diagnostics.go +++ b/internal/diagnostics/diagnostics.go @@ -1,11 +1,19 @@ // Package diagnostics contains generated localizable diagnostic messages. package diagnostics -import "github.com/microsoft/typescript-go/internal/stringutil" +import ( + "fmt" + "regexp" + "strconv" + "sync" -//go:generate go run generate.go -output ./diagnostics_generated.go + "github.com/microsoft/typescript-go/internal/locale" + "golang.org/x/text/language" +) + +//go:generate go run generate.go -diagnostics ./diagnostics_generated.go -loc ./loc_generated.go -locdir ./loc //go:generate go tool golang.org/x/tools/cmd/stringer -type=Category -output=stringer_generated.go -//go:generate go tool mvdan.cc/gofumpt -w diagnostics_generated.go stringer_generated.go +//go:generate go tool mvdan.cc/gofumpt -w diagnostics_generated.go loc_generated.go stringer_generated.go type Category int32 @@ -30,10 +38,12 @@ func (category Category) Name() string { panic("Unhandled diagnostic category") } +type Key string + type Message struct { code int32 category Category - key string + key Key text string reportsUnnecessary bool elidedInCompatibilityPyramid bool @@ -42,22 +52,92 @@ type Message struct { func (m *Message) Code() int32 { return m.code } func (m *Message) Category() Category { return m.category } -func (m *Message) Key() string { return m.key } -func (m *Message) Message() string { return m.text } +func (m *Message) Key() Key { return m.key } func (m *Message) ReportsUnnecessary() bool { return m.reportsUnnecessary } func (m *Message) ElidedInCompatibilityPyramid() bool { return m.elidedInCompatibilityPyramid } func (m *Message) ReportsDeprecated() bool { return m.reportsDeprecated } -func (m *Message) Format(args ...any) string { - text := m.Message() - if len(args) != 0 { - text = stringutil.Format(text, args) +// For debugging only. +func (m *Message) String() string { + return m.text +} + +func (m *Message) Localize(locale locale.Locale, args ...any) string { + return Localize(locale, m, "", StringifyArgs(args)...) +} + +func Localize(locale locale.Locale, message *Message, key Key, args ...string) string { + if message == nil { + message = keyToMessage(key) + } + if message == nil { + panic("Unknown diagnostic message: " + string(key)) } - return text + + text := message.text + if localized, ok := getLocalizedMessages(language.Tag(locale))[message.key]; ok { + text = localized + } + + return Format(text, args) } -func FormatMessage(m *Message, args ...any) *Message { - result := *m - result.text = stringutil.Format(m.text, args) - return &result +var localizedMessagesCache sync.Map // map[language.Tag]map[Key]string + +func getLocalizedMessages(loc language.Tag) map[Key]string { + if loc == language.Und { + return nil + } + + // Check cache first + if cached, ok := localizedMessagesCache.Load(loc); ok { + if cached == nil { + return nil + } + return cached.(map[Key]string) + } + + var messages map[Key]string + + _, index, confidence := matcher.Match(loc) + if confidence >= language.Low && index >= 0 && index < len(localeFuncs) { + if fn := localeFuncs[index]; fn != nil { + messages = fn() + } + } + + localizedMessagesCache.Store(loc, messages) + return messages +} + +var placeholderRegexp = regexp.MustCompile(`{(\d+)}`) + +func Format(text string, args []string) string { + if len(args) == 0 { + return text + } + + return placeholderRegexp.ReplaceAllStringFunc(text, func(match string) string { + index, err := strconv.ParseInt(match[1:len(match)-1], 10, 0) + if err != nil || int(index) >= len(args) { + panic("Invalid formatting placeholder") + } + return args[int(index)] + }) +} + +func StringifyArgs(args []any) []string { + if len(args) == 0 { + return nil + } + + result := make([]string, len(args)) + for i, arg := range args { + if s, ok := arg.(string); ok { + result[i] = s + } else { + result[i] = fmt.Sprintf("%v", arg) + } + } + return result } diff --git a/internal/diagnostics/diagnostics_generated.go b/internal/diagnostics/diagnostics_generated.go index 5c32430d2b..d59fa2ec20 100644 --- a/internal/diagnostics/diagnostics_generated.go +++ b/internal/diagnostics/diagnostics_generated.go @@ -926,6 +926,8 @@ var X_using_declarations_are_not_allowed_in_ambient_contexts = &Message{code: 15 var X_await_using_declarations_are_not_allowed_in_ambient_contexts = &Message{code: 1546, category: CategoryError, key: "await_using_declarations_are_not_allowed_in_ambient_contexts_1546", text: "'await using' declarations are not allowed in ambient contexts."} +var Ignore_the_tsconfig_found_and_build_with_commandline_options_and_files = &Message{code: 1549, category: CategoryMessage, key: "Ignore_the_tsconfig_found_and_build_with_commandline_options_and_files_1549", text: "Ignore the tsconfig found and build with commandline options and files."} + var The_types_of_0_are_incompatible_between_these_types = &Message{code: 2200, category: CategoryError, key: "The_types_of_0_are_incompatible_between_these_types_2200", text: "The types of '{0}' are incompatible between these types."} var The_types_returned_by_0_are_incompatible_between_these_types = &Message{code: 2201, category: CategoryError, key: "The_types_returned_by_0_are_incompatible_between_these_types_2201", text: "The types returned by '{0}' are incompatible between these types."} @@ -2326,7 +2328,7 @@ var Compiler_option_0_may_only_be_used_with_build = &Message{code: 5093, categor var Compiler_option_0_may_not_be_used_with_build = &Message{code: 5094, category: CategoryError, key: "Compiler_option_0_may_not_be_used_with_build_5094", text: "Compiler option '--{0}' may not be used with '--build'."} -var Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later = &Message{code: 5095, category: CategoryError, key: "Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later_5095", text: "Option '{0}' can only be used when 'module' is set to 'preserve' or to 'es2015' or later."} +var Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later = &Message{code: 5095, category: CategoryError, key: "Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later_5095", text: "Option '{0}' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later."} var Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set = &Message{code: 5096, category: CategoryError, key: "Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set_5096", text: "Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set."} @@ -2354,6 +2356,10 @@ var Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_mod var Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1 = &Message{code: 5110, category: CategoryError, key: "Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1_5110", text: "Option 'module' must be set to '{0}' when option 'moduleResolution' is set to '{1}'."} +var Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information = &Message{code: 5111, category: CategoryMessage, key: "Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information_5111", text: "Visit https://aka.ms/ts6 for migration information."} + +var X_tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_commandline_Use_ignoreConfig_to_skip_this_error = &Message{code: 5112, category: CategoryError, key: "tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_commandline_Use_ignoreConf_5112", text: "tsconfig.json is present but will not be loaded if files are specified on commandline. Use '--ignoreConfig' to skip this error."} + var Generates_a_sourcemap_for_each_corresponding_d_ts_file = &Message{code: 6000, category: CategoryMessage, key: "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", text: "Generates a sourcemap for each corresponding '.d.ts' file."} var Concatenate_and_emit_output_to_single_file = &Message{code: 6001, category: CategoryMessage, key: "Concatenate_and_emit_output_to_single_file_6001", text: "Concatenate and emit output to single file."} @@ -2434,7 +2440,7 @@ var Unterminated_quoted_string_in_response_file_0 = &Message{code: 6045, categor var Argument_for_0_option_must_be_Colon_1 = &Message{code: 6046, category: CategoryError, key: "Argument_for_0_option_must_be_Colon_1_6046", text: "Argument for '{0}' option must be: {1}."} -var Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1 = &Message{code: 6048, category: CategoryError, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", text: "Locale must be of the form or -. For example '{0}' or '{1}'."} +var Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1 = &Message{code: 6048, category: CategoryError, key: "Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1_6048", text: "Locale must be an IETF BCP 47 language tag. Examples: '{0}', '{1}'."} var Unable_to_open_file_0 = &Message{code: 6050, category: CategoryError, key: "Unable_to_open_file_0_6050", text: "Unable to open file '{0}'."} @@ -3516,8 +3522,6 @@ var Decorators_may_not_appear_after_export_or_export_default_if_they_also_appear var A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag = &Message{code: 8039, category: CategoryError, key: "A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag_8039", text: "A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag"} -var A_JSDoc_type_tag_may_not_occur_with_a_param_or_returns_tag = &Message{code: 8040, category: CategoryError, key: "A_JSDoc_type_tag_may_not_occur_with_a_param_or_returns_tag_8040", text: "A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag."} - var Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit = &Message{code: 9005, category: CategoryError, key: "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", text: "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."} var Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit = &Message{code: 9006, category: CategoryError, key: "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", text: "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."} @@ -3732,7 +3736,7 @@ var Deferred_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_or var X_0_is_not_a_valid_meta_property_for_keyword_import_Did_you_mean_meta_or_defer = &Message{code: 18061, category: CategoryError, key: "_0_is_not_a_valid_meta_property_for_keyword_import_Did_you_mean_meta_or_defer_18061", text: "'{0}' is not a valid meta-property for keyword 'import'. Did you mean 'meta' or 'defer'?"} -var X_module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node = &Message{code: 69010, category: CategoryMessage, key: "module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node_69010", text: "module === `AMD` or `UMD` or `System` or `ES6`, then `Classic`, Otherwise `Node`"} +var X_nodenext_if_module_is_nodenext_node16_if_module_is_node16_or_node18_otherwise_bundler = &Message{code: 69010, category: CategoryMessage, key: "nodenext_if_module_is_nodenext_node16_if_module_is_node16_or_node18_otherwise_bundler_69010", text: "`nodenext` if `module` is `nodenext`; `node16` if `module` is `node16` or `node18`; otherwise, `bundler`."} var File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module = &Message{code: 80001, category: CategorySuggestion, key: "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001", text: "File is a CommonJS module; it may be converted to an ES module."} @@ -4253,3 +4257,4274 @@ var Do_not_print_diagnostics = &Message{code: 100000, category: CategoryMessage, var Run_in_single_threaded_mode = &Message{code: 100001, category: CategoryMessage, key: "Run_in_single_threaded_mode_100001", text: "Run in single threaded mode."} var Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory = &Message{code: 100002, category: CategoryMessage, key: "Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory_100002", text: "Generate pprof CPU/memory profiles to the given directory."} + +var Set_the_number_of_checkers_per_project = &Message{code: 100003, category: CategoryMessage, key: "Set_the_number_of_checkers_per_project_100003", text: "Set the number of checkers per project."} + +var X_4_unless_singleThreaded_is_passed = &Message{code: 100004, category: CategoryMessage, key: "4_unless_singleThreaded_is_passed_100004", text: "4, unless --singleThreaded is passed."} + +func keyToMessage(key Key) *Message { + switch key { + case "Unterminated_string_literal_1002": + return Unterminated_string_literal + case "Identifier_expected_1003": + return Identifier_expected + case "_0_expected_1005": + return X_0_expected + case "A_file_cannot_have_a_reference_to_itself_1006": + return A_file_cannot_have_a_reference_to_itself + case "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007": + return The_parser_expected_to_find_a_1_to_match_the_0_token_here + case "Trailing_comma_not_allowed_1009": + return Trailing_comma_not_allowed + case "Asterisk_Slash_expected_1010": + return Asterisk_Slash_expected + case "An_element_access_expression_should_take_an_argument_1011": + return An_element_access_expression_should_take_an_argument + case "Unexpected_token_1012": + return Unexpected_token + case "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013": + return A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma + case "A_rest_parameter_must_be_last_in_a_parameter_list_1014": + return A_rest_parameter_must_be_last_in_a_parameter_list + case "Parameter_cannot_have_question_mark_and_initializer_1015": + return Parameter_cannot_have_question_mark_and_initializer + case "A_required_parameter_cannot_follow_an_optional_parameter_1016": + return A_required_parameter_cannot_follow_an_optional_parameter + case "An_index_signature_cannot_have_a_rest_parameter_1017": + return An_index_signature_cannot_have_a_rest_parameter + case "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018": + return An_index_signature_parameter_cannot_have_an_accessibility_modifier + case "An_index_signature_parameter_cannot_have_a_question_mark_1019": + return An_index_signature_parameter_cannot_have_a_question_mark + case "An_index_signature_parameter_cannot_have_an_initializer_1020": + return An_index_signature_parameter_cannot_have_an_initializer + case "An_index_signature_must_have_a_type_annotation_1021": + return An_index_signature_must_have_a_type_annotation + case "An_index_signature_parameter_must_have_a_type_annotation_1022": + return An_index_signature_parameter_must_have_a_type_annotation + case "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": + return X_readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature + case "An_index_signature_cannot_have_a_trailing_comma_1025": + return An_index_signature_cannot_have_a_trailing_comma + case "Accessibility_modifier_already_seen_1028": + return Accessibility_modifier_already_seen + case "_0_modifier_must_precede_1_modifier_1029": + return X_0_modifier_must_precede_1_modifier + case "_0_modifier_already_seen_1030": + return X_0_modifier_already_seen + case "_0_modifier_cannot_appear_on_class_elements_of_this_kind_1031": + return X_0_modifier_cannot_appear_on_class_elements_of_this_kind + case "super_must_be_followed_by_an_argument_list_or_member_access_1034": + return X_super_must_be_followed_by_an_argument_list_or_member_access + case "Only_ambient_modules_can_use_quoted_names_1035": + return Only_ambient_modules_can_use_quoted_names + case "Statements_are_not_allowed_in_ambient_contexts_1036": + return Statements_are_not_allowed_in_ambient_contexts + case "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038": + return A_declare_modifier_cannot_be_used_in_an_already_ambient_context + case "Initializers_are_not_allowed_in_ambient_contexts_1039": + return Initializers_are_not_allowed_in_ambient_contexts + case "_0_modifier_cannot_be_used_in_an_ambient_context_1040": + return X_0_modifier_cannot_be_used_in_an_ambient_context + case "_0_modifier_cannot_be_used_here_1042": + return X_0_modifier_cannot_be_used_here + case "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044": + return X_0_modifier_cannot_appear_on_a_module_or_namespace_element + case "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": + return Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier + case "A_rest_parameter_cannot_be_optional_1047": + return A_rest_parameter_cannot_be_optional + case "A_rest_parameter_cannot_have_an_initializer_1048": + return A_rest_parameter_cannot_have_an_initializer + case "A_set_accessor_must_have_exactly_one_parameter_1049": + return A_set_accessor_must_have_exactly_one_parameter + case "A_set_accessor_cannot_have_an_optional_parameter_1051": + return A_set_accessor_cannot_have_an_optional_parameter + case "A_set_accessor_parameter_cannot_have_an_initializer_1052": + return A_set_accessor_parameter_cannot_have_an_initializer + case "A_set_accessor_cannot_have_rest_parameter_1053": + return A_set_accessor_cannot_have_rest_parameter + case "A_get_accessor_cannot_have_parameters_1054": + return A_get_accessor_cannot_have_parameters + case "Type_0_is_not_a_valid_async_function_return_type_in_ES5_because_it_does_not_refer_to_a_Promise_compa_1055": + return Type_0_is_not_a_valid_async_function_return_type_in_ES5_because_it_does_not_refer_to_a_Promise_compatible_constructor_value + case "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056": + return Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher + case "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058": + return The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + case "A_promise_must_have_a_then_method_1059": + return A_promise_must_have_a_then_method + case "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": + return The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback + case "Enum_member_must_have_initializer_1061": + return Enum_member_must_have_initializer + case "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062": + return Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method + case "An_export_assignment_cannot_be_used_in_a_namespace_1063": + return An_export_assignment_cannot_be_used_in_a_namespace + case "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064": + return The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0 + case "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065": + return The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type + case "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066": + return In_ambient_enum_declarations_member_initializer_must_be_constant_expression + case "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068": + return Unexpected_token_A_constructor_method_accessor_or_property_was_expected + case "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069": + return Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces + case "_0_modifier_cannot_appear_on_a_type_member_1070": + return X_0_modifier_cannot_appear_on_a_type_member + case "_0_modifier_cannot_appear_on_an_index_signature_1071": + return X_0_modifier_cannot_appear_on_an_index_signature + case "A_0_modifier_cannot_be_used_with_an_import_declaration_1079": + return A_0_modifier_cannot_be_used_with_an_import_declaration + case "Invalid_reference_directive_syntax_1084": + return Invalid_reference_directive_syntax + case "_0_modifier_cannot_appear_on_a_constructor_declaration_1089": + return X_0_modifier_cannot_appear_on_a_constructor_declaration + case "_0_modifier_cannot_appear_on_a_parameter_1090": + return X_0_modifier_cannot_appear_on_a_parameter + case "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": + return Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement + case "Type_parameters_cannot_appear_on_a_constructor_declaration_1092": + return Type_parameters_cannot_appear_on_a_constructor_declaration + case "Type_annotation_cannot_appear_on_a_constructor_declaration_1093": + return Type_annotation_cannot_appear_on_a_constructor_declaration + case "An_accessor_cannot_have_type_parameters_1094": + return An_accessor_cannot_have_type_parameters + case "A_set_accessor_cannot_have_a_return_type_annotation_1095": + return A_set_accessor_cannot_have_a_return_type_annotation + case "An_index_signature_must_have_exactly_one_parameter_1096": + return An_index_signature_must_have_exactly_one_parameter + case "_0_list_cannot_be_empty_1097": + return X_0_list_cannot_be_empty + case "Type_parameter_list_cannot_be_empty_1098": + return Type_parameter_list_cannot_be_empty + case "Type_argument_list_cannot_be_empty_1099": + return Type_argument_list_cannot_be_empty + case "Invalid_use_of_0_in_strict_mode_1100": + return Invalid_use_of_0_in_strict_mode + case "with_statements_are_not_allowed_in_strict_mode_1101": + return X_with_statements_are_not_allowed_in_strict_mode + case "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102": + return X_delete_cannot_be_called_on_an_identifier_in_strict_mode + case "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103": + return X_for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules + case "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104": + return A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement + case "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105": + return A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement + case "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106": + return The_left_hand_side_of_a_for_of_statement_may_not_be_async + case "Jump_target_cannot_cross_function_boundary_1107": + return Jump_target_cannot_cross_function_boundary + case "A_return_statement_can_only_be_used_within_a_function_body_1108": + return A_return_statement_can_only_be_used_within_a_function_body + case "Expression_expected_1109": + return Expression_expected + case "Type_expected_1110": + return Type_expected + case "Private_field_0_must_be_declared_in_an_enclosing_class_1111": + return Private_field_0_must_be_declared_in_an_enclosing_class + case "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113": + return A_default_clause_cannot_appear_more_than_once_in_a_switch_statement + case "Duplicate_label_0_1114": + return Duplicate_label_0 + case "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115": + return A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement + case "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116": + return A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement + case "An_object_literal_cannot_have_multiple_properties_with_the_same_name_1117": + return An_object_literal_cannot_have_multiple_properties_with_the_same_name + case "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118": + return An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name + case "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119": + return An_object_literal_cannot_have_property_and_accessor_with_the_same_name + case "An_export_assignment_cannot_have_modifiers_1120": + return An_export_assignment_cannot_have_modifiers + case "Octal_literals_are_not_allowed_Use_the_syntax_0_1121": + return Octal_literals_are_not_allowed_Use_the_syntax_0 + case "Variable_declaration_list_cannot_be_empty_1123": + return Variable_declaration_list_cannot_be_empty + case "Digit_expected_1124": + return Digit_expected + case "Hexadecimal_digit_expected_1125": + return Hexadecimal_digit_expected + case "Unexpected_end_of_text_1126": + return Unexpected_end_of_text + case "Invalid_character_1127": + return Invalid_character + case "Declaration_or_statement_expected_1128": + return Declaration_or_statement_expected + case "Statement_expected_1129": + return Statement_expected + case "case_or_default_expected_1130": + return X_case_or_default_expected + case "Property_or_signature_expected_1131": + return Property_or_signature_expected + case "Enum_member_expected_1132": + return Enum_member_expected + case "Variable_declaration_expected_1134": + return Variable_declaration_expected + case "Argument_expression_expected_1135": + return Argument_expression_expected + case "Property_assignment_expected_1136": + return Property_assignment_expected + case "Expression_or_comma_expected_1137": + return Expression_or_comma_expected + case "Parameter_declaration_expected_1138": + return Parameter_declaration_expected + case "Type_parameter_declaration_expected_1139": + return Type_parameter_declaration_expected + case "Type_argument_expected_1140": + return Type_argument_expected + case "String_literal_expected_1141": + return String_literal_expected + case "Line_break_not_permitted_here_1142": + return Line_break_not_permitted_here + case "or_expected_1144": + return X_or_expected + case "or_JSX_element_expected_1145": + return X_or_JSX_element_expected + case "Declaration_expected_1146": + return Declaration_expected + case "Import_declarations_in_a_namespace_cannot_reference_a_module_1147": + return Import_declarations_in_a_namespace_cannot_reference_a_module + case "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148": + return Cannot_use_imports_exports_or_module_augmentations_when_module_is_none + case "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149": + return File_name_0_differs_from_already_included_file_name_1_only_in_casing + case "_0_declarations_must_be_initialized_1155": + return X_0_declarations_must_be_initialized + case "_0_declarations_can_only_be_declared_inside_a_block_1156": + return X_0_declarations_can_only_be_declared_inside_a_block + case "Unterminated_template_literal_1160": + return Unterminated_template_literal + case "Unterminated_regular_expression_literal_1161": + return Unterminated_regular_expression_literal + case "An_object_member_cannot_be_declared_optional_1162": + return An_object_member_cannot_be_declared_optional + case "A_yield_expression_is_only_allowed_in_a_generator_body_1163": + return A_yield_expression_is_only_allowed_in_a_generator_body + case "Computed_property_names_are_not_allowed_in_enums_1164": + return Computed_property_names_are_not_allowed_in_enums + case "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165": + return A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type + case "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166": + return A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type + case "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168": + return A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type + case "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169": + return A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type + case "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170": + return A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type + case "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171": + return A_comma_expression_is_not_allowed_in_a_computed_property_name + case "extends_clause_already_seen_1172": + return X_extends_clause_already_seen + case "extends_clause_must_precede_implements_clause_1173": + return X_extends_clause_must_precede_implements_clause + case "Classes_can_only_extend_a_single_class_1174": + return Classes_can_only_extend_a_single_class + case "implements_clause_already_seen_1175": + return X_implements_clause_already_seen + case "Interface_declaration_cannot_have_implements_clause_1176": + return Interface_declaration_cannot_have_implements_clause + case "Binary_digit_expected_1177": + return Binary_digit_expected + case "Octal_digit_expected_1178": + return Octal_digit_expected + case "Unexpected_token_expected_1179": + return Unexpected_token_expected + case "Property_destructuring_pattern_expected_1180": + return Property_destructuring_pattern_expected + case "Array_element_destructuring_pattern_expected_1181": + return Array_element_destructuring_pattern_expected + case "A_destructuring_declaration_must_have_an_initializer_1182": + return A_destructuring_declaration_must_have_an_initializer + case "An_implementation_cannot_be_declared_in_ambient_contexts_1183": + return An_implementation_cannot_be_declared_in_ambient_contexts + case "Modifiers_cannot_appear_here_1184": + return Modifiers_cannot_appear_here + case "Merge_conflict_marker_encountered_1185": + return Merge_conflict_marker_encountered + case "A_rest_element_cannot_have_an_initializer_1186": + return A_rest_element_cannot_have_an_initializer + case "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187": + return A_parameter_property_may_not_be_declared_using_a_binding_pattern + case "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": + return Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement + case "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189": + return The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer + case "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190": + return The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer + case "An_import_declaration_cannot_have_modifiers_1191": + return An_import_declaration_cannot_have_modifiers + case "Module_0_has_no_default_export_1192": + return Module_0_has_no_default_export + case "An_export_declaration_cannot_have_modifiers_1193": + return An_export_declaration_cannot_have_modifiers + case "Export_declarations_are_not_permitted_in_a_namespace_1194": + return Export_declarations_are_not_permitted_in_a_namespace + case "export_Asterisk_does_not_re_export_a_default_1195": + return X_export_Asterisk_does_not_re_export_a_default + case "Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified_1196": + return Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified + case "Catch_clause_variable_cannot_have_an_initializer_1197": + return Catch_clause_variable_cannot_have_an_initializer + case "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198": + return An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive + case "Unterminated_Unicode_escape_sequence_1199": + return Unterminated_Unicode_escape_sequence + case "Line_terminator_not_permitted_before_arrow_1200": + return Line_terminator_not_permitted_before_arrow + case "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202": + return Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead + case "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203": + return Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead + case "Re_exporting_a_type_when_0_is_enabled_requires_using_export_type_1205": + return Re_exporting_a_type_when_0_is_enabled_requires_using_export_type + case "Decorators_are_not_valid_here_1206": + return Decorators_are_not_valid_here + case "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207": + return Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name + case "Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0_1209": + return Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0 + case "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210": + return Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode + case "A_class_declaration_without_the_default_modifier_must_have_a_name_1211": + return A_class_declaration_without_the_default_modifier_must_have_a_name + case "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212": + return Identifier_expected_0_is_a_reserved_word_in_strict_mode + case "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213": + return Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode + case "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214": + return Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode + case "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215": + return Invalid_use_of_0_Modules_are_automatically_in_strict_mode + case "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": + return Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules + case "Export_assignment_is_not_supported_when_module_flag_is_system_1218": + return Export_assignment_is_not_supported_when_module_flag_is_system + case "Generators_are_not_allowed_in_an_ambient_context_1221": + return Generators_are_not_allowed_in_an_ambient_context + case "An_overload_signature_cannot_be_declared_as_a_generator_1222": + return An_overload_signature_cannot_be_declared_as_a_generator + case "_0_tag_already_specified_1223": + return X_0_tag_already_specified + case "Signature_0_must_be_a_type_predicate_1224": + return Signature_0_must_be_a_type_predicate + case "Cannot_find_parameter_0_1225": + return Cannot_find_parameter_0 + case "Type_predicate_0_is_not_assignable_to_1_1226": + return Type_predicate_0_is_not_assignable_to_1 + case "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": + return Parameter_0_is_not_in_the_same_position_as_parameter_1 + case "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228": + return A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods + case "A_type_predicate_cannot_reference_a_rest_parameter_1229": + return A_type_predicate_cannot_reference_a_rest_parameter + case "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230": + return A_type_predicate_cannot_reference_element_0_in_a_binding_pattern + case "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231": + return An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + case "An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1232": + return An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module + case "An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1233": + return An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module + case "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234": + return An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file + case "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235": + return A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module + case "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236": + return The_return_type_of_a_property_decorator_function_must_be_either_void_or_any + case "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237": + return The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any + case "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238": + return Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression + case "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239": + return Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression + case "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240": + return Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression + case "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241": + return Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression + case "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242": + return X_abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration + case "_0_modifier_cannot_be_used_with_1_modifier_1243": + return X_0_modifier_cannot_be_used_with_1_modifier + case "Abstract_methods_can_only_appear_within_an_abstract_class_1244": + return Abstract_methods_can_only_appear_within_an_abstract_class + case "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245": + return Method_0_cannot_have_an_implementation_because_it_is_marked_abstract + case "An_interface_property_cannot_have_an_initializer_1246": + return An_interface_property_cannot_have_an_initializer + case "A_type_literal_property_cannot_have_an_initializer_1247": + return A_type_literal_property_cannot_have_an_initializer + case "A_class_member_cannot_have_the_0_keyword_1248": + return A_class_member_cannot_have_the_0_keyword + case "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249": + return A_decorator_can_only_decorate_a_method_implementation_not_an_overload + case "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_1250": + return Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5 + case "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Class_definiti_1251": + return Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Class_definitions_are_automatically_in_strict_mode + case "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Modules_are_au_1252": + return Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Modules_are_automatically_in_strict_mode + case "Abstract_properties_can_only_appear_within_an_abstract_class_1253": + return Abstract_properties_can_only_appear_within_an_abstract_class + case "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254": + return A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference + case "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255": + return A_definite_assignment_assertion_is_not_permitted_in_this_context + case "A_required_element_cannot_follow_an_optional_element_1257": + return A_required_element_cannot_follow_an_optional_element + case "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258": + return A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration + case "Module_0_can_only_be_default_imported_using_the_1_flag_1259": + return Module_0_can_only_be_default_imported_using_the_1_flag + case "Keywords_cannot_contain_escape_characters_1260": + return Keywords_cannot_contain_escape_characters + case "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261": + return Already_included_file_name_0_differs_from_file_name_1_only_in_casing + case "Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module_1262": + return Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module + case "Declarations_with_initializers_cannot_also_have_definite_assignment_assertions_1263": + return Declarations_with_initializers_cannot_also_have_definite_assignment_assertions + case "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264": + return Declarations_with_definite_assignment_assertions_must_also_have_type_annotations + case "A_rest_element_cannot_follow_another_rest_element_1265": + return A_rest_element_cannot_follow_another_rest_element + case "An_optional_element_cannot_follow_a_rest_element_1266": + return An_optional_element_cannot_follow_a_rest_element + case "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267": + return Property_0_cannot_have_an_initializer_because_it_is_marked_abstract + case "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": + return An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type + case "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled_1269": + return Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled + case "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270": + return Decorator_function_return_type_0_is_not_assignable_to_type_1 + case "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271": + return Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any + case "A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_w_1272": + return A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled + case "_0_modifier_cannot_appear_on_a_type_parameter_1273": + return X_0_modifier_cannot_appear_on_a_type_parameter + case "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274": + return X_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias + case "accessor_modifier_can_only_appear_on_a_property_declaration_1275": + return X_accessor_modifier_can_only_appear_on_a_property_declaration + case "An_accessor_property_cannot_be_declared_optional_1276": + return An_accessor_property_cannot_be_declared_optional + case "_0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class_1277": + return X_0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class + case "The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_0_1278": + return The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_0 + case "The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_at_least_0_1279": + return The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_at_least_0 + case "Namespaces_are_not_allowed_in_global_script_files_when_0_is_enabled_If_this_file_is_not_intended_to__1280": + return Namespaces_are_not_allowed_in_global_script_files_when_0_is_enabled_If_this_file_is_not_intended_to_be_a_global_script_set_moduleDetection_to_force_or_add_an_empty_export_statement + case "Cannot_access_0_from_another_file_without_qualification_when_1_is_enabled_Use_2_instead_1281": + return Cannot_access_0_from_another_file_without_qualification_when_1_is_enabled_Use_2_instead + case "An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers__1282": + return An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type + case "An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolve_1283": + return An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration + case "An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_1284": + return An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type + case "An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_1285": + return An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration + case "ECMAScript_imports_and_exports_cannot_be_written_in_a_CommonJS_file_under_verbatimModuleSyntax_1286": + return ECMAScript_imports_and_exports_cannot_be_written_in_a_CommonJS_file_under_verbatimModuleSyntax + case "A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimM_1287": + return A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled + case "An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabl_1288": + return An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabled + case "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1289": + return X_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported + case "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290": + return X_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default + case "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291": + return X_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported + case "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292": + return X_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default + case "ECMAScript_module_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve_1293": + return ECMAScript_module_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve + case "This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled_1294": + return This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled + case "ECMAScript_imports_and_exports_cannot_be_written_in_a_CommonJS_file_under_verbatimModuleSyntax_Adjus_1295": + return ECMAScript_imports_and_exports_cannot_be_written_in_a_CommonJS_file_under_verbatimModuleSyntax_Adjust_the_type_field_in_the_nearest_package_json_to_make_this_file_an_ECMAScript_module_or_adjust_your_verbatimModuleSyntax_module_and_moduleResolution_settings_in_TypeScript + case "with_statements_are_not_allowed_in_an_async_function_block_1300": + return X_with_statements_are_not_allowed_in_an_async_function_block + case "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308": + return X_await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules + case "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309": + return The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level + case "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312": + return Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern + case "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313": + return The_body_of_an_if_statement_cannot_be_the_empty_statement + case "Global_module_exports_may_only_appear_in_module_files_1314": + return Global_module_exports_may_only_appear_in_module_files + case "Global_module_exports_may_only_appear_in_declaration_files_1315": + return Global_module_exports_may_only_appear_in_declaration_files + case "Global_module_exports_may_only_appear_at_top_level_1316": + return Global_module_exports_may_only_appear_at_top_level + case "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": + return A_parameter_property_cannot_be_declared_using_a_rest_parameter + case "An_abstract_accessor_cannot_have_an_implementation_1318": + return An_abstract_accessor_cannot_have_an_implementation + case "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319": + return A_default_export_can_only_be_used_in_an_ECMAScript_style_module + case "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": + return Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + case "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": + return Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + case "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": + return Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + case "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": + return Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_node18_node20_or_nodenext + case "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_node18_1324": + return Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_node18_node20_nodenext_or_preserve + case "Argument_of_dynamic_import_cannot_be_spread_element_1325": + return Argument_of_dynamic_import_cannot_be_spread_element + case "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": + return This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments + case "String_literal_with_double_quotes_expected_1327": + return String_literal_with_double_quotes_expected + case "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328": + return Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal + case "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": + return X_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0 + case "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330": + return A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly + case "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331": + return A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly + case "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332": + return A_variable_whose_type_is_a_unique_symbol_type_must_be_const + case "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333": + return X_unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name + case "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334": + return X_unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement + case "unique_symbol_types_are_not_allowed_here_1335": + return X_unique_symbol_types_are_not_allowed_here + case "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": + return An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead + case "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338": + return X_infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type + case "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339": + return Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + case "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340": + return Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0 + case "Class_constructor_may_not_be_an_accessor_1341": + return Class_constructor_may_not_be_an_accessor + case "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343": + return The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_node18_node20_or_nodenext + case "A_label_is_not_allowed_here_1344": + return A_label_is_not_allowed_here + case "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345": + return An_expression_of_type_void_cannot_be_tested_for_truthiness + case "This_parameter_is_not_allowed_with_use_strict_directive_1346": + return This_parameter_is_not_allowed_with_use_strict_directive + case "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347": + return X_use_strict_directive_cannot_be_used_with_non_simple_parameter_list + case "Non_simple_parameter_declared_here_1348": + return Non_simple_parameter_declared_here + case "use_strict_directive_used_here_1349": + return X_use_strict_directive_used_here + case "Print_the_final_configuration_instead_of_building_1350": + return Print_the_final_configuration_instead_of_building + case "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351": + return An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal + case "A_bigint_literal_cannot_use_exponential_notation_1352": + return A_bigint_literal_cannot_use_exponential_notation + case "A_bigint_literal_must_be_an_integer_1353": + return A_bigint_literal_must_be_an_integer + case "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354": + return X_readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types + case "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355": + return A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals + case "Did_you_mean_to_mark_this_function_as_async_1356": + return Did_you_mean_to_mark_this_function_as_async + case "An_enum_member_name_must_be_followed_by_a_or_1357": + return An_enum_member_name_must_be_followed_by_a_or + case "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358": + return Tagged_template_expressions_are_not_permitted_in_an_optional_chain + case "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": + return Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here + case "Type_0_does_not_satisfy_the_expected_type_1_1360": + return Type_0_does_not_satisfy_the_expected_type_1 + case "_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type_1361": + return X_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type + case "_0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type_1362": + return X_0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type + case "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": + return A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both + case "Convert_to_type_only_export_1364": + return Convert_to_type_only_export + case "Convert_all_re_exported_types_to_type_only_exports_1365": + return Convert_all_re_exported_types_to_type_only_exports + case "Split_into_two_separate_import_declarations_1366": + return Split_into_two_separate_import_declarations + case "Split_all_invalid_type_only_imports_1367": + return Split_all_invalid_type_only_imports + case "Class_constructor_may_not_be_a_generator_1368": + return Class_constructor_may_not_be_a_generator + case "Did_you_mean_0_1369": + return Did_you_mean_0 + case "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375": + return X_await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module + case "_0_was_imported_here_1376": + return X_0_was_imported_here + case "_0_was_exported_here_1377": + return X_0_was_exported_here + case "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": + return Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_node20_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher + case "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": + return An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type + case "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": + return An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type + case "Unexpected_token_Did_you_mean_or_rbrace_1381": + return Unexpected_token_Did_you_mean_or_rbrace + case "Unexpected_token_Did_you_mean_or_gt_1382": + return Unexpected_token_Did_you_mean_or_gt + case "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385": + return Function_type_notation_must_be_parenthesized_when_used_in_a_union_type + case "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386": + return Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type + case "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387": + return Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type + case "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388": + return Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type + case "_0_is_not_allowed_as_a_variable_declaration_name_1389": + return X_0_is_not_allowed_as_a_variable_declaration_name + case "_0_is_not_allowed_as_a_parameter_name_1390": + return X_0_is_not_allowed_as_a_parameter_name + case "An_import_alias_cannot_use_import_type_1392": + return An_import_alias_cannot_use_import_type + case "Imported_via_0_from_file_1_1393": + return Imported_via_0_from_file_1 + case "Imported_via_0_from_file_1_with_packageId_2_1394": + return Imported_via_0_from_file_1_with_packageId_2 + case "Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions_1395": + return Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions + case "Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions_1396": + return Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions + case "Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions_1397": + return Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions + case "Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions_1398": + return Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions + case "File_is_included_via_import_here_1399": + return File_is_included_via_import_here + case "Referenced_via_0_from_file_1_1400": + return Referenced_via_0_from_file_1 + case "File_is_included_via_reference_here_1401": + return File_is_included_via_reference_here + case "Type_library_referenced_via_0_from_file_1_1402": + return Type_library_referenced_via_0_from_file_1 + case "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": + return Type_library_referenced_via_0_from_file_1_with_packageId_2 + case "File_is_included_via_type_library_reference_here_1404": + return File_is_included_via_type_library_reference_here + case "Library_referenced_via_0_from_file_1_1405": + return Library_referenced_via_0_from_file_1 + case "File_is_included_via_library_reference_here_1406": + return File_is_included_via_library_reference_here + case "Matched_by_include_pattern_0_in_1_1407": + return Matched_by_include_pattern_0_in_1 + case "File_is_matched_by_include_pattern_specified_here_1408": + return File_is_matched_by_include_pattern_specified_here + case "Part_of_files_list_in_tsconfig_json_1409": + return Part_of_files_list_in_tsconfig_json + case "File_is_matched_by_files_list_specified_here_1410": + return File_is_matched_by_files_list_specified_here + case "Output_from_referenced_project_0_included_because_1_specified_1411": + return Output_from_referenced_project_0_included_because_1_specified + case "Output_from_referenced_project_0_included_because_module_is_specified_as_none_1412": + return Output_from_referenced_project_0_included_because_module_is_specified_as_none + case "File_is_output_from_referenced_project_specified_here_1413": + return File_is_output_from_referenced_project_specified_here + case "Source_from_referenced_project_0_included_because_1_specified_1414": + return Source_from_referenced_project_0_included_because_1_specified + case "Source_from_referenced_project_0_included_because_module_is_specified_as_none_1415": + return Source_from_referenced_project_0_included_because_module_is_specified_as_none + case "File_is_source_from_referenced_project_specified_here_1416": + return File_is_source_from_referenced_project_specified_here + case "Entry_point_of_type_library_0_specified_in_compilerOptions_1417": + return Entry_point_of_type_library_0_specified_in_compilerOptions + case "Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1_1418": + return Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1 + case "File_is_entry_point_of_type_library_specified_here_1419": + return File_is_entry_point_of_type_library_specified_here + case "Entry_point_for_implicit_type_library_0_1420": + return Entry_point_for_implicit_type_library_0 + case "Entry_point_for_implicit_type_library_0_with_packageId_1_1421": + return Entry_point_for_implicit_type_library_0_with_packageId_1 + case "Library_0_specified_in_compilerOptions_1422": + return Library_0_specified_in_compilerOptions + case "File_is_library_specified_here_1423": + return File_is_library_specified_here + case "Default_library_1424": + return Default_library + case "Default_library_for_target_0_1425": + return Default_library_for_target_0 + case "File_is_default_library_for_target_specified_here_1426": + return File_is_default_library_for_target_specified_here + case "Root_file_specified_for_compilation_1427": + return Root_file_specified_for_compilation + case "File_is_output_of_project_reference_source_0_1428": + return File_is_output_of_project_reference_source_0 + case "File_redirects_to_file_0_1429": + return File_redirects_to_file_0 + case "The_file_is_in_the_program_because_Colon_1430": + return The_file_is_in_the_program_because_Colon + case "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431": + return X_for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module + case "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432": + return Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_node20_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher + case "Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters_1433": + return Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters + case "Unexpected_keyword_or_identifier_1434": + return Unexpected_keyword_or_identifier + case "Unknown_keyword_or_identifier_Did_you_mean_0_1435": + return Unknown_keyword_or_identifier_Did_you_mean_0 + case "Decorators_must_precede_the_name_and_all_keywords_of_property_declarations_1436": + return Decorators_must_precede_the_name_and_all_keywords_of_property_declarations + case "Namespace_must_be_given_a_name_1437": + return Namespace_must_be_given_a_name + case "Interface_must_be_given_a_name_1438": + return Interface_must_be_given_a_name + case "Type_alias_must_be_given_a_name_1439": + return Type_alias_must_be_given_a_name + case "Variable_declaration_not_allowed_at_this_location_1440": + return Variable_declaration_not_allowed_at_this_location + case "Cannot_start_a_function_call_in_a_type_annotation_1441": + return Cannot_start_a_function_call_in_a_type_annotation + case "Expected_for_property_initializer_1442": + return Expected_for_property_initializer + case "Module_declaration_names_may_only_use_or_quoted_strings_1443": + return Module_declaration_names_may_only_use_or_quoted_strings + case "_0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_1_is_1448": + return X_0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_1_is_enabled + case "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449": + return Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed + case "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_set_of_attributes_as_arguments_1450": + return Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_set_of_attributes_as_arguments + case "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451": + return Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression + case "resolution_mode_should_be_either_require_or_import_1453": + return X_resolution_mode_should_be_either_require_or_import + case "resolution_mode_can_only_be_set_for_type_only_imports_1454": + return X_resolution_mode_can_only_be_set_for_type_only_imports + case "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455": + return X_resolution_mode_is_the_only_valid_key_for_type_import_assertions + case "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456": + return Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require + case "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457": + return Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk + case "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": + return File_is_ECMAScript_module_because_0_has_field_type_with_value_module + case "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": + return File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module + case "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": + return File_is_CommonJS_module_because_0_does_not_have_field_type + case "File_is_CommonJS_module_because_package_json_was_not_found_1461": + return File_is_CommonJS_module_because_package_json_was_not_found + case "resolution_mode_is_the_only_valid_key_for_type_import_attributes_1463": + return X_resolution_mode_is_the_only_valid_key_for_type_import_attributes + case "Type_import_attributes_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1464": + return Type_import_attributes_should_have_exactly_one_key_resolution_mode_with_value_import_or_require + case "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470": + return The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output + case "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471": + return Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead + case "catch_or_finally_expected_1472": + return X_catch_or_finally_expected + case "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473": + return An_import_declaration_can_only_be_used_at_the_top_level_of_a_module + case "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474": + return An_export_declaration_can_only_be_used_at_the_top_level_of_a_module + case "Control_what_method_is_used_to_detect_module_format_JS_files_1475": + return Control_what_method_is_used_to_detect_module_format_JS_files + case "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476": + return X_auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules + case "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": + return An_instantiation_expression_cannot_be_followed_by_a_property_access + case "Identifier_or_string_literal_expected_1478": + return Identifier_or_string_literal_expected + case "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479": + return The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead + case "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480": + return To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module + case "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481": + return To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1 + case "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482": + return To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0 + case "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483": + return To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module + case "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled_1484": + return X_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled + case "_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimMo_1485": + return X_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled + case "Decorator_used_before_export_here_1486": + return Decorator_used_before_export_here + case "Octal_escape_sequences_are_not_allowed_Use_the_syntax_0_1487": + return Octal_escape_sequences_are_not_allowed_Use_the_syntax_0 + case "Escape_sequence_0_is_not_allowed_1488": + return Escape_sequence_0_is_not_allowed + case "Decimals_with_leading_zeros_are_not_allowed_1489": + return Decimals_with_leading_zeros_are_not_allowed + case "File_appears_to_be_binary_1490": + return File_appears_to_be_binary + case "_0_modifier_cannot_appear_on_a_using_declaration_1491": + return X_0_modifier_cannot_appear_on_a_using_declaration + case "_0_declarations_may_not_have_binding_patterns_1492": + return X_0_declarations_may_not_have_binding_patterns + case "The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration_1493": + return The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration + case "The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration_1494": + return The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration + case "_0_modifier_cannot_appear_on_an_await_using_declaration_1495": + return X_0_modifier_cannot_appear_on_an_await_using_declaration + case "Identifier_string_literal_or_number_literal_expected_1496": + return Identifier_string_literal_or_number_literal_expected + case "Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator_1497": + return Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator + case "Invalid_syntax_in_decorator_1498": + return Invalid_syntax_in_decorator + case "Unknown_regular_expression_flag_1499": + return Unknown_regular_expression_flag + case "Duplicate_regular_expression_flag_1500": + return Duplicate_regular_expression_flag + case "This_regular_expression_flag_is_only_available_when_targeting_0_or_later_1501": + return This_regular_expression_flag_is_only_available_when_targeting_0_or_later + case "The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously_1502": + return The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously + case "Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later_1503": + return Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later + case "Subpattern_flags_must_be_present_when_there_is_a_minus_sign_1504": + return Subpattern_flags_must_be_present_when_there_is_a_minus_sign + case "Incomplete_quantifier_Digit_expected_1505": + return Incomplete_quantifier_Digit_expected + case "Numbers_out_of_order_in_quantifier_1506": + return Numbers_out_of_order_in_quantifier + case "There_is_nothing_available_for_repetition_1507": + return There_is_nothing_available_for_repetition + case "Unexpected_0_Did_you_mean_to_escape_it_with_backslash_1508": + return Unexpected_0_Did_you_mean_to_escape_it_with_backslash + case "This_regular_expression_flag_cannot_be_toggled_within_a_subpattern_1509": + return This_regular_expression_flag_cannot_be_toggled_within_a_subpattern + case "k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets_1510": + return X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets + case "q_is_only_available_inside_character_class_1511": + return X_q_is_only_available_inside_character_class + case "c_must_be_followed_by_an_ASCII_letter_1512": + return X_c_must_be_followed_by_an_ASCII_letter + case "Undetermined_character_escape_1513": + return Undetermined_character_escape + case "Expected_a_capturing_group_name_1514": + return Expected_a_capturing_group_name + case "Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other_1515": + return Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other + case "A_character_class_range_must_not_be_bounded_by_another_character_class_1516": + return A_character_class_range_must_not_be_bounded_by_another_character_class + case "Range_out_of_order_in_character_class_1517": + return Range_out_of_order_in_character_class + case "Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_characte_1518": + return Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class + case "Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead_1519": + return Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead + case "Expected_a_class_set_operand_1520": + return Expected_a_class_set_operand + case "q_must_be_followed_by_string_alternatives_enclosed_in_braces_1521": + return X_q_must_be_followed_by_string_alternatives_enclosed_in_braces + case "A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backs_1522": + return A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash + case "Expected_a_Unicode_property_name_1523": + return Expected_a_Unicode_property_name + case "Unknown_Unicode_property_name_1524": + return Unknown_Unicode_property_name + case "Expected_a_Unicode_property_value_1525": + return Expected_a_Unicode_property_value + case "Unknown_Unicode_property_value_1526": + return Unknown_Unicode_property_value + case "Expected_a_Unicode_property_name_or_value_1527": + return Expected_a_Unicode_property_name_or_value + case "Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_t_1528": + return Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set + case "Unknown_Unicode_property_name_or_value_1529": + return Unknown_Unicode_property_name_or_value + case "Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v__1530": + return Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set + case "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1531": + return X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces + case "There_is_no_capturing_group_named_0_in_this_regular_expression_1532": + return There_is_no_capturing_group_named_0_in_this_regular_expression + case "This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_r_1533": + return This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression + case "This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regul_1534": + return This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression + case "This_character_cannot_be_escaped_in_a_regular_expression_1535": + return This_character_cannot_be_escaped_in_a_regular_expression + case "Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended__1536": + return Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended_as_an_escape_sequence_use_the_syntax_0_instead + case "Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_1537": + return Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class + case "Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_se_1538": + return Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set + case "A_bigint_literal_cannot_be_used_as_a_property_name_1539": + return A_bigint_literal_cannot_be_used_as_a_property_name + case "A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_key_1540": + return A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead + case "Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribut_1541": + return Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute + case "Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute_1542": + return Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute + case "Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_mod_1543": + return Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_module_is_set_to_0 + case "Named_imports_from_a_JSON_file_into_an_ECMAScript_module_are_not_allowed_when_module_is_set_to_0_1544": + return Named_imports_from_a_JSON_file_into_an_ECMAScript_module_are_not_allowed_when_module_is_set_to_0 + case "using_declarations_are_not_allowed_in_ambient_contexts_1545": + return X_using_declarations_are_not_allowed_in_ambient_contexts + case "await_using_declarations_are_not_allowed_in_ambient_contexts_1546": + return X_await_using_declarations_are_not_allowed_in_ambient_contexts + case "Ignore_the_tsconfig_found_and_build_with_commandline_options_and_files_1549": + return Ignore_the_tsconfig_found_and_build_with_commandline_options_and_files + case "The_types_of_0_are_incompatible_between_these_types_2200": + return The_types_of_0_are_incompatible_between_these_types + case "The_types_returned_by_0_are_incompatible_between_these_types_2201": + return The_types_returned_by_0_are_incompatible_between_these_types + case "Call_signature_return_types_0_and_1_are_incompatible_2202": + return Call_signature_return_types_0_and_1_are_incompatible + case "Construct_signature_return_types_0_and_1_are_incompatible_2203": + return Construct_signature_return_types_0_and_1_are_incompatible + case "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204": + return Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1 + case "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205": + return Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1 + case "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206": + return The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement + case "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207": + return The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement + case "This_type_parameter_might_need_an_extends_0_constraint_2208": + return This_type_parameter_might_need_an_extends_0_constraint + case "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209": + return The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + case "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210": + return The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + case "Add_extends_constraint_2211": + return Add_extends_constraint + case "Add_extends_constraint_to_all_type_parameters_2212": + return Add_extends_constraint_to_all_type_parameters + case "Duplicate_identifier_0_2300": + return Duplicate_identifier_0 + case "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": + return Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + case "Static_members_cannot_reference_class_type_parameters_2302": + return Static_members_cannot_reference_class_type_parameters + case "Circular_definition_of_import_alias_0_2303": + return Circular_definition_of_import_alias_0 + case "Cannot_find_name_0_2304": + return Cannot_find_name_0 + case "Module_0_has_no_exported_member_1_2305": + return Module_0_has_no_exported_member_1 + case "File_0_is_not_a_module_2306": + return File_0_is_not_a_module + case "Cannot_find_module_0_or_its_corresponding_type_declarations_2307": + return Cannot_find_module_0_or_its_corresponding_type_declarations + case "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308": + return Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity + case "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": + return An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements + case "Type_0_recursively_references_itself_as_a_base_type_2310": + return Type_0_recursively_references_itself_as_a_base_type + case "Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function_2311": + return Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function + case "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": + return An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members + case "Type_parameter_0_has_a_circular_constraint_2313": + return Type_parameter_0_has_a_circular_constraint + case "Generic_type_0_requires_1_type_argument_s_2314": + return Generic_type_0_requires_1_type_argument_s + case "Type_0_is_not_generic_2315": + return Type_0_is_not_generic + case "Global_type_0_must_be_a_class_or_interface_type_2316": + return Global_type_0_must_be_a_class_or_interface_type + case "Global_type_0_must_have_1_type_parameter_s_2317": + return Global_type_0_must_have_1_type_parameter_s + case "Cannot_find_global_type_0_2318": + return Cannot_find_global_type_0 + case "Named_property_0_of_types_1_and_2_are_not_identical_2319": + return Named_property_0_of_types_1_and_2_are_not_identical + case "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320": + return Interface_0_cannot_simultaneously_extend_types_1_and_2 + case "Excessive_stack_depth_comparing_types_0_and_1_2321": + return Excessive_stack_depth_comparing_types_0_and_1 + case "Type_0_is_not_assignable_to_type_1_2322": + return Type_0_is_not_assignable_to_type_1 + case "Cannot_redeclare_exported_variable_0_2323": + return Cannot_redeclare_exported_variable_0 + case "Property_0_is_missing_in_type_1_2324": + return Property_0_is_missing_in_type_1 + case "Property_0_is_private_in_type_1_but_not_in_type_2_2325": + return Property_0_is_private_in_type_1_but_not_in_type_2 + case "Types_of_property_0_are_incompatible_2326": + return Types_of_property_0_are_incompatible + case "Property_0_is_optional_in_type_1_but_required_in_type_2_2327": + return Property_0_is_optional_in_type_1_but_required_in_type_2 + case "Types_of_parameters_0_and_1_are_incompatible_2328": + return Types_of_parameters_0_and_1_are_incompatible + case "Index_signature_for_type_0_is_missing_in_type_1_2329": + return Index_signature_for_type_0_is_missing_in_type_1 + case "_0_and_1_index_signatures_are_incompatible_2330": + return X_0_and_1_index_signatures_are_incompatible + case "this_cannot_be_referenced_in_a_module_or_namespace_body_2331": + return X_this_cannot_be_referenced_in_a_module_or_namespace_body + case "this_cannot_be_referenced_in_current_location_2332": + return X_this_cannot_be_referenced_in_current_location + case "this_cannot_be_referenced_in_a_static_property_initializer_2334": + return X_this_cannot_be_referenced_in_a_static_property_initializer + case "super_can_only_be_referenced_in_a_derived_class_2335": + return X_super_can_only_be_referenced_in_a_derived_class + case "super_cannot_be_referenced_in_constructor_arguments_2336": + return X_super_cannot_be_referenced_in_constructor_arguments + case "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337": + return Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors + case "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338": + return X_super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class + case "Property_0_does_not_exist_on_type_1_2339": + return Property_0_does_not_exist_on_type_1 + case "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340": + return Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword + case "Property_0_is_private_and_only_accessible_within_class_1_2341": + return Property_0_is_private_and_only_accessible_within_class_1 + case "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": + return This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0 + case "Type_0_does_not_satisfy_the_constraint_1_2344": + return Type_0_does_not_satisfy_the_constraint_1 + case "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345": + return Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 + case "Call_target_does_not_contain_any_signatures_2346": + return Call_target_does_not_contain_any_signatures + case "Untyped_function_calls_may_not_accept_type_arguments_2347": + return Untyped_function_calls_may_not_accept_type_arguments + case "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348": + return Value_of_type_0_is_not_callable_Did_you_mean_to_include_new + case "This_expression_is_not_callable_2349": + return This_expression_is_not_callable + case "Only_a_void_function_can_be_called_with_the_new_keyword_2350": + return Only_a_void_function_can_be_called_with_the_new_keyword + case "This_expression_is_not_constructable_2351": + return This_expression_is_not_constructable + case "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352": + return Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first + case "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353": + return Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1 + case "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": + return This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found + case "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355": + return A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value + case "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356": + return An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type + case "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": + return The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access + case "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358": + return The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter + case "The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_2359": + return The_right_hand_side_of_an_instanceof_expression_must_be_either_of_type_any_a_class_function_or_other_type_assignable_to_the_Function_interface_type_or_an_object_type_with_a_Symbol_hasInstance_method + case "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362": + return The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type + case "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363": + return The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type + case "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364": + return The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access + case "Operator_0_cannot_be_applied_to_types_1_and_2_2365": + return Operator_0_cannot_be_applied_to_types_1_and_2 + case "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": + return Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined + case "This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap_2367": + return This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap + case "Type_parameter_name_cannot_be_0_2368": + return Type_parameter_name_cannot_be_0 + case "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": + return A_parameter_property_is_only_allowed_in_a_constructor_implementation + case "A_rest_parameter_must_be_of_an_array_type_2370": + return A_rest_parameter_must_be_of_an_array_type + case "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": + return A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation + case "Parameter_0_cannot_reference_itself_2372": + return Parameter_0_cannot_reference_itself + case "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": + return Parameter_0_cannot_reference_identifier_1_declared_after_it + case "Duplicate_index_signature_for_type_0_2374": + return Duplicate_index_signature_for_type_0 + case "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375": + return Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties + case "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376": + return A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers + case "Constructors_for_derived_classes_must_contain_a_super_call_2377": + return Constructors_for_derived_classes_must_contain_a_super_call + case "A_get_accessor_must_return_a_value_2378": + return A_get_accessor_must_return_a_value + case "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379": + return Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties + case "Overload_signatures_must_all_be_exported_or_non_exported_2383": + return Overload_signatures_must_all_be_exported_or_non_exported + case "Overload_signatures_must_all_be_ambient_or_non_ambient_2384": + return Overload_signatures_must_all_be_ambient_or_non_ambient + case "Overload_signatures_must_all_be_public_private_or_protected_2385": + return Overload_signatures_must_all_be_public_private_or_protected + case "Overload_signatures_must_all_be_optional_or_required_2386": + return Overload_signatures_must_all_be_optional_or_required + case "Function_overload_must_be_static_2387": + return Function_overload_must_be_static + case "Function_overload_must_not_be_static_2388": + return Function_overload_must_not_be_static + case "Function_implementation_name_must_be_0_2389": + return Function_implementation_name_must_be_0 + case "Constructor_implementation_is_missing_2390": + return Constructor_implementation_is_missing + case "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": + return Function_implementation_is_missing_or_not_immediately_following_the_declaration + case "Multiple_constructor_implementations_are_not_allowed_2392": + return Multiple_constructor_implementations_are_not_allowed + case "Duplicate_function_implementation_2393": + return Duplicate_function_implementation + case "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394": + return This_overload_signature_is_not_compatible_with_its_implementation_signature + case "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": + return Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local + case "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396": + return Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters + case "Declaration_name_conflicts_with_built_in_global_identifier_0_2397": + return Declaration_name_conflicts_with_built_in_global_identifier_0 + case "constructor_cannot_be_used_as_a_parameter_property_name_2398": + return X_constructor_cannot_be_used_as_a_parameter_property_name + case "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399": + return Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference + case "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400": + return Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference + case "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401": + return A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers + case "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402": + return Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference + case "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403": + return Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2 + case "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404": + return The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation + case "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405": + return The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any + case "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406": + return The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access + case "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407": + return The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0 + case "Setters_cannot_return_a_value_2408": + return Setters_cannot_return_a_value + case "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409": + return Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class + case "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410": + return The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any + case "Property_0_of_type_1_is_not_assignable_to_2_index_type_3_2411": + return Property_0_of_type_1_is_not_assignable_to_2_index_type_3 + case "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2412": + return Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target + case "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": + return X_0_index_type_1_is_not_assignable_to_2_index_type_3 + case "Class_name_cannot_be_0_2414": + return Class_name_cannot_be_0 + case "Class_0_incorrectly_extends_base_class_1_2415": + return Class_0_incorrectly_extends_base_class_1 + case "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": + return Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2 + case "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": + return Class_static_side_0_incorrectly_extends_base_class_static_side_1 + case "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": + return Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 + case "Types_of_construct_signatures_are_incompatible_2419": + return Types_of_construct_signatures_are_incompatible + case "Class_0_incorrectly_implements_interface_1_2420": + return Class_0_incorrectly_implements_interface_1 + case "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422": + return A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members + case "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423": + return Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor + case "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425": + return Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function + case "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426": + return Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function + case "Interface_name_cannot_be_0_2427": + return Interface_name_cannot_be_0 + case "All_declarations_of_0_must_have_identical_type_parameters_2428": + return All_declarations_of_0_must_have_identical_type_parameters + case "Interface_0_incorrectly_extends_interface_1_2430": + return Interface_0_incorrectly_extends_interface_1 + case "Enum_name_cannot_be_0_2431": + return Enum_name_cannot_be_0 + case "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432": + return In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element + case "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433": + return A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged + case "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": + return A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged + case "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435": + return Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces + case "Ambient_module_declaration_cannot_specify_relative_module_name_2436": + return Ambient_module_declaration_cannot_specify_relative_module_name + case "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437": + return Module_0_is_hidden_by_a_local_declaration_with_the_same_name + case "Import_name_cannot_be_0_2438": + return Import_name_cannot_be_0 + case "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439": + return Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name + case "Import_declaration_conflicts_with_local_declaration_of_0_2440": + return Import_declaration_conflicts_with_local_declaration_of_0 + case "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441": + return Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module + case "Types_have_separate_declarations_of_a_private_property_0_2442": + return Types_have_separate_declarations_of_a_private_property_0 + case "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443": + return Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2 + case "Property_0_is_protected_in_type_1_but_public_in_type_2_2444": + return Property_0_is_protected_in_type_1_but_public_in_type_2 + case "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445": + return Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses + case "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446": + return Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2 + case "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447": + return The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead + case "Block_scoped_variable_0_used_before_its_declaration_2448": + return Block_scoped_variable_0_used_before_its_declaration + case "Class_0_used_before_its_declaration_2449": + return Class_0_used_before_its_declaration + case "Enum_0_used_before_its_declaration_2450": + return Enum_0_used_before_its_declaration + case "Cannot_redeclare_block_scoped_variable_0_2451": + return Cannot_redeclare_block_scoped_variable_0 + case "An_enum_member_cannot_have_a_numeric_name_2452": + return An_enum_member_cannot_have_a_numeric_name + case "Variable_0_is_used_before_being_assigned_2454": + return Variable_0_is_used_before_being_assigned + case "Type_alias_0_circularly_references_itself_2456": + return Type_alias_0_circularly_references_itself + case "Type_alias_name_cannot_be_0_2457": + return Type_alias_name_cannot_be_0 + case "An_AMD_module_cannot_have_multiple_name_assignments_2458": + return An_AMD_module_cannot_have_multiple_name_assignments + case "Module_0_declares_1_locally_but_it_is_not_exported_2459": + return Module_0_declares_1_locally_but_it_is_not_exported + case "Module_0_declares_1_locally_but_it_is_exported_as_2_2460": + return Module_0_declares_1_locally_but_it_is_exported_as_2 + case "Type_0_is_not_an_array_type_2461": + return Type_0_is_not_an_array_type + case "A_rest_element_must_be_last_in_a_destructuring_pattern_2462": + return A_rest_element_must_be_last_in_a_destructuring_pattern + case "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463": + return A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature + case "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464": + return A_computed_property_name_must_be_of_type_string_number_symbol_or_any + case "this_cannot_be_referenced_in_a_computed_property_name_2465": + return X_this_cannot_be_referenced_in_a_computed_property_name + case "super_cannot_be_referenced_in_a_computed_property_name_2466": + return X_super_cannot_be_referenced_in_a_computed_property_name + case "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467": + return A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type + case "Cannot_find_global_value_0_2468": + return Cannot_find_global_value_0 + case "The_0_operator_cannot_be_applied_to_type_symbol_2469": + return The_0_operator_cannot_be_applied_to_type_symbol + case "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472": + return Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher + case "Enum_declarations_must_all_be_const_or_non_const_2473": + return Enum_declarations_must_all_be_const_or_non_const + case "const_enum_member_initializers_must_be_constant_expressions_2474": + return X_const_enum_member_initializers_must_be_constant_expressions + case "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475": + return X_const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query + case "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476": + return A_const_enum_member_can_only_be_accessed_using_a_string_literal + case "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477": + return X_const_enum_member_initializer_was_evaluated_to_a_non_finite_value + case "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478": + return X_const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN + case "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480": + return X_let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations + case "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481": + return Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1 + case "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483": + return The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation + case "Export_declaration_conflicts_with_exported_declaration_of_0_2484": + return Export_declaration_conflicts_with_exported_declaration_of_0 + case "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487": + return The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access + case "Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488": + return Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator + case "An_iterator_must_have_a_next_method_2489": + return An_iterator_must_have_a_next_method + case "The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property_2490": + return The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property + case "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491": + return The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern + case "Cannot_redeclare_identifier_0_in_catch_clause_2492": + return Cannot_redeclare_identifier_0_in_catch_clause + case "Tuple_type_0_of_length_1_has_no_element_at_index_2_2493": + return Tuple_type_0_of_length_1_has_no_element_at_index_2 + case "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": + return Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher + case "Type_0_is_not_an_array_type_or_a_string_type_2495": + return Type_0_is_not_an_array_type_or_a_string_type + case "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES5_Consider_using_a_standard_func_2496": + return The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES5_Consider_using_a_standard_function_expression + case "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": + return This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export + case "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498": + return Module_0_uses_export_and_cannot_be_used_with_export_Asterisk + case "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": + return An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments + case "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500": + return A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments + case "A_rest_element_cannot_contain_a_binding_pattern_2501": + return A_rest_element_cannot_contain_a_binding_pattern + case "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502": + return X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation + case "Cannot_find_namespace_0_2503": + return Cannot_find_namespace_0 + case "Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504": + return Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + case "A_generator_cannot_have_a_void_type_annotation_2505": + return A_generator_cannot_have_a_void_type_annotation + case "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506": + return X_0_is_referenced_directly_or_indirectly_in_its_own_base_expression + case "Type_0_is_not_a_constructor_function_type_2507": + return Type_0_is_not_a_constructor_function_type + case "No_base_constructor_has_the_specified_number_of_type_arguments_2508": + return No_base_constructor_has_the_specified_number_of_type_arguments + case "Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_2509": + return Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members + case "Base_constructors_must_all_have_the_same_return_type_2510": + return Base_constructors_must_all_have_the_same_return_type + case "Cannot_create_an_instance_of_an_abstract_class_2511": + return Cannot_create_an_instance_of_an_abstract_class + case "Overload_signatures_must_all_be_abstract_or_non_abstract_2512": + return Overload_signatures_must_all_be_abstract_or_non_abstract + case "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513": + return Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression + case "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": + return A_tuple_type_cannot_be_indexed_with_a_negative_value + case "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515": + return Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2 + case "All_declarations_of_an_abstract_method_must_be_consecutive_2516": + return All_declarations_of_an_abstract_method_must_be_consecutive + case "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517": + return Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type + case "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518": + return A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard + case "An_async_iterator_must_have_a_next_method_2519": + return An_async_iterator_must_have_a_next_method + case "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520": + return Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions + case "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_sta_2522": + return The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_standard_function_or_method + case "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523": + return X_yield_expressions_cannot_be_used_in_a_parameter_initializer + case "await_expressions_cannot_be_used_in_a_parameter_initializer_2524": + return X_await_expressions_cannot_be_used_in_a_parameter_initializer + case "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": + return A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface + case "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": + return The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary + case "A_module_cannot_have_multiple_default_exports_2528": + return A_module_cannot_have_multiple_default_exports + case "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529": + return Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions + case "Property_0_is_incompatible_with_index_signature_2530": + return Property_0_is_incompatible_with_index_signature + case "Object_is_possibly_null_2531": + return Object_is_possibly_null + case "Object_is_possibly_undefined_2532": + return Object_is_possibly_undefined + case "Object_is_possibly_null_or_undefined_2533": + return Object_is_possibly_null_or_undefined + case "A_function_returning_never_cannot_have_a_reachable_end_point_2534": + return A_function_returning_never_cannot_have_a_reachable_end_point + case "Type_0_cannot_be_used_to_index_type_1_2536": + return Type_0_cannot_be_used_to_index_type_1 + case "Type_0_has_no_matching_index_signature_for_type_1_2537": + return Type_0_has_no_matching_index_signature_for_type_1 + case "Type_0_cannot_be_used_as_an_index_type_2538": + return Type_0_cannot_be_used_as_an_index_type + case "Cannot_assign_to_0_because_it_is_not_a_variable_2539": + return Cannot_assign_to_0_because_it_is_not_a_variable + case "Cannot_assign_to_0_because_it_is_a_read_only_property_2540": + return Cannot_assign_to_0_because_it_is_a_read_only_property + case "Index_signature_in_type_0_only_permits_reading_2542": + return Index_signature_in_type_0_only_permits_reading + case "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543": + return Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference + case "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544": + return Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference + case "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545": + return A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any + case "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547": + return The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + case "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": + return Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + case "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": + return Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + case "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": + return Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later + case "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": + return Property_0_does_not_exist_on_type_1_Did_you_mean_2 + case "Cannot_find_name_0_Did_you_mean_1_2552": + return Cannot_find_name_0_Did_you_mean_1 + case "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553": + return Computed_values_are_not_permitted_in_an_enum_with_string_valued_members + case "Expected_0_arguments_but_got_1_2554": + return Expected_0_arguments_but_got_1 + case "Expected_at_least_0_arguments_but_got_1_2555": + return Expected_at_least_0_arguments_but_got_1 + case "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556": + return A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter + case "Expected_0_type_arguments_but_got_1_2558": + return Expected_0_type_arguments_but_got_1 + case "Type_0_has_no_properties_in_common_with_type_1_2559": + return Type_0_has_no_properties_in_common_with_type_1 + case "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560": + return Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it + case "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561": + return Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2 + case "Base_class_expressions_cannot_reference_class_type_parameters_2562": + return Base_class_expressions_cannot_reference_class_type_parameters + case "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563": + return The_containing_function_or_module_body_is_too_large_for_control_flow_analysis + case "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": + return Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor + case "Property_0_is_used_before_being_assigned_2565": + return Property_0_is_used_before_being_assigned + case "A_rest_element_cannot_have_a_property_name_2566": + return A_rest_element_cannot_have_a_property_name + case "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567": + return Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations + case "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568": + return Property_0_may_not_exist_on_type_1_Did_you_mean_2 + case "Could_not_find_name_0_Did_you_mean_1_2570": + return Could_not_find_name_0_Did_you_mean_1 + case "Object_is_of_type_unknown_2571": + return Object_is_of_type_unknown + case "A_rest_element_type_must_be_an_array_type_2574": + return A_rest_element_type_must_be_an_array_type + case "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575": + return No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments + case "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": + return Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead + case "Return_type_annotation_circularly_references_itself_2577": + return Return_type_annotation_circularly_references_itself + case "Unused_ts_expect_error_directive_2578": + return Unused_ts_expect_error_directive + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha + case "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583": + return Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later + case "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584": + return Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom + case "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585": + return X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later + case "Cannot_assign_to_0_because_it_is_a_constant_2588": + return Cannot_assign_to_0_because_it_is_a_constant + case "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589": + return Type_instantiation_is_excessively_deep_and_possibly_infinite + case "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590": + return Expression_produces_a_union_type_that_is_too_complex_to_represent + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig + case "This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag_2594": + return This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag + case "_0_can_only_be_imported_by_using_a_default_import_2595": + return X_0_can_only_be_imported_by_using_a_default_import + case "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596": + return X_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import + case "_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import_2597": + return X_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import + case "_0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using__2598": + return X_0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import + case "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602": + return JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist + case "Property_0_in_type_1_is_not_assignable_to_type_2_2603": + return Property_0_in_type_1_is_not_assignable_to_type_2 + case "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604": + return JSX_element_type_0_does_not_have_any_construct_or_call_signatures + case "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606": + return Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property + case "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607": + return JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property + case "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": + return The_global_type_JSX_0_may_not_have_more_than_one_property + case "JSX_spread_child_must_be_an_array_type_2609": + return JSX_spread_child_must_be_an_array_type + case "_0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property_2610": + return X_0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property + case "_0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor_2611": + return X_0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor + case "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612": + return Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration + case "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613": + return Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead + case "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614": + return Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead + case "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": + return Type_of_property_0_circularly_references_itself_in_mapped_type_1 + case "_0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import_2616": + return X_0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import + case "_0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_us_2617": + return X_0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import + case "Source_has_0_element_s_but_target_requires_1_2618": + return Source_has_0_element_s_but_target_requires_1 + case "Source_has_0_element_s_but_target_allows_only_1_2619": + return Source_has_0_element_s_but_target_allows_only_1 + case "Target_requires_0_element_s_but_source_may_have_fewer_2620": + return Target_requires_0_element_s_but_source_may_have_fewer + case "Target_allows_only_0_element_s_but_source_may_have_more_2621": + return Target_allows_only_0_element_s_but_source_may_have_more + case "Source_provides_no_match_for_required_element_at_position_0_in_target_2623": + return Source_provides_no_match_for_required_element_at_position_0_in_target + case "Source_provides_no_match_for_variadic_element_at_position_0_in_target_2624": + return Source_provides_no_match_for_variadic_element_at_position_0_in_target + case "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": + return Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target + case "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626": + return Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target + case "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627": + return Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target + case "Cannot_assign_to_0_because_it_is_an_enum_2628": + return Cannot_assign_to_0_because_it_is_an_enum + case "Cannot_assign_to_0_because_it_is_a_class_2629": + return Cannot_assign_to_0_because_it_is_a_class + case "Cannot_assign_to_0_because_it_is_a_function_2630": + return Cannot_assign_to_0_because_it_is_a_function + case "Cannot_assign_to_0_because_it_is_a_namespace_2631": + return Cannot_assign_to_0_because_it_is_a_namespace + case "Cannot_assign_to_0_because_it_is_an_import_2632": + return Cannot_assign_to_0_because_it_is_an_import + case "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633": + return JSX_property_access_expressions_cannot_include_JSX_namespace_names + case "_0_index_signatures_are_incompatible_2634": + return X_0_index_signatures_are_incompatible + case "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635": + return Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable + case "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636": + return Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation + case "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": + return Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types + case "Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operato_2638": + return Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator + case "React_components_cannot_include_JSX_namespace_names_2639": + return React_components_cannot_include_JSX_namespace_names + case "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649": + return Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity + case "Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1_and__2650": + return Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1_and_2_more + case "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651": + return A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums + case "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652": + return Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead + case "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653": + return Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1 + case "Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2_2654": + return Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2 + case "Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2_and_3_more_2655": + return Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2_and_3_more + case "Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1_2656": + return Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1 + case "JSX_expressions_must_have_one_parent_element_2657": + return JSX_expressions_must_have_one_parent_element + case "Type_0_provides_no_match_for_the_signature_1_2658": + return Type_0_provides_no_match_for_the_signature_1 + case "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659": + return X_super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher + case "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660": + return X_super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions + case "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661": + return Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module + case "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662": + return Cannot_find_name_0_Did_you_mean_the_static_member_1_0 + case "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663": + return Cannot_find_name_0_Did_you_mean_the_instance_member_this_0 + case "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664": + return Invalid_module_name_in_augmentation_module_0_cannot_be_found + case "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665": + return Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented + case "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666": + return Exports_and_export_assignments_are_not_permitted_in_module_augmentations + case "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667": + return Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module + case "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668": + return X_export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible + case "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669": + return Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations + case "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670": + return Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context + case "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671": + return Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity + case "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672": + return Cannot_assign_a_0_constructor_type_to_a_1_constructor_type + case "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673": + return Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration + case "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": + return Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration + case "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675": + return Cannot_extend_a_class_0_Class_constructor_is_marked_as_private + case "Accessors_must_both_be_abstract_or_non_abstract_2676": + return Accessors_must_both_be_abstract_or_non_abstract + case "A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type_2677": + return A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type + case "Type_0_is_not_comparable_to_type_1_2678": + return Type_0_is_not_comparable_to_type_1 + case "A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void_2679": + return A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void + case "A_0_parameter_must_be_the_first_parameter_2680": + return A_0_parameter_must_be_the_first_parameter + case "A_constructor_cannot_have_a_this_parameter_2681": + return A_constructor_cannot_have_a_this_parameter + case "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683": + return X_this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation + case "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684": + return The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 + case "The_this_types_of_each_signature_are_incompatible_2685": + return The_this_types_of_each_signature_are_incompatible + case "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686": + return X_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead + case "All_declarations_of_0_must_have_identical_modifiers_2687": + return All_declarations_of_0_must_have_identical_modifiers + case "Cannot_find_type_definition_file_for_0_2688": + return Cannot_find_type_definition_file_for_0 + case "Cannot_extend_an_interface_0_Did_you_mean_implements_2689": + return Cannot_extend_an_interface_0_Did_you_mean_implements + case "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0_2690": + return X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0 + case "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": + return X_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible + case "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693": + return X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here + case "Namespace_0_has_no_exported_member_1_2694": + return Namespace_0_has_no_exported_member_1 + case "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695": + return Left_side_of_comma_operator_is_unused_and_has_no_side_effects + case "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696": + return The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead + case "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697": + return An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option + case "Spread_types_may_only_be_created_from_object_types_2698": + return Spread_types_may_only_be_created_from_object_types + case "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699": + return Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1 + case "Rest_types_may_only_be_created_from_object_types_2700": + return Rest_types_may_only_be_created_from_object_types + case "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701": + return The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access + case "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702": + return X_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here + case "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": + return The_operand_of_a_delete_operator_must_be_a_property_reference + case "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": + return The_operand_of_a_delete_operator_cannot_be_a_read_only_property + case "An_async_function_or_method_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_2705": + return An_async_function_or_method_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option + case "Required_type_parameters_may_not_follow_optional_type_parameters_2706": + return Required_type_parameters_may_not_follow_optional_type_parameters + case "Generic_type_0_requires_between_1_and_2_type_arguments_2707": + return Generic_type_0_requires_between_1_and_2_type_arguments + case "Cannot_use_namespace_0_as_a_value_2708": + return Cannot_use_namespace_0_as_a_value + case "Cannot_use_namespace_0_as_a_type_2709": + return Cannot_use_namespace_0_as_a_type + case "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710": + return X_0_are_specified_twice_The_attribute_named_0_will_be_overwritten + case "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711": + return A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option + case "A_dynamic_import_call_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_t_2712": + return A_dynamic_import_call_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option + case "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713": + return Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1 + case "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714": + return The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context + case "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715": + return Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor + case "Type_parameter_0_has_a_circular_default_2716": + return Type_parameter_0_has_a_circular_default + case "Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_t_2717": + return Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 + case "Duplicate_property_0_2718": + return Duplicate_property_0 + case "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_2719": + return Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated + case "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720": + return Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass + case "Cannot_invoke_an_object_which_is_possibly_null_2721": + return Cannot_invoke_an_object_which_is_possibly_null + case "Cannot_invoke_an_object_which_is_possibly_undefined_2722": + return Cannot_invoke_an_object_which_is_possibly_undefined + case "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723": + return Cannot_invoke_an_object_which_is_possibly_null_or_undefined + case "_0_has_no_exported_member_named_1_Did_you_mean_2_2724": + return X_0_has_no_exported_member_named_1_Did_you_mean_2 + case "Class_name_cannot_be_Object_when_targeting_ES5_and_above_with_module_0_2725": + return Class_name_cannot_be_Object_when_targeting_ES5_and_above_with_module_0 + case "Cannot_find_lib_definition_for_0_2726": + return Cannot_find_lib_definition_for_0 + case "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727": + return Cannot_find_lib_definition_for_0_Did_you_mean_1 + case "_0_is_declared_here_2728": + return X_0_is_declared_here + case "Property_0_is_used_before_its_initialization_2729": + return Property_0_is_used_before_its_initialization + case "An_arrow_function_cannot_have_a_this_parameter_2730": + return An_arrow_function_cannot_have_a_this_parameter + case "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731": + return Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String + case "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732": + return Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension + case "Property_0_was_also_declared_here_2733": + return Property_0_was_also_declared_here + case "Are_you_missing_a_semicolon_2734": + return Are_you_missing_a_semicolon + case "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735": + return Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1 + case "Operator_0_cannot_be_applied_to_type_1_2736": + return Operator_0_cannot_be_applied_to_type_1 + case "BigInt_literals_are_not_available_when_targeting_lower_than_ES2020_2737": + return BigInt_literals_are_not_available_when_targeting_lower_than_ES2020 + case "An_outer_value_of_this_is_shadowed_by_this_container_2738": + return An_outer_value_of_this_is_shadowed_by_this_container + case "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": + return Type_0_is_missing_the_following_properties_from_type_1_Colon_2 + case "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": + return Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more + case "Property_0_is_missing_in_type_1_but_required_in_type_2_2741": + return Property_0_is_missing_in_type_1_but_required_in_type_2 + case "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": + return The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary + case "No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments_2743": + return No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments + case "Type_parameter_defaults_can_only_reference_previously_declared_type_parameters_2744": + return Type_parameter_defaults_can_only_reference_previously_declared_type_parameters + case "This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_pr_2745": + return This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided + case "This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided_2746": + return This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided + case "_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_t_2747": + return X_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2 + case "Cannot_access_ambient_const_enums_when_0_is_enabled_2748": + return Cannot_access_ambient_const_enums_when_0_is_enabled + case "_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0_2749": + return X_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0 + case "The_implementation_signature_is_declared_here_2750": + return The_implementation_signature_is_declared_here + case "Circularity_originates_in_type_at_this_location_2751": + return Circularity_originates_in_type_at_this_location + case "The_first_export_default_is_here_2752": + return The_first_export_default_is_here + case "Another_export_default_is_here_2753": + return Another_export_default_is_here + case "super_may_not_use_type_arguments_2754": + return X_super_may_not_use_type_arguments + case "No_constituent_of_type_0_is_callable_2755": + return No_constituent_of_type_0_is_callable + case "Not_all_constituents_of_type_0_are_callable_2756": + return Not_all_constituents_of_type_0_are_callable + case "Type_0_has_no_call_signatures_2757": + return Type_0_has_no_call_signatures + case "Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_2758": + return Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other + case "No_constituent_of_type_0_is_constructable_2759": + return No_constituent_of_type_0_is_constructable + case "Not_all_constituents_of_type_0_are_constructable_2760": + return Not_all_constituents_of_type_0_are_constructable + case "Type_0_has_no_construct_signatures_2761": + return Type_0_has_no_construct_signatures + case "Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_2762": + return Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other + case "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_s_2763": + return Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 + case "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_al_2764": + return Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 + case "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring__2765": + return Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 + case "Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_co_2766": + return Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 + case "The_0_property_of_an_iterator_must_be_a_method_2767": + return The_0_property_of_an_iterator_must_be_a_method + case "The_0_property_of_an_async_iterator_must_be_a_method_2768": + return The_0_property_of_an_async_iterator_must_be_a_method + case "No_overload_matches_this_call_2769": + return No_overload_matches_this_call + case "The_last_overload_gave_the_following_error_2770": + return The_last_overload_gave_the_following_error + case "The_last_overload_is_declared_here_2771": + return The_last_overload_is_declared_here + case "Overload_0_of_1_2_gave_the_following_error_2772": + return Overload_0_of_1_2_gave_the_following_error + case "Did_you_forget_to_use_await_2773": + return Did_you_forget_to_use_await + case "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774": + return This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead + case "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775": + return Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation + case "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776": + return Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name + case "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": + return The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access + case "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778": + return The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access + case "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779": + return The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access + case "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780": + return The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access + case "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781": + return The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access + case "_0_needs_an_explicit_type_annotation_2782": + return X_0_needs_an_explicit_type_annotation + case "_0_is_specified_more_than_once_so_this_usage_will_be_overwritten_2783": + return X_0_is_specified_more_than_once_so_this_usage_will_be_overwritten + case "get_and_set_accessors_cannot_declare_this_parameters_2784": + return X_get_and_set_accessors_cannot_declare_this_parameters + case "This_spread_always_overwrites_this_property_2785": + return This_spread_always_overwrites_this_property + case "_0_cannot_be_used_as_a_JSX_component_2786": + return X_0_cannot_be_used_as_a_JSX_component + case "Its_return_type_0_is_not_a_valid_JSX_element_2787": + return Its_return_type_0_is_not_a_valid_JSX_element + case "Its_instance_type_0_is_not_a_valid_JSX_element_2788": + return Its_instance_type_0_is_not_a_valid_JSX_element + case "Its_element_type_0_is_not_a_valid_JSX_element_2789": + return Its_element_type_0_is_not_a_valid_JSX_element + case "The_operand_of_a_delete_operator_must_be_optional_2790": + return The_operand_of_a_delete_operator_must_be_optional + case "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791": + return Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later + case "Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_t_2792": + return Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option + case "The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_2793": + return The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible + case "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": + return Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + case "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795": + return The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types + case "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796": + return It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked + case "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797": + return A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract + case "The_declaration_was_marked_as_deprecated_here_2798": + return The_declaration_was_marked_as_deprecated_here + case "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799": + return Type_produces_a_tuple_type_that_is_too_large_to_represent + case "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800": + return Expression_produces_a_tuple_type_that_is_too_large_to_represent + case "This_condition_will_always_return_true_since_this_0_is_always_defined_2801": + return This_condition_will_always_return_true_since_this_0_is_always_defined + case "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802": + return Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher + case "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803": + return Cannot_assign_to_private_method_0_Private_methods_are_not_writable + case "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804": + return Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name + case "Private_accessor_was_defined_without_a_getter_2806": + return Private_accessor_was_defined_without_a_getter + case "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": + return This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0 + case "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808": + return A_get_accessor_must_be_at_least_as_accessible_as_the_setter + case "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809": + return Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_whole_assignment_in_parentheses + case "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": + return Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments + case "Initializer_for_property_0_2811": + return Initializer_for_property_0 + case "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812": + return Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + case "Class_declaration_cannot_implement_overload_list_for_0_2813": + return Class_declaration_cannot_implement_overload_list_for_0 + case "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814": + return Function_with_bodies_can_only_merge_with_classes_that_are_ambient + case "arguments_cannot_be_referenced_in_property_initializers_or_class_static_initialization_blocks_2815": + return X_arguments_cannot_be_referenced_in_property_initializers_or_class_static_initialization_blocks + case "Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class_2816": + return Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class + case "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_a_class_static_block_2817": + return Property_0_has_no_initializer_and_is_not_definitely_assigned_in_a_class_static_block + case "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818": + return Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers + case "Namespace_name_cannot_be_0_2819": + return Namespace_name_cannot_be_0 + case "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820": + return Type_0_is_not_assignable_to_type_1_Did_you_mean_2 + case "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_node18_node20_nodenext__2821": + return Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_node18_node20_nodenext_or_preserve + case "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822": + return Import_assertions_cannot_be_used_with_type_only_imports_or_exports + case "Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_node18_node20_nodenext__2823": + return Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_node18_node20_nodenext_or_preserve + case "Cannot_find_namespace_0_Did_you_mean_1_2833": + return Cannot_find_namespace_0_Did_you_mean_1 + case "Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_n_2834": + return Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path + case "Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_n_2835": + return Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0 + case "Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls_2836": + return Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls + case "Import_assertion_values_must_be_string_literal_expressions_2837": + return Import_assertion_values_must_be_string_literal_expressions + case "All_declarations_of_0_must_have_identical_constraints_2838": + return All_declarations_of_0_must_have_identical_constraints + case "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839": + return This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value + case "An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types_2840": + return An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types + case "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": + return X_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation + case "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843": + return We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here + case "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": + return Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + case "This_condition_will_always_return_0_2845": + return This_condition_will_always_return_0 + case "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846": + return A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead + case "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848": + return The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression + case "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849": + return Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1 + case "The_initializer_of_a_using_declaration_must_be_either_an_object_with_a_Symbol_dispose_method_or_be_n_2850": + return The_initializer_of_a_using_declaration_must_be_either_an_object_with_a_Symbol_dispose_method_or_be_null_or_undefined + case "The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_2851": + return The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_Symbol_dispose_method_or_be_null_or_undefined + case "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852": + return X_await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules + case "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853": + return X_await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module + case "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854": + return Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_node20_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher + case "Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super_2855": + return Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super + case "Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls_2856": + return Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls + case "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857": + return Import_attributes_cannot_be_used_with_type_only_imports_or_exports + case "Import_attribute_values_must_be_string_literal_expressions_2858": + return Import_attribute_values_must_be_string_literal_expressions + case "Excessive_complexity_comparing_types_0_and_1_2859": + return Excessive_complexity_comparing_types_0_and_1 + case "The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_2860": + return The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method + case "An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_han_2861": + return An_object_s_Symbol_hasInstance_method_must_return_a_boolean_value_for_it_to_be_used_on_the_right_hand_side_of_an_instanceof_expression + case "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862": + return Type_0_is_generic_and_can_only_be_indexed_for_reading + case "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863": + return A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values + case "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864": + return A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types + case "Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_2865": + return Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled + case "Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_w_2866": + return Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_2867": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun + case "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_2868": + return Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig + case "Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish_2869": + return Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish + case "This_binary_expression_is_never_nullish_Are_you_missing_parentheses_2870": + return This_binary_expression_is_never_nullish_Are_you_missing_parentheses + case "This_expression_is_always_nullish_2871": + return This_expression_is_always_nullish + case "This_kind_of_expression_is_always_truthy_2872": + return This_kind_of_expression_is_always_truthy + case "This_kind_of_expression_is_always_falsy_2873": + return This_kind_of_expression_is_always_falsy + case "This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found_2874": + return This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found + case "This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_fo_2875": + return This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_for_the_appropriate_package_installed + case "This_relative_import_path_is_unsafe_to_rewrite_because_it_looks_like_a_file_name_but_actually_resolv_2876": + return This_relative_import_path_is_unsafe_to_rewrite_because_it_looks_like_a_file_name_but_actually_resolves_to_0 + case "This_import_uses_a_0_extension_to_resolve_to_an_input_TypeScript_file_but_will_not_be_rewritten_duri_2877": + return This_import_uses_a_0_extension_to_resolve_to_an_input_TypeScript_file_but_will_not_be_rewritten_during_emit_because_it_is_not_a_relative_path + case "This_import_path_is_unsafe_to_rewrite_because_it_resolves_to_another_project_and_the_relative_path_b_2878": + return This_import_path_is_unsafe_to_rewrite_because_it_resolves_to_another_project_and_the_relative_path_between_the_projects_output_files_is_not_the_same_as_the_relative_path_between_its_input_files + case "Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found_2879": + return Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found + case "Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert_2880": + return Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert + case "This_expression_is_never_nullish_2881": + return This_expression_is_never_nullish + case "Import_declaration_0_is_using_private_name_1_4000": + return Import_declaration_0_is_using_private_name_1 + case "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002": + return Type_parameter_0_of_exported_class_has_or_is_using_private_name_1 + case "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004": + return Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1 + case "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006": + return Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1 + case "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008": + return Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1 + case "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010": + return Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1 + case "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012": + return Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1 + case "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014": + return Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1 + case "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016": + return Type_parameter_0_of_exported_function_has_or_is_using_private_name_1 + case "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019": + return Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 + case "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020": + return X_extends_clause_of_exported_class_0_has_or_is_using_private_name_1 + case "extends_clause_of_exported_class_has_or_is_using_private_name_0_4021": + return X_extends_clause_of_exported_class_has_or_is_using_private_name_0 + case "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022": + return X_extends_clause_of_exported_interface_0_has_or_is_using_private_name_1 + case "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023": + return Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024": + return Exported_variable_0_has_or_is_using_name_1_from_private_module_2 + case "Exported_variable_0_has_or_is_using_private_name_1_4025": + return Exported_variable_0_has_or_is_using_private_name_1 + case "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026": + return Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027": + return Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028": + return Public_static_property_0_of_exported_class_has_or_is_using_private_name_1 + case "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029": + return Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030": + return Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031": + return Public_property_0_of_exported_class_has_or_is_using_private_name_1 + case "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032": + return Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 + case "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033": + return Property_0_of_exported_interface_has_or_is_using_private_name_1 + case "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_mod_4034": + return Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1_4035": + return Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1 + case "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4036": + return Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1_4037": + return Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1 + case "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_modul_4038": + return Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_4039": + return Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1_4040": + return Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1 + case "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_4041": + return Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4042": + return Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1_4043": + return Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1 + case "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044": + return Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045": + return Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0 + case "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046": + return Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047": + return Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0 + case "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048": + return Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049": + return Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0 + case "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050": + return Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named + case "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051": + return Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052": + return Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0 + case "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053": + return Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named + case "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054": + return Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055": + return Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0 + case "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056": + return Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057": + return Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0 + case "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058": + return Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named + case "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059": + return Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 + case "Return_type_of_exported_function_has_or_is_using_private_name_0_4060": + return Return_type_of_exported_function_has_or_is_using_private_name_0 + case "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061": + return Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062": + return Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063": + return Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1 + case "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064": + return Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065": + return Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1 + case "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066": + return Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067": + return Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1 + case "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068": + return Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069": + return Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070": + return Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1 + case "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071": + return Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072": + return Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073": + return Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1 + case "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074": + return Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075": + return Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1 + case "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076": + return Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077": + return Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078": + return Parameter_0_of_exported_function_has_or_is_using_private_name_1 + case "Exported_type_alias_0_has_or_is_using_private_name_1_4081": + return Exported_type_alias_0_has_or_is_using_private_name_1 + case "Default_export_of_the_module_has_or_is_using_private_name_0_4082": + return Default_export_of_the_module_has_or_is_using_private_name_0 + case "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083": + return Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1 + case "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084": + return Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + case "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085": + return Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1 + case "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091": + return Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092": + return Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1 + case "Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected_4094": + return Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected + case "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_4095": + return Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4096": + return Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Public_static_method_0_of_exported_class_has_or_is_using_private_name_1_4097": + return Public_static_method_0_of_exported_class_has_or_is_using_private_name_1 + case "Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4098": + return Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4099": + return Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 + case "Public_method_0_of_exported_class_has_or_is_using_private_name_1_4100": + return Public_method_0_of_exported_class_has_or_is_using_private_name_1 + case "Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4101": + return Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 + case "Method_0_of_exported_interface_has_or_is_using_private_name_1_4102": + return Method_0_of_exported_interface_has_or_is_using_private_name_1 + case "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103": + return Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1 + case "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104": + return The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1 + case "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105": + return Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter + case "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106": + return Parameter_0_of_accessor_has_or_is_using_private_name_1 + case "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107": + return Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 + case "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108": + return Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named + case "Type_arguments_for_0_circularly_reference_themselves_4109": + return Type_arguments_for_0_circularly_reference_themselves + case "Tuple_type_arguments_circularly_reference_themselves_4110": + return Tuple_type_arguments_circularly_reference_themselves + case "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": + return Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0 + case "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112": + return This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class + case "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113": + return This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0 + case "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114": + return This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0 + case "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115": + return This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 + case "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116": + return This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0 + case "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117": + return This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 + case "The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized_4118": + return The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized + case "This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_4119": + return This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 + case "This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_4120": + return This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 + case "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_4121": + return This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class + case "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122": + return This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 + case "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123": + return This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 + case "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124": + return Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next + case "Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given_4125": + return Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given + case "One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value_4126": + return One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value + case "This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic_4127": + return This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic + case "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic_4128": + return This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic + case "The_current_host_does_not_support_the_0_option_5001": + return The_current_host_does_not_support_the_0_option + case "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009": + return Cannot_find_the_common_subdirectory_path_for_the_input_files + case "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010": + return File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 + case "Cannot_read_file_0_Colon_1_5012": + return Cannot_read_file_0_Colon_1 + case "Unknown_compiler_option_0_5023": + return Unknown_compiler_option_0 + case "Compiler_option_0_requires_a_value_of_type_1_5024": + return Compiler_option_0_requires_a_value_of_type_1 + case "Unknown_compiler_option_0_Did_you_mean_1_5025": + return Unknown_compiler_option_0_Did_you_mean_1 + case "Could_not_write_file_0_Colon_1_5033": + return Could_not_write_file_0_Colon_1 + case "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042": + return Option_project_cannot_be_mixed_with_source_files_on_a_command_line + case "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047": + return Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher + case "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051": + return Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided + case "Option_0_cannot_be_specified_without_specifying_option_1_5052": + return Option_0_cannot_be_specified_without_specifying_option_1 + case "Option_0_cannot_be_specified_with_option_1_5053": + return Option_0_cannot_be_specified_with_option_1 + case "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": + return A_tsconfig_json_file_is_already_defined_at_Colon_0 + case "Cannot_write_file_0_because_it_would_overwrite_input_file_5055": + return Cannot_write_file_0_because_it_would_overwrite_input_file + case "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056": + return Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files + case "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057": + return Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0 + case "The_specified_path_does_not_exist_Colon_0_5058": + return The_specified_path_does_not_exist_Colon_0 + case "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059": + return Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier + case "Pattern_0_can_have_at_most_one_Asterisk_character_5061": + return Pattern_0_can_have_at_most_one_Asterisk_character + case "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062": + return Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character + case "Substitutions_for_pattern_0_should_be_an_array_5063": + return Substitutions_for_pattern_0_should_be_an_array + case "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064": + return Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2 + case "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065": + return File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 + case "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066": + return Substitutions_for_pattern_0_shouldn_t_be_an_empty_array + case "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067": + return Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name + case "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": + return Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig + case "Option_0_cannot_be_specified_without_specifying_option_1_or_option_2_5069": + return Option_0_cannot_be_specified_without_specifying_option_1_or_option_2 + case "Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic_5070": + return Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic + case "Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd_5071": + return Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd + case "Unknown_build_option_0_5072": + return Unknown_build_option_0 + case "Build_option_0_requires_a_value_of_type_1_5073": + return Build_option_0_requires_a_value_of_type_1 + case "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074": + return Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified + case "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": + return X_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2 + case "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076": + return X_0_and_1_operations_cannot_be_mixed_without_parentheses + case "Unknown_build_option_0_Did_you_mean_1_5077": + return Unknown_build_option_0_Did_you_mean_1 + case "Unknown_watch_option_0_5078": + return Unknown_watch_option_0 + case "Unknown_watch_option_0_Did_you_mean_1_5079": + return Unknown_watch_option_0_Did_you_mean_1 + case "Watch_option_0_requires_a_value_of_type_1_5080": + return Watch_option_0_requires_a_value_of_type_1 + case "Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0_5081": + return Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0 + case "_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1_5082": + return X_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1 + case "Cannot_read_file_0_5083": + return Cannot_read_file_0 + case "A_tuple_member_cannot_be_both_optional_and_rest_5085": + return A_tuple_member_cannot_be_both_optional_and_rest + case "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086": + return A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type + case "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087": + return A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type + case "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": + return The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary + case "Option_0_cannot_be_specified_when_option_jsx_is_1_5089": + return Option_0_cannot_be_specified_when_option_jsx_is_1 + case "Non_relative_paths_are_not_allowed_Did_you_forget_a_leading_Slash_5090": + return Non_relative_paths_are_not_allowed_Did_you_forget_a_leading_Slash + case "Option_preserveConstEnums_cannot_be_disabled_when_0_is_enabled_5091": + return Option_preserveConstEnums_cannot_be_disabled_when_0_is_enabled + case "The_root_value_of_a_0_file_must_be_an_object_5092": + return The_root_value_of_a_0_file_must_be_an_object + case "Compiler_option_0_may_only_be_used_with_build_5093": + return Compiler_option_0_may_only_be_used_with_build + case "Compiler_option_0_may_not_be_used_with_build_5094": + return Compiler_option_0_may_not_be_used_with_build + case "Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later_5095": + return Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later + case "Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set_5096": + return Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set + case "An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled_5097": + return An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled + case "Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler_5098": + return Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler + case "Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprec_5101": + return Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error + case "Option_0_has_been_removed_Please_remove_it_from_your_configuration_5102": + return Option_0_has_been_removed_Please_remove_it_from_your_configuration + case "Invalid_value_for_ignoreDeprecations_5103": + return Invalid_value_for_ignoreDeprecations + case "Option_0_is_redundant_and_cannot_be_specified_with_option_1_5104": + return Option_0_is_redundant_and_cannot_be_specified_with_option_1 + case "Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System_5105": + return Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System + case "Use_0_instead_5106": + return Use_0_instead + case "Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDepr_5107": + return Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error + case "Option_0_1_has_been_removed_Please_remove_it_from_your_configuration_5108": + return Option_0_1_has_been_removed_Please_remove_it_from_your_configuration + case "Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_module_is_set_to_1_5109": + return Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_module_is_set_to_1 + case "Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1_5110": + return Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1 + case "Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information_5111": + return Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information + case "tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_commandline_Use_ignoreConf_5112": + return X_tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_commandline_Use_ignoreConfig_to_skip_this_error + case "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000": + return Generates_a_sourcemap_for_each_corresponding_d_ts_file + case "Concatenate_and_emit_output_to_single_file_6001": + return Concatenate_and_emit_output_to_single_file + case "Generates_corresponding_d_ts_file_6002": + return Generates_corresponding_d_ts_file + case "Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004": + return Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations + case "Watch_input_files_6005": + return Watch_input_files + case "Redirect_output_structure_to_the_directory_6006": + return Redirect_output_structure_to_the_directory + case "Do_not_erase_const_enum_declarations_in_generated_code_6007": + return Do_not_erase_const_enum_declarations_in_generated_code + case "Do_not_emit_outputs_if_any_errors_were_reported_6008": + return Do_not_emit_outputs_if_any_errors_were_reported + case "Do_not_emit_comments_to_output_6009": + return Do_not_emit_comments_to_output + case "Do_not_emit_outputs_6010": + return Do_not_emit_outputs + case "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": + return Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + case "Skip_type_checking_of_declaration_files_6012": + return Skip_type_checking_of_declaration_files + case "Do_not_resolve_the_real_path_of_symlinks_6013": + return Do_not_resolve_the_real_path_of_symlinks + case "Only_emit_d_ts_declaration_files_6014": + return Only_emit_d_ts_declaration_files + case "Specify_ECMAScript_target_version_6015": + return Specify_ECMAScript_target_version + case "Specify_module_code_generation_6016": + return Specify_module_code_generation + case "Print_this_message_6017": + return Print_this_message + case "Print_the_compiler_s_version_6019": + return Print_the_compiler_s_version + case "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020": + return Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json + case "Syntax_Colon_0_6023": + return Syntax_Colon_0 + case "options_6024": + return X_options + case "file_6025": + return X_file + case "Examples_Colon_0_6026": + return Examples_Colon_0 + case "Options_Colon_6027": + return Options_Colon + case "Version_0_6029": + return Version_0 + case "Insert_command_line_options_and_files_from_a_file_6030": + return Insert_command_line_options_and_files_from_a_file + case "Starting_compilation_in_watch_mode_6031": + return Starting_compilation_in_watch_mode + case "File_change_detected_Starting_incremental_compilation_6032": + return File_change_detected_Starting_incremental_compilation + case "KIND_6034": + return KIND + case "FILE_6035": + return FILE + case "VERSION_6036": + return VERSION + case "LOCATION_6037": + return LOCATION + case "DIRECTORY_6038": + return DIRECTORY + case "STRATEGY_6039": + return STRATEGY + case "FILE_OR_DIRECTORY_6040": + return FILE_OR_DIRECTORY + case "Errors_Files_6041": + return Errors_Files + case "Generates_corresponding_map_file_6043": + return Generates_corresponding_map_file + case "Compiler_option_0_expects_an_argument_6044": + return Compiler_option_0_expects_an_argument + case "Unterminated_quoted_string_in_response_file_0_6045": + return Unterminated_quoted_string_in_response_file_0 + case "Argument_for_0_option_must_be_Colon_1_6046": + return Argument_for_0_option_must_be_Colon_1 + case "Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1_6048": + return Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1 + case "Unable_to_open_file_0_6050": + return Unable_to_open_file_0 + case "Corrupted_locale_file_0_6051": + return Corrupted_locale_file_0 + case "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052": + return Raise_error_on_expressions_and_declarations_with_an_implied_any_type + case "File_0_not_found_6053": + return File_0_not_found + case "File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1_6054": + return File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1 + case "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055": + return Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + case "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056": + return Do_not_emit_declarations_for_code_that_has_an_internal_annotation + case "Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir_6058": + return Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + case "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059": + return File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files + case "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060": + return Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix + case "NEWLINE_6061": + return NEWLINE + case "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064": + return Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line + case "Enables_experimental_support_for_ES7_decorators_6065": + return Enables_experimental_support_for_ES7_decorators + case "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066": + return Enables_experimental_support_for_emitting_type_metadata_for_decorators + case "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": + return Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + case "Successfully_created_a_tsconfig_json_file_6071": + return Successfully_created_a_tsconfig_json_file + case "Suppress_excess_property_checks_for_object_literals_6072": + return Suppress_excess_property_checks_for_object_literals + case "Stylize_errors_and_messages_using_color_and_context_experimental_6073": + return Stylize_errors_and_messages_using_color_and_context_experimental + case "Do_not_report_errors_on_unused_labels_6074": + return Do_not_report_errors_on_unused_labels + case "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": + return Report_error_when_not_all_code_paths_in_function_return_a_value + case "Report_errors_for_fallthrough_cases_in_switch_statement_6076": + return Report_errors_for_fallthrough_cases_in_switch_statement + case "Do_not_report_errors_on_unreachable_code_6077": + return Do_not_report_errors_on_unreachable_code + case "Disallow_inconsistently_cased_references_to_the_same_file_6078": + return Disallow_inconsistently_cased_references_to_the_same_file + case "Specify_library_files_to_be_included_in_the_compilation_6079": + return Specify_library_files_to_be_included_in_the_compilation + case "Specify_JSX_code_generation_6080": + return Specify_JSX_code_generation + case "Only_amd_and_system_modules_are_supported_alongside_0_6082": + return Only_amd_and_system_modules_are_supported_alongside_0 + case "Base_directory_to_resolve_non_absolute_module_names_6083": + return Base_directory_to_resolve_non_absolute_module_names + case "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": + return Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + case "Enable_tracing_of_the_name_resolution_process_6085": + return Enable_tracing_of_the_name_resolution_process + case "Resolving_module_0_from_1_6086": + return Resolving_module_0_from_1 + case "Explicitly_specified_module_resolution_kind_Colon_0_6087": + return Explicitly_specified_module_resolution_kind_Colon_0 + case "Module_resolution_kind_is_not_specified_using_0_6088": + return Module_resolution_kind_is_not_specified_using_0 + case "Module_name_0_was_successfully_resolved_to_1_6089": + return Module_name_0_was_successfully_resolved_to_1 + case "Module_name_0_was_not_resolved_6090": + return Module_name_0_was_not_resolved + case "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091": + return X_paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0 + case "Module_name_0_matched_pattern_1_6092": + return Module_name_0_matched_pattern_1 + case "Trying_substitution_0_candidate_module_location_Colon_1_6093": + return Trying_substitution_0_candidate_module_location_Colon_1 + case "Resolving_module_name_0_relative_to_base_url_1_2_6094": + return Resolving_module_name_0_relative_to_base_url_1_2 + case "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1_6095": + return Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1 + case "File_0_does_not_exist_6096": + return File_0_does_not_exist + case "File_0_exists_use_it_as_a_name_resolution_result_6097": + return File_0_exists_use_it_as_a_name_resolution_result + case "Loading_module_0_from_node_modules_folder_target_file_types_Colon_1_6098": + return Loading_module_0_from_node_modules_folder_target_file_types_Colon_1 + case "Found_package_json_at_0_6099": + return Found_package_json_at_0 + case "package_json_does_not_have_a_0_field_6100": + return X_package_json_does_not_have_a_0_field + case "package_json_has_0_field_1_that_references_2_6101": + return X_package_json_has_0_field_1_that_references_2 + case "Allow_javascript_files_to_be_compiled_6102": + return Allow_javascript_files_to_be_compiled + case "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104": + return Checking_if_0_is_the_longest_matching_prefix_for_1_2 + case "Expected_type_of_0_field_in_package_json_to_be_1_got_2_6105": + return Expected_type_of_0_field_in_package_json_to_be_1_got_2 + case "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106": + return X_baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1 + case "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107": + return X_rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0 + case "Longest_matching_prefix_for_0_is_1_6108": + return Longest_matching_prefix_for_0_is_1 + case "Loading_0_from_the_root_dir_1_candidate_location_2_6109": + return Loading_0_from_the_root_dir_1_candidate_location_2 + case "Trying_other_entries_in_rootDirs_6110": + return Trying_other_entries_in_rootDirs + case "Module_resolution_using_rootDirs_has_failed_6111": + return Module_resolution_using_rootDirs_has_failed + case "Do_not_emit_use_strict_directives_in_module_output_6112": + return Do_not_emit_use_strict_directives_in_module_output + case "Enable_strict_null_checks_6113": + return Enable_strict_null_checks + case "Unknown_option_excludes_Did_you_mean_exclude_6114": + return Unknown_option_excludes_Did_you_mean_exclude + case "Raise_error_on_this_expressions_with_an_implied_any_type_6115": + return Raise_error_on_this_expressions_with_an_implied_any_type + case "Resolving_type_reference_directive_0_containing_file_1_root_directory_2_6116": + return Resolving_type_reference_directive_0_containing_file_1_root_directory_2 + case "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": + return Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2 + case "Type_reference_directive_0_was_not_resolved_6120": + return Type_reference_directive_0_was_not_resolved + case "Resolving_with_primary_search_path_0_6121": + return Resolving_with_primary_search_path_0 + case "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122": + return Root_directory_cannot_be_determined_skipping_primary_search_paths + case "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123": + return Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set + case "Type_declaration_files_to_be_included_in_compilation_6124": + return Type_declaration_files_to_be_included_in_compilation + case "Looking_up_in_node_modules_folder_initial_location_0_6125": + return Looking_up_in_node_modules_folder_initial_location_0 + case "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": + return Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder + case "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127": + return Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1 + case "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128": + return Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set + case "Resolving_real_path_for_0_result_1_6130": + return Resolving_real_path_for_0_result_1 + case "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131": + return Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system + case "File_name_0_has_a_1_extension_stripping_it_6132": + return File_name_0_has_a_1_extension_stripping_it + case "_0_is_declared_but_its_value_is_never_read_6133": + return X_0_is_declared_but_its_value_is_never_read + case "Report_errors_on_unused_locals_6134": + return Report_errors_on_unused_locals + case "Report_errors_on_unused_parameters_6135": + return Report_errors_on_unused_parameters + case "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136": + return The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + case "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137": + return Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1 + case "Property_0_is_declared_but_its_value_is_never_read_6138": + return Property_0_is_declared_but_its_value_is_never_read + case "Import_emit_helpers_from_tslib_6139": + return Import_emit_helpers_from_tslib + case "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140": + return Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2 + case "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141": + return Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + case "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142": + return Module_0_was_resolved_to_1_but_jsx_is_not_set + case "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144": + return Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1 + case "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146": + return Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + case "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": + return Resolution_for_module_0_was_found_in_cache_from_location_1 + case "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148": + return Directory_0_does_not_exist_skipping_all_lookups_in_it + case "Show_diagnostic_information_6149": + return Show_diagnostic_information + case "Show_verbose_diagnostic_information_6150": + return Show_verbose_diagnostic_information + case "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151": + return Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + case "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152": + return Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + case "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153": + return Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + case "Print_names_of_generated_files_part_of_the_compilation_6154": + return Print_names_of_generated_files_part_of_the_compilation + case "Print_names_of_files_part_of_the_compilation_6155": + return Print_names_of_files_part_of_the_compilation + case "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156": + return The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + case "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157": + return Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + case "Do_not_include_the_default_library_file_lib_d_ts_6158": + return Do_not_include_the_default_library_file_lib_d_ts + case "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159": + return Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + case "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160": + return Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + case "List_of_folders_to_include_type_definitions_from_6161": + return List_of_folders_to_include_type_definitions_from + case "Disable_size_limitations_on_JavaScript_projects_6162": + return Disable_size_limitations_on_JavaScript_projects + case "The_character_set_of_the_input_files_6163": + return The_character_set_of_the_input_files + case "Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1_6164": + return Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1 + case "Do_not_truncate_error_messages_6165": + return Do_not_truncate_error_messages + case "Output_directory_for_generated_declaration_files_6166": + return Output_directory_for_generated_declaration_files + case "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167": + return A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + case "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168": + return List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + case "Show_all_compiler_options_6169": + return Show_all_compiler_options + case "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": + return Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file + case "Command_line_Options_6171": + return Command_line_Options + case "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_6179": + return Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5 + case "Enable_all_strict_type_checking_options_6180": + return Enable_all_strict_type_checking_options + case "Scoped_package_detected_looking_in_0_6182": + return Scoped_package_detected_looking_in_0 + case "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183": + return Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 + case "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184": + return Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 + case "Enable_strict_checking_of_function_types_6186": + return Enable_strict_checking_of_function_types + case "Enable_strict_checking_of_property_initialization_in_classes_6187": + return Enable_strict_checking_of_property_initialization_in_classes + case "Numeric_separators_are_not_allowed_here_6188": + return Numeric_separators_are_not_allowed_here + case "Multiple_consecutive_numeric_separators_are_not_permitted_6189": + return Multiple_consecutive_numeric_separators_are_not_permitted + case "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191": + return Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen + case "All_imports_in_import_declaration_are_unused_6192": + return All_imports_in_import_declaration_are_unused + case "Found_1_error_Watching_for_file_changes_6193": + return Found_1_error_Watching_for_file_changes + case "Found_0_errors_Watching_for_file_changes_6194": + return Found_0_errors_Watching_for_file_changes + case "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": + return Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols + case "_0_is_declared_but_never_used_6196": + return X_0_is_declared_but_never_used + case "Include_modules_imported_with_json_extension_6197": + return Include_modules_imported_with_json_extension + case "All_destructured_elements_are_unused_6198": + return All_destructured_elements_are_unused + case "All_variables_are_unused_6199": + return All_variables_are_unused + case "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": + return Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0 + case "Conflicts_are_in_this_file_6201": + return Conflicts_are_in_this_file + case "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": + return Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0 + case "_0_was_also_declared_here_6203": + return X_0_was_also_declared_here + case "and_here_6204": + return X_and_here + case "All_type_parameters_are_unused_6205": + return All_type_parameters_are_unused + case "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206": + return X_package_json_has_a_typesVersions_field_with_version_specific_path_mappings + case "package_json_does_not_have_a_typesVersions_entry_that_matches_version_0_6207": + return X_package_json_does_not_have_a_typesVersions_entry_that_matches_version_0 + case "package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_ma_6208": + return X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 + case "package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range_6209": + return X_package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range + case "An_argument_for_0_was_not_provided_6210": + return An_argument_for_0_was_not_provided + case "An_argument_matching_this_binding_pattern_was_not_provided_6211": + return An_argument_matching_this_binding_pattern_was_not_provided + case "Did_you_mean_to_call_this_expression_6212": + return Did_you_mean_to_call_this_expression + case "Did_you_mean_to_use_new_with_this_expression_6213": + return Did_you_mean_to_use_new_with_this_expression + case "Enable_strict_bind_call_and_apply_methods_on_functions_6214": + return Enable_strict_bind_call_and_apply_methods_on_functions + case "Using_compiler_options_of_project_reference_redirect_0_6215": + return Using_compiler_options_of_project_reference_redirect_0 + case "Found_1_error_6216": + return Found_1_error + case "Found_0_errors_6217": + return Found_0_errors + case "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218": + return Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2 + case "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": + return Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3 + case "package_json_had_a_falsy_0_field_6220": + return X_package_json_had_a_falsy_0_field + case "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221": + return Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + case "Emit_class_fields_with_Define_instead_of_Set_6222": + return Emit_class_fields_with_Define_instead_of_Set + case "Generates_a_CPU_profile_6223": + return Generates_a_CPU_profile + case "Disable_solution_searching_for_this_project_6224": + return Disable_solution_searching_for_this_project + case "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225": + return Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory + case "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226": + return Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling + case "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227": + return Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize + case "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229": + return Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3 + case "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230": + return Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line + case "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": + return Could_not_resolve_the_path_0_with_the_extensions_Colon_1 + case "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": + return Declaration_augments_declaration_in_another_file_This_cannot_be_serialized + case "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": + return This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file + case "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": + return This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without + case "Disable_loading_referenced_projects_6235": + return Disable_loading_referenced_projects + case "Arguments_for_the_rest_parameter_0_were_not_provided_6236": + return Arguments_for_the_rest_parameter_0_were_not_provided + case "Generates_an_event_trace_and_a_list_of_types_6237": + return Generates_an_event_trace_and_a_list_of_types + case "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238": + return Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react + case "File_0_exists_according_to_earlier_cached_lookups_6239": + return File_0_exists_according_to_earlier_cached_lookups + case "File_0_does_not_exist_according_to_earlier_cached_lookups_6240": + return File_0_does_not_exist_according_to_earlier_cached_lookups + case "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241": + return Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1 + case "Resolving_type_reference_directive_0_containing_file_1_6242": + return Resolving_type_reference_directive_0_containing_file_1 + case "Interpret_optional_property_types_as_written_rather_than_adding_undefined_6243": + return Interpret_optional_property_types_as_written_rather_than_adding_undefined + case "Modules_6244": + return Modules + case "File_Management_6245": + return File_Management + case "Emit_6246": + return Emit + case "JavaScript_Support_6247": + return JavaScript_Support + case "Type_Checking_6248": + return Type_Checking + case "Editor_Support_6249": + return Editor_Support + case "Watch_and_Build_Modes_6250": + return Watch_and_Build_Modes + case "Compiler_Diagnostics_6251": + return Compiler_Diagnostics + case "Interop_Constraints_6252": + return Interop_Constraints + case "Backwards_Compatibility_6253": + return Backwards_Compatibility + case "Language_and_Environment_6254": + return Language_and_Environment + case "Projects_6255": + return Projects + case "Output_Formatting_6256": + return Output_Formatting + case "Completeness_6257": + return Completeness + case "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258": + return X_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file + case "Found_1_error_in_0_6259": + return Found_1_error_in_0 + case "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260": + return Found_0_errors_in_the_same_file_starting_at_Colon_1 + case "Found_0_errors_in_1_files_6261": + return Found_0_errors_in_1_files + case "File_name_0_has_a_1_extension_looking_up_2_instead_6262": + return File_name_0_has_a_1_extension_looking_up_2_instead + case "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263": + return Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set + case "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264": + return Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present + case "Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_no_6265": + return Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder + case "Option_0_can_only_be_specified_on_command_line_6266": + return Option_0_can_only_be_specified_on_command_line + case "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270": + return Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve + case "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271": + return Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1 + case "Invalid_import_specifier_0_has_no_possible_resolutions_6272": + return Invalid_import_specifier_0_has_no_possible_resolutions + case "package_json_scope_0_has_no_imports_defined_6273": + return X_package_json_scope_0_has_no_imports_defined + case "package_json_scope_0_explicitly_maps_specifier_1_to_null_6274": + return X_package_json_scope_0_explicitly_maps_specifier_1_to_null + case "package_json_scope_0_has_invalid_type_for_target_of_specifier_1_6275": + return X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1 + case "Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6276": + return Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1 + case "Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_i_6277": + return Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update + case "There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The__6278": + return There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings + case "Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_ne_6279": + return Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_need_configuration_update + case "There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setti_6280": + return There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setting_Consider_updating_to_node16_nodenext_or_bundler + case "package_json_has_a_peerDependencies_field_6281": + return X_package_json_has_a_peerDependencies_field + case "Found_peerDependency_0_with_1_version_6282": + return Found_peerDependency_0_with_1_version + case "Failed_to_find_peerDependency_0_6283": + return Failed_to_find_peerDependency_0 + case "File_Layout_6284": + return File_Layout + case "Environment_Settings_6285": + return Environment_Settings + case "See_also_https_Colon_Slash_Slashaka_ms_Slashtsconfig_Slashmodule_6286": + return See_also_https_Colon_Slash_Slashaka_ms_Slashtsconfig_Slashmodule + case "For_nodejs_Colon_6287": + return For_nodejs_Colon + case "and_npm_install_D_types_Slashnode_6290": + return X_and_npm_install_D_types_Slashnode + case "Other_Outputs_6291": + return Other_Outputs + case "Stricter_Typechecking_Options_6292": + return Stricter_Typechecking_Options + case "Style_Options_6293": + return Style_Options + case "Recommended_Options_6294": + return Recommended_Options + case "Enable_project_compilation_6302": + return Enable_project_compilation + case "Composite_projects_may_not_disable_declaration_emit_6304": + return Composite_projects_may_not_disable_declaration_emit + case "Output_file_0_has_not_been_built_from_source_file_1_6305": + return Output_file_0_has_not_been_built_from_source_file_1 + case "Referenced_project_0_must_have_setting_composite_Colon_true_6306": + return Referenced_project_0_must_have_setting_composite_Colon_true + case "File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_includ_6307": + return File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern + case "Referenced_project_0_may_not_disable_emit_6310": + return Referenced_project_0_may_not_disable_emit + case "Project_0_is_out_of_date_because_output_1_is_older_than_input_2_6350": + return Project_0_is_out_of_date_because_output_1_is_older_than_input_2 + case "Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2_6351": + return Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2 + case "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352": + return Project_0_is_out_of_date_because_output_file_1_does_not_exist + case "Failed_to_delete_file_0_6353": + return Failed_to_delete_file_0 + case "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354": + return Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies + case "Projects_in_this_build_Colon_0_6355": + return Projects_in_this_build_Colon_0 + case "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": + return A_non_dry_build_would_delete_the_following_files_Colon_0 + case "A_non_dry_build_would_build_project_0_6357": + return A_non_dry_build_would_build_project_0 + case "Building_project_0_6358": + return Building_project_0 + case "Updating_output_timestamps_of_project_0_6359": + return Updating_output_timestamps_of_project_0 + case "Project_0_is_up_to_date_6361": + return Project_0_is_up_to_date + case "Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362": + return Skipping_build_of_project_0_because_its_dependency_1_has_errors + case "Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363": + return Project_0_can_t_be_built_because_its_dependency_1_has_errors + case "Build_one_or_more_projects_and_their_dependencies_if_out_of_date_6364": + return Build_one_or_more_projects_and_their_dependencies_if_out_of_date + case "Delete_the_outputs_of_all_projects_6365": + return Delete_the_outputs_of_all_projects + case "Show_what_would_be_built_or_deleted_if_specified_with_clean_6367": + return Show_what_would_be_built_or_deleted_if_specified_with_clean + case "Option_build_must_be_the_first_command_line_argument_6369": + return Option_build_must_be_the_first_command_line_argument + case "Options_0_and_1_cannot_be_combined_6370": + return Options_0_and_1_cannot_be_combined + case "Updating_unchanged_output_timestamps_of_project_0_6371": + return Updating_unchanged_output_timestamps_of_project_0 + case "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374": + return A_non_dry_build_would_update_timestamps_for_output_of_project_0 + case "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377": + return Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1 + case "Composite_projects_may_not_disable_incremental_compilation_6379": + return Composite_projects_may_not_disable_incremental_compilation + case "Specify_file_to_store_incremental_compilation_information_6380": + return Specify_file_to_store_incremental_compilation_information + case "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381": + return Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2 + case "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382": + return Skipping_build_of_project_0_because_its_dependency_1_was_not_built + case "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383": + return Project_0_can_t_be_built_because_its_dependency_1_was_not_built + case "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384": + return Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it + case "_0_is_deprecated_6385": + return X_0_is_deprecated + case "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386": + return Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found + case "The_signature_0_of_1_is_deprecated_6387": + return The_signature_0_of_1_is_deprecated + case "Project_0_is_being_forcibly_rebuilt_6388": + return Project_0_is_being_forcibly_rebuilt + case "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389": + return Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved + case "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390": + return Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 + case "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391": + return Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 + case "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392": + return Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved + case "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393": + return Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 + case "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394": + return Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 + case "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395": + return Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved + case "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396": + return Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 + case "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397": + return Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 + case "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398": + return Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved + case "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399": + return Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted + case "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400": + return Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files + case "Project_0_is_out_of_date_because_config_file_does_not_exist_6401": + return Project_0_is_out_of_date_because_config_file_does_not_exist + case "Resolving_in_0_mode_with_conditions_1_6402": + return Resolving_in_0_mode_with_conditions_1 + case "Matched_0_condition_1_6403": + return Matched_0_condition_1 + case "Using_0_subpath_1_with_target_2_6404": + return Using_0_subpath_1_with_target_2 + case "Saw_non_matching_condition_0_6405": + return Saw_non_matching_condition_0 + case "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions_6406": + return Project_0_is_out_of_date_because_buildinfo_file_1_indicates_there_is_change_in_compilerOptions + case "Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noE_6407": + return Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set + case "Use_the_package_json_exports_field_when_resolving_package_imports_6408": + return Use_the_package_json_exports_field_when_resolving_package_imports + case "Use_the_package_json_imports_field_when_resolving_imports_6409": + return Use_the_package_json_imports_field_when_resolving_imports + case "Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports_6410": + return Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports + case "true_when_moduleResolution_is_node16_nodenext_or_bundler_otherwise_false_6411": + return X_true_when_moduleResolution_is_node16_nodenext_or_bundler_otherwise_false + case "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_file_2_was_root_file_of_compilation_6412": + return Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_file_2_was_root_file_of_compilation_but_not_any_more + case "Entering_conditional_exports_6413": + return Entering_conditional_exports + case "Resolved_under_condition_0_6414": + return Resolved_under_condition_0 + case "Failed_to_resolve_under_condition_0_6415": + return Failed_to_resolve_under_condition_0 + case "Exiting_conditional_exports_6416": + return Exiting_conditional_exports + case "Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0_6417": + return Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0 + case "Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0_6418": + return Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0 + case "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors_6419": + return Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors + case "Project_0_is_out_of_date_because_input_1_does_not_exist_6420": + return Project_0_is_out_of_date_because_input_1_does_not_exist + case "Rewrite_ts_tsx_mts_and_cts_file_extensions_in_relative_import_paths_to_their_JavaScript_equivalent_i_6421": + return Rewrite_ts_tsx_mts_and_cts_file_extensions_in_relative_import_paths_to_their_JavaScript_equivalent_in_output_files + case "Project_0_is_out_of_date_because_it_has_errors_6423": + return Project_0_is_out_of_date_because_it_has_errors + case "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500": + return The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1 + case "The_expected_type_comes_from_this_index_signature_6501": + return The_expected_type_comes_from_this_index_signature + case "The_expected_type_comes_from_the_return_type_of_this_signature_6502": + return The_expected_type_comes_from_the_return_type_of_this_signature + case "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503": + return Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + case "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504": + return File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option + case "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505": + return Print_names_of_files_and_the_reason_they_are_part_of_the_compilation + case "Consider_adding_a_declare_modifier_to_this_class_6506": + return Consider_adding_a_declare_modifier_to_this_class + case "Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJs_option_to_get_errors_from_these__6600": + return Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJs_option_to_get_errors_from_these_files + case "Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export_6601": + return Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export + case "Allow_accessing_UMD_globals_from_modules_6602": + return Allow_accessing_UMD_globals_from_modules + case "Disable_error_reporting_for_unreachable_code_6603": + return Disable_error_reporting_for_unreachable_code + case "Disable_error_reporting_for_unused_labels_6604": + return Disable_error_reporting_for_unused_labels + case "Ensure_use_strict_is_always_emitted_6605": + return Ensure_use_strict_is_always_emitted + case "Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_wi_6606": + return Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it + case "Specify_the_base_directory_to_resolve_non_relative_module_names_6607": + return Specify_the_base_directory_to_resolve_non_relative_module_names + case "No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files_6608": + return No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files + case "Enable_error_reporting_in_type_checked_JavaScript_files_6609": + return Enable_error_reporting_in_type_checked_JavaScript_files + case "Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references_6611": + return Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references + case "Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project_6612": + return Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project + case "Specify_the_output_directory_for_generated_declaration_files_6613": + return Specify_the_output_directory_for_generated_declaration_files + case "Create_sourcemaps_for_d_ts_files_6614": + return Create_sourcemaps_for_d_ts_files + case "Output_compiler_performance_information_after_building_6615": + return Output_compiler_performance_information_after_building + case "Disables_inference_for_type_acquisition_by_looking_at_filenames_in_a_project_6616": + return Disables_inference_for_type_acquisition_by_looking_at_filenames_in_a_project + case "Reduce_the_number_of_projects_loaded_automatically_by_TypeScript_6617": + return Reduce_the_number_of_projects_loaded_automatically_by_TypeScript + case "Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server_6618": + return Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server + case "Opt_a_project_out_of_multi_project_reference_checking_when_editing_6619": + return Opt_a_project_out_of_multi_project_reference_checking_when_editing + case "Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects_6620": + return Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects + case "Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration_6621": + return Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration + case "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6622": + return Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + case "Only_output_d_ts_files_and_not_JavaScript_files_6623": + return Only_output_d_ts_files_and_not_JavaScript_files + case "Emit_design_type_metadata_for_decorated_declarations_in_source_files_6624": + return Emit_design_type_metadata_for_decorated_declarations_in_source_files + case "Disable_the_type_acquisition_for_JavaScript_projects_6625": + return Disable_the_type_acquisition_for_JavaScript_projects + case "Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheti_6626": + return Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility + case "Filters_results_from_the_include_option_6627": + return Filters_results_from_the_include_option + case "Remove_a_list_of_directories_from_the_watch_process_6628": + return Remove_a_list_of_directories_from_the_watch_process + case "Remove_a_list_of_files_from_the_watch_mode_s_processing_6629": + return Remove_a_list_of_files_from_the_watch_mode_s_processing + case "Enable_experimental_support_for_legacy_experimental_decorators_6630": + return Enable_experimental_support_for_legacy_experimental_decorators + case "Print_files_read_during_the_compilation_including_why_it_was_included_6631": + return Print_files_read_during_the_compilation_including_why_it_was_included + case "Output_more_detailed_compiler_performance_information_after_building_6632": + return Output_more_detailed_compiler_performance_information_after_building + case "Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_a_6633": + return Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_are_inherited + case "Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers_6634": + return Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers + case "Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include_6635": + return Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include + case "Build_all_projects_including_those_that_appear_to_be_up_to_date_6636": + return Build_all_projects_including_those_that_appear_to_be_up_to_date + case "Ensure_that_casing_is_correct_in_imports_6637": + return Ensure_that_casing_is_correct_in_imports + case "Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging_6638": + return Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging + case "Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file_6639": + return Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file + case "Skip_building_downstream_projects_on_error_in_upstream_project_6640": + return Skip_building_downstream_projects_on_error_in_upstream_project + case "Specify_a_list_of_glob_patterns_that_match_files_to_be_included_in_compilation_6641": + return Specify_a_list_of_glob_patterns_that_match_files_to_be_included_in_compilation + case "Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects_6642": + return Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects + case "Include_sourcemap_files_inside_the_emitted_JavaScript_6643": + return Include_sourcemap_files_inside_the_emitted_JavaScript + case "Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript_6644": + return Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript + case "Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports_6645": + return Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports + case "Specify_what_JSX_code_is_generated_6646": + return Specify_what_JSX_code_is_generated + case "Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h_6647": + return Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h + case "Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragme_6648": + return Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment + case "Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Ast_6649": + return Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk + case "Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option_6650": + return Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option + case "Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment_6651": + return Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment + case "Print_the_names_of_emitted_files_after_a_compilation_6652": + return Print_the_names_of_emitted_files_after_a_compilation + case "Print_all_of_the_files_read_during_the_compilation_6653": + return Print_all_of_the_files_read_during_the_compilation + case "Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit_6654": + return Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit + case "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6655": + return Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations + case "Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicabl_6656": + return Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs + case "Specify_what_module_code_is_generated_6657": + return Specify_what_module_code_is_generated + case "Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier_6658": + return Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier + case "Set_the_newline_character_for_emitting_files_6659": + return Set_the_newline_character_for_emitting_files + case "Disable_emitting_files_from_a_compilation_6660": + return Disable_emitting_files_from_a_compilation + case "Disable_generating_custom_helper_functions_like_extends_in_compiled_output_6661": + return Disable_generating_custom_helper_functions_like_extends_in_compiled_output + case "Disable_emitting_files_if_any_type_checking_errors_are_reported_6662": + return Disable_emitting_files_if_any_type_checking_errors_are_reported + case "Disable_truncating_types_in_error_messages_6663": + return Disable_truncating_types_in_error_messages + case "Enable_error_reporting_for_fallthrough_cases_in_switch_statements_6664": + return Enable_error_reporting_for_fallthrough_cases_in_switch_statements + case "Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type_6665": + return Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type + case "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6666": + return Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + case "Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function_6667": + return Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function + case "Enable_error_reporting_when_this_is_given_the_type_any_6668": + return Enable_error_reporting_when_this_is_given_the_type_any + case "Disable_adding_use_strict_directives_in_emitted_JavaScript_files_6669": + return Disable_adding_use_strict_directives_in_emitted_JavaScript_files + case "Disable_including_any_library_files_including_the_default_lib_d_ts_6670": + return Disable_including_any_library_files_including_the_default_lib_d_ts + case "Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type_6671": + return Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type + case "Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add__6672": + return Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project + case "Disable_strict_checking_of_generic_signatures_in_function_types_6673": + return Disable_strict_checking_of_generic_signatures_in_function_types + case "Add_undefined_to_a_type_when_accessed_using_an_index_6674": + return Add_undefined_to_a_type_when_accessed_using_an_index + case "Enable_error_reporting_when_local_variables_aren_t_read_6675": + return Enable_error_reporting_when_local_variables_aren_t_read + case "Raise_an_error_when_a_function_parameter_isn_t_read_6676": + return Raise_an_error_when_a_function_parameter_isn_t_read + case "Deprecated_setting_Use_outFile_instead_6677": + return Deprecated_setting_Use_outFile_instead + case "Specify_an_output_folder_for_all_emitted_files_6678": + return Specify_an_output_folder_for_all_emitted_files + case "Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designa_6679": + return Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output + case "Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations_6680": + return Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations + case "Specify_a_list_of_language_service_plugins_to_include_6681": + return Specify_a_list_of_language_service_plugins_to_include + case "Disable_erasing_const_enum_declarations_in_generated_code_6682": + return Disable_erasing_const_enum_declarations_in_generated_code + case "Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node_6683": + return Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node + case "Disable_wiping_the_console_in_watch_mode_6684": + return Disable_wiping_the_console_in_watch_mode + case "Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read_6685": + return Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read + case "Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit_6686": + return Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit + case "Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references_6687": + return Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references + case "Disable_emitting_comments_6688": + return Disable_emitting_comments + case "Enable_importing_json_files_6689": + return Enable_importing_json_files + case "Specify_the_root_folder_within_your_source_files_6690": + return Specify_the_root_folder_within_your_source_files + case "Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules_6691": + return Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules + case "Skip_type_checking_d_ts_files_that_are_included_with_TypeScript_6692": + return Skip_type_checking_d_ts_files_that_are_included_with_TypeScript + case "Skip_type_checking_all_d_ts_files_6693": + return Skip_type_checking_all_d_ts_files + case "Create_source_map_files_for_emitted_JavaScript_files_6694": + return Create_source_map_files_for_emitted_JavaScript_files + case "Specify_the_root_path_for_debuggers_to_find_the_reference_source_code_6695": + return Specify_the_root_path_for_debuggers_to_find_the_reference_source_code + case "Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function_6697": + return Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function + case "When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible_6698": + return When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible + case "When_type_checking_take_into_account_null_and_undefined_6699": + return When_type_checking_take_into_account_null_and_undefined + case "Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor_6700": + return Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor + case "Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments_6701": + return Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments + case "Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals_6702": + return Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals + case "Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures_6703": + return Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures + case "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6704": + return Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively + case "Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declaratio_6705": + return Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations + case "Log_paths_used_during_the_moduleResolution_process_6706": + return Log_paths_used_during_the_moduleResolution_process + case "Specify_the_path_to_tsbuildinfo_incremental_compilation_file_6707": + return Specify_the_path_to_tsbuildinfo_incremental_compilation_file + case "Specify_options_for_automatic_acquisition_of_declaration_files_6709": + return Specify_options_for_automatic_acquisition_of_declaration_files + case "Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types_6710": + return Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types + case "Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file_6711": + return Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file + case "Emit_ECMAScript_standard_compliant_class_fields_6712": + return Emit_ECMAScript_standard_compliant_class_fields + case "Enable_verbose_logging_6713": + return Enable_verbose_logging + case "Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality_6714": + return Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality + case "Specify_how_the_TypeScript_watch_mode_works_6715": + return Specify_how_the_TypeScript_watch_mode_works + case "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717": + return Require_undeclared_properties_from_index_signatures_to_use_element_accesses + case "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718": + return Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types + case "Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files_6719": + return Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files + case "Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any_6720": + return Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any + case "Do_not_allow_runtime_constructs_that_are_not_part_of_ECMAScript_6721": + return Do_not_allow_runtime_constructs_that_are_not_part_of_ECMAScript + case "Default_catch_clause_variables_as_unknown_instead_of_any_6803": + return Default_catch_clause_variables_as_unknown_instead_of_any + case "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804": + return Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting + case "Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported_6805": + return Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported + case "Check_side_effect_imports_6806": + return Check_side_effect_imports + case "This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2_6807": + return This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2 + case "Enable_lib_replacement_6808": + return Enable_lib_replacement + case "one_of_Colon_6900": + return X_one_of_Colon + case "one_or_more_Colon_6901": + return X_one_or_more_Colon + case "type_Colon_6902": + return X_type_Colon + case "default_Colon_6903": + return X_default_Colon + case "module_system_or_esModuleInterop_6904": + return X_module_system_or_esModuleInterop + case "false_unless_strict_is_set_6905": + return X_false_unless_strict_is_set + case "false_unless_composite_is_set_6906": + return X_false_unless_composite_is_set + case "node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified_6907": + return X_node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified + case "if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk_6908": + return X_if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk + case "true_if_composite_false_otherwise_6909": + return X_true_if_composite_false_otherwise + case "Computed_from_the_list_of_input_files_6911": + return Computed_from_the_list_of_input_files + case "Platform_specific_6912": + return Platform_specific + case "You_can_learn_about_all_of_the_compiler_options_at_0_6913": + return You_can_learn_about_all_of_the_compiler_options_at_0 + case "Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_conf_6914": + return Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon + case "Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_tr_6915": + return Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0 + case "COMMON_COMMANDS_6916": + return COMMON_COMMANDS + case "ALL_COMPILER_OPTIONS_6917": + return ALL_COMPILER_OPTIONS + case "WATCH_OPTIONS_6918": + return WATCH_OPTIONS + case "BUILD_OPTIONS_6919": + return BUILD_OPTIONS + case "COMMON_COMPILER_OPTIONS_6920": + return COMMON_COMPILER_OPTIONS + case "COMMAND_LINE_FLAGS_6921": + return COMMAND_LINE_FLAGS + case "tsc_Colon_The_TypeScript_Compiler_6922": + return X_tsc_Colon_The_TypeScript_Compiler + case "Compiles_the_current_project_tsconfig_json_in_the_working_directory_6923": + return Compiles_the_current_project_tsconfig_json_in_the_working_directory + case "Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options_6924": + return Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options + case "Build_a_composite_project_in_the_working_directory_6925": + return Build_a_composite_project_in_the_working_directory + case "Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory_6926": + return Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory + case "Compiles_the_TypeScript_project_located_at_the_specified_path_6927": + return Compiles_the_TypeScript_project_located_at_the_specified_path + case "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928": + return An_expanded_version_of_this_information_showing_all_possible_compiler_options + case "Compiles_the_current_project_with_additional_settings_6929": + return Compiles_the_current_project_with_additional_settings + case "true_for_ES2022_and_above_including_ESNext_6930": + return X_true_for_ES2022_and_above_including_ESNext + case "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931": + return List_of_file_name_suffixes_to_search_when_resolving_a_module + case "Variable_0_implicitly_has_an_1_type_7005": + return Variable_0_implicitly_has_an_1_type + case "Parameter_0_implicitly_has_an_1_type_7006": + return Parameter_0_implicitly_has_an_1_type + case "Member_0_implicitly_has_an_1_type_7008": + return Member_0_implicitly_has_an_1_type + case "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009": + return X_new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type + case "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010": + return X_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type + case "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011": + return Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type + case "This_overload_implicitly_returns_the_type_0_because_it_lacks_a_return_type_annotation_7012": + return This_overload_implicitly_returns_the_type_0_because_it_lacks_a_return_type_annotation + case "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013": + return Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type + case "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014": + return Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type + case "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015": + return Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number + case "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016": + return Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type + case "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017": + return Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature + case "Object_literal_s_property_0_implicitly_has_an_1_type_7018": + return Object_literal_s_property_0_implicitly_has_an_1_type + case "Rest_parameter_0_implicitly_has_an_any_type_7019": + return Rest_parameter_0_implicitly_has_an_any_type + case "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020": + return Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type + case "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022": + return X_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer + case "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023": + return X_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions + case "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": + return Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions + case "Generator_implicitly_has_yield_type_0_Consider_supplying_a_return_type_annotation_7025": + return Generator_implicitly_has_yield_type_0_Consider_supplying_a_return_type_annotation + case "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026": + return JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists + case "Unreachable_code_detected_7027": + return Unreachable_code_detected + case "Unused_label_7028": + return Unused_label + case "Fallthrough_case_in_switch_7029": + return Fallthrough_case_in_switch + case "Not_all_code_paths_return_a_value_7030": + return Not_all_code_paths_return_a_value + case "Binding_element_0_implicitly_has_an_1_type_7031": + return Binding_element_0_implicitly_has_an_1_type + case "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032": + return Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation + case "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": + return Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation + case "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034": + return Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined + case "Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare__7035": + return Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0 + case "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": + return Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0 + case "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037": + return Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports + case "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": + return Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead + case "Mapped_object_type_implicitly_has_an_any_template_type_7039": + return Mapped_object_type_implicitly_has_an_any_template_type + case "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": + return If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1 + case "The_containing_arrow_function_captures_the_global_value_of_this_7041": + return The_containing_arrow_function_captures_the_global_value_of_this + case "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042": + return Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used + case "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043": + return Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage + case "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": + return Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage + case "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045": + return Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage + case "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046": + return Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage + case "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047": + return Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage + case "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048": + return Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage + case "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049": + return Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage + case "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050": + return X_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage + case "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051": + return Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1 + case "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052": + return Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1 + case "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053": + return Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1 + case "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054": + return No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1 + case "_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type_7055": + return X_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type + case "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056": + return The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed + case "yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057": + return X_yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation + case "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": + return If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1 + case "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059": + return This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead + case "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060": + return This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint + case "A_mapped_type_may_not_declare_properties_or_methods_7061": + return A_mapped_type_may_not_declare_properties_or_methods + case "You_cannot_rename_this_element_8000": + return You_cannot_rename_this_element + case "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": + return You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library + case "import_can_only_be_used_in_TypeScript_files_8002": + return X_import_can_only_be_used_in_TypeScript_files + case "export_can_only_be_used_in_TypeScript_files_8003": + return X_export_can_only_be_used_in_TypeScript_files + case "Type_parameter_declarations_can_only_be_used_in_TypeScript_files_8004": + return Type_parameter_declarations_can_only_be_used_in_TypeScript_files + case "implements_clauses_can_only_be_used_in_TypeScript_files_8005": + return X_implements_clauses_can_only_be_used_in_TypeScript_files + case "_0_declarations_can_only_be_used_in_TypeScript_files_8006": + return X_0_declarations_can_only_be_used_in_TypeScript_files + case "Type_aliases_can_only_be_used_in_TypeScript_files_8008": + return Type_aliases_can_only_be_used_in_TypeScript_files + case "The_0_modifier_can_only_be_used_in_TypeScript_files_8009": + return The_0_modifier_can_only_be_used_in_TypeScript_files + case "Type_annotations_can_only_be_used_in_TypeScript_files_8010": + return Type_annotations_can_only_be_used_in_TypeScript_files + case "Type_arguments_can_only_be_used_in_TypeScript_files_8011": + return Type_arguments_can_only_be_used_in_TypeScript_files + case "Parameter_modifiers_can_only_be_used_in_TypeScript_files_8012": + return Parameter_modifiers_can_only_be_used_in_TypeScript_files + case "Non_null_assertions_can_only_be_used_in_TypeScript_files_8013": + return Non_null_assertions_can_only_be_used_in_TypeScript_files + case "Type_assertion_expressions_can_only_be_used_in_TypeScript_files_8016": + return Type_assertion_expressions_can_only_be_used_in_TypeScript_files + case "Signature_declarations_can_only_be_used_in_TypeScript_files_8017": + return Signature_declarations_can_only_be_used_in_TypeScript_files + case "Report_errors_in_js_files_8019": + return Report_errors_in_js_files + case "JSDoc_types_can_only_be_used_inside_documentation_comments_8020": + return JSDoc_types_can_only_be_used_inside_documentation_comments + case "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021": + return JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags + case "JSDoc_0_is_not_attached_to_a_class_8022": + return JSDoc_0_is_not_attached_to_a_class + case "JSDoc_0_1_does_not_match_the_extends_2_clause_8023": + return JSDoc_0_1_does_not_match_the_extends_2_clause + case "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024": + return JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name + case "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": + return Class_declarations_cannot_have_more_than_one_augments_or_extends_tag + case "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": + return Expected_0_type_arguments_provide_these_with_an_extends_tag + case "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027": + return Expected_0_1_type_arguments_provide_these_with_an_extends_tag + case "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028": + return JSDoc_may_only_appear_in_the_last_parameter_of_a_signature + case "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_h_8029": + return JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type + case "A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments_8030": + return A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments + case "You_cannot_rename_a_module_via_a_global_import_8031": + return You_cannot_rename_a_module_via_a_global_import + case "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032": + return Qualified_name_0_is_not_allowed_without_a_leading_param_object_1 + case "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033": + return A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags + case "The_tag_was_first_specified_here_8034": + return The_tag_was_first_specified_here + case "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": + return You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder + case "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": + return You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder + case "Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files_8037": + return Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files + case "Decorators_may_not_appear_after_export_or_export_default_if_they_also_appear_before_export_8038": + return Decorators_may_not_appear_after_export_or_export_default_if_they_also_appear_before_export + case "A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag_8039": + return A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag + case "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": + return Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit + case "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": + return Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + case "Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9007": + return Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations + case "Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9008": + return Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations + case "At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9009": + return At_least_one_accessor_must_have_an_explicit_type_annotation_with_isolatedDeclarations + case "Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9010": + return Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations + case "Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9011": + return Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations + case "Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9012": + return Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations + case "Expression_type_can_t_be_inferred_with_isolatedDeclarations_9013": + return Expression_type_can_t_be_inferred_with_isolatedDeclarations + case "Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedD_9014": + return Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations + case "Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations_9015": + return Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations + case "Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations_9016": + return Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations + case "Only_const_arrays_can_be_inferred_with_isolatedDeclarations_9017": + return Only_const_arrays_can_be_inferred_with_isolatedDeclarations + case "Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations_9018": + return Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations + case "Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations_9019": + return Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations + case "Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDecl_9020": + return Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations + case "Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations_9021": + return Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations + case "Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations_9022": + return Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations + case "Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations__9023": + return Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function + case "Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_sup_9025": + return Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_supported_with_isolatedDeclarations + case "Declaration_emit_for_this_file_requires_preserving_this_import_for_augmentations_This_is_not_support_9026": + return Declaration_emit_for_this_file_requires_preserving_this_import_for_augmentations_This_is_not_supported_with_isolatedDeclarations + case "Add_a_type_annotation_to_the_variable_0_9027": + return Add_a_type_annotation_to_the_variable_0 + case "Add_a_type_annotation_to_the_parameter_0_9028": + return Add_a_type_annotation_to_the_parameter_0 + case "Add_a_type_annotation_to_the_property_0_9029": + return Add_a_type_annotation_to_the_property_0 + case "Add_a_return_type_to_the_function_expression_9030": + return Add_a_return_type_to_the_function_expression + case "Add_a_return_type_to_the_function_declaration_9031": + return Add_a_return_type_to_the_function_declaration + case "Add_a_return_type_to_the_get_accessor_declaration_9032": + return Add_a_return_type_to_the_get_accessor_declaration + case "Add_a_type_to_parameter_of_the_set_accessor_declaration_9033": + return Add_a_type_to_parameter_of_the_set_accessor_declaration + case "Add_a_return_type_to_the_method_9034": + return Add_a_return_type_to_the_method + case "Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit_9035": + return Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit + case "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036": + return Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it + case "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037": + return Default_exports_can_t_be_inferred_with_isolatedDeclarations + case "Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations_9038": + return Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations + case "Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations_9039": + return Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations + case "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000": + return JSX_attributes_must_only_be_assigned_a_non_empty_expression + case "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001": + return JSX_elements_cannot_have_multiple_attributes_with_the_same_name + case "Expected_corresponding_JSX_closing_tag_for_0_17002": + return Expected_corresponding_JSX_closing_tag_for_0 + case "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004": + return Cannot_use_JSX_unless_the_jsx_flag_is_provided + case "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005": + return A_constructor_cannot_contain_a_super_call_when_its_class_extends_null + case "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006": + return An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses + case "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": + return A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses + case "JSX_element_0_has_no_corresponding_closing_tag_17008": + return JSX_element_0_has_no_corresponding_closing_tag + case "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009": + return X_super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class + case "Unknown_type_acquisition_option_0_17010": + return Unknown_type_acquisition_option_0 + case "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011": + return X_super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class + case "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012": + return X_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2 + case "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013": + return Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor + case "JSX_fragment_has_no_corresponding_closing_tag_17014": + return JSX_fragment_has_no_corresponding_closing_tag + case "Expected_corresponding_closing_tag_for_JSX_fragment_17015": + return Expected_corresponding_closing_tag_for_JSX_fragment + case "The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_com_17016": + return The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option + case "An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments_17017": + return An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments + case "Unknown_type_acquisition_option_0_Did_you_mean_1_17018": + return Unknown_type_acquisition_option_0_Did_you_mean_1 + case "_0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1_17019": + return X_0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1 + case "_0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1_17020": + return X_0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1 + case "Unicode_escape_sequence_cannot_appear_here_17021": + return Unicode_escape_sequence_cannot_appear_here + case "Circularity_detected_while_resolving_configuration_Colon_0_18000": + return Circularity_detected_while_resolving_configuration_Colon_0 + case "The_files_list_in_config_file_0_is_empty_18002": + return The_files_list_in_config_file_0_is_empty + case "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003": + return No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2 + case "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004": + return No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer + case "Classes_may_not_have_a_field_named_constructor_18006": + return Classes_may_not_have_a_field_named_constructor + case "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007": + return JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array + case "Private_identifiers_cannot_be_used_as_parameters_18009": + return Private_identifiers_cannot_be_used_as_parameters + case "An_accessibility_modifier_cannot_be_used_with_a_private_identifier_18010": + return An_accessibility_modifier_cannot_be_used_with_a_private_identifier + case "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": + return The_operand_of_a_delete_operator_cannot_be_a_private_identifier + case "constructor_is_a_reserved_word_18012": + return X_constructor_is_a_reserved_word + case "Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier_18013": + return Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier + case "The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_priv_18014": + return The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling + case "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": + return Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2 + case "Private_identifiers_are_not_allowed_outside_class_bodies_18016": + return Private_identifiers_are_not_allowed_outside_class_bodies + case "The_shadowing_declaration_of_0_is_defined_here_18017": + return The_shadowing_declaration_of_0_is_defined_here + case "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018": + return The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here + case "_0_modifier_cannot_be_used_with_a_private_identifier_18019": + return X_0_modifier_cannot_be_used_with_a_private_identifier + case "An_enum_member_cannot_be_named_with_a_private_identifier_18024": + return An_enum_member_cannot_be_named_with_a_private_identifier + case "can_only_be_used_at_the_start_of_a_file_18026": + return X_can_only_be_used_at_the_start_of_a_file + case "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": + return Compiler_reserves_name_0_when_emitting_private_identifier_downlevel + case "Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher_18028": + return Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher + case "Private_identifiers_are_not_allowed_in_variable_declarations_18029": + return Private_identifiers_are_not_allowed_in_variable_declarations + case "An_optional_chain_cannot_contain_private_identifiers_18030": + return An_optional_chain_cannot_contain_private_identifiers + case "The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituent_18031": + return The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents + case "The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_pr_18032": + return The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some + case "Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values_18033": + return Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values + case "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034": + return Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment + case "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035": + return Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name + case "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036": + return Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator + case "await_expression_cannot_be_used_inside_a_class_static_block_18037": + return X_await_expression_cannot_be_used_inside_a_class_static_block + case "for_await_loops_cannot_be_used_inside_a_class_static_block_18038": + return X_for_await_loops_cannot_be_used_inside_a_class_static_block + case "Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block_18039": + return Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block + case "A_return_statement_cannot_be_used_inside_a_class_static_block_18041": + return A_return_statement_cannot_be_used_inside_a_class_static_block + case "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": + return X_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation + case "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": + return Types_cannot_appear_in_export_declarations_in_JavaScript_files + case "_0_is_automatically_exported_here_18044": + return X_0_is_automatically_exported_here + case "Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher_18045": + return Properties_with_the_accessor_modifier_are_only_available_when_targeting_ECMAScript_2015_and_higher + case "_0_is_of_type_unknown_18046": + return X_0_is_of_type_unknown + case "_0_is_possibly_null_18047": + return X_0_is_possibly_null + case "_0_is_possibly_undefined_18048": + return X_0_is_possibly_undefined + case "_0_is_possibly_null_or_undefined_18049": + return X_0_is_possibly_null_or_undefined + case "The_value_0_cannot_be_used_here_18050": + return The_value_0_cannot_be_used_here + case "Compiler_option_0_cannot_be_given_an_empty_string_18051": + return Compiler_option_0_cannot_be_given_an_empty_string + case "Its_type_0_is_not_a_valid_JSX_element_type_18053": + return Its_type_0_is_not_a_valid_JSX_element_type + case "await_using_statements_cannot_be_used_inside_a_class_static_block_18054": + return X_await_using_statements_cannot_be_used_inside_a_class_static_block + case "_0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is__18055": + return X_0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled + case "Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is__18056": + return Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled + case "String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es_18057": + return String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020 + case "Default_imports_are_not_allowed_in_a_deferred_import_18058": + return Default_imports_are_not_allowed_in_a_deferred_import + case "Named_imports_are_not_allowed_in_a_deferred_import_18059": + return Named_imports_are_not_allowed_in_a_deferred_import + case "Deferred_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_or_preserve_18060": + return Deferred_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_or_preserve + case "_0_is_not_a_valid_meta_property_for_keyword_import_Did_you_mean_meta_or_defer_18061": + return X_0_is_not_a_valid_meta_property_for_keyword_import_Did_you_mean_meta_or_defer + case "nodenext_if_module_is_nodenext_node16_if_module_is_node16_or_node18_otherwise_bundler_69010": + return X_nodenext_if_module_is_nodenext_node16_if_module_is_node16_or_node18_otherwise_bundler + case "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": + return File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module + case "This_constructor_function_may_be_converted_to_a_class_declaration_80002": + return This_constructor_function_may_be_converted_to_a_class_declaration + case "Import_may_be_converted_to_a_default_import_80003": + return Import_may_be_converted_to_a_default_import + case "JSDoc_types_may_be_moved_to_TypeScript_types_80004": + return JSDoc_types_may_be_moved_to_TypeScript_types + case "require_call_may_be_converted_to_an_import_80005": + return X_require_call_may_be_converted_to_an_import + case "This_may_be_converted_to_an_async_function_80006": + return This_may_be_converted_to_an_async_function + case "await_has_no_effect_on_the_type_of_this_expression_80007": + return X_await_has_no_effect_on_the_type_of_this_expression + case "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008": + return Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers + case "JSDoc_typedef_may_be_converted_to_TypeScript_type_80009": + return JSDoc_typedef_may_be_converted_to_TypeScript_type + case "JSDoc_typedefs_may_be_converted_to_TypeScript_types_80010": + return JSDoc_typedefs_may_be_converted_to_TypeScript_types + case "Add_missing_super_call_90001": + return Add_missing_super_call + case "Make_super_call_the_first_statement_in_the_constructor_90002": + return Make_super_call_the_first_statement_in_the_constructor + case "Change_extends_to_implements_90003": + return Change_extends_to_implements + case "Remove_unused_declaration_for_Colon_0_90004": + return Remove_unused_declaration_for_Colon_0 + case "Remove_import_from_0_90005": + return Remove_import_from_0 + case "Implement_interface_0_90006": + return Implement_interface_0 + case "Implement_inherited_abstract_class_90007": + return Implement_inherited_abstract_class + case "Add_0_to_unresolved_variable_90008": + return Add_0_to_unresolved_variable + case "Remove_variable_statement_90010": + return Remove_variable_statement + case "Remove_template_tag_90011": + return Remove_template_tag + case "Remove_type_parameters_90012": + return Remove_type_parameters + case "Import_0_from_1_90013": + return Import_0_from_1 + case "Change_0_to_1_90014": + return Change_0_to_1 + case "Declare_property_0_90016": + return Declare_property_0 + case "Add_index_signature_for_property_0_90017": + return Add_index_signature_for_property_0 + case "Disable_checking_for_this_file_90018": + return Disable_checking_for_this_file + case "Ignore_this_error_message_90019": + return Ignore_this_error_message + case "Initialize_property_0_in_the_constructor_90020": + return Initialize_property_0_in_the_constructor + case "Initialize_static_property_0_90021": + return Initialize_static_property_0 + case "Change_spelling_to_0_90022": + return Change_spelling_to_0 + case "Declare_method_0_90023": + return Declare_method_0 + case "Declare_static_method_0_90024": + return Declare_static_method_0 + case "Prefix_0_with_an_underscore_90025": + return Prefix_0_with_an_underscore + case "Rewrite_as_the_indexed_access_type_0_90026": + return Rewrite_as_the_indexed_access_type_0 + case "Declare_static_property_0_90027": + return Declare_static_property_0 + case "Call_decorator_expression_90028": + return Call_decorator_expression + case "Add_async_modifier_to_containing_function_90029": + return Add_async_modifier_to_containing_function + case "Replace_infer_0_with_unknown_90030": + return Replace_infer_0_with_unknown + case "Replace_all_unused_infer_with_unknown_90031": + return Replace_all_unused_infer_with_unknown + case "Add_parameter_name_90034": + return Add_parameter_name + case "Declare_private_property_0_90035": + return Declare_private_property_0 + case "Replace_0_with_Promise_1_90036": + return Replace_0_with_Promise_1 + case "Fix_all_incorrect_return_type_of_an_async_functions_90037": + return Fix_all_incorrect_return_type_of_an_async_functions + case "Declare_private_method_0_90038": + return Declare_private_method_0 + case "Remove_unused_destructuring_declaration_90039": + return Remove_unused_destructuring_declaration + case "Remove_unused_declarations_for_Colon_0_90041": + return Remove_unused_declarations_for_Colon_0 + case "Declare_a_private_field_named_0_90053": + return Declare_a_private_field_named_0 + case "Includes_imports_of_types_referenced_by_0_90054": + return Includes_imports_of_types_referenced_by_0 + case "Remove_type_from_import_declaration_from_0_90055": + return Remove_type_from_import_declaration_from_0 + case "Remove_type_from_import_of_0_from_1_90056": + return Remove_type_from_import_of_0_from_1 + case "Add_import_from_0_90057": + return Add_import_from_0 + case "Update_import_from_0_90058": + return Update_import_from_0 + case "Export_0_from_module_1_90059": + return Export_0_from_module_1 + case "Export_all_referenced_locals_90060": + return Export_all_referenced_locals + case "Update_modifiers_of_0_90061": + return Update_modifiers_of_0 + case "Add_annotation_of_type_0_90062": + return Add_annotation_of_type_0 + case "Add_return_type_0_90063": + return Add_return_type_0 + case "Extract_base_class_to_variable_90064": + return Extract_base_class_to_variable + case "Extract_default_export_to_variable_90065": + return Extract_default_export_to_variable + case "Extract_binding_expressions_to_variable_90066": + return Extract_binding_expressions_to_variable + case "Add_all_missing_type_annotations_90067": + return Add_all_missing_type_annotations + case "Add_satisfies_and_an_inline_type_assertion_with_0_90068": + return Add_satisfies_and_an_inline_type_assertion_with_0 + case "Extract_to_variable_and_replace_with_0_as_typeof_0_90069": + return Extract_to_variable_and_replace_with_0_as_typeof_0 + case "Mark_array_literal_as_const_90070": + return Mark_array_literal_as_const + case "Annotate_types_of_properties_expando_function_in_a_namespace_90071": + return Annotate_types_of_properties_expando_function_in_a_namespace + case "Convert_function_to_an_ES2015_class_95001": + return Convert_function_to_an_ES2015_class + case "Convert_0_to_1_in_0_95003": + return Convert_0_to_1_in_0 + case "Extract_to_0_in_1_95004": + return Extract_to_0_in_1 + case "Extract_function_95005": + return Extract_function + case "Extract_constant_95006": + return Extract_constant + case "Extract_to_0_in_enclosing_scope_95007": + return Extract_to_0_in_enclosing_scope + case "Extract_to_0_in_1_scope_95008": + return Extract_to_0_in_1_scope + case "Annotate_with_type_from_JSDoc_95009": + return Annotate_with_type_from_JSDoc + case "Infer_type_of_0_from_usage_95011": + return Infer_type_of_0_from_usage + case "Infer_parameter_types_from_usage_95012": + return Infer_parameter_types_from_usage + case "Convert_to_default_import_95013": + return Convert_to_default_import + case "Install_0_95014": + return Install_0 + case "Replace_import_with_0_95015": + return Replace_import_with_0 + case "Use_synthetic_default_member_95016": + return Use_synthetic_default_member + case "Convert_to_ES_module_95017": + return Convert_to_ES_module + case "Add_undefined_type_to_property_0_95018": + return Add_undefined_type_to_property_0 + case "Add_initializer_to_property_0_95019": + return Add_initializer_to_property_0 + case "Add_definite_assignment_assertion_to_property_0_95020": + return Add_definite_assignment_assertion_to_property_0 + case "Convert_all_type_literals_to_mapped_type_95021": + return Convert_all_type_literals_to_mapped_type + case "Add_all_missing_members_95022": + return Add_all_missing_members + case "Infer_all_types_from_usage_95023": + return Infer_all_types_from_usage + case "Delete_all_unused_declarations_95024": + return Delete_all_unused_declarations + case "Prefix_all_unused_declarations_with_where_possible_95025": + return Prefix_all_unused_declarations_with_where_possible + case "Fix_all_detected_spelling_errors_95026": + return Fix_all_detected_spelling_errors + case "Add_initializers_to_all_uninitialized_properties_95027": + return Add_initializers_to_all_uninitialized_properties + case "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": + return Add_definite_assignment_assertions_to_all_uninitialized_properties + case "Add_undefined_type_to_all_uninitialized_properties_95029": + return Add_undefined_type_to_all_uninitialized_properties + case "Change_all_jsdoc_style_types_to_TypeScript_95030": + return Change_all_jsdoc_style_types_to_TypeScript + case "Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types_95031": + return Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types + case "Implement_all_unimplemented_interfaces_95032": + return Implement_all_unimplemented_interfaces + case "Install_all_missing_types_packages_95033": + return Install_all_missing_types_packages + case "Rewrite_all_as_indexed_access_types_95034": + return Rewrite_all_as_indexed_access_types + case "Convert_all_to_default_imports_95035": + return Convert_all_to_default_imports + case "Make_all_super_calls_the_first_statement_in_their_constructor_95036": + return Make_all_super_calls_the_first_statement_in_their_constructor + case "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": + return Add_qualifier_to_all_unresolved_variables_matching_a_member_name + case "Change_all_extended_interfaces_to_implements_95038": + return Change_all_extended_interfaces_to_implements + case "Add_all_missing_super_calls_95039": + return Add_all_missing_super_calls + case "Implement_all_inherited_abstract_classes_95040": + return Implement_all_inherited_abstract_classes + case "Add_all_missing_async_modifiers_95041": + return Add_all_missing_async_modifiers + case "Add_ts_ignore_to_all_error_messages_95042": + return Add_ts_ignore_to_all_error_messages + case "Annotate_everything_with_types_from_JSDoc_95043": + return Annotate_everything_with_types_from_JSDoc + case "Add_to_all_uncalled_decorators_95044": + return Add_to_all_uncalled_decorators + case "Convert_all_constructor_functions_to_classes_95045": + return Convert_all_constructor_functions_to_classes + case "Generate_get_and_set_accessors_95046": + return Generate_get_and_set_accessors + case "Convert_require_to_import_95047": + return Convert_require_to_import + case "Convert_all_require_to_import_95048": + return Convert_all_require_to_import + case "Move_to_a_new_file_95049": + return Move_to_a_new_file + case "Remove_unreachable_code_95050": + return Remove_unreachable_code + case "Remove_all_unreachable_code_95051": + return Remove_all_unreachable_code + case "Add_missing_typeof_95052": + return Add_missing_typeof + case "Remove_unused_label_95053": + return Remove_unused_label + case "Remove_all_unused_labels_95054": + return Remove_all_unused_labels + case "Convert_0_to_mapped_object_type_95055": + return Convert_0_to_mapped_object_type + case "Convert_namespace_import_to_named_imports_95056": + return Convert_namespace_import_to_named_imports + case "Convert_named_imports_to_namespace_import_95057": + return Convert_named_imports_to_namespace_import + case "Add_or_remove_braces_in_an_arrow_function_95058": + return Add_or_remove_braces_in_an_arrow_function + case "Add_braces_to_arrow_function_95059": + return Add_braces_to_arrow_function + case "Remove_braces_from_arrow_function_95060": + return Remove_braces_from_arrow_function + case "Convert_default_export_to_named_export_95061": + return Convert_default_export_to_named_export + case "Convert_named_export_to_default_export_95062": + return Convert_named_export_to_default_export + case "Add_missing_enum_member_0_95063": + return Add_missing_enum_member_0 + case "Add_all_missing_imports_95064": + return Add_all_missing_imports + case "Convert_to_async_function_95065": + return Convert_to_async_function + case "Convert_all_to_async_functions_95066": + return Convert_all_to_async_functions + case "Add_missing_call_parentheses_95067": + return Add_missing_call_parentheses + case "Add_all_missing_call_parentheses_95068": + return Add_all_missing_call_parentheses + case "Add_unknown_conversion_for_non_overlapping_types_95069": + return Add_unknown_conversion_for_non_overlapping_types + case "Add_unknown_to_all_conversions_of_non_overlapping_types_95070": + return Add_unknown_to_all_conversions_of_non_overlapping_types + case "Add_missing_new_operator_to_call_95071": + return Add_missing_new_operator_to_call + case "Add_missing_new_operator_to_all_calls_95072": + return Add_missing_new_operator_to_all_calls + case "Add_names_to_all_parameters_without_names_95073": + return Add_names_to_all_parameters_without_names + case "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074": + return Enable_the_experimentalDecorators_option_in_your_configuration_file + case "Convert_parameters_to_destructured_object_95075": + return Convert_parameters_to_destructured_object + case "Extract_type_95077": + return Extract_type + case "Extract_to_type_alias_95078": + return Extract_to_type_alias + case "Extract_to_typedef_95079": + return Extract_to_typedef + case "Infer_this_type_of_0_from_usage_95080": + return Infer_this_type_of_0_from_usage + case "Add_const_to_unresolved_variable_95081": + return Add_const_to_unresolved_variable + case "Add_const_to_all_unresolved_variables_95082": + return Add_const_to_all_unresolved_variables + case "Add_await_95083": + return Add_await + case "Add_await_to_initializer_for_0_95084": + return Add_await_to_initializer_for_0 + case "Fix_all_expressions_possibly_missing_await_95085": + return Fix_all_expressions_possibly_missing_await + case "Remove_unnecessary_await_95086": + return Remove_unnecessary_await + case "Remove_all_unnecessary_uses_of_await_95087": + return Remove_all_unnecessary_uses_of_await + case "Enable_the_jsx_flag_in_your_configuration_file_95088": + return Enable_the_jsx_flag_in_your_configuration_file + case "Add_await_to_initializers_95089": + return Add_await_to_initializers + case "Extract_to_interface_95090": + return Extract_to_interface + case "Convert_to_a_bigint_numeric_literal_95091": + return Convert_to_a_bigint_numeric_literal + case "Convert_all_to_bigint_numeric_literals_95092": + return Convert_all_to_bigint_numeric_literals + case "Convert_const_to_let_95093": + return Convert_const_to_let + case "Prefix_with_declare_95094": + return Prefix_with_declare + case "Prefix_all_incorrect_property_declarations_with_declare_95095": + return Prefix_all_incorrect_property_declarations_with_declare + case "Convert_to_template_string_95096": + return Convert_to_template_string + case "Add_export_to_make_this_file_into_a_module_95097": + return Add_export_to_make_this_file_into_a_module + case "Set_the_target_option_in_your_configuration_file_to_0_95098": + return Set_the_target_option_in_your_configuration_file_to_0 + case "Set_the_module_option_in_your_configuration_file_to_0_95099": + return Set_the_module_option_in_your_configuration_file_to_0 + case "Convert_invalid_character_to_its_html_entity_code_95100": + return Convert_invalid_character_to_its_html_entity_code + case "Convert_all_invalid_characters_to_HTML_entity_code_95101": + return Convert_all_invalid_characters_to_HTML_entity_code + case "Convert_all_const_to_let_95102": + return Convert_all_const_to_let + case "Convert_function_expression_0_to_arrow_function_95105": + return Convert_function_expression_0_to_arrow_function + case "Convert_function_declaration_0_to_arrow_function_95106": + return Convert_function_declaration_0_to_arrow_function + case "Fix_all_implicit_this_errors_95107": + return Fix_all_implicit_this_errors + case "Wrap_invalid_character_in_an_expression_container_95108": + return Wrap_invalid_character_in_an_expression_container + case "Wrap_all_invalid_characters_in_an_expression_container_95109": + return Wrap_all_invalid_characters_in_an_expression_container + case "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": + return Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file + case "Add_a_return_statement_95111": + return Add_a_return_statement + case "Remove_braces_from_arrow_function_body_95112": + return Remove_braces_from_arrow_function_body + case "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": + return Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal + case "Add_all_missing_return_statement_95114": + return Add_all_missing_return_statement + case "Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115": + return Remove_braces_from_all_arrow_function_bodies_with_relevant_issues + case "Wrap_all_object_literal_with_parentheses_95116": + return Wrap_all_object_literal_with_parentheses + case "Move_labeled_tuple_element_modifiers_to_labels_95117": + return Move_labeled_tuple_element_modifiers_to_labels + case "Convert_overload_list_to_single_signature_95118": + return Convert_overload_list_to_single_signature + case "Generate_get_and_set_accessors_for_all_overriding_properties_95119": + return Generate_get_and_set_accessors_for_all_overriding_properties + case "Wrap_in_JSX_fragment_95120": + return Wrap_in_JSX_fragment + case "Wrap_all_unparented_JSX_in_JSX_fragment_95121": + return Wrap_all_unparented_JSX_in_JSX_fragment + case "Convert_arrow_function_or_function_expression_95122": + return Convert_arrow_function_or_function_expression + case "Convert_to_anonymous_function_95123": + return Convert_to_anonymous_function + case "Convert_to_named_function_95124": + return Convert_to_named_function + case "Convert_to_arrow_function_95125": + return Convert_to_arrow_function + case "Remove_parentheses_95126": + return Remove_parentheses + case "Could_not_find_a_containing_arrow_function_95127": + return Could_not_find_a_containing_arrow_function + case "Containing_function_is_not_an_arrow_function_95128": + return Containing_function_is_not_an_arrow_function + case "Could_not_find_export_statement_95129": + return Could_not_find_export_statement + case "This_file_already_has_a_default_export_95130": + return This_file_already_has_a_default_export + case "Could_not_find_import_clause_95131": + return Could_not_find_import_clause + case "Could_not_find_namespace_import_or_named_imports_95132": + return Could_not_find_namespace_import_or_named_imports + case "Selection_is_not_a_valid_type_node_95133": + return Selection_is_not_a_valid_type_node + case "No_type_could_be_extracted_from_this_type_node_95134": + return No_type_could_be_extracted_from_this_type_node + case "Could_not_find_property_for_which_to_generate_accessor_95135": + return Could_not_find_property_for_which_to_generate_accessor + case "Name_is_not_valid_95136": + return Name_is_not_valid + case "Can_only_convert_property_with_modifier_95137": + return Can_only_convert_property_with_modifier + case "Switch_each_misused_0_to_1_95138": + return Switch_each_misused_0_to_1 + case "Convert_to_optional_chain_expression_95139": + return Convert_to_optional_chain_expression + case "Could_not_find_convertible_access_expression_95140": + return Could_not_find_convertible_access_expression + case "Could_not_find_matching_access_expressions_95141": + return Could_not_find_matching_access_expressions + case "Can_only_convert_logical_AND_access_chains_95142": + return Can_only_convert_logical_AND_access_chains + case "Add_void_to_Promise_resolved_without_a_value_95143": + return Add_void_to_Promise_resolved_without_a_value + case "Add_void_to_all_Promises_resolved_without_a_value_95144": + return Add_void_to_all_Promises_resolved_without_a_value + case "Use_element_access_for_0_95145": + return Use_element_access_for_0 + case "Use_element_access_for_all_undeclared_properties_95146": + return Use_element_access_for_all_undeclared_properties + case "Delete_all_unused_imports_95147": + return Delete_all_unused_imports + case "Infer_function_return_type_95148": + return Infer_function_return_type + case "Return_type_must_be_inferred_from_a_function_95149": + return Return_type_must_be_inferred_from_a_function + case "Could_not_determine_function_return_type_95150": + return Could_not_determine_function_return_type + case "Could_not_convert_to_arrow_function_95151": + return Could_not_convert_to_arrow_function + case "Could_not_convert_to_named_function_95152": + return Could_not_convert_to_named_function + case "Could_not_convert_to_anonymous_function_95153": + return Could_not_convert_to_anonymous_function + case "Can_only_convert_string_concatenations_and_string_literals_95154": + return Can_only_convert_string_concatenations_and_string_literals + case "Selection_is_not_a_valid_statement_or_statements_95155": + return Selection_is_not_a_valid_statement_or_statements + case "Add_missing_function_declaration_0_95156": + return Add_missing_function_declaration_0 + case "Add_all_missing_function_declarations_95157": + return Add_all_missing_function_declarations + case "Method_not_implemented_95158": + return Method_not_implemented + case "Function_not_implemented_95159": + return Function_not_implemented + case "Add_override_modifier_95160": + return Add_override_modifier + case "Remove_override_modifier_95161": + return Remove_override_modifier + case "Add_all_missing_override_modifiers_95162": + return Add_all_missing_override_modifiers + case "Remove_all_unnecessary_override_modifiers_95163": + return Remove_all_unnecessary_override_modifiers + case "Can_only_convert_named_export_95164": + return Can_only_convert_named_export + case "Add_missing_properties_95165": + return Add_missing_properties + case "Add_all_missing_properties_95166": + return Add_all_missing_properties + case "Add_missing_attributes_95167": + return Add_missing_attributes + case "Add_all_missing_attributes_95168": + return Add_all_missing_attributes + case "Add_undefined_to_optional_property_type_95169": + return Add_undefined_to_optional_property_type + case "Convert_named_imports_to_default_import_95170": + return Convert_named_imports_to_default_import + case "Delete_unused_param_tag_0_95171": + return Delete_unused_param_tag_0 + case "Delete_all_unused_param_tags_95172": + return Delete_all_unused_param_tags + case "Rename_param_tag_name_0_to_1_95173": + return Rename_param_tag_name_0_to_1 + case "Use_0_95174": + return Use_0 + case "Use_Number_isNaN_in_all_conditions_95175": + return Use_Number_isNaN_in_all_conditions + case "Convert_typedef_to_TypeScript_type_95176": + return Convert_typedef_to_TypeScript_type + case "Convert_all_typedef_to_TypeScript_types_95177": + return Convert_all_typedef_to_TypeScript_types + case "Move_to_file_95178": + return Move_to_file + case "Cannot_move_to_file_selected_file_is_invalid_95179": + return Cannot_move_to_file_selected_file_is_invalid + case "Use_import_type_95180": + return Use_import_type + case "Use_type_0_95181": + return Use_type_0 + case "Fix_all_with_type_only_imports_95182": + return Fix_all_with_type_only_imports + case "Cannot_move_statements_to_the_selected_file_95183": + return Cannot_move_statements_to_the_selected_file + case "Inline_variable_95184": + return Inline_variable + case "Could_not_find_variable_to_inline_95185": + return Could_not_find_variable_to_inline + case "Variables_with_multiple_declarations_cannot_be_inlined_95186": + return Variables_with_multiple_declarations_cannot_be_inlined + case "Add_missing_comma_for_object_member_completion_0_95187": + return Add_missing_comma_for_object_member_completion_0 + case "Add_missing_parameter_to_0_95188": + return Add_missing_parameter_to_0 + case "Add_missing_parameters_to_0_95189": + return Add_missing_parameters_to_0 + case "Add_all_missing_parameters_95190": + return Add_all_missing_parameters + case "Add_optional_parameter_to_0_95191": + return Add_optional_parameter_to_0 + case "Add_optional_parameters_to_0_95192": + return Add_optional_parameters_to_0 + case "Add_all_optional_parameters_95193": + return Add_all_optional_parameters + case "Wrap_in_parentheses_95194": + return Wrap_in_parentheses + case "Wrap_all_invalid_decorator_expressions_in_parentheses_95195": + return Wrap_all_invalid_decorator_expressions_in_parentheses + case "Add_resolution_mode_import_attribute_95196": + return Add_resolution_mode_import_attribute + case "Add_resolution_mode_import_attribute_to_all_type_only_imports_that_need_it_95197": + return Add_resolution_mode_import_attribute_to_all_type_only_imports_that_need_it + case "Do_not_print_diagnostics_100000": + return Do_not_print_diagnostics + case "Run_in_single_threaded_mode_100001": + return Run_in_single_threaded_mode + case "Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory_100002": + return Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory + case "Set_the_number_of_checkers_per_project_100003": + return Set_the_number_of_checkers_per_project + case "4_unless_singleThreaded_is_passed_100004": + return X_4_unless_singleThreaded_is_passed + default: + return nil + } +} diff --git a/internal/diagnostics/diagnostics_test.go b/internal/diagnostics/diagnostics_test.go new file mode 100644 index 0000000000..b93bedad3f --- /dev/null +++ b/internal/diagnostics/diagnostics_test.go @@ -0,0 +1,145 @@ +package diagnostics + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/locale" + "golang.org/x/text/language" + "gotest.tools/v3/assert" +) + +func TestLocalize(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + message *Message + locale locale.Locale + args []any + expected string + }{ + { + name: "english default", + message: Identifier_expected, + locale: locale.Locale(language.English), + expected: "Identifier expected.", + }, + { + name: "undefined locale uses english", + message: Identifier_expected, + locale: locale.Locale(language.Und), + expected: "Identifier expected.", + }, + { + name: "with single argument", + message: X_0_expected, + locale: locale.Locale(language.English), + args: []any{")"}, + expected: "')' expected.", + }, + { + name: "with multiple arguments", + message: The_parser_expected_to_find_a_1_to_match_the_0_token_here, + locale: locale.Locale(language.English), + args: []any{"{", "}"}, + expected: "The parser expected to find a '}' to match the '{' token here.", + }, + { + name: "fallback to english for unknown locale", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("af-ZA")), + expected: "Identifier expected.", + }, + { + name: "german", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("de-DE")), + expected: "Es wurde ein Bezeichner erwartet.", + }, + { + name: "french", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("fr-FR")), + expected: "Identificateur attendu.", + }, + { + name: "spanish", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("es-ES")), + expected: "Se esperaba un identificador.", + }, + { + name: "japanese", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("ja-JP")), + expected: "識åˆĨ子がåŋ…čĻã§ã™ã€‚", + }, + { + name: "chinese simplified", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("zh-CN")), + expected: "åē”ä¸ēæ ‡č¯†įŦĻ。", + }, + { + name: "korean", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("ko-KR")), + expected: "ė‹ëŗ„ėžę°€ í•„ėš”í•Šë‹ˆë‹¤.", + }, + { + name: "russian", + message: Identifier_expected, + locale: locale.Locale(language.MustParse("ru-RU")), + expected: "ОĐļидаĐģŅŅ идĐĩĐŊŅ‚Đ¸Ņ„Đ¸ĐēĐ°Ņ‚ĐžŅ€.", + }, + { + name: "german with args", + message: X_0_expected, + locale: locale.Locale(language.MustParse("de-DE")), + args: []any{")"}, + expected: "\")\" wurde erwartet.", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + result := tt.message.Localize(tt.locale, tt.args...) + assert.Equal(t, result, tt.expected) + }) + } +} + +func TestLocalize_ByKey(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + key Key + locale locale.Locale + args []string + expected string + }{ + { + name: "by key without args", + key: "Identifier_expected_1003", + locale: locale.Locale(language.English), + expected: "Identifier expected.", + }, + { + name: "by key with args", + key: "_0_expected_1005", + locale: locale.Locale(language.English), + args: []string{")"}, + expected: "')' expected.", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + result := Localize(tt.locale, nil, tt.key, tt.args...) + assert.Equal(t, result, tt.expected) + }) + } +} diff --git a/internal/diagnostics/extraDiagnosticMessages.json b/internal/diagnostics/extraDiagnosticMessages.json index b735a67695..47d3e93a11 100644 --- a/internal/diagnostics/extraDiagnosticMessages.json +++ b/internal/diagnostics/extraDiagnosticMessages.json @@ -11,6 +11,14 @@ "category": "Message", "code": 100002 }, + "Set the number of checkers per project.": { + "category": "Message", + "code": 100003 + }, + "4, unless --singleThreaded is passed.": { + "category": "Message", + "code": 100004 + }, "Non-relative paths are not allowed. Did you forget a leading './'?": { "category": "Error", "code": 5090 @@ -19,10 +27,6 @@ "category": "Error", "code": 8030 }, - "A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag.": { - "category": "Error", - "code": 8040 - }, "Failed to delete file '{0}'.": { "category": "Message", "code": 6353 @@ -38,5 +42,17 @@ "Project '{0}' is out of date because it has errors.": { "category": "Message", "code": 6423 + }, + "Locale must be an IETF BCP 47 language tag. Examples: '{0}', '{1}'.": { + "category": "Error", + "code": 6048 + }, + "Ignore the tsconfig found and build with commandline options and files.": { + "category": "Message", + "code": 1549 + }, + "tsconfig.json is present but will not be loaded if files are specified on commandline. Use '--ignoreConfig' to skip this error.": { + "category": "Error", + "code": 5112 } } diff --git a/internal/diagnostics/generate.go b/internal/diagnostics/generate.go index 991d84dc1d..a66d4fde69 100644 --- a/internal/diagnostics/generate.go +++ b/internal/diagnostics/generate.go @@ -5,6 +5,8 @@ package main import ( "bytes" "cmp" + "compress/gzip" + "encoding/xml" "flag" "fmt" "go/format" @@ -21,7 +23,9 @@ import ( "unicode" "github.com/go-json-experiment/json" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/repo" + "golang.org/x/text/language" ) type diagnosticMessage struct { @@ -35,13 +39,44 @@ type diagnosticMessage struct { key string } +type LCX struct { + TgtCul string `xml:"TgtCul,attr"` + RootItems []RootItem `xml:"Item"` +} + +type RootItem struct { + ItemId string `xml:"ItemId,attr"` + Items []StringTableItem `xml:"Item"` +} + +type StringTableItem struct { + ItemId string `xml:"ItemId,attr"` + Items []LocalizedItem `xml:"Item"` +} + +type LocalizedItem struct { + ItemId string `xml:"ItemId,attr"` + Str Str `xml:"Str"` +} + +type Str struct { + Val string `xml:"Val"` + Tgt *Tgt `xml:"Tgt"` +} + +type Tgt struct { + Val string `xml:"Val"` +} + func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) - output := flag.String("output", "", "path to the output diagnostics_generated.go file") + diagnosticsOutput := flag.String("diagnostics", "", "path to the output diagnostics_generated.go file") + locOutput := flag.String("loc", "", "path to the output loc_generated.go file") + locDir := flag.String("locdir", "", "directory to write locale .json.gz files") flag.Parse() - if *output == "" { + if *diagnosticsOutput == "" || *locOutput == "" || *locDir == "" { flag.Usage() return } @@ -63,6 +98,43 @@ func main() { return cmp.Compare(a.Code, b.Code) }) + // Collect known keys for filtering localizations + knownKeys := make(map[string]bool, len(diagnosticMessages)) + for _, m := range diagnosticMessages { + _, key := convertPropertyName(m.key, m.Code) + knownKeys[key] = true + } + + // Generate diagnostics file + diagnosticsBuf := generateDiagnostics(diagnosticMessages) + + formatted, err := format.Source(diagnosticsBuf.Bytes()) + if err != nil { + log.Fatalf("failed to format diagnostics output: %v", err) + return + } + + if err := os.WriteFile(*diagnosticsOutput, formatted, 0o666); err != nil { + log.Fatalf("failed to write diagnostics output: %v", err) + return + } + + // Generate localizations file + locBuf := generateLocalizations(knownKeys, *locDir) + + formatted, err = format.Source(locBuf.Bytes()) + if err != nil { + log.Fatalf("failed to format localizations output: %v", err) + return + } + + if err := os.WriteFile(*locOutput, formatted, 0o666); err != nil { + log.Fatalf("failed to write localizations output: %v", err) + return + } +} + +func generateDiagnostics(diagnosticMessages []*diagnosticMessage) *bytes.Buffer { var buf bytes.Buffer buf.WriteString("// Code generated by generate.go; DO NOT EDIT.\n") @@ -87,16 +159,182 @@ func main() { buf.WriteString("}\n\n") } - formatted, err := format.Source(buf.Bytes()) + buf.WriteString("func keyToMessage(key Key) *Message {\n") + buf.WriteString("\tswitch key {\n") + for _, m := range diagnosticMessages { + _, key := convertPropertyName(m.key, m.Code) + varName, _ := convertPropertyName(m.key, m.Code) + fmt.Fprintf(&buf, "\tcase %q:\n\t\treturn %s\n", key, varName) + } + buf.WriteString("\tdefault:\n\t\treturn nil\n") + buf.WriteString("\t}\n") + buf.WriteString("}\n") + + return &buf +} + +func generateLocalizations(knownKeys map[string]bool, locDir string) *bytes.Buffer { + var buf bytes.Buffer + + buf.WriteString("// Code generated by generate.go; DO NOT EDIT.\n") + buf.WriteString("\n") + buf.WriteString("package diagnostics\n") + buf.WriteString("\n") + buf.WriteString("import (\n") + buf.WriteString("\t\"compress/gzip\"\n") + buf.WriteString("\t_ \"embed\"\n") + buf.WriteString("\t\"strings\"\n") + buf.WriteString("\t\"sync\"\n") + buf.WriteString("\t\"golang.org/x/text/language\"\n") + buf.WriteString("\t\"github.com/go-json-experiment/json\"\n") + buf.WriteString(")\n") + + // Remove and recreate the loc directory for a clean state + if err := os.RemoveAll(locDir); err != nil { + log.Fatalf("failed to remove locale directory: %v", err) + } + if err := os.MkdirAll(locDir, 0o755); err != nil { + log.Fatalf("failed to create locale directory: %v", err) + } + + // Generate locale maps + localeFiles, err := filepath.Glob(filepath.Join(repo.TypeScriptSubmodulePath, "src", "loc", "lcl", "*", "diagnosticMessages", "diagnosticMessages.generated.json.lcl")) if err != nil { - log.Fatalf("failed to format output: %v", err) - return + log.Fatalf("failed to find locale files: %v", err) + } + if len(localeFiles) == 0 { + log.Fatalf("no locale files found in %s", filepath.Join(repo.TypeScriptSubmodulePath, "src", "loc", "lcl")) + } + slices.Sort(localeFiles) + + type localeInfo struct { + varName string + tgtCul string + canonical string // canonical lowercase form (e.g., "zh-cn", "pt-br") + lang string + messages map[string]string + filename string } - if err := os.WriteFile(*output, formatted, 0o666); err != nil { - log.Fatalf("failed to write output: %v", err) - return + var locales []localeInfo + + for _, localeFile := range localeFiles { + localizedMessages, tgtCul := readLocalizedMessages(localeFile) + if len(localizedMessages) == 0 { + continue + } + + // Filter to only known keys + for key := range localizedMessages { + if !knownKeys[key] { + delete(localizedMessages, key) + } + } + + if len(localizedMessages) == 0 { + continue + } + + // Convert locale code to valid Go identifier + localeVar := strings.ReplaceAll(strings.ReplaceAll(tgtCul, "-", ""), "_", "") + + // Parse the locale using language.Tag to get canonical forms + tag, err := language.Parse(tgtCul) + if err != nil { + log.Printf("failed to parse locale %q: %v", tgtCul, err) + continue + } + + base, _ := tag.Base() + lang := strings.ToLower(base.String()) + + // Get canonical form (lowercase with dash) + canonical := strings.ToLower(tgtCul) + + // Filename for the JSON.gz file (use the original tgtCul as standard language tag) + filename := fmt.Sprintf("%s.json.gz", tgtCul) + + // Write the JSON.gz file + // Convert map to OrderedMap with sorted keys for consistent ordering + keys := slices.Sorted(maps.Keys(localizedMessages)) + var orderedMessages collections.OrderedMap[string, string] + for _, key := range keys { + orderedMessages.Set(key, localizedMessages[key]) + } + jsonData, err := json.Marshal(&orderedMessages) + if err != nil { + log.Fatalf("failed to marshal locale %s: %v", tgtCul, err) + } + + var compressed bytes.Buffer + gzipWriter, err := gzip.NewWriterLevel(&compressed, gzip.BestCompression) + if err != nil { + log.Fatalf("failed to create gzip writer for locale %s: %v", tgtCul, err) + } + if _, err := gzipWriter.Write(jsonData); err != nil { + log.Fatalf("failed to compress locale %s: %v", tgtCul, err) + } + if err := gzipWriter.Close(); err != nil { + log.Fatalf("failed to close gzip writer for locale %s: %v", tgtCul, err) + } + + outputPath := filepath.Join(locDir, filename) + if err := os.WriteFile(outputPath, compressed.Bytes(), 0o644); err != nil { + log.Fatalf("failed to write locale file %s: %v", outputPath, err) + } + + locales = append(locales, localeInfo{ + varName: localeVar, + tgtCul: tgtCul, + canonical: canonical, + lang: lang, + messages: localizedMessages, + filename: filename, + }) + } + + // Generate matcher with inlined tags + // English is first (index 0) as the default/fallback with no translation needed + buf.WriteString("\nvar matcher = language.NewMatcher([]language.Tag{\n") + buf.WriteString("\tlanguage.English,\n") + for _, loc := range locales { + fmt.Fprintf(&buf, "\tlanguage.MustParse(%q),\n", loc.tgtCul) + } + buf.WriteString("})\n") + + // Generate index-to-function map for matcher results + // English (index 0) returns nil since we use the default English text + buf.WriteString("\nvar localeFuncs = []func() map[Key]string{\n") + buf.WriteString("\tnil, // English (default)\n") + for _, loc := range locales { + fmt.Fprintf(&buf, "\t%s,\n", loc.varName) + } + buf.WriteString("}\n") + + // Generate helper function for decompressing locale data + buf.WriteString("\nfunc loadLocaleData(data string) map[Key]string {\n") + buf.WriteString("\tgr, err := gzip.NewReader(strings.NewReader(data))\n") + buf.WriteString("\tif err != nil {\n") + buf.WriteString("\t\tpanic(\"failed to create gzip reader: \" + err.Error())\n") + buf.WriteString("\t}\n") + buf.WriteString("\tdefer gr.Close()\n") + buf.WriteString("\tvar result map[Key]string\n") + buf.WriteString("\tif err := json.UnmarshalRead(gr, &result); err != nil {\n") + buf.WriteString("\t\tpanic(\"failed to unmarshal locale data: \" + err.Error())\n") + buf.WriteString("\t}\n") + buf.WriteString("\treturn result\n") + buf.WriteString("}\n") + + // Generate embed directives, vars, and loader functions interleaved at the bottom + for _, loc := range locales { + fmt.Fprintf(&buf, "\n//go:embed loc/%s\n", loc.filename) + fmt.Fprintf(&buf, "var %sData string\n", loc.varName) + fmt.Fprintf(&buf, "\nvar %s = sync.OnceValue(func() map[Key]string {\n", loc.varName) + fmt.Fprintf(&buf, "\treturn loadLocaleData(%sData)\n", loc.varName) + buf.WriteString("})\n") } + + return &buf } func readRawMessages(p string) map[int]*diagnosticMessage { @@ -122,6 +360,45 @@ func readRawMessages(p string) map[int]*diagnosticMessage { return codeToMessage } +func readLocalizedMessages(p string) (map[string]string, string) { + file, err := os.Open(p) + if err != nil { + log.Printf("failed to open locale file %s: %v", p, err) + return nil, "" + } + defer file.Close() + + var lcx LCX + if err := xml.NewDecoder(file).Decode(&lcx); err != nil { + log.Printf("failed to decode locale file %s: %v", p, err) + return nil, "" + } + + messages := make(map[string]string) + + // Navigate the nested Item structure + for _, rootItem := range lcx.RootItems { + for _, stringTable := range rootItem.Items { + for _, item := range stringTable.Items { + // ItemId has format ";key_code", remove the leading semicolon + itemId := strings.TrimPrefix(item.ItemId, ";") + + // Get the localized text from Tgt if available, otherwise use Val + var text string + if item.Str.Tgt != nil && item.Str.Tgt.Val != "" { + text = item.Str.Tgt.Val + } else { + text = item.Str.Val + } + + messages[itemId] = text + } + } + } + + return messages, lcx.TgtCul +} + var ( multipleUnderscoreRegexp = regexp.MustCompile(`_+`) leadingUnderscoreUnlessDigitRegexp = regexp.MustCompile(`^_+(\D)`) diff --git a/internal/diagnostics/loc/cs-CZ.json.gz b/internal/diagnostics/loc/cs-CZ.json.gz new file mode 100644 index 0000000000..df21c307f0 Binary files /dev/null and b/internal/diagnostics/loc/cs-CZ.json.gz differ diff --git a/internal/diagnostics/loc/de-DE.json.gz b/internal/diagnostics/loc/de-DE.json.gz new file mode 100644 index 0000000000..5b398845ea Binary files /dev/null and b/internal/diagnostics/loc/de-DE.json.gz differ diff --git a/internal/diagnostics/loc/es-ES.json.gz b/internal/diagnostics/loc/es-ES.json.gz new file mode 100644 index 0000000000..d068162ce1 Binary files /dev/null and b/internal/diagnostics/loc/es-ES.json.gz differ diff --git a/internal/diagnostics/loc/fr-FR.json.gz b/internal/diagnostics/loc/fr-FR.json.gz new file mode 100644 index 0000000000..ac9536dbef Binary files /dev/null and b/internal/diagnostics/loc/fr-FR.json.gz differ diff --git a/internal/diagnostics/loc/it-IT.json.gz b/internal/diagnostics/loc/it-IT.json.gz new file mode 100644 index 0000000000..31328e9ee4 Binary files /dev/null and b/internal/diagnostics/loc/it-IT.json.gz differ diff --git a/internal/diagnostics/loc/ja-JP.json.gz b/internal/diagnostics/loc/ja-JP.json.gz new file mode 100644 index 0000000000..035a86ccce Binary files /dev/null and b/internal/diagnostics/loc/ja-JP.json.gz differ diff --git a/internal/diagnostics/loc/ko-KR.json.gz b/internal/diagnostics/loc/ko-KR.json.gz new file mode 100644 index 0000000000..05a48d3142 Binary files /dev/null and b/internal/diagnostics/loc/ko-KR.json.gz differ diff --git a/internal/diagnostics/loc/pl-PL.json.gz b/internal/diagnostics/loc/pl-PL.json.gz new file mode 100644 index 0000000000..33a6f2812b Binary files /dev/null and b/internal/diagnostics/loc/pl-PL.json.gz differ diff --git a/internal/diagnostics/loc/pt-BR.json.gz b/internal/diagnostics/loc/pt-BR.json.gz new file mode 100644 index 0000000000..2b8064be3e Binary files /dev/null and b/internal/diagnostics/loc/pt-BR.json.gz differ diff --git a/internal/diagnostics/loc/ru-RU.json.gz b/internal/diagnostics/loc/ru-RU.json.gz new file mode 100644 index 0000000000..0c31506b61 Binary files /dev/null and b/internal/diagnostics/loc/ru-RU.json.gz differ diff --git a/internal/diagnostics/loc/tr-TR.json.gz b/internal/diagnostics/loc/tr-TR.json.gz new file mode 100644 index 0000000000..4ef9c4594f Binary files /dev/null and b/internal/diagnostics/loc/tr-TR.json.gz differ diff --git a/internal/diagnostics/loc/zh-CN.json.gz b/internal/diagnostics/loc/zh-CN.json.gz new file mode 100644 index 0000000000..9498a59ae0 Binary files /dev/null and b/internal/diagnostics/loc/zh-CN.json.gz differ diff --git a/internal/diagnostics/loc/zh-TW.json.gz b/internal/diagnostics/loc/zh-TW.json.gz new file mode 100644 index 0000000000..d95f48c53a Binary files /dev/null and b/internal/diagnostics/loc/zh-TW.json.gz differ diff --git a/internal/diagnostics/loc_generated.go b/internal/diagnostics/loc_generated.go new file mode 100644 index 0000000000..c71b3dcfe4 --- /dev/null +++ b/internal/diagnostics/loc_generated.go @@ -0,0 +1,151 @@ +// Code generated by generate.go; DO NOT EDIT. + +package diagnostics + +import ( + "compress/gzip" + _ "embed" + "strings" + "sync" + + "github.com/go-json-experiment/json" + "golang.org/x/text/language" +) + +var matcher = language.NewMatcher([]language.Tag{ + language.English, + language.MustParse("zh-CN"), + language.MustParse("zh-TW"), + language.MustParse("cs-CZ"), + language.MustParse("de-DE"), + language.MustParse("es-ES"), + language.MustParse("fr-FR"), + language.MustParse("it-IT"), + language.MustParse("ja-JP"), + language.MustParse("ko-KR"), + language.MustParse("pl-PL"), + language.MustParse("pt-BR"), + language.MustParse("ru-RU"), + language.MustParse("tr-TR"), +}) + +var localeFuncs = []func() map[Key]string{ + nil, // English (default) + zhCN, + zhTW, + csCZ, + deDE, + esES, + frFR, + itIT, + jaJP, + koKR, + plPL, + ptBR, + ruRU, + trTR, +} + +func loadLocaleData(data string) map[Key]string { + gr, err := gzip.NewReader(strings.NewReader(data)) + if err != nil { + panic("failed to create gzip reader: " + err.Error()) + } + defer gr.Close() + var result map[Key]string + if err := json.UnmarshalRead(gr, &result); err != nil { + panic("failed to unmarshal locale data: " + err.Error()) + } + return result +} + +//go:embed loc/zh-CN.json.gz +var zhCNData string + +var zhCN = sync.OnceValue(func() map[Key]string { + return loadLocaleData(zhCNData) +}) + +//go:embed loc/zh-TW.json.gz +var zhTWData string + +var zhTW = sync.OnceValue(func() map[Key]string { + return loadLocaleData(zhTWData) +}) + +//go:embed loc/cs-CZ.json.gz +var csCZData string + +var csCZ = sync.OnceValue(func() map[Key]string { + return loadLocaleData(csCZData) +}) + +//go:embed loc/de-DE.json.gz +var deDEData string + +var deDE = sync.OnceValue(func() map[Key]string { + return loadLocaleData(deDEData) +}) + +//go:embed loc/es-ES.json.gz +var esESData string + +var esES = sync.OnceValue(func() map[Key]string { + return loadLocaleData(esESData) +}) + +//go:embed loc/fr-FR.json.gz +var frFRData string + +var frFR = sync.OnceValue(func() map[Key]string { + return loadLocaleData(frFRData) +}) + +//go:embed loc/it-IT.json.gz +var itITData string + +var itIT = sync.OnceValue(func() map[Key]string { + return loadLocaleData(itITData) +}) + +//go:embed loc/ja-JP.json.gz +var jaJPData string + +var jaJP = sync.OnceValue(func() map[Key]string { + return loadLocaleData(jaJPData) +}) + +//go:embed loc/ko-KR.json.gz +var koKRData string + +var koKR = sync.OnceValue(func() map[Key]string { + return loadLocaleData(koKRData) +}) + +//go:embed loc/pl-PL.json.gz +var plPLData string + +var plPL = sync.OnceValue(func() map[Key]string { + return loadLocaleData(plPLData) +}) + +//go:embed loc/pt-BR.json.gz +var ptBRData string + +var ptBR = sync.OnceValue(func() map[Key]string { + return loadLocaleData(ptBRData) +}) + +//go:embed loc/ru-RU.json.gz +var ruRUData string + +var ruRU = sync.OnceValue(func() map[Key]string { + return loadLocaleData(ruRUData) +}) + +//go:embed loc/tr-TR.json.gz +var trTRData string + +var trTR = sync.OnceValue(func() map[Key]string { + return loadLocaleData(trTRData) +}) diff --git a/internal/diagnostics/stringer_generated.go b/internal/diagnostics/stringer_generated.go index c4bcd79940..4e326809fe 100644 --- a/internal/diagnostics/stringer_generated.go +++ b/internal/diagnostics/stringer_generated.go @@ -19,8 +19,9 @@ const _Category_name = "CategoryWarningCategoryErrorCategorySuggestionCategoryMe var _Category_index = [...]uint8{0, 15, 28, 46, 61} func (i Category) String() string { - if i < 0 || i >= Category(len(_Category_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_Category_index)-1 { return "Category(" + strconv.FormatInt(int64(i), 10) + ")" } - return _Category_name[_Category_index[i]:_Category_index[i+1]] + return _Category_name[_Category_index[idx]:_Category_index[idx+1]] } diff --git a/internal/diagnosticwriter/diagnosticwriter.go b/internal/diagnosticwriter/diagnosticwriter.go index 9603935457..2ac8c2e268 100644 --- a/internal/diagnosticwriter/diagnosticwriter.go +++ b/internal/diagnosticwriter/diagnosticwriter.go @@ -12,11 +12,94 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/tspath" ) +type FileLike interface { + FileName() string + Text() string + ECMALineMap() []core.TextPos +} + +// Diagnostic interface abstracts over ast.Diagnostic and LSP diagnostics +type Diagnostic interface { + File() FileLike + Pos() int + End() int + Len() int + Code() int32 + Category() diagnostics.Category + Localize(locale locale.Locale) string + MessageChain() []Diagnostic + RelatedInformation() []Diagnostic +} + +// ASTDiagnostic wraps ast.Diagnostic to implement the Diagnostic interface +type ASTDiagnostic struct { + *ast.Diagnostic +} + +func (d *ASTDiagnostic) RelatedInformation() []Diagnostic { + related := d.Diagnostic.RelatedInformation() + result := make([]Diagnostic, len(related)) + for i, r := range related { + result[i] = &ASTDiagnostic{r} + } + return result +} + +func (d *ASTDiagnostic) File() FileLike { + if file := d.Diagnostic.File(); file != nil { + return file + } + return nil +} + +func (d *ASTDiagnostic) MessageChain() []Diagnostic { + chain := d.Diagnostic.MessageChain() + result := make([]Diagnostic, len(chain)) + for i, c := range chain { + result[i] = &ASTDiagnostic{c} + } + return result +} + +func WrapASTDiagnostic(d *ast.Diagnostic) *ASTDiagnostic { + return &ASTDiagnostic{d} +} + +func WrapASTDiagnostics(diags []*ast.Diagnostic) []*ASTDiagnostic { + result := make([]*ASTDiagnostic, len(diags)) + for i, d := range diags { + result[i] = WrapASTDiagnostic(d) + } + return result +} + +func FromASTDiagnostics(diags []*ast.Diagnostic) []Diagnostic { + result := make([]Diagnostic, len(diags)) + for i, d := range diags { + result[i] = WrapASTDiagnostic(d) + } + return result +} + +func ToDiagnostics[T Diagnostic](diags []T) []Diagnostic { + result := make([]Diagnostic, len(diags)) + for i, d := range diags { + result[i] = d + } + return result +} + +func CompareASTDiagnostics(a, b *ASTDiagnostic) int { + return ast.CompareDiagnostics(a.Diagnostic, b.Diagnostic) +} + type FormattingOptions struct { + Locale locale.Locale tspath.ComparePathsOptions NewLine string } @@ -36,7 +119,7 @@ const ( ellipsis = "..." ) -func FormatDiagnosticsWithColorAndContext(output io.Writer, diags []*ast.Diagnostic, formatOpts *FormattingOptions) { +func FormatDiagnosticsWithColorAndContext(output io.Writer, diags []Diagnostic, formatOpts *FormattingOptions) { if len(diags) == 0 { return } @@ -48,17 +131,17 @@ func FormatDiagnosticsWithColorAndContext(output io.Writer, diags []*ast.Diagnos } } -func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic *ast.Diagnostic, formatOpts *FormattingOptions) { +func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic Diagnostic, formatOpts *FormattingOptions) { if diagnostic.File() != nil { file := diagnostic.File() - pos := diagnostic.Loc().Pos() + pos := diagnostic.Pos() WriteLocation(output, file, pos, formatOpts, writeWithStyleAndReset) fmt.Fprint(output, " - ") } writeWithStyleAndReset(output, diagnostic.Category().Name(), getCategoryFormat(diagnostic.Category())) fmt.Fprintf(output, "%s TS%d: %s", foregroundColorEscapeGrey, diagnostic.Code(), resetEscapeSequence) - WriteFlattenedDiagnosticMessage(output, diagnostic, formatOpts.NewLine) + WriteFlattenedDiagnosticMessage(output, diagnostic, formatOpts.NewLine, formatOpts.Locale) if diagnostic.File() != nil && diagnostic.Code() != diagnostics.File_appears_to_be_binary.Code() { fmt.Fprint(output, formatOpts.NewLine) @@ -75,7 +158,7 @@ func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic *ast.Diagn pos := relatedInformation.Pos() WriteLocation(output, file, pos, formatOpts, writeWithStyleAndReset) fmt.Fprint(output, " - ") - WriteFlattenedDiagnosticMessage(output, relatedInformation, formatOpts.NewLine) + WriteFlattenedDiagnosticMessage(output, relatedInformation, formatOpts.NewLine, formatOpts.Locale) writeCodeSnippet(output, file, pos, relatedInformation.Len(), foregroundColorEscapeCyan, " ", formatOpts) } fmt.Fprint(output, formatOpts.NewLine) @@ -83,14 +166,14 @@ func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic *ast.Diagn } } -func writeCodeSnippet(writer io.Writer, sourceFile *ast.SourceFile, start int, length int, squiggleColor string, indent string, formatOpts *FormattingOptions) { +func writeCodeSnippet(writer io.Writer, sourceFile FileLike, start int, length int, squiggleColor string, indent string, formatOpts *FormattingOptions) { firstLine, firstLineChar := scanner.GetECMALineAndCharacterOfPosition(sourceFile, start) lastLine, lastLineChar := scanner.GetECMALineAndCharacterOfPosition(sourceFile, start+length) if length == 0 { lastLineChar++ // When length is zero, squiggle the character right after the start position. } - lastLineOfFile, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, len(sourceFile.Text())) + lastLineOfFile := scanner.GetECMALineOfPosition(sourceFile, len(sourceFile.Text())) hasMoreThanFiveLines := lastLine-firstLine >= 4 gutterWidth := len(strconv.Itoa(lastLine + 1)) @@ -118,7 +201,7 @@ func writeCodeSnippet(writer io.Writer, sourceFile *ast.SourceFile, start int, l if i < lastLineOfFile { lineEnd = scanner.GetECMAPositionOfLineAndCharacter(sourceFile, i+1, 0) } else { - lineEnd = sourceFile.Loc.End() + lineEnd = len(sourceFile.Text()) } lineContent := strings.TrimRightFunc(sourceFile.Text()[lineStart:lineEnd], unicode.IsSpace) // trim from end @@ -167,29 +250,33 @@ func writeCodeSnippet(writer io.Writer, sourceFile *ast.SourceFile, start int, l } } -func FlattenDiagnosticMessage(d *ast.Diagnostic, newLine string) string { +func FlattenDiagnosticMessage(d Diagnostic, newLine string, locale locale.Locale) string { var output strings.Builder - WriteFlattenedDiagnosticMessage(&output, d, newLine) + WriteFlattenedDiagnosticMessage(&output, d, newLine, locale) return output.String() } -func WriteFlattenedDiagnosticMessage(writer io.Writer, diagnostic *ast.Diagnostic, newline string) { - fmt.Fprint(writer, diagnostic.Message()) +func WriteFlattenedASTDiagnosticMessage(writer io.Writer, diagnostic *ast.Diagnostic, newline string, locale locale.Locale) { + WriteFlattenedDiagnosticMessage(writer, WrapASTDiagnostic(diagnostic), newline, locale) +} + +func WriteFlattenedDiagnosticMessage(writer io.Writer, diagnostic Diagnostic, newline string, locale locale.Locale) { + fmt.Fprint(writer, diagnostic.Localize(locale)) for _, chain := range diagnostic.MessageChain() { - flattenDiagnosticMessageChain(writer, chain, newline, 1 /*level*/) + flattenDiagnosticMessageChain(writer, chain, newline, locale, 1 /*level*/) } } -func flattenDiagnosticMessageChain(writer io.Writer, chain *ast.Diagnostic, newLine string, level int) { +func flattenDiagnosticMessageChain(writer io.Writer, chain Diagnostic, newLine string, locale locale.Locale, level int) { fmt.Fprint(writer, newLine) for range level { fmt.Fprint(writer, " ") } - fmt.Fprint(writer, chain.Message()) + fmt.Fprint(writer, chain.Localize(locale)) for _, child := range chain.MessageChain() { - flattenDiagnosticMessageChain(writer, child, newLine, level+1) + flattenDiagnosticMessageChain(writer, child, newLine, locale, level+1) } } @@ -215,7 +302,7 @@ func writeWithStyleAndReset(output io.Writer, text string, formatStyle string) { fmt.Fprint(output, resetEscapeSequence) } -func WriteLocation(output io.Writer, file *ast.SourceFile, pos int, formatOpts *FormattingOptions, writeWithStyleAndReset FormattedWriter) { +func WriteLocation(output io.Writer, file FileLike, pos int, formatOpts *FormattingOptions, writeWithStyleAndReset FormattedWriter) { firstLine, firstChar := scanner.GetECMALineAndCharacterOfPosition(file, pos) var relativeFileName string if formatOpts != nil { @@ -235,12 +322,12 @@ func WriteLocation(output io.Writer, file *ast.SourceFile, pos int, formatOpts * type ErrorSummary struct { TotalErrorCount int - GlobalErrors []*ast.Diagnostic - ErrorsByFiles map[*ast.SourceFile][]*ast.Diagnostic - SortedFileList []*ast.SourceFile + GlobalErrors []Diagnostic + ErrorsByFile map[FileLike][]Diagnostic + SortedFiles []FileLike } -func WriteErrorSummaryText(output io.Writer, allDiagnostics []*ast.Diagnostic, formatOpts *FormattingOptions) { +func WriteErrorSummaryText(output io.Writer, allDiagnostics []Diagnostic, formatOpts *FormattingOptions) { // Roughly corresponds to 'getErrorSummaryText' from watch.ts errorSummary := getErrorSummary(allDiagnostics) @@ -249,32 +336,32 @@ func WriteErrorSummaryText(output io.Writer, allDiagnostics []*ast.Diagnostic, f return } - firstFile := &ast.SourceFile{} - if len(errorSummary.SortedFileList) > 0 { - firstFile = errorSummary.SortedFileList[0] + var firstFile FileLike + if len(errorSummary.SortedFiles) > 0 { + firstFile = errorSummary.SortedFiles[0] } - firstFileName := prettyPathForFileError(firstFile, errorSummary.ErrorsByFiles[firstFile], formatOpts) - numErroringFiles := len(errorSummary.ErrorsByFiles) + firstFileName := prettyPathForFileError(firstFile, errorSummary.ErrorsByFile[firstFile], formatOpts) + numErroringFiles := len(errorSummary.ErrorsByFile) var message string if totalErrorCount == 1 { // Special-case a single error. if len(errorSummary.GlobalErrors) > 0 || firstFileName == "" { - message = diagnostics.Found_1_error.Format() + message = diagnostics.Found_1_error.Localize(formatOpts.Locale) } else { - message = diagnostics.Found_1_error_in_0.Format(firstFileName) + message = diagnostics.Found_1_error_in_0.Localize(formatOpts.Locale, firstFileName) } } else { switch numErroringFiles { case 0: // No file-specific errors. - message = diagnostics.Found_0_errors.Format(totalErrorCount) + message = diagnostics.Found_0_errors.Localize(formatOpts.Locale, totalErrorCount) case 1: // One file with errors. - message = diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1.Format(totalErrorCount, firstFileName) + message = diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1.Localize(formatOpts.Locale, totalErrorCount, firstFileName) default: // Multiple files with errors. - message = diagnostics.Found_0_errors_in_1_files.Format(totalErrorCount, numErroringFiles) + message = diagnostics.Found_0_errors_in_1_files.Localize(formatOpts.Locale, totalErrorCount, numErroringFiles) } } fmt.Fprint(output, formatOpts.NewLine) @@ -287,10 +374,10 @@ func WriteErrorSummaryText(output io.Writer, allDiagnostics []*ast.Diagnostic, f } } -func getErrorSummary(diags []*ast.Diagnostic) *ErrorSummary { +func getErrorSummary(diags []Diagnostic) *ErrorSummary { var totalErrorCount int - var globalErrors []*ast.Diagnostic - var errorsByFiles map[*ast.SourceFile][]*ast.Diagnostic + var globalErrors []Diagnostic + var errorsByFile map[FileLike][]Diagnostic for _, diagnostic := range diags { if diagnostic.Category() != diagnostics.CategoryError { @@ -301,39 +388,39 @@ func getErrorSummary(diags []*ast.Diagnostic) *ErrorSummary { if diagnostic.File() == nil { globalErrors = append(globalErrors, diagnostic) } else { - if errorsByFiles == nil { - errorsByFiles = make(map[*ast.SourceFile][]*ast.Diagnostic) + if errorsByFile == nil { + errorsByFile = make(map[FileLike][]Diagnostic) } - errorsByFiles[diagnostic.File()] = append(errorsByFiles[diagnostic.File()], diagnostic) + errorsByFile[diagnostic.File()] = append(errorsByFile[diagnostic.File()], diagnostic) } } // !!! // Need an ordered map here, but sorting for consistency. - sortedFileList := slices.SortedFunc(maps.Keys(errorsByFiles), func(a, b *ast.SourceFile) int { + sortedFiles := slices.SortedFunc(maps.Keys(errorsByFile), func(a, b FileLike) int { return strings.Compare(a.FileName(), b.FileName()) }) return &ErrorSummary{ TotalErrorCount: totalErrorCount, GlobalErrors: globalErrors, - ErrorsByFiles: errorsByFiles, - SortedFileList: sortedFileList, + ErrorsByFile: errorsByFile, + SortedFiles: sortedFiles, } } func writeTabularErrorsDisplay(output io.Writer, errorSummary *ErrorSummary, formatOpts *FormattingOptions) { - sortedFiles := errorSummary.SortedFileList + sortedFiles := errorSummary.SortedFiles maxErrors := 0 - for _, errorsForFile := range errorSummary.ErrorsByFiles { + for _, errorsForFile := range errorSummary.ErrorsByFile { maxErrors = max(maxErrors, len(errorsForFile)) } // !!! // TODO (drosen): This was never localized. // Should make this better. - headerRow := diagnostics.Errors_Files.Message() + headerRow := diagnostics.Errors_Files.Localize(formatOpts.Locale) leftColumnHeadingLength := len(strings.Split(headerRow, " ")[0]) lengthOfBiggestErrorCount := len(strconv.Itoa(maxErrors)) leftPaddingGoal := max(leftColumnHeadingLength, lengthOfBiggestErrorCount) @@ -344,7 +431,7 @@ func writeTabularErrorsDisplay(output io.Writer, errorSummary *ErrorSummary, for fmt.Fprint(output, formatOpts.NewLine) for _, file := range sortedFiles { - fileErrors := errorSummary.ErrorsByFiles[file] + fileErrors := errorSummary.ErrorsByFile[file] errorCount := len(fileErrors) fmt.Fprintf(output, "%*d ", leftPaddingGoal, errorCount) @@ -353,11 +440,11 @@ func writeTabularErrorsDisplay(output io.Writer, errorSummary *ErrorSummary, for } } -func prettyPathForFileError(file *ast.SourceFile, fileErrors []*ast.Diagnostic, formatOpts *FormattingOptions) string { +func prettyPathForFileError(file FileLike, fileErrors []Diagnostic, formatOpts *FormattingOptions) string { if file == nil || len(fileErrors) == 0 { return "" } - line, _ := scanner.GetECMALineAndCharacterOfPosition(file, fileErrors[0].Loc().Pos()) + line := scanner.GetECMALineOfPosition(file, fileErrors[0].Pos()) fileName := file.FileName() if tspath.PathIsAbsolute(fileName) && tspath.PathIsAbsolute(formatOpts.CurrentDirectory) { fileName = tspath.ConvertToRelativePath(file.FileName(), formatOpts.ComparePathsOptions) @@ -370,35 +457,35 @@ func prettyPathForFileError(file *ast.SourceFile, fileErrors []*ast.Diagnostic, ) } -func WriteFormatDiagnostics(output io.Writer, diagnostics []*ast.Diagnostic, formatOpts *FormattingOptions) { +func WriteFormatDiagnostics(output io.Writer, diagnostics []Diagnostic, formatOpts *FormattingOptions) { for _, diagnostic := range diagnostics { WriteFormatDiagnostic(output, diagnostic, formatOpts) } } -func WriteFormatDiagnostic(output io.Writer, diagnostic *ast.Diagnostic, formatOpts *FormattingOptions) { +func WriteFormatDiagnostic(output io.Writer, diagnostic Diagnostic, formatOpts *FormattingOptions) { if diagnostic.File() != nil { - line, character := scanner.GetECMALineAndCharacterOfPosition(diagnostic.File(), diagnostic.Loc().Pos()) + line, character := scanner.GetECMALineAndCharacterOfPosition(diagnostic.File(), diagnostic.Pos()) fileName := diagnostic.File().FileName() relativeFileName := tspath.ConvertToRelativePath(fileName, formatOpts.ComparePathsOptions) fmt.Fprintf(output, "%s(%d,%d): ", relativeFileName, line+1, character+1) } fmt.Fprintf(output, "%s TS%d: ", diagnostic.Category().Name(), diagnostic.Code()) - WriteFlattenedDiagnosticMessage(output, diagnostic, formatOpts.NewLine) + WriteFlattenedDiagnosticMessage(output, diagnostic, formatOpts.NewLine, formatOpts.Locale) fmt.Fprint(output, formatOpts.NewLine) } -func FormatDiagnosticsStatusWithColorAndTime(output io.Writer, time string, diag *ast.Diagnostic, formatOpts *FormattingOptions) { +func FormatDiagnosticsStatusWithColorAndTime(output io.Writer, time string, diag Diagnostic, formatOpts *FormattingOptions) { fmt.Fprint(output, "[") writeWithStyleAndReset(output, time, foregroundColorEscapeGrey) fmt.Fprint(output, "] ") - WriteFlattenedDiagnosticMessage(output, diag, formatOpts.NewLine) + WriteFlattenedDiagnosticMessage(output, diag, formatOpts.NewLine, formatOpts.Locale) } -func FormatDiagnosticsStatusAndTime(output io.Writer, time string, diag *ast.Diagnostic, formatOpts *FormattingOptions) { +func FormatDiagnosticsStatusAndTime(output io.Writer, time string, diag Diagnostic, formatOpts *FormattingOptions) { fmt.Fprint(output, time, " - ") - WriteFlattenedDiagnosticMessage(output, diag, formatOpts.NewLine) + WriteFlattenedDiagnosticMessage(output, diag, formatOpts.NewLine, formatOpts.Locale) } var ScreenStartingCodes = []int32{ @@ -406,7 +493,7 @@ var ScreenStartingCodes = []int32{ diagnostics.File_change_detected_Starting_incremental_compilation.Code(), } -func TryClearScreen(output io.Writer, diag *ast.Diagnostic, options *core.CompilerOptions) bool { +func TryClearScreen(output io.Writer, diag Diagnostic, options *core.CompilerOptions) bool { if !options.PreserveWatchOutput.IsTrue() && !options.ExtendedDiagnostics.IsTrue() && !options.Diagnostics.IsTrue() && diff --git a/internal/evaluator/evaluator.go b/internal/evaluator/evaluator.go index 3c4cf65eea..50e5ca3e74 100644 --- a/internal/evaluator/evaluator.go +++ b/internal/evaluator/evaluator.go @@ -140,7 +140,6 @@ func evaluateTemplateExpression(expr *ast.Node, location *ast.Node, evaluate Eva } func AnyToString(v any) string { - // !!! This function should behave identically to the expression `"" + v` in JS switch v := v.(type) { case string: return v @@ -155,7 +154,6 @@ func AnyToString(v any) string { } func IsTruthy(v any) bool { - // !!! This function should behave identically to the expression `!!v` in JS switch v := v.(type) { case string: return len(v) != 0 diff --git a/internal/execute/build/buildtask.go b/internal/execute/build/buildtask.go index 72b58fd7a9..3ead8e4fe2 100644 --- a/internal/execute/build/buildtask.go +++ b/internal/execute/build/buildtask.go @@ -36,7 +36,7 @@ const ( ) type upstreamTask struct { - task *buildTask + task *BuildTask refIndex int } type buildInfoEntry struct { @@ -57,17 +57,17 @@ type taskResult struct { filesToDelete []string } -type buildTask struct { +type BuildTask struct { config string resolved *tsoptions.ParsedCommandLine upStream []*upstreamTask - downStream []*buildTask // Only set and used in watch mode + downStream []*BuildTask // Only set and used in watch mode status *upToDateStatus done chan struct{} // task reporting result *taskResult - prevReporter *buildTask + prevReporter *BuildTask reportDone chan struct{} // Watching things @@ -85,24 +85,24 @@ type buildTask struct { dirty bool } -func (t *buildTask) waitOnUpstream() { +func (t *BuildTask) waitOnUpstream() { for _, upstream := range t.upStream { <-upstream.task.done } } -func (t *buildTask) unblockDownstream() { +func (t *BuildTask) unblockDownstream() { t.pending.Store(false) t.isInitialCycle = false close(t.done) } -func (t *buildTask) reportDiagnostic(err *ast.Diagnostic) { +func (t *BuildTask) reportDiagnostic(err *ast.Diagnostic) { t.errors = append(t.errors, err) t.result.diagnosticReporter(err) } -func (t *buildTask) report(orchestrator *Orchestrator, configPath tspath.Path, buildResult *orchestratorResult) { +func (t *BuildTask) report(orchestrator *Orchestrator, configPath tspath.Path, buildResult *orchestratorResult) { if t.prevReporter != nil { <-t.prevReporter.reportDone } @@ -132,7 +132,7 @@ func (t *buildTask) report(orchestrator *Orchestrator, configPath tspath.Path, b close(t.reportDone) } -func (t *buildTask) buildProject(orchestrator *Orchestrator, path tspath.Path) { +func (t *BuildTask) buildProject(orchestrator *Orchestrator, path tspath.Path) { // Wait on upstream tasks to complete t.waitOnUpstream() if t.pending.Load() { @@ -163,7 +163,7 @@ func (t *buildTask) buildProject(orchestrator *Orchestrator, path tspath.Path) { t.unblockDownstream() } -func (t *buildTask) updateDownstream(orchestrator *Orchestrator, path tspath.Path) { +func (t *BuildTask) updateDownstream(orchestrator *Orchestrator, path tspath.Path) { if t.isInitialCycle { return } @@ -199,7 +199,7 @@ func (t *buildTask) updateDownstream(orchestrator *Orchestrator, path tspath.Pat } } -func (t *buildTask) compileAndEmit(orchestrator *Orchestrator, path tspath.Path) { +func (t *BuildTask) compileAndEmit(orchestrator *Orchestrator, path tspath.Path) { t.errors = nil if orchestrator.opts.Command.BuildOptions.Verbose.IsTrue() { t.result.reportStatus(ast.NewCompilerDiagnostic(diagnostics.Building_project_0, orchestrator.relativeFileName(t.config))) @@ -220,7 +220,7 @@ func (t *buildTask) compileAndEmit(orchestrator *Orchestrator, path tspath.Path) Config: t.resolved, Host: &compilerHost{ host: orchestrator.host, - trace: tsc.GetTraceWithWriterFromSys(&t.result.builder, orchestrator.opts.Testing), + trace: tsc.GetTraceWithWriterFromSys(&t.result.builder, orchestrator.opts.Command.Locale(), orchestrator.opts.Testing), }, JSDocParsingMode: ast.JSDocParsingModeParseForTypeErrors, }) @@ -265,7 +265,7 @@ func (t *buildTask) compileAndEmit(orchestrator *Orchestrator, path tspath.Path) } } -func (t *buildTask) handleStatusThatDoesntRequireBuild(orchestrator *Orchestrator) bool { +func (t *BuildTask) handleStatusThatDoesntRequireBuild(orchestrator *Orchestrator) bool { switch t.status.kind { case upToDateStatusTypeUpToDate: if orchestrator.opts.Command.BuildOptions.Dry.IsTrue() { @@ -315,7 +315,7 @@ func (t *buildTask) handleStatusThatDoesntRequireBuild(orchestrator *Orchestrato return false } -func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tspath.Path) *upToDateStatus { +func (t *BuildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tspath.Path) *upToDateStatus { if t.status != nil { return t.status } @@ -527,7 +527,7 @@ func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tsp } } -func (t *buildTask) reportUpToDateStatus(orchestrator *Orchestrator) { +func (t *BuildTask) reportUpToDateStatus(orchestrator *Orchestrator) { if !orchestrator.opts.Command.BuildOptions.Verbose.IsTrue() { return } @@ -639,11 +639,11 @@ func (t *buildTask) reportUpToDateStatus(orchestrator *Orchestrator) { } } -func (t *buildTask) canUpdateJsDtsOutputTimestamps() bool { +func (t *BuildTask) canUpdateJsDtsOutputTimestamps() bool { return !t.resolved.CompilerOptions().NoEmit.IsTrue() && !t.resolved.CompilerOptions().IsIncremental() } -func (t *buildTask) updateTimeStamps(orchestrator *Orchestrator, emittedFiles []string, verboseMessage *diagnostics.Message) { +func (t *BuildTask) updateTimeStamps(orchestrator *Orchestrator, emittedFiles []string, verboseMessage *diagnostics.Message) { emitted := collections.NewSetFromItems(emittedFiles...) var verboseMessageReported bool buildInfoName := t.resolved.GetBuildInfoFileName() @@ -678,7 +678,7 @@ func (t *buildTask) updateTimeStamps(orchestrator *Orchestrator, emittedFiles [] updateTimeStamp(t.resolved.GetBuildInfoFileName()) } -func (t *buildTask) cleanProject(orchestrator *Orchestrator, path tspath.Path) { +func (t *BuildTask) cleanProject(orchestrator *Orchestrator, path tspath.Path) { if t.resolved == nil { t.reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.File_0_not_found, t.config)) t.result.exitStatus = tsc.ExitStatusDiagnosticsPresent_OutputsSkipped @@ -692,7 +692,7 @@ func (t *buildTask) cleanProject(orchestrator *Orchestrator, path tspath.Path) { t.cleanProjectOutput(orchestrator, t.resolved.GetBuildInfoFileName(), inputs) } -func (t *buildTask) cleanProjectOutput(orchestrator *Orchestrator, outputFile string, inputs *collections.Set[tspath.Path]) { +func (t *BuildTask) cleanProjectOutput(orchestrator *Orchestrator, outputFile string, inputs *collections.Set[tspath.Path]) { outputPath := orchestrator.toPath(outputFile) // If output name is same as input file name, do not delete and ignore the error if inputs.Has(outputPath) { @@ -710,7 +710,7 @@ func (t *buildTask) cleanProjectOutput(orchestrator *Orchestrator, outputFile st } } -func (t *buildTask) updateWatch(orchestrator *Orchestrator, oldCache *collections.SyncMap[tspath.Path, time.Time]) { +func (t *BuildTask) updateWatch(orchestrator *Orchestrator, oldCache *collections.SyncMap[tspath.Path, time.Time]) { t.configTime = orchestrator.host.loadOrStoreMTime(t.config, oldCache, false) if t.resolved != nil { t.extendedConfigTimes = core.Map(t.resolved.ExtendedSourceFiles(), func(p string) time.Time { @@ -727,18 +727,18 @@ func (t *buildTask) updateWatch(orchestrator *Orchestrator, oldCache *collection } } -func (t *buildTask) resetStatus() { +func (t *BuildTask) resetStatus() { t.status = nil t.pending.Store(true) t.errors = nil } -func (t *buildTask) resetConfig(orchestrator *Orchestrator, path tspath.Path) { +func (t *BuildTask) resetConfig(orchestrator *Orchestrator, path tspath.Path) { t.dirty = true orchestrator.host.resolvedReferences.delete(path) } -func (t *buildTask) hasUpdate(orchestrator *Orchestrator, path tspath.Path) updateKind { +func (t *BuildTask) hasUpdate(orchestrator *Orchestrator, path tspath.Path) updateKind { var needsConfigUpdate bool var needsUpdate bool if configTime := orchestrator.host.GetMTime(t.config); configTime != t.configTime { @@ -777,7 +777,7 @@ func (t *buildTask) hasUpdate(orchestrator *Orchestrator, path tspath.Path) upda return core.IfElse(needsConfigUpdate, updateKindConfig, core.IfElse(needsUpdate, updateKindUpdate, updateKindNone)) } -func (t *buildTask) loadOrStoreBuildInfo(orchestrator *Orchestrator, configPath tspath.Path, buildInfoFileName string) (*incremental.BuildInfo, time.Time) { +func (t *BuildTask) loadOrStoreBuildInfo(orchestrator *Orchestrator, configPath tspath.Path, buildInfoFileName string) (*incremental.BuildInfo, time.Time) { path := orchestrator.toPath(buildInfoFileName) t.buildInfoEntryMu.Lock() defer t.buildInfoEntryMu.Unlock() @@ -796,7 +796,7 @@ func (t *buildTask) loadOrStoreBuildInfo(orchestrator *Orchestrator, configPath return t.buildInfoEntry.buildInfo, mTime } -func (t *buildTask) onBuildInfoEmit(orchestrator *Orchestrator, buildInfoFileName string, buildInfo *incremental.BuildInfo, hasChangedDtsFile bool) { +func (t *BuildTask) onBuildInfoEmit(orchestrator *Orchestrator, buildInfoFileName string, buildInfo *incremental.BuildInfo, hasChangedDtsFile bool) { t.buildInfoEntryMu.Lock() defer t.buildInfoEntryMu.Unlock() var dtsTime *time.Time @@ -814,14 +814,14 @@ func (t *buildTask) onBuildInfoEmit(orchestrator *Orchestrator, buildInfoFileNam } } -func (t *buildTask) hasConflictingBuildInfo(orchestrator *Orchestrator, upstream *buildTask) bool { +func (t *BuildTask) hasConflictingBuildInfo(orchestrator *Orchestrator, upstream *BuildTask) bool { if t.buildInfoEntry != nil && upstream.buildInfoEntry != nil { return t.buildInfoEntry.path == upstream.buildInfoEntry.path } return false } -func (t *buildTask) getLatestChangedDtsMTime(orchestrator *Orchestrator) time.Time { +func (t *BuildTask) getLatestChangedDtsMTime(orchestrator *Orchestrator) time.Time { t.buildInfoEntryMu.Lock() defer t.buildInfoEntryMu.Unlock() if t.buildInfoEntry.dtsTime != nil { @@ -837,11 +837,11 @@ func (t *buildTask) getLatestChangedDtsMTime(orchestrator *Orchestrator) time.Ti return dtsTime } -func (t *buildTask) storeOutputTimeStamp(orchestrator *Orchestrator) bool { +func (t *BuildTask) storeOutputTimeStamp(orchestrator *Orchestrator) bool { return orchestrator.opts.Command.CompilerOptions.Watch.IsTrue() && !t.resolved.CompilerOptions().IsIncremental() } -func (t *buildTask) writeFile(orchestrator *Orchestrator, fileName string, text string, writeByteOrderMark bool, data *compiler.WriteFileData) error { +func (t *BuildTask) writeFile(orchestrator *Orchestrator, fileName string, text string, writeByteOrderMark bool, data *compiler.WriteFileData) error { err := orchestrator.host.FS().WriteFile(fileName, text, writeByteOrderMark) if err == nil { if data != nil && data.BuildInfo != nil { diff --git a/internal/execute/build/compilerHost.go b/internal/execute/build/compilerHost.go index 5d94dac42f..4980f47342 100644 --- a/internal/execute/build/compilerHost.go +++ b/internal/execute/build/compilerHost.go @@ -4,6 +4,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" @@ -12,7 +13,7 @@ import ( type compilerHost struct { host *host - trace func(msg string) + trace func(msg *diagnostics.Message, args ...any) } var _ compiler.CompilerHost = (*compilerHost)(nil) @@ -37,8 +38,8 @@ func (h *compilerHost) IsNodeSourceFile(path tspath.Path) bool { return h.host.IsNodeSourceFile(path) } -func (h *compilerHost) Trace(msg string) { - h.trace(msg) +func (h *compilerHost) Trace(msg *diagnostics.Message, args ...any) { + h.trace(msg, args...) } func (h *compilerHost) GetSourceFile(opts ast.SourceFileParseOptions) *ast.SourceFile { diff --git a/internal/execute/build/host.go b/internal/execute/build/host.go index accf68d3c4..5b921b421d 100644 --- a/internal/execute/build/host.go +++ b/internal/execute/build/host.go @@ -7,6 +7,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/execute/incremental" "github.com/microsoft/typescript-go/internal/execute/tsc" "github.com/microsoft/typescript-go/internal/module" @@ -60,7 +61,7 @@ func (h *host) GetCurrentDirectory() string { return h.host.GetCurrentDirectory() } -func (h *host) Trace(msg string) { +func (h *host) Trace(msg *diagnostics.Message, args ...any) { panic("build.Orchestrator.host does not support tracing, use a different host for tracing") } diff --git a/internal/execute/build/orchestrator.go b/internal/execute/build/orchestrator.go index d521031780..af59265532 100644 --- a/internal/execute/build/orchestrator.go +++ b/internal/execute/build/orchestrator.go @@ -58,7 +58,7 @@ type Orchestrator struct { host *host // order generation result - tasks *collections.SyncMap[tspath.Path, *buildTask] + tasks *collections.SyncMap[tspath.Path, *BuildTask] order []string errors []*ast.Diagnostic @@ -91,12 +91,12 @@ func (o *Orchestrator) Upstream(configName string) []string { func (o *Orchestrator) Downstream(configName string) []string { path := o.toPath(configName) task := o.getTask(path) - return core.Map(task.downStream, func(t *buildTask) string { + return core.Map(task.downStream, func(t *BuildTask) string { return t.config }) } -func (o *Orchestrator) getTask(path tspath.Path) *buildTask { +func (o *Orchestrator) getTask(path tspath.Path) *BuildTask { task, ok := o.tasks.Load(path) if !ok { panic("No build task found for " + path) @@ -104,11 +104,11 @@ func (o *Orchestrator) getTask(path tspath.Path) *buildTask { return task } -func (o *Orchestrator) createBuildTasks(oldTasks *collections.SyncMap[tspath.Path, *buildTask], configs []string, wg core.WorkGroup) { +func (o *Orchestrator) createBuildTasks(oldTasks *collections.SyncMap[tspath.Path, *BuildTask], configs []string, wg core.WorkGroup) { for _, config := range configs { wg.Queue(func() { path := o.toPath(config) - var task *buildTask + var task *BuildTask var buildInfo *buildInfoEntry if oldTasks != nil { if existing, ok := oldTasks.Load(path); ok { @@ -121,7 +121,7 @@ func (o *Orchestrator) createBuildTasks(oldTasks *collections.SyncMap[tspath.Pat } } if task == nil { - task = &buildTask{config: config, isInitialCycle: oldTasks == nil} + task = &BuildTask{config: config, isInitialCycle: oldTasks == nil} task.pending.Store(true) task.buildInfoEntry = buildInfo } @@ -139,12 +139,12 @@ func (o *Orchestrator) createBuildTasks(oldTasks *collections.SyncMap[tspath.Pat func (o *Orchestrator) setupBuildTask( configName string, - downStream *buildTask, + downStream *BuildTask, inCircularContext bool, completed *collections.Set[tspath.Path], analyzing *collections.Set[tspath.Path], circularityStack []string, -) *buildTask { +) *BuildTask { path := o.toPath(configName) task := o.getTask(path) if !completed.Has(path) { @@ -185,13 +185,13 @@ func (o *Orchestrator) setupBuildTask( func (o *Orchestrator) GenerateGraphReusingOldTasks() { tasks := o.tasks - o.tasks = &collections.SyncMap[tspath.Path, *buildTask]{} + o.tasks = &collections.SyncMap[tspath.Path, *BuildTask]{} o.order = nil o.errors = nil o.GenerateGraph(tasks) } -func (o *Orchestrator) GenerateGraph(oldTasks *collections.SyncMap[tspath.Path, *buildTask]) { +func (o *Orchestrator) GenerateGraph(oldTasks *collections.SyncMap[tspath.Path, *BuildTask]) { projects := o.opts.Command.ResolvedProjectPaths() // Parse all config files in parallel wg := core.NewWorkGroup(o.opts.Command.CompilerOptions.SingleThreaded.IsTrue()) @@ -239,7 +239,7 @@ func (o *Orchestrator) updateWatch() { oldCache := o.host.mTimes o.host.mTimes = &collections.SyncMap[tspath.Path, time.Time]{} wg := core.NewWorkGroup(o.opts.Command.CompilerOptions.SingleThreaded.IsTrue()) - o.tasks.Range(func(path tspath.Path, task *buildTask) bool { + o.tasks.Range(func(path tspath.Path, task *BuildTask) bool { wg.Queue(func() { task.updateWatch(o, oldCache) }) @@ -262,7 +262,7 @@ func (o *Orchestrator) DoCycle() { var needsUpdate atomic.Bool mTimes := o.host.mTimes.Clone() wg := core.NewWorkGroup(o.opts.Command.CompilerOptions.SingleThreaded.IsTrue()) - o.tasks.Range(func(path tspath.Path, task *buildTask) bool { + o.tasks.Range(func(path tspath.Path, task *BuildTask) bool { wg.Queue(func() { if updateKind := task.hasUpdate(o, path); updateKind != updateKindNone { needsUpdate.Store(true) @@ -335,7 +335,7 @@ func (o *Orchestrator) singleThreadedBuildOrClean(buildResult *orchestratorResul func (o *Orchestrator) multiThreadedBuildOrClean(buildResult *orchestratorResult) { // Spin off the threads with waiting on upstream to build before actual project build wg := core.NewWorkGroup(false) - o.tasks.Range(func(path tspath.Path, task *buildTask) bool { + o.tasks.Range(func(path tspath.Path, task *BuildTask) bool { wg.Queue(func() { o.buildOrCleanProject(task, path, buildResult) }) @@ -344,7 +344,7 @@ func (o *Orchestrator) multiThreadedBuildOrClean(buildResult *orchestratorResult wg.RunAndWait() } -func (o *Orchestrator) buildOrCleanProject(task *buildTask, path tspath.Path, buildResult *orchestratorResult) { +func (o *Orchestrator) buildOrCleanProject(task *BuildTask, path tspath.Path, buildResult *orchestratorResult) { task.result = &taskResult{} task.result.reportStatus = o.createBuilderStatusReporter(task) task.result.diagnosticReporter = o.createDiagnosticReporter(task) @@ -356,19 +356,19 @@ func (o *Orchestrator) buildOrCleanProject(task *buildTask, path tspath.Path, bu task.report(o, path, buildResult) } -func (o *Orchestrator) getWriter(task *buildTask) io.Writer { +func (o *Orchestrator) getWriter(task *BuildTask) io.Writer { if task == nil { return o.opts.Sys.Writer() } return &task.result.builder } -func (o *Orchestrator) createBuilderStatusReporter(task *buildTask) tsc.DiagnosticReporter { - return tsc.CreateBuilderStatusReporter(o.opts.Sys, o.getWriter(task), o.opts.Command.CompilerOptions, o.opts.Testing) +func (o *Orchestrator) createBuilderStatusReporter(task *BuildTask) tsc.DiagnosticReporter { + return tsc.CreateBuilderStatusReporter(o.opts.Sys, o.getWriter(task), o.opts.Command.Locale(), o.opts.Command.CompilerOptions, o.opts.Testing) } -func (o *Orchestrator) createDiagnosticReporter(task *buildTask) tsc.DiagnosticReporter { - return tsc.CreateDiagnosticReporter(o.opts.Sys, o.getWriter(task), o.opts.Command.CompilerOptions) +func (o *Orchestrator) createDiagnosticReporter(task *BuildTask) tsc.DiagnosticReporter { + return tsc.CreateDiagnosticReporter(o.opts.Sys, o.getWriter(task), o.opts.Command.Locale(), o.opts.Command.CompilerOptions) } func NewOrchestrator(opts Options) *Orchestrator { @@ -378,7 +378,7 @@ func NewOrchestrator(opts Options) *Orchestrator { CurrentDirectory: opts.Sys.GetCurrentDirectory(), UseCaseSensitiveFileNames: opts.Sys.FS().UseCaseSensitiveFileNames(), }, - tasks: &collections.SyncMap[tspath.Path, *buildTask]{}, + tasks: &collections.SyncMap[tspath.Path, *BuildTask]{}, } orchestrator.host = &host{ orchestrator: orchestrator, @@ -392,9 +392,9 @@ func NewOrchestrator(opts Options) *Orchestrator { mTimes: &collections.SyncMap[tspath.Path, time.Time]{}, } if opts.Command.CompilerOptions.Watch.IsTrue() { - orchestrator.watchStatusReporter = tsc.CreateWatchStatusReporter(opts.Sys, opts.Command.CompilerOptions, opts.Testing) + orchestrator.watchStatusReporter = tsc.CreateWatchStatusReporter(opts.Sys, opts.Command.Locale(), opts.Command.CompilerOptions, opts.Testing) } else { - orchestrator.errorSummaryReporter = tsc.CreateReportErrorSummary(opts.Sys, opts.Command.CompilerOptions) + orchestrator.errorSummaryReporter = tsc.CreateReportErrorSummary(opts.Sys, opts.Command.Locale(), opts.Command.CompilerOptions) } return orchestrator } diff --git a/internal/execute/incremental/affectedfileshandler.go b/internal/execute/incremental/affectedfileshandler.go index 01273df775..cd230986c4 100644 --- a/internal/execute/incremental/affectedfileshandler.go +++ b/internal/execute/incremental/affectedfileshandler.go @@ -229,7 +229,7 @@ func (h *affectedFilesHandler) handleDtsMayChangeOfAffectedFile(dtsMayChange dts break } if typeChecker == nil { - typeChecker, done = h.program.program.GetTypeCheckerForFile(h.ctx, affectedFile) + typeChecker, done = h.program.program.GetTypeCheckerForFileExclusive(h.ctx, affectedFile) } aliased := checker.SkipAlias(exported, typeChecker) if aliased == exported { diff --git a/internal/execute/incremental/buildInfo.go b/internal/execute/incremental/buildInfo.go index ab5b622363..73d9f0849a 100644 --- a/internal/execute/incremental/buildInfo.go +++ b/internal/execute/incremental/buildInfo.go @@ -92,7 +92,7 @@ type BuildInfoFileInfo struct { fileInfo *buildInfoFileInfoWithSignature } -func newBuildInfoFileInfo(fileInfo *fileInfo) *BuildInfoFileInfo { +func newBuildInfoFileInfo(fileInfo *FileInfo) *BuildInfoFileInfo { if fileInfo.version == fileInfo.signature { if !fileInfo.affectsGlobalScope && fileInfo.impliedNodeFormat == core.ResolutionModeCommonJS { return &BuildInfoFileInfo{signature: fileInfo.signature} @@ -113,25 +113,25 @@ func newBuildInfoFileInfo(fileInfo *fileInfo) *BuildInfoFileInfo { }} } -func (b *BuildInfoFileInfo) GetFileInfo() *fileInfo { +func (b *BuildInfoFileInfo) GetFileInfo() *FileInfo { if b == nil { return nil } if b.signature != "" { - return &fileInfo{ + return &FileInfo{ version: b.signature, signature: b.signature, impliedNodeFormat: core.ResolutionModeCommonJS, } } if b.noSignature != nil { - return &fileInfo{ + return &FileInfo{ version: b.noSignature.Version, affectsGlobalScope: b.noSignature.AffectsGlobalScope, impliedNodeFormat: b.noSignature.ImpliedNodeFormat, } } - return &fileInfo{ + return &FileInfo{ version: b.fileInfo.Version, signature: core.IfElse(b.fileInfo.Signature == "", b.fileInfo.Version, b.fileInfo.Signature), affectsGlobalScope: b.fileInfo.AffectsGlobalScope, @@ -201,7 +201,8 @@ type BuildInfoDiagnostic struct { End int `json:"end,omitzero"` Code int32 `json:"code,omitzero"` Category diagnostics.Category `json:"category,omitzero"` - Message string `json:"message,omitzero"` + MessageKey diagnostics.Key `json:"messageKey,omitzero"` + MessageArgs []string `json:"messageArgs,omitzero"` MessageChain []*BuildInfoDiagnostic `json:"messageChain,omitzero"` RelatedInformation []*BuildInfoDiagnostic `json:"relatedInformation,omitzero"` ReportsUnnecessary bool `json:"reportsUnnecessary,omitzero"` diff --git a/internal/execute/incremental/buildinfotosnapshot.go b/internal/execute/incremental/buildinfotosnapshot.go index 10ebb40f64..7a10212771 100644 --- a/internal/execute/incremental/buildinfotosnapshot.go +++ b/internal/execute/incremental/buildinfotosnapshot.go @@ -79,7 +79,8 @@ func (t *toSnapshot) toBuildInfoDiagnosticsWithFileName(diagnostics []*BuildInfo end: d.End, code: d.Code, category: d.Category, - message: d.Message, + messageKey: d.MessageKey, + messageArgs: d.MessageArgs, messageChain: t.toBuildInfoDiagnosticsWithFileName(d.MessageChain), relatedInformation: t.toBuildInfoDiagnosticsWithFileName(d.RelatedInformation), reportsUnnecessary: d.ReportsUnnecessary, @@ -89,8 +90,8 @@ func (t *toSnapshot) toBuildInfoDiagnosticsWithFileName(diagnostics []*BuildInfo }) } -func (t *toSnapshot) toDiagnosticsOrBuildInfoDiagnosticsWithFileName(dig *BuildInfoDiagnosticsOfFile) *diagnosticsOrBuildInfoDiagnosticsWithFileName { - return &diagnosticsOrBuildInfoDiagnosticsWithFileName{ +func (t *toSnapshot) toDiagnosticsOrBuildInfoDiagnosticsWithFileName(dig *BuildInfoDiagnosticsOfFile) *DiagnosticsOrBuildInfoDiagnosticsWithFileName { + return &DiagnosticsOrBuildInfoDiagnosticsWithFileName{ buildInfoDiagnostics: t.toBuildInfoDiagnosticsWithFileName(dig.Diagnostics), } } @@ -135,10 +136,10 @@ func (t *toSnapshot) setChangeFileSet() { } func (t *toSnapshot) setSemanticDiagnostics() { - t.snapshot.fileInfos.Range(func(path tspath.Path, info *fileInfo) bool { + t.snapshot.fileInfos.Range(func(path tspath.Path, info *FileInfo) bool { // Initialize to have no diagnostics if its not changed file if !t.snapshot.changedFilesSet.Has(path) { - t.snapshot.semanticDiagnosticsPerFile.Store(path, &diagnosticsOrBuildInfoDiagnosticsWithFileName{}) + t.snapshot.semanticDiagnosticsPerFile.Store(path, &DiagnosticsOrBuildInfoDiagnosticsWithFileName{}) } return true }) diff --git a/internal/execute/incremental/emitfileshandler.go b/internal/execute/incremental/emitfileshandler.go index 4cde6a6df2..bb40199dc3 100644 --- a/internal/execute/incremental/emitfileshandler.go +++ b/internal/execute/incremental/emitfileshandler.go @@ -145,7 +145,7 @@ func (h *emitFilesHandler) emitFilesIncremental(options compiler.EmitOptions) [] } // Get updated errors that were not included in affected files emit - h.program.snapshot.emitDiagnosticsPerFile.Range(func(path tspath.Path, diagnostics *diagnosticsOrBuildInfoDiagnosticsWithFileName) bool { + h.program.snapshot.emitDiagnosticsPerFile.Range(func(path tspath.Path, diagnostics *DiagnosticsOrBuildInfoDiagnosticsWithFileName) bool { if _, ok := h.emitUpdates.Load(path); !ok { affectedFile := h.program.program.GetSourceFileByPath(path) if affectedFile == nil || !h.program.program.SourceFileMayBeEmitted(affectedFile, false) { @@ -299,7 +299,7 @@ func (h *emitFilesHandler) updateSnapshot() []*compiler.EmitResult { if update.result != nil { results = append(results, update.result) if len(update.result.Diagnostics) != 0 { - h.program.snapshot.emitDiagnosticsPerFile.Store(file.Path(), &diagnosticsOrBuildInfoDiagnosticsWithFileName{diagnostics: update.result.Diagnostics}) + h.program.snapshot.emitDiagnosticsPerFile.Store(file.Path(), &DiagnosticsOrBuildInfoDiagnosticsWithFileName{diagnostics: update.result.Diagnostics}) } } } diff --git a/internal/execute/incremental/program.go b/internal/execute/incremental/program.go index 3e2fd1eecd..dd94d16241 100644 --- a/internal/execute/incremental/program.go +++ b/internal/execute/incremental/program.go @@ -47,7 +47,7 @@ func NewProgram(program *compiler.Program, oldProgram *Program, host Host, testi if oldProgram != nil { incrementalProgram.testingData.OldProgramSemanticDiagnosticsPerFile = &oldProgram.snapshot.semanticDiagnosticsPerFile } else { - incrementalProgram.testingData.OldProgramSemanticDiagnosticsPerFile = &collections.SyncMap[tspath.Path, *diagnosticsOrBuildInfoDiagnosticsWithFileName]{} + incrementalProgram.testingData.OldProgramSemanticDiagnosticsPerFile = &collections.SyncMap[tspath.Path, *DiagnosticsOrBuildInfoDiagnosticsWithFileName]{} } incrementalProgram.testingData.UpdatedSignatureKinds = make(map[tspath.Path]SignatureUpdateKind) } @@ -55,8 +55,8 @@ func NewProgram(program *compiler.Program, oldProgram *Program, host Host, testi } type TestingData struct { - SemanticDiagnosticsPerFile *collections.SyncMap[tspath.Path, *diagnosticsOrBuildInfoDiagnosticsWithFileName] - OldProgramSemanticDiagnosticsPerFile *collections.SyncMap[tspath.Path, *diagnosticsOrBuildInfoDiagnosticsWithFileName] + SemanticDiagnosticsPerFile *collections.SyncMap[tspath.Path, *DiagnosticsOrBuildInfoDiagnosticsWithFileName] + OldProgramSemanticDiagnosticsPerFile *collections.SyncMap[tspath.Path, *DiagnosticsOrBuildInfoDiagnosticsWithFileName] UpdatedSignatureKinds map[tspath.Path]SignatureUpdateKind } @@ -84,12 +84,36 @@ func (p *Program) Options() *core.CompilerOptions { return p.snapshot.options } +// CommonSourceDirectory implements compiler.AnyProgram interface. +func (p *Program) CommonSourceDirectory() string { + p.panicIfNoProgram("CommonSourceDirectory") + return p.program.CommonSourceDirectory() +} + +// Program implements compiler.AnyProgram interface. +func (p *Program) Program() *compiler.Program { + p.panicIfNoProgram("Program") + return p.program +} + +// IsSourceFileDefaultLibrary implements compiler.AnyProgram interface. +func (p *Program) IsSourceFileDefaultLibrary(path tspath.Path) bool { + p.panicIfNoProgram("IsSourceFileDefaultLibrary") + return p.program.IsSourceFileDefaultLibrary(path) +} + // GetSourceFiles implements compiler.AnyProgram interface. func (p *Program) GetSourceFiles() []*ast.SourceFile { p.panicIfNoProgram("GetSourceFiles") return p.program.GetSourceFiles() } +// GetSourceFile implements compiler.AnyProgram interface. +func (p *Program) GetSourceFile(path string) *ast.SourceFile { + p.panicIfNoProgram("GetSourceFile") + return p.program.GetSourceFile(path) +} + // GetConfigFileParsingDiagnostics implements compiler.AnyProgram interface. func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic { p.panicIfNoProgram("GetConfigFileParsingDiagnostics") @@ -172,6 +196,12 @@ func (p *Program) GetDeclarationDiagnostics(ctx context.Context, file *ast.Sourc return nil } +// GetSuggestionDiagnostics implements compiler.AnyProgram interface. +func (p *Program) GetSuggestionDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic { + p.panicIfNoProgram("GetSuggestionDiagnostics") + return p.program.GetSuggestionDiagnostics(ctx, file) // TODO: incremental suggestion diagnostics (only relevant in editor incremental builder?) +} + // GetModeForUsageLocation implements compiler.AnyProgram interface. func (p *Program) Emit(ctx context.Context, options compiler.EmitOptions) *compiler.EmitResult { p.panicIfNoProgram("Emit") @@ -240,7 +270,7 @@ func (p *Program) collectSemanticDiagnosticsOfAffectedFiles(ctx context.Context, // Commit changes to snapshot for file, diagnostics := range diagnosticsPerFile { - p.snapshot.semanticDiagnosticsPerFile.Store(file.Path(), &diagnosticsOrBuildInfoDiagnosticsWithFileName{diagnostics: diagnostics}) + p.snapshot.semanticDiagnosticsPerFile.Store(file.Path(), &DiagnosticsOrBuildInfoDiagnosticsWithFileName{diagnostics: diagnostics}) } if p.snapshot.semanticDiagnosticsPerFile.Size() == len(p.program.GetSourceFiles()) && p.snapshot.checkPending && !p.snapshot.options.NoCheck.IsTrue() { p.snapshot.checkPending = false diff --git a/internal/execute/incremental/programtosnapshot.go b/internal/execute/incremental/programtosnapshot.go index c8514f5667..e5df5cbbb0 100644 --- a/internal/execute/incremental/programtosnapshot.go +++ b/internal/execute/incremental/programtosnapshot.go @@ -140,7 +140,7 @@ func (t *toProgramSnapshot) computeProgramFileChanges() { t.snapshot.addFileToAffectedFilesPendingEmit(file.Path(), GetFileEmitKind(t.snapshot.options)) signature = version } - t.snapshot.fileInfos.Store(file.Path(), &fileInfo{ + t.snapshot.fileInfos.Store(file.Path(), &FileInfo{ version: version, signature: signature, affectsGlobalScope: affectsGlobalScope, @@ -154,7 +154,7 @@ func (t *toProgramSnapshot) computeProgramFileChanges() { func (t *toProgramSnapshot) handleFileDelete() { if t.oldProgram != nil { // If the global file is removed, add all files as changed - t.oldProgram.snapshot.fileInfos.Range(func(filePath tspath.Path, oldInfo *fileInfo) bool { + t.oldProgram.snapshot.fileInfos.Range(func(filePath tspath.Path, oldInfo *FileInfo) bool { if _, ok := t.snapshot.fileInfos.Load(filePath); !ok { if oldInfo.affectsGlobalScope { for _, file := range t.snapshot.getAllFilesExcludingDefaultLibraryFile(t.program, nil) { @@ -263,7 +263,7 @@ func getReferencedFiles(program *compiler.Program, file *ast.SourceFile) *collec // We need to use a set here since the code can contain the same import twice, // but that will only be one dependency. // To avoid invernal conversion, the key of the referencedFiles map must be of type Path - checker, done := program.GetTypeCheckerForFile(context.TODO(), file) + checker, done := program.GetTypeCheckerForFileExclusive(context.TODO(), file) defer done() for _, importName := range file.Imports() { addReferencedFilesFromImportLiteral(file, &referencedFiles, checker, importName) diff --git a/internal/execute/incremental/snapshot.go b/internal/execute/incremental/snapshot.go index d1ce2053cd..33e2351a3e 100644 --- a/internal/execute/incremental/snapshot.go +++ b/internal/execute/incremental/snapshot.go @@ -16,17 +16,17 @@ import ( "github.com/zeebo/xxh3" ) -type fileInfo struct { +type FileInfo struct { version string signature string affectsGlobalScope bool impliedNodeFormat core.ResolutionMode } -func (f *fileInfo) Version() string { return f.version } -func (f *fileInfo) Signature() string { return f.signature } -func (f *fileInfo) AffectsGlobalScope() bool { return f.affectsGlobalScope } -func (f *fileInfo) ImpliedNodeFormat() core.ResolutionMode { return f.impliedNodeFormat } +func (f *FileInfo) Version() string { return f.version } +func (f *FileInfo) Signature() string { return f.signature } +func (f *FileInfo) AffectsGlobalScope() bool { return f.affectsGlobalScope } +func (f *FileInfo) ImpliedNodeFormat() core.ResolutionMode { return f.impliedNodeFormat } func ComputeHash(text string, hashWithText bool) string { hashBytes := xxh3.Hash128([]byte(text)).Bytes() @@ -137,7 +137,8 @@ type buildInfoDiagnosticWithFileName struct { end int code int32 category diagnostics.Category - message string + messageKey diagnostics.Key + messageArgs []string messageChain []*buildInfoDiagnosticWithFileName relatedInformation []*buildInfoDiagnosticWithFileName reportsUnnecessary bool @@ -145,7 +146,7 @@ type buildInfoDiagnosticWithFileName struct { skippedOnNoEmit bool } -type diagnosticsOrBuildInfoDiagnosticsWithFileName struct { +type DiagnosticsOrBuildInfoDiagnosticsWithFileName struct { diagnostics []*ast.Diagnostic buildInfoDiagnostics []*buildInfoDiagnosticWithFileName } @@ -165,12 +166,13 @@ func (b *buildInfoDiagnosticWithFileName) toDiagnostic(p *compiler.Program, file for _, info := range b.relatedInformation { relatedInformation = append(relatedInformation, info.toDiagnostic(p, fileForDiagnostic)) } - return ast.NewDiagnosticWith( + return ast.NewDiagnosticFromSerialized( fileForDiagnostic, core.NewTextRange(b.pos, b.end), b.code, b.category, - b.message, + b.messageKey, + b.messageArgs, messageChain, relatedInformation, b.reportsUnnecessary, @@ -179,7 +181,7 @@ func (b *buildInfoDiagnosticWithFileName) toDiagnostic(p *compiler.Program, file ) } -func (d *diagnosticsOrBuildInfoDiagnosticsWithFileName) getDiagnostics(p *compiler.Program, file *ast.SourceFile) []*ast.Diagnostic { +func (d *DiagnosticsOrBuildInfoDiagnosticsWithFileName) getDiagnostics(p *compiler.Program, file *ast.SourceFile) []*ast.Diagnostic { if d.diagnostics != nil { return d.diagnostics } @@ -194,14 +196,14 @@ type snapshot struct { // These are the fields that get serialized // Information of the file eg. its version, signature etc - fileInfos collections.SyncMap[tspath.Path, *fileInfo] + fileInfos collections.SyncMap[tspath.Path, *FileInfo] options *core.CompilerOptions // Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled referencedMap referenceMap // Cache of semantic diagnostics for files with their Path being the key - semanticDiagnosticsPerFile collections.SyncMap[tspath.Path, *diagnosticsOrBuildInfoDiagnosticsWithFileName] + semanticDiagnosticsPerFile collections.SyncMap[tspath.Path, *DiagnosticsOrBuildInfoDiagnosticsWithFileName] // Cache of dts emit diagnostics for files with their Path being the key - emitDiagnosticsPerFile collections.SyncMap[tspath.Path, *diagnosticsOrBuildInfoDiagnosticsWithFileName] + emitDiagnosticsPerFile collections.SyncMap[tspath.Path, *DiagnosticsOrBuildInfoDiagnosticsWithFileName] // The map has key by source file's path that has been changed changedFilesSet collections.SyncSet[tspath.Path] // Files pending to be emitted @@ -301,7 +303,12 @@ func diagnosticToStringBuilder(diagnostic *ast.Diagnostic, file *ast.SourceFile, } builder.WriteString(diagnostic.Category().Name()) builder.WriteString(fmt.Sprintf("%d: ", diagnostic.Code())) - builder.WriteString(diagnostic.Message()) + builder.WriteString(string(diagnostic.MessageKey())) + builder.WriteString("\n") + for _, arg := range diagnostic.MessageArgs() { + builder.WriteString(arg) + builder.WriteString("\n") + } for _, chain := range diagnostic.MessageChain() { diagnosticToStringBuilder(chain, file, builder) } diff --git a/internal/execute/incremental/snapshottobuildinfo.go b/internal/execute/incremental/snapshottobuildinfo.go index c700ccb330..fc83153362 100644 --- a/internal/execute/incremental/snapshottobuildinfo.go +++ b/internal/execute/incremental/snapshottobuildinfo.go @@ -128,7 +128,8 @@ func (t *toBuildInfo) toBuildInfoDiagnosticsFromFileNameDiagnostics(diagnostics End: d.end, Code: d.code, Category: d.category, - Message: d.message, + MessageKey: d.messageKey, + MessageArgs: d.messageArgs, MessageChain: t.toBuildInfoDiagnosticsFromFileNameDiagnostics(d.messageChain), RelatedInformation: t.toBuildInfoDiagnosticsFromFileNameDiagnostics(d.relatedInformation), ReportsUnnecessary: d.reportsUnnecessary, @@ -154,7 +155,8 @@ func (t *toBuildInfo) toBuildInfoDiagnosticsFromDiagnostics(filePath tspath.Path End: d.Loc().End(), Code: d.Code(), Category: d.Category(), - Message: d.Message(), + MessageKey: d.MessageKey(), + MessageArgs: d.MessageArgs(), MessageChain: t.toBuildInfoDiagnosticsFromDiagnostics(filePath, d.MessageChain()), RelatedInformation: t.toBuildInfoDiagnosticsFromDiagnostics(filePath, d.RelatedInformation()), ReportsUnnecessary: d.ReportsUnnecessary(), @@ -164,7 +166,7 @@ func (t *toBuildInfo) toBuildInfoDiagnosticsFromDiagnostics(filePath tspath.Path }) } -func (t *toBuildInfo) toBuildInfoDiagnosticsOfFile(filePath tspath.Path, diags *diagnosticsOrBuildInfoDiagnosticsWithFileName) *BuildInfoDiagnosticsOfFile { +func (t *toBuildInfo) toBuildInfoDiagnosticsOfFile(filePath tspath.Path, diags *DiagnosticsOrBuildInfoDiagnosticsWithFileName) *BuildInfoDiagnosticsOfFile { if len(diags.diagnostics) > 0 { return &BuildInfoDiagnosticsOfFile{ FileId: t.toFileId(filePath), diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index 65bf8d43bb..f70b053ea5 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" @@ -14,6 +15,7 @@ import ( "github.com/microsoft/typescript-go/internal/execute/tsc" "github.com/microsoft/typescript-go/internal/format" "github.com/microsoft/typescript-go/internal/jsonutil" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/pprof" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -22,7 +24,6 @@ import ( func CommandLine(sys tsc.System, commandLineArgs []string, testing tsc.CommandLineTesting) tsc.CommandLineResult { if len(commandLineArgs) > 0 { - // !!! build mode switch strings.ToLower(commandLineArgs[0]) { case "-b", "--b", "-build", "--build": return tscBuildCompilation(sys, tsoptions.ParseBuildCommandLine(commandLineArgs, sys), testing) @@ -61,11 +62,8 @@ func fmtMain(sys tsc.System, input, output string) tsc.ExitStatus { } func tscBuildCompilation(sys tsc.System, buildCommand *tsoptions.ParsedBuildCommandLine, testing tsc.CommandLineTesting) tsc.CommandLineResult { - reportDiagnostic := tsc.CreateDiagnosticReporter(sys, sys.Writer(), buildCommand.CompilerOptions) - - // if (buildOptions.locale) { - // validateLocaleAndSetLanguage(buildOptions.locale, sys, errors); - // } + locale := buildCommand.Locale() + reportDiagnostic := tsc.CreateDiagnosticReporter(sys, sys.Writer(), locale, buildCommand.CompilerOptions) if len(buildCommand.Errors) > 0 { for _, err := range buildCommand.Errors { @@ -81,8 +79,8 @@ func tscBuildCompilation(sys tsc.System, buildCommand *tsoptions.ParsedBuildComm } if buildCommand.CompilerOptions.Help.IsTrue() { - tsc.PrintVersion(sys) - tsc.PrintBuildHelp(sys, tsoptions.BuildOpts) + tsc.PrintVersion(sys, locale) + tsc.PrintBuildHelp(sys, locale, tsoptions.BuildOpts) return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} } @@ -96,8 +94,8 @@ func tscBuildCompilation(sys tsc.System, buildCommand *tsoptions.ParsedBuildComm func tscCompilation(sys tsc.System, commandLine *tsoptions.ParsedCommandLine, testing tsc.CommandLineTesting) tsc.CommandLineResult { configFileName := "" - reportDiagnostic := tsc.CreateDiagnosticReporter(sys, sys.Writer(), commandLine.CompilerOptions()) - // if commandLine.Options().Locale != nil + locale := commandLine.Locale() + reportDiagnostic := tsc.CreateDiagnosticReporter(sys, sys.Writer(), locale, commandLine.CompilerOptions()) if len(commandLine.Errors) > 0 { for _, e := range commandLine.Errors { @@ -113,16 +111,17 @@ func tscCompilation(sys tsc.System, commandLine *tsoptions.ParsedCommandLine, te } if commandLine.CompilerOptions().Init.IsTrue() { - return tsc.CommandLineResult{Status: tsc.ExitStatusNotImplemented} + tsc.WriteConfigFile(sys, locale, reportDiagnostic, commandLine.Raw.(*collections.OrderedMap[string, any])) + return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} } if commandLine.CompilerOptions().Version.IsTrue() { - tsc.PrintVersion(sys) + tsc.PrintVersion(sys, locale) return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} } if commandLine.CompilerOptions().Help.IsTrue() || commandLine.CompilerOptions().All.IsTrue() { - tsc.PrintHelp(sys, commandLine) + tsc.PrintHelp(sys, locale, commandLine) return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} } @@ -151,19 +150,24 @@ func tscCompilation(sys tsc.System, commandLine *tsoptions.ParsedCommandLine, te return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} } } - } else if len(commandLine.FileNames()) == 0 { + } else if !commandLine.CompilerOptions().IgnoreConfig.IsTrue() || len(commandLine.FileNames()) == 0 { searchPath := tspath.NormalizePath(sys.GetCurrentDirectory()) configFileName = findConfigFile(searchPath, sys.FS().FileExists, "tsconfig.json") - } - - if configFileName == "" && len(commandLine.FileNames()) == 0 { - if commandLine.CompilerOptions().ShowConfig.IsTrue() { - reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, tspath.NormalizePath(sys.GetCurrentDirectory()))) - } else { - tsc.PrintVersion(sys) - tsc.PrintHelp(sys, commandLine) + if len(commandLine.FileNames()) != 0 { + if configFileName != "" { + // Error to not specify config file + reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.X_tsconfig_json_is_present_but_will_not_be_loaded_if_files_are_specified_on_commandline_Use_ignoreConfig_to_skip_this_error)) + return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} + } + } else if configFileName == "" { + if commandLine.CompilerOptions().ShowConfig.IsTrue() { + reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, tspath.NormalizePath(sys.GetCurrentDirectory()))) + } else { + tsc.PrintVersion(sys, locale) + tsc.PrintHelp(sys, locale, commandLine) + } + return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} } - return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} } // !!! convert to options with absolute paths is usually done here, but for ease of implementation, it's done in `tsoptions.ParseCommandLine()` @@ -184,16 +188,23 @@ func tscCompilation(sys tsc.System, commandLine *tsoptions.ParsedCommandLine, te } configForCompilation = configParseResult // Updater to reflect pretty - reportDiagnostic = tsc.CreateDiagnosticReporter(sys, sys.Writer(), commandLine.CompilerOptions()) + reportDiagnostic = tsc.CreateDiagnosticReporter(sys, sys.Writer(), locale, commandLine.CompilerOptions()) } - reportErrorSummary := tsc.CreateReportErrorSummary(sys, configForCompilation.CompilerOptions()) + reportErrorSummary := tsc.CreateReportErrorSummary(sys, locale, configForCompilation.CompilerOptions()) if compilerOptionsFromCommandLine.ShowConfig.IsTrue() { showConfig(sys, configForCompilation.CompilerOptions()) return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} } if configForCompilation.CompilerOptions().Watch.IsTrue() { - watcher := createWatcher(sys, configForCompilation, reportDiagnostic, reportErrorSummary, testing) + watcher := createWatcher( + sys, + configForCompilation, + compilerOptionsFromCommandLine, + reportDiagnostic, + reportErrorSummary, + testing, + ) watcher.start() return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess, Watcher: watcher} } else if configForCompilation.CompilerOptions().IsIncremental() { @@ -232,8 +243,8 @@ func findConfigFile(searchPath string, fileExists func(string) bool, configName return result } -func getTraceFromSys(sys tsc.System, testing tsc.CommandLineTesting) func(msg string) { - return tsc.GetTraceWithWriterFromSys(sys.Writer(), testing) +func getTraceFromSys(sys tsc.System, locale locale.Locale, testing tsc.CommandLineTesting) func(msg *diagnostics.Message, args ...any) { + return tsc.GetTraceWithWriterFromSys(sys.Writer(), locale, testing) } func performIncrementalCompilation( @@ -245,7 +256,7 @@ func performIncrementalCompilation( compileTimes *tsc.CompileTimes, testing tsc.CommandLineTesting, ) tsc.CommandLineResult { - host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, testing)) + host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, config.Locale(), testing)) buildInfoReadStart := sys.Now() oldProgram := incremental.ReadBuildInfoProgram(config, incremental.NewBuildInfoReader(host), host) compileTimes.BuildInfoReadTime = sys.Now().Sub(buildInfoReadStart) @@ -288,7 +299,7 @@ func performCompilation( compileTimes *tsc.CompileTimes, testing tsc.CommandLineTesting, ) tsc.CommandLineResult { - host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, testing)) + host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, config.Locale(), testing)) // todo: cache, statistics, tracing parseStart := sys.Now() program := compiler.NewProgram(compiler.ProgramOptions{ diff --git a/internal/execute/tsc/compile.go b/internal/execute/tsc/compile.go index 4adc1df9e9..4fdd27f7c2 100644 --- a/internal/execute/tsc/compile.go +++ b/internal/execute/tsc/compile.go @@ -7,7 +7,9 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/execute/incremental" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" ) @@ -56,7 +58,7 @@ type CommandLineTesting interface { OnBuildStatusReportEnd(w io.Writer) OnWatchStatusReportStart() OnWatchStatusReportEnd() - GetTrace(w io.Writer) func(msg string) + GetTrace(w io.Writer, locale locale.Locale) func(msg *diagnostics.Message, args ...any) OnProgram(program *incremental.Program) } diff --git a/internal/execute/tsc/diagnostics.go b/internal/execute/tsc/diagnostics.go index a477867417..5a3d752a02 100644 --- a/internal/execute/tsc/diagnostics.go +++ b/internal/execute/tsc/diagnostics.go @@ -8,16 +8,18 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnosticwriter" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/tspath" ) -func getFormatOptsOfSys(sys System) *diagnosticwriter.FormattingOptions { +func getFormatOptsOfSys(sys System, locale locale.Locale) *diagnosticwriter.FormattingOptions { return &diagnosticwriter.FormattingOptions{ NewLine: "\n", ComparePathsOptions: tspath.ComparePathsOptions{ CurrentDirectory: sys.GetCurrentDirectory(), UseCaseSensitiveFileNames: sys.FS().UseCaseSensitiveFileNames(), }, + Locale: locale, } } @@ -25,19 +27,19 @@ type DiagnosticReporter = func(*ast.Diagnostic) func QuietDiagnosticReporter(diagnostic *ast.Diagnostic) {} -func CreateDiagnosticReporter(sys System, w io.Writer, options *core.CompilerOptions) DiagnosticReporter { +func CreateDiagnosticReporter(sys System, w io.Writer, locale locale.Locale, options *core.CompilerOptions) DiagnosticReporter { if options.Quiet.IsTrue() { return QuietDiagnosticReporter } - formatOpts := getFormatOptsOfSys(sys) + formatOpts := getFormatOptsOfSys(sys, locale) if shouldBePretty(sys, options) { return func(diagnostic *ast.Diagnostic) { - diagnosticwriter.FormatDiagnosticWithColorAndContext(w, diagnostic, formatOpts) + diagnosticwriter.FormatDiagnosticWithColorAndContext(w, diagnosticwriter.WrapASTDiagnostic(diagnostic), formatOpts) fmt.Fprint(w, formatOpts.NewLine) } } return func(diagnostic *ast.Diagnostic) { - diagnosticwriter.WriteFormatDiagnostic(w, diagnostic, formatOpts) + diagnosticwriter.WriteFormatDiagnostic(w, diagnosticwriter.WrapASTDiagnostic(diagnostic), formatOpts) } } @@ -123,44 +125,46 @@ type DiagnosticsReporter = func(diagnostics []*ast.Diagnostic) func QuietDiagnosticsReporter(diagnostics []*ast.Diagnostic) {} -func CreateReportErrorSummary(sys System, options *core.CompilerOptions) DiagnosticsReporter { +func CreateReportErrorSummary(sys System, locale locale.Locale, options *core.CompilerOptions) DiagnosticsReporter { if shouldBePretty(sys, options) { - formatOpts := getFormatOptsOfSys(sys) + formatOpts := getFormatOptsOfSys(sys, locale) return func(diagnostics []*ast.Diagnostic) { - diagnosticwriter.WriteErrorSummaryText(sys.Writer(), diagnostics, formatOpts) + diagnosticwriter.WriteErrorSummaryText(sys.Writer(), diagnosticwriter.FromASTDiagnostics(diagnostics), formatOpts) } } return QuietDiagnosticsReporter } -func CreateBuilderStatusReporter(sys System, w io.Writer, options *core.CompilerOptions, testing CommandLineTesting) DiagnosticReporter { +func CreateBuilderStatusReporter(sys System, w io.Writer, locale locale.Locale, options *core.CompilerOptions, testing CommandLineTesting) DiagnosticReporter { if options.Quiet.IsTrue() { return QuietDiagnosticReporter } - formatOpts := getFormatOptsOfSys(sys) + formatOpts := getFormatOptsOfSys(sys, locale) writeStatus := core.IfElse(shouldBePretty(sys, options), diagnosticwriter.FormatDiagnosticsStatusWithColorAndTime, diagnosticwriter.FormatDiagnosticsStatusAndTime) return func(diagnostic *ast.Diagnostic) { + writerDiagnostic := diagnosticwriter.WrapASTDiagnostic(diagnostic) if testing != nil { testing.OnBuildStatusReportStart(w) defer testing.OnBuildStatusReportEnd(w) } - writeStatus(w, sys.Now().Format("03:04:05 PM"), diagnostic, formatOpts) + writeStatus(w, sys.Now().Format("03:04:05 PM"), writerDiagnostic, formatOpts) fmt.Fprint(w, formatOpts.NewLine, formatOpts.NewLine) } } -func CreateWatchStatusReporter(sys System, options *core.CompilerOptions, testing CommandLineTesting) DiagnosticReporter { - formatOpts := getFormatOptsOfSys(sys) +func CreateWatchStatusReporter(sys System, locale locale.Locale, options *core.CompilerOptions, testing CommandLineTesting) DiagnosticReporter { + formatOpts := getFormatOptsOfSys(sys, locale) writeStatus := core.IfElse(shouldBePretty(sys, options), diagnosticwriter.FormatDiagnosticsStatusWithColorAndTime, diagnosticwriter.FormatDiagnosticsStatusAndTime) return func(diagnostic *ast.Diagnostic) { + writerDiagnostic := diagnosticwriter.WrapASTDiagnostic(diagnostic) writer := sys.Writer() if testing != nil { testing.OnWatchStatusReportStart() defer testing.OnWatchStatusReportEnd() } - diagnosticwriter.TryClearScreen(writer, diagnostic, options) - writeStatus(writer, sys.Now().Format("03:04:05 PM"), diagnostic, formatOpts) + diagnosticwriter.TryClearScreen(writer, writerDiagnostic, options) + writeStatus(writer, sys.Now().Format("03:04:05 PM"), writerDiagnostic, formatOpts) fmt.Fprint(writer, formatOpts.NewLine, formatOpts.NewLine) } } diff --git a/internal/execute/tsc/emit.go b/internal/execute/tsc/emit.go index f03e25b14d..44dc673d96 100644 --- a/internal/execute/tsc/emit.go +++ b/internal/execute/tsc/emit.go @@ -10,17 +10,19 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" ) -func GetTraceWithWriterFromSys(w io.Writer, testing CommandLineTesting) func(msg string) { +func GetTraceWithWriterFromSys(w io.Writer, locale locale.Locale, testing CommandLineTesting) func(msg *diagnostics.Message, args ...any) { if testing == nil { - return func(msg string) { - fmt.Fprintln(w, msg) + return func(msg *diagnostics.Message, args ...any) { + fmt.Fprintln(w, msg.Localize(locale, args...)) } } else { - return testing.GetTrace(w) + return testing.GetTrace(w, locale) } } @@ -133,7 +135,7 @@ func listFiles(input EmitInput, emitResult *compiler.EmitResult) { } } if options.ExplainFiles.IsTrue() { - input.Program.ExplainFiles(input.Writer) + input.Program.ExplainFiles(input.Writer, input.Config.Locale()) } else if options.ListFiles.IsTrue() || options.ListFilesOnly.IsTrue() { for _, file := range input.Program.GetSourceFiles() { fmt.Fprintln(input.Writer, file.FileName()) diff --git a/internal/execute/tsc/help.go b/internal/execute/tsc/help.go index f3467a6b6d..02e2b6d49c 100644 --- a/internal/execute/tsc/help.go +++ b/internal/execute/tsc/help.go @@ -8,18 +8,19 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/tsoptions" ) -func PrintVersion(sys System) { - fmt.Fprintln(sys.Writer(), diagnostics.Version_0.Format(core.Version())) +func PrintVersion(sys System, locale locale.Locale) { + fmt.Fprintln(sys.Writer(), diagnostics.Version_0.Localize(locale, core.Version())) } -func PrintHelp(sys System, commandLine *tsoptions.ParsedCommandLine) { +func PrintHelp(sys System, locale locale.Locale, commandLine *tsoptions.ParsedCommandLine) { if commandLine.CompilerOptions().All.IsFalseOrUnknown() { - printEasyHelp(sys, getOptionsForHelp(commandLine)) + printEasyHelp(sys, locale, getOptionsForHelp(commandLine)) } else { - // !!! printAllHelp(sys, getOptionsForHelp(commandLine)) + printAllHelp(sys, locale, getOptionsForHelp(commandLine)) } } @@ -63,20 +64,20 @@ func getHeader(sys System, message string) []string { return header } -func printEasyHelp(sys System, simpleOptions []*tsoptions.CommandLineOption) { +func printEasyHelp(sys System, locale locale.Locale, simpleOptions []*tsoptions.CommandLineOption) { colors := createColors(sys) var output []string example := func(examples []string, desc *diagnostics.Message) { for _, example := range examples { output = append(output, " ", colors.blue(example), "\n") } - output = append(output, " ", desc.Format(), "\n", "\n") + output = append(output, " ", desc.Localize(locale), "\n", "\n") } - msg := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format() + " - " + diagnostics.Version_0.Format(core.Version()) + msg := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Localize(locale) + " - " + diagnostics.Version_0.Localize(locale, core.Version()) output = append(output, getHeader(sys, msg)...) - output = append(output, colors.bold(diagnostics.COMMON_COMMANDS.Format()), "\n", "\n") + output = append(output, colors.bold(diagnostics.COMMON_COMMANDS.Localize(locale)), "\n", "\n") example([]string{"tsc"}, diagnostics.Compiles_the_current_project_tsconfig_json_in_the_working_directory) example([]string{"tsc app.ts util.ts"}, diagnostics.Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options) @@ -96,25 +97,49 @@ func printEasyHelp(sys System, simpleOptions []*tsoptions.CommandLineOption) { } } - output = append(output, generateSectionOptionsOutput(sys, diagnostics.COMMAND_LINE_FLAGS.Format(), cliCommands /*subCategory*/, false /*beforeOptionsDescription*/, nil /*afterOptionsDescription*/, nil)...) + output = append(output, generateSectionOptionsOutput(sys, locale, diagnostics.COMMAND_LINE_FLAGS.Localize(locale), cliCommands /*subCategory*/, false /*beforeOptionsDescription*/, nil /*afterOptionsDescription*/, nil)...) - // !!! locale formatMessage - after := diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0.Format("https://aka.ms/tsc") - output = append(output, generateSectionOptionsOutput(sys, diagnostics.COMMON_COMPILER_OPTIONS.Format(), configOpts /*subCategory*/, false /*beforeOptionsDescription*/, nil, &after)...) + after := diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0.Localize(locale, "https://aka.ms/tsc") + output = append(output, generateSectionOptionsOutput(sys, locale, diagnostics.COMMON_COMPILER_OPTIONS.Localize(locale), configOpts /*subCategory*/, false /*beforeOptionsDescription*/, nil, &after)...) for _, chunk := range output { fmt.Fprint(sys.Writer(), chunk) } } -func PrintBuildHelp(sys System, buildOptions []*tsoptions.CommandLineOption) { +func printAllHelp(sys System, locale locale.Locale, options []*tsoptions.CommandLineOption) { var output []string - output = append(output, getHeader(sys, diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format()+" - "+diagnostics.Version_0.Format(core.Version()))...) - before := diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0.Format("https://aka.ms/tsc-composite-builds") + msg := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Localize(locale) + " - " + diagnostics.Version_0.Localize(locale, core.Version()) + output = append(output, getHeader(sys, msg)...) + + // ALL COMPILER OPTIONS section + afterCompilerOptions := diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0.Localize(locale, "https://aka.ms/tsc") + output = append(output, generateSectionOptionsOutput(sys, locale, diagnostics.ALL_COMPILER_OPTIONS.Localize(locale), options, true, nil, &afterCompilerOptions)...) + + // WATCH OPTIONS section + beforeWatchOptions := diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon.Localize(locale) + output = append(output, generateSectionOptionsOutput(sys, locale, diagnostics.WATCH_OPTIONS.Localize(locale), tsoptions.OptionsForWatch, false, &beforeWatchOptions, nil)...) + + // BUILD OPTIONS section + beforeBuildOptions := diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0.Localize(locale, "https://aka.ms/tsc-composite-builds") + buildOptions := core.Filter(tsoptions.OptionsForBuild, func(option *tsoptions.CommandLineOption) bool { + return option != &tsoptions.TscBuildOption + }) + output = append(output, generateSectionOptionsOutput(sys, locale, diagnostics.BUILD_OPTIONS.Localize(locale), buildOptions, false, &beforeBuildOptions, nil)...) + + for _, chunk := range output { + fmt.Fprint(sys.Writer(), chunk) + } +} + +func PrintBuildHelp(sys System, locale locale.Locale, buildOptions []*tsoptions.CommandLineOption) { + var output []string + output = append(output, getHeader(sys, diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Localize(locale)+" - "+diagnostics.Version_0.Localize(locale, core.Version()))...) + before := diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0.Localize(locale, "https://aka.ms/tsc-composite-builds") options := core.Filter(buildOptions, func(option *tsoptions.CommandLineOption) bool { return option != &tsoptions.TscBuildOption }) - output = append(output, generateSectionOptionsOutput(sys, diagnostics.BUILD_OPTIONS.Format(), options, false, &before, nil)...) + output = append(output, generateSectionOptionsOutput(sys, locale, diagnostics.BUILD_OPTIONS.Localize(locale), options, false, &before, nil)...) for _, chunk := range output { fmt.Fprint(sys.Writer(), chunk) @@ -123,6 +148,7 @@ func PrintBuildHelp(sys System, buildOptions []*tsoptions.CommandLineOption) { func generateSectionOptionsOutput( sys System, + locale locale.Locale, sectionName string, options []*tsoptions.CommandLineOption, subCategory bool, @@ -135,23 +161,28 @@ func generateSectionOptionsOutput( output = append(output, *beforeOptionsDescription, "\n", "\n") } if !subCategory { - output = append(output, generateGroupOptionOutput(sys, options)...) + output = append(output, generateGroupOptionOutput(sys, locale, options)...) if afterOptionsDescription != nil { output = append(output, *afterOptionsDescription, "\n", "\n") } return output } categoryMap := make(map[string][]*tsoptions.CommandLineOption) + var categoryOrder []string for _, option := range options { if option.Category == nil { continue } - curCategory := option.Category.Format() + curCategory := option.Category.Localize(locale) + if _, exists := categoryMap[curCategory]; !exists { + categoryOrder = append(categoryOrder, curCategory) + } categoryMap[curCategory] = append(categoryMap[curCategory], option) } - for key, value := range categoryMap { + for _, key := range categoryOrder { + value := categoryMap[key] output = append(output, "### ", key, "\n", "\n") - output = append(output, generateGroupOptionOutput(sys, value)...) + output = append(output, generateGroupOptionOutput(sys, locale, value)...) } if afterOptionsDescription != nil { output = append(output, *afterOptionsDescription, "\n", "\n") @@ -160,7 +191,7 @@ func generateSectionOptionsOutput( return output } -func generateGroupOptionOutput(sys System, optionsList []*tsoptions.CommandLineOption) []string { +func generateGroupOptionOutput(sys System, locale locale.Locale, optionsList []*tsoptions.CommandLineOption) []string { var maxLength int for _, option := range optionsList { curLenght := len(getDisplayNameTextOfOption(option)) @@ -176,7 +207,7 @@ func generateGroupOptionOutput(sys System, optionsList []*tsoptions.CommandLineO var lines []string for _, option := range optionsList { - tmp := generateOptionOutput(sys, option, rightAlignOfLeftPart, leftAlignOfRightPart) + tmp := generateOptionOutput(sys, locale, option, rightAlignOfLeftPart, leftAlignOfRightPart) lines = append(lines, tmp...) } @@ -190,6 +221,7 @@ func generateGroupOptionOutput(sys System, optionsList []*tsoptions.CommandLineO func generateOptionOutput( sys System, + locale locale.Locale, option *tsoptions.CommandLineOption, rightAlignOfLeft, leftAlignOfRight int, ) []string { @@ -200,11 +232,11 @@ func generateOptionOutput( name := getDisplayNameTextOfOption(option) // value type and possible value - valueCandidates := getValueCandidate(option) + valueCandidates := getValueCandidate(sys, locale, option) var defaultValueDescription string if msg, ok := option.DefaultValueDescription.(*diagnostics.Message); ok && msg != nil { - defaultValueDescription = msg.Format() + defaultValueDescription = msg.Localize(locale) } else { defaultValueDescription = formatDefaultValue( option.DefaultValueDescription, @@ -220,7 +252,7 @@ func generateOptionOutput( if terminalWidth >= 80 { description := "" if option.Description != nil { - description = option.Description.Format() + description = option.Description.Localize(locale) } text = append(text, getPrettyOutput(colors, name, description, rightAlignOfLeft, leftAlignOfRight, terminalWidth, true /*colorLeft*/)...) text = append(text, "\n") @@ -230,7 +262,7 @@ func generateOptionOutput( text = append(text, "\n") } if defaultValueDescription != "" { - text = append(text, getPrettyOutput(colors, diagnostics.X_default_Colon.Format(), defaultValueDescription, rightAlignOfLeft, leftAlignOfRight, terminalWidth, false /*colorLeft*/)...) + text = append(text, getPrettyOutput(colors, diagnostics.X_default_Colon.Localize(locale), defaultValueDescription, rightAlignOfLeft, leftAlignOfRight, terminalWidth, false /*colorLeft*/)...) text = append(text, "\n") } } @@ -238,7 +270,7 @@ func generateOptionOutput( } else { text = append(text, colors.blue(name), "\n") if option.Description != nil { - text = append(text, option.Description.Format()) + text = append(text, option.Description.Localize(locale)) } text = append(text, "\n") if showAdditionalInfoOutput(valueCandidates, option) { @@ -249,7 +281,7 @@ func generateOptionOutput( if valueCandidates != nil { text = append(text, "\n") } - text = append(text, diagnostics.X_default_Colon.Format(), " ", defaultValueDescription) + text = append(text, diagnostics.X_default_Colon.Localize(locale), " ", defaultValueDescription) } text = append(text, "\n") @@ -297,7 +329,7 @@ func showAdditionalInfoOutput(valueCandidates *valueCandidate, option *tsoptions return true } -func getValueCandidate(option *tsoptions.CommandLineOption) *valueCandidate { +func getValueCandidate(sys System, locale locale.Locale, option *tsoptions.CommandLineOption) *valueCandidate { // option.type might be "string" | "number" | "boolean" | "object" | "list" | Map // string -- any of: string // number -- any of: number @@ -319,11 +351,11 @@ func getValueCandidate(option *tsoptions.CommandLineOption) *valueCandidate { case tsoptions.CommandLineOptionTypeString, tsoptions.CommandLineOptionTypeNumber, tsoptions.CommandLineOptionTypeBoolean: - res.valueType = diagnostics.X_type_Colon.Format() + res.valueType = diagnostics.X_type_Colon.Localize(locale) case tsoptions.CommandLineOptionTypeList: - res.valueType = diagnostics.X_one_or_more_Colon.Format() + res.valueType = diagnostics.X_one_or_more_Colon.Localize(locale) default: - res.valueType = diagnostics.X_one_of_Colon.Format() + res.valueType = diagnostics.X_one_of_Colon.Localize(locale) } res.possibleValues = getPossibleValues(option) diff --git a/internal/execute/tsc/init.go b/internal/execute/tsc/init.go new file mode 100644 index 0000000000..035888fecb --- /dev/null +++ b/internal/execute/tsc/init.go @@ -0,0 +1,215 @@ +package tsc + +import ( + "fmt" + "reflect" + "slices" + "strings" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/jsonutil" + "github.com/microsoft/typescript-go/internal/locale" + "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/tspath" +) + +func WriteConfigFile(sys System, locale locale.Locale, reportDiagnostic DiagnosticReporter, options *collections.OrderedMap[string, any]) { + getCurrentDirectory := sys.GetCurrentDirectory() + file := tspath.NormalizePath(tspath.CombinePaths(getCurrentDirectory, "tsconfig.json")) + if sys.FS().FileExists(file) { + reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)) + } else { + _ = sys.FS().WriteFile(file, generateTSConfig(options, locale), false) + output := []string{"\n"} + output = append(output, getHeader(sys, "Created a new tsconfig.json")...) + output = append(output, "You can learn more at https://aka.ms/tsconfig", "\n") + fmt.Fprint(sys.Writer(), strings.Join(output, "")) + } +} + +func generateTSConfig(options *collections.OrderedMap[string, any], locale locale.Locale) string { + const tab = " " + var result []string + + allSetOptions := make([]string, 0, options.Size()) + for k := range options.Keys() { + if k != "init" && k != "help" && k != "watch" { + allSetOptions = append(allSetOptions, k) + } + } + + emitHeader := func(header *diagnostics.Message) { + result = append(result, tab+tab+"// "+header.Localize(locale)) + } + newline := func() { + result = append(result, "") + } + push := func(args ...string) { + result = append(result, args...) + } + + formatSingleValue := func(value any, enumMap *collections.OrderedMap[string, any]) string { + if enumMap != nil { + var found bool + for k, v := range enumMap.Entries() { + if value == v { + value = k + found = true + break + } + } + if !found { + panic(fmt.Sprintf("No matching value of %v", value)) + } + } + + b, err := jsonutil.MarshalIndent(value, "", "") + if err != nil { + panic(fmt.Sprintf("should not happen: %v", err)) + } + return string(b) + } + + formatValueOrArray := func(settingName string, value any) string { + var option *tsoptions.CommandLineOption + for _, decl := range tsoptions.OptionsDeclarations { + if decl.Name == settingName { + option = decl + } + } + if option == nil { + panic(`No option named ` + settingName) + } + + rval := reflect.ValueOf(value) + if rval.Kind() == reflect.Slice { + var enumMap *collections.OrderedMap[string, any] + if elemOption := option.Elements(); elemOption != nil { + enumMap = elemOption.EnumMap() + } + + var elems []string + for i := range rval.Len() { + elems = append(elems, formatSingleValue(rval.Index(i).Interface(), enumMap)) + } + return `[` + strings.Join(elems, ", ") + `]` + } else { + return formatSingleValue(value, option.EnumMap()) + } + } + + // commentedNever': Never comment this out + // commentedAlways': Always comment this out, even if it's on commandline + // commentedOptional': Comment out unless it's on commandline + type commented int + const ( + commentedNever commented = iota + commentedAlways + commentedOptional + ) + emitOption := func(setting string, defaultValue any, commented commented) { + if commented > 2 { + panic("should not happen: invalid `commented`, must be a bug.") + } + + existingOptionIndex := slices.Index(allSetOptions, setting) + if existingOptionIndex >= 0 { + allSetOptions = slices.Delete(allSetOptions, existingOptionIndex, existingOptionIndex+1) + } + + var comment bool + switch commented { + case commentedAlways: + comment = true + case commentedNever: + comment = false + default: + comment = !options.Has(setting) + } + + value, ok := options.Get(setting) + if !ok { + value = defaultValue + } + + if comment { + push(tab + tab + `// "` + setting + `": ` + formatValueOrArray(setting, value) + `,`) + } else { + push(tab + tab + `"` + setting + `": ` + formatValueOrArray(setting, value) + `,`) + } + } + + push("{") + push(tab + `// ` + diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file.Localize(locale)) + push(tab + `"compilerOptions": {`) + + emitHeader(diagnostics.File_Layout) + emitOption("rootDir", "./src", commentedOptional) + emitOption("outDir", "./dist", commentedOptional) + + newline() + + emitHeader(diagnostics.Environment_Settings) + emitHeader(diagnostics.See_also_https_Colon_Slash_Slashaka_ms_Slashtsconfig_Slashmodule) + emitOption("module", core.ModuleKindNodeNext, commentedNever) + emitOption("target", core.ScriptTargetESNext, commentedNever) + emitOption("types", []any{}, commentedNever) + if lib, ok := options.Get("lib"); ok { + emitOption("lib", lib, commentedNever) + } + emitHeader(diagnostics.For_nodejs_Colon) + push(tab + tab + `// "lib": ["esnext"],`) + push(tab + tab + `// "types": ["node"],`) + emitHeader(diagnostics.X_and_npm_install_D_types_Slashnode) + + newline() + + emitHeader(diagnostics.Other_Outputs) + emitOption("sourceMap" /*defaultValue*/, true, commentedNever) + emitOption("declaration" /*defaultValue*/, true, commentedNever) + emitOption("declarationMap" /*defaultValue*/, true, commentedNever) + + newline() + + emitHeader(diagnostics.Stricter_Typechecking_Options) + emitOption("noUncheckedIndexedAccess" /*defaultValue*/, true, commentedNever) + emitOption("exactOptionalPropertyTypes" /*defaultValue*/, true, commentedNever) + + newline() + + emitHeader(diagnostics.Style_Options) + emitOption("noImplicitReturns" /*defaultValue*/, true, commentedOptional) + emitOption("noImplicitOverride" /*defaultValue*/, true, commentedOptional) + emitOption("noUnusedLocals" /*defaultValue*/, true, commentedOptional) + emitOption("noUnusedParameters" /*defaultValue*/, true, commentedOptional) + emitOption("noFallthroughCasesInSwitch" /*defaultValue*/, true, commentedOptional) + emitOption("noPropertyAccessFromIndexSignature" /*defaultValue*/, true, commentedOptional) + + newline() + + emitHeader(diagnostics.Recommended_Options) + emitOption("strict" /*defaultValue*/, true, commentedNever) + emitOption("jsx", core.JsxEmitReactJSX, commentedNever) + emitOption("verbatimModuleSyntax" /*defaultValue*/, true, commentedNever) + emitOption("isolatedModules" /*defaultValue*/, true, commentedNever) + emitOption("noUncheckedSideEffectImports" /*defaultValue*/, true, commentedNever) + emitOption("moduleDetection", core.ModuleDetectionKindForce, commentedNever) + emitOption("skipLibCheck" /*defaultValue*/, true, commentedNever) + + // Write any user-provided options we haven't already + if len(allSetOptions) > 0 { + newline() + for len(allSetOptions) > 0 { + emitOption(allSetOptions[0], options.GetOrZero(allSetOptions[0]), commentedNever) + } + } + + push(tab + "}") + push(`}`) + push(``) + + return strings.Join(result, "\n") +} diff --git a/internal/execute/tsctests/readablebuildinfo.go b/internal/execute/tsctests/readablebuildinfo.go index 3969ac5f75..cdc9688c9a 100644 --- a/internal/execute/tsctests/readablebuildinfo.go +++ b/internal/execute/tsctests/readablebuildinfo.go @@ -62,7 +62,8 @@ type readableBuildInfoDiagnostic struct { End int `json:"end,omitzero"` Code int32 `json:"code,omitzero"` Category diagnostics.Category `json:"category,omitzero"` - Message string `json:"message,omitzero"` + MessageKey diagnostics.Key `json:"messageKey,omitzero"` + MessageArgs []string `json:"messageArgs,omitzero"` MessageChain []*readableBuildInfoDiagnostic `json:"messageChain,omitzero"` RelatedInformation []*readableBuildInfoDiagnostic `json:"relatedInformation,omitzero"` ReportsUnnecessary bool `json:"reportsUnnecessary,omitzero"` @@ -254,7 +255,8 @@ func (r *readableBuildInfo) toReadableBuildInfoDiagnostic(diagnostics []*increme End: d.End, Code: d.Code, Category: d.Category, - Message: d.Message, + MessageKey: d.MessageKey, + MessageArgs: d.MessageArgs, MessageChain: r.toReadableBuildInfoDiagnostic(d.MessageChain), RelatedInformation: r.toReadableBuildInfoDiagnostic(d.RelatedInformation), ReportsUnnecessary: d.ReportsUnnecessary, diff --git a/internal/execute/tsctests/runner.go b/internal/execute/tsctests/runner.go index 7cb8c261bd..8e51f0521d 100644 --- a/internal/execute/tsctests/runner.go +++ b/internal/execute/tsctests/runner.go @@ -17,7 +17,7 @@ import ( type tscEdit struct { caption string commandLineArgs []string - edit func(*testSys) + edit func(*TestSys) expectedDiff string } @@ -40,7 +40,7 @@ type tscInput struct { windowsStyleRoot string } -func (test *tscInput) executeCommand(sys *testSys, baselineBuilder *strings.Builder, commandLineArgs []string) tsc.CommandLineResult { +func (test *tscInput) executeCommand(sys *TestSys, baselineBuilder *strings.Builder, commandLineArgs []string) tsc.CommandLineResult { fmt.Fprint(baselineBuilder, "tsgo ", strings.Join(commandLineArgs, " "), "\n") result := execute.CommandLine(sys, commandLineArgs, sys) switch result.Status { @@ -85,7 +85,7 @@ func (test *tscInput) run(t *testing.T, scenario string) { for index, do := range test.edits { sys.clearOutput() wg := core.NewWorkGroup(false) - var nonIncrementalSys *testSys + var nonIncrementalSys *TestSys commandLineArgs := core.IfElse(do.commandLineArgs == nil, test.commandLineArgs, do.commandLineArgs) wg.Queue(func() { baselineBuilder.WriteString(fmt.Sprintf("\n\nEdit [%d]:: %s\n", index, do.caption)) @@ -119,7 +119,7 @@ func (test *tscInput) run(t *testing.T, scenario string) { baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!", do.expectedDiff))) baselineBuilder.WriteString(diff) if do.expectedDiff == "" { - unexpectedDiff += fmt.Sprintf("Edit [%d]:: %s\n!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!\n%s\n", index, do.caption, diff) + unexpectedDiff += fmt.Sprintf("Edit [%d]:: %s\n!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!\n%s\n", index, do.caption, diff) //nolint:perfsprint } } else if do.expectedDiff != "" { baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s !!! Diff not found but explanation present, please review and remove the explanation !!!\n", do.expectedDiff)) @@ -133,7 +133,7 @@ func (test *tscInput) run(t *testing.T, scenario string) { }) } -func getDiffForIncremental(incrementalSys *testSys, nonIncrementalSys *testSys) string { +func getDiffForIncremental(incrementalSys *TestSys, nonIncrementalSys *TestSys) string { var diffBuilder strings.Builder nonIncrementalOutputs := nonIncrementalSys.fs.writtenFiles.ToSlice() diff --git a/internal/execute/tsctests/sys.go b/internal/execute/tsctests/sys.go index 199fce8e76..f0fceb4f52 100644 --- a/internal/execute/tsctests/sys.go +++ b/internal/execute/tsctests/sys.go @@ -3,9 +3,7 @@ package tsctests import ( "fmt" "io" - "io/fs" "maps" - "slices" "strconv" "strings" "sync" @@ -14,8 +12,12 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/execute" "github.com/microsoft/typescript-go/internal/execute/incremental" "github.com/microsoft/typescript-go/internal/execute/tsc" + "github.com/microsoft/typescript-go/internal/locale" + "github.com/microsoft/typescript-go/internal/testutil/fsbaselineutil" "github.com/microsoft/typescript-go/internal/testutil/harnessutil" "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -23,6 +25,7 @@ import ( "github.com/microsoft/typescript-go/internal/vfs" "github.com/microsoft/typescript-go/internal/vfs/iovfs" "github.com/microsoft/typescript-go/internal/vfs/vfstest" + "golang.org/x/text/language" ) type FileMap map[string]any @@ -84,9 +87,9 @@ func (t *TestClock) SinceStart() time.Duration { return t.Now().Sub(t.start) } -func NewTscSystem(files FileMap, useCaseSensitiveFileNames bool, cwd string) *testSys { +func NewTscSystem(files FileMap, useCaseSensitiveFileNames bool, cwd string) *TestSys { clock := &TestClock{start: time.Now()} - return &testSys{ + return &TestSys{ fs: &testFs{ FS: vfstest.FromMapWithClock(files, useCaseSensitiveFileNames, clock), }, @@ -95,7 +98,21 @@ func NewTscSystem(files FileMap, useCaseSensitiveFileNames bool, cwd string) *te } } -func newTestSys(tscInput *tscInput, forIncrementalCorrectness bool) *testSys { +func GetFileMapWithBuild(files FileMap, commandLineArgs []string) FileMap { + sys := newTestSys(&tscInput{ + files: maps.Clone(files), + }, false) + execute.CommandLine(sys, commandLineArgs, sys) + sys.fs.writtenFiles.Range(func(key string) bool { + if text, ok := sys.fsFromFileMap().ReadFile(key); ok { + files[key] = text + } + return true + }) + return files +} + +func newTestSys(tscInput *tscInput, forIncrementalCorrectness bool) *TestSys { cwd := tscInput.cwd if cwd == "" { cwd = "/home/src/workspaces/project" @@ -114,6 +131,11 @@ func newTestSys(tscInput *tscInput, forIncrementalCorrectness bool) *testSys { }, currentWrite) sys.env = tscInput.env sys.forIncrementalCorrectness = forIncrementalCorrectness + sys.fsDiffer = &fsbaselineutil.FSDiffer{ + FS: sys.fs.FS.(iovfs.FsWithSys), + DefaultLibs: func() *collections.SyncSet[string] { return sys.fs.defaultLibs }, + WrittenFiles: &sys.fs.writtenFiles, + } // Ensure the default library file is present sys.ensureLibPathExists("lib.d.ts") @@ -126,24 +148,12 @@ func newTestSys(tscInput *tscInput, forIncrementalCorrectness bool) *testSys { return sys } -type diffEntry struct { - content string - mTime time.Time - isWritten bool - symlinkTarget string -} - -type snapshot struct { - snap map[string]*diffEntry - defaultLibs *collections.SyncSet[string] -} - -type testSys struct { +type TestSys struct { currentWrite *strings.Builder programBaselines strings.Builder programIncludeBaselines strings.Builder tracer *harnessutil.TracerForBaselining - serializedDiff *snapshot + fsDiffer *fsbaselineutil.FSDiffer forIncrementalCorrectness bool fs *testFs @@ -154,31 +164,31 @@ type testSys struct { } var ( - _ tsc.System = (*testSys)(nil) - _ tsc.CommandLineTesting = (*testSys)(nil) + _ tsc.System = (*TestSys)(nil) + _ tsc.CommandLineTesting = (*TestSys)(nil) ) -func (s *testSys) Now() time.Time { +func (s *TestSys) Now() time.Time { return s.clock.Now() } -func (s *testSys) SinceStart() time.Duration { +func (s *TestSys) SinceStart() time.Duration { return s.clock.SinceStart() } -func (s *testSys) FS() vfs.FS { +func (s *TestSys) FS() vfs.FS { return s.fs } -func (s *testSys) fsFromFileMap() iovfs.FsWithSys { - return s.fs.FS.(iovfs.FsWithSys) +func (s *TestSys) fsFromFileMap() iovfs.FsWithSys { + return s.fsDiffer.FS } -func (s *testSys) mapFs() *vfstest.MapFS { - return s.fsFromFileMap().FSys().(*vfstest.MapFS) +func (s *TestSys) mapFs() *vfstest.MapFS { + return s.fsDiffer.MapFs() } -func (s *testSys) ensureLibPathExists(path string) { +func (s *TestSys) ensureLibPathExists(path string) { path = s.defaultLibraryPath + "/" + path if _, ok := s.fsFromFileMap().ReadFile(path); !ok { if s.fs.defaultLibs == nil { @@ -192,39 +202,39 @@ func (s *testSys) ensureLibPathExists(path string) { } } -func (s *testSys) DefaultLibraryPath() string { +func (s *TestSys) DefaultLibraryPath() string { return s.defaultLibraryPath } -func (s *testSys) GetCurrentDirectory() string { +func (s *TestSys) GetCurrentDirectory() string { return s.cwd } -func (s *testSys) Writer() io.Writer { +func (s *TestSys) Writer() io.Writer { return s.currentWrite } -func (s *testSys) WriteOutputIsTTY() bool { +func (s *TestSys) WriteOutputIsTTY() bool { return true } -func (s *testSys) GetWidthOfTerminal() int { +func (s *TestSys) GetWidthOfTerminal() int { if widthStr := s.GetEnvironmentVariable("TS_TEST_TERMINAL_WIDTH"); widthStr != "" { return core.Must(strconv.Atoi(widthStr)) } return 0 } -func (s *testSys) GetEnvironmentVariable(name string) string { +func (s *TestSys) GetEnvironmentVariable(name string) string { return s.env[name] } -func (s *testSys) OnEmittedFiles(result *compiler.EmitResult, mTimesCache *collections.SyncMap[tspath.Path, time.Time]) { +func (s *TestSys) OnEmittedFiles(result *compiler.EmitResult, mTimesCache *collections.SyncMap[tspath.Path, time.Time]) { if result != nil { for _, file := range result.EmittedFiles { modTime := s.mapFs().GetModTime(file) - if s.serializedDiff != nil { - if diff, ok := s.serializedDiff.snap[file]; ok && diff.mTime.Equal(modTime) { + if serializedDiff := s.fsDiffer.SerializedDiff(); serializedDiff != nil { + if diff, ok := serializedDiff.Snap[file]; ok && diff.MTime.Equal(modTime) { // Even though written, timestamp was reverted continue } @@ -246,49 +256,50 @@ func (s *testSys) OnEmittedFiles(result *compiler.EmitResult, mTimesCache *colle } } -func (s *testSys) OnListFilesStart(w io.Writer) { +func (s *TestSys) OnListFilesStart(w io.Writer) { fmt.Fprintln(w, listFileStart) } -func (s *testSys) OnListFilesEnd(w io.Writer) { +func (s *TestSys) OnListFilesEnd(w io.Writer) { fmt.Fprintln(w, listFileEnd) } -func (s *testSys) OnStatisticsStart(w io.Writer) { +func (s *TestSys) OnStatisticsStart(w io.Writer) { fmt.Fprintln(w, statisticsStart) } -func (s *testSys) OnStatisticsEnd(w io.Writer) { +func (s *TestSys) OnStatisticsEnd(w io.Writer) { fmt.Fprintln(w, statisticsEnd) } -func (s *testSys) OnBuildStatusReportStart(w io.Writer) { +func (s *TestSys) OnBuildStatusReportStart(w io.Writer) { fmt.Fprintln(w, buildStatusReportStart) } -func (s *testSys) OnBuildStatusReportEnd(w io.Writer) { +func (s *TestSys) OnBuildStatusReportEnd(w io.Writer) { fmt.Fprintln(w, buildStatusReportEnd) } -func (s *testSys) OnWatchStatusReportStart() { +func (s *TestSys) OnWatchStatusReportStart() { fmt.Fprintln(s.Writer(), watchStatusReportStart) } -func (s *testSys) OnWatchStatusReportEnd() { +func (s *TestSys) OnWatchStatusReportEnd() { fmt.Fprintln(s.Writer(), watchStatusReportEnd) } -func (s *testSys) GetTrace(w io.Writer) func(str string) { - return func(str string) { +func (s *TestSys) GetTrace(w io.Writer, locale locale.Locale) func(msg *diagnostics.Message, args ...any) { + return func(msg *diagnostics.Message, args ...any) { fmt.Fprintln(w, traceStart) defer fmt.Fprintln(w, traceEnd) // With tsc -b building projects in parallel we cannot serialize the package.json lookup trace // so trace as if it wasnt cached + str := msg.Localize(locale, args...) s.tracer.TraceWithWriter(w, str, w == s.Writer()) } } -func (s *testSys) writeHeaderToBaseline(builder *strings.Builder, program *incremental.Program) { +func (s *TestSys) writeHeaderToBaseline(builder *strings.Builder, program *incremental.Program) { if builder.Len() != 0 { builder.WriteString("\n") } @@ -301,7 +312,7 @@ func (s *testSys) writeHeaderToBaseline(builder *strings.Builder, program *incre } } -func (s *testSys) OnProgram(program *incremental.Program) { +func (s *TestSys) OnProgram(program *incremental.Program) { s.writeHeaderToBaseline(&s.programBaselines, program) testingData := program.GetTestingData() @@ -357,7 +368,7 @@ func (s *testSys) OnProgram(program *incremental.Program) { } } -func (s *testSys) baselinePrograms(baseline *strings.Builder, header string) string { +func (s *TestSys) baselinePrograms(baseline *strings.Builder, header string) string { baseline.WriteString(s.programBaselines.String()) s.programBaselines.Reset() var result string @@ -370,7 +381,7 @@ func (s *testSys) baselinePrograms(baseline *strings.Builder, header string) str return result } -func (s *testSys) serializeState(baseline *strings.Builder) { +func (s *TestSys) serializeState(baseline *strings.Builder) { s.baselineOutput(baseline) s.baselineFSwithDiff(baseline) // todo watch @@ -399,7 +410,7 @@ var ( traceEnd = "!!! Trace end" ) -func (s *testSys) baselineOutput(baseline io.Writer) { +func (s *TestSys) baselineOutput(baseline io.Writer) { fmt.Fprint(baseline, "\nOutput::\n") output := s.getOutput(false) fmt.Fprint(baseline, output) @@ -412,13 +423,18 @@ type outputSanitizer struct { outputLines []string } +var ( + englishVersion = diagnostics.Version_0.Localize(locale.Default, core.Version()) + fakeEnglishVersion = diagnostics.Version_0.Localize(locale.Default, harnessutil.FakeTSVersion) + czech = locale.Locale(language.MustParse("cs")) + czechVersion = diagnostics.Version_0.Localize(czech, core.Version()) + fakeCzechVersion = diagnostics.Version_0.Localize(czech, harnessutil.FakeTSVersion) +) + func (o *outputSanitizer) addOutputLine(s string) { - if change := strings.ReplaceAll(s, fmt.Sprintf("'%s'", core.Version()), fmt.Sprintf("'%s'", harnessutil.FakeTSVersion)); change != s { - s = change - } - if change := strings.ReplaceAll(s, "Version "+core.Version(), "Version "+harnessutil.FakeTSVersion); change != s { - s = change - } + s = strings.ReplaceAll(s, fmt.Sprintf("'%s'", core.Version()), fmt.Sprintf("'%s'", harnessutil.FakeTSVersion)) + s = strings.ReplaceAll(s, englishVersion, fakeEnglishVersion) + s = strings.ReplaceAll(s, czechVersion, fakeCzechVersion) o.outputLines = append(o.outputLines, s) } @@ -484,7 +500,7 @@ func (o *outputSanitizer) addOrSkipLinesForComparing( panic("Expected lineEnd" + lineEnd + " not found after " + lineStart) } -func (s *testSys) getOutput(forComparing bool) string { +func (s *TestSys) getOutput(forComparing bool) string { lines := strings.Split(s.currentWrite.String(), "\n") transformer := &outputSanitizer{ forComparing: forComparing, @@ -494,104 +510,28 @@ func (s *testSys) getOutput(forComparing bool) string { return transformer.transformLines() } -func (s *testSys) clearOutput() { +func (s *TestSys) clearOutput() { s.currentWrite.Reset() s.tracer.Reset() } -func (s *testSys) baselineFSwithDiff(baseline io.Writer) { - // todo: baselines the entire fs, possibly doesn't correctly diff all cases of emitted files, since emit isn't fully implemented and doesn't always emit the same way as strada - snap := map[string]*diffEntry{} - - diffs := map[string]string{} - - for path, file := range s.mapFs().Entries() { - if file.Mode&fs.ModeSymlink != 0 { - target, ok := s.mapFs().GetTargetOfSymlink(path) - if !ok { - panic("Failed to resolve symlink target: " + path) - } - newEntry := &diffEntry{symlinkTarget: target} - snap[path] = newEntry - s.addFsEntryDiff(diffs, newEntry, path) - continue - } else if file.Mode.IsRegular() { - newEntry := &diffEntry{content: string(file.Data), mTime: file.ModTime, isWritten: s.fs.writtenFiles.Has(path)} - snap[path] = newEntry - s.addFsEntryDiff(diffs, newEntry, path) - } - } - if s.serializedDiff != nil { - for path := range s.serializedDiff.snap { - if fileInfo := s.mapFs().GetFileInfo(path); fileInfo == nil { - // report deleted - s.addFsEntryDiff(diffs, nil, path) - } - } - } - var defaultLibs collections.SyncSet[string] - if s.fs.defaultLibs != nil { - s.fs.defaultLibs.Range(func(libPath string) bool { - defaultLibs.Add(libPath) - return true - }) - } - s.serializedDiff = &snapshot{ - snap: snap, - defaultLibs: &defaultLibs, - } - diffKeys := slices.Collect(maps.Keys(diffs)) - slices.Sort(diffKeys) - for _, path := range diffKeys { - fmt.Fprint(baseline, "//// ["+path+"] ", diffs[path], "\n") - } - fmt.Fprintln(baseline) - s.fs.writtenFiles = collections.SyncSet[string]{} // Reset written files after baseline -} - -func (s *testSys) addFsEntryDiff(diffs map[string]string, newDirContent *diffEntry, path string) { - var oldDirContent *diffEntry - var defaultLibs *collections.SyncSet[string] - if s.serializedDiff != nil { - oldDirContent = s.serializedDiff.snap[path] - defaultLibs = s.serializedDiff.defaultLibs - } - // todo handle more cases of fs changes - if oldDirContent == nil { - if s.fs.defaultLibs == nil || !s.fs.defaultLibs.Has(path) { - if newDirContent.symlinkTarget != "" { - diffs[path] = "-> " + newDirContent.symlinkTarget + " *new*" - } else { - diffs[path] = "*new* \n" + newDirContent.content - } - } - } else if newDirContent == nil { - diffs[path] = "*deleted*" - } else if newDirContent.content != oldDirContent.content { - diffs[path] = "*modified* \n" + newDirContent.content - } else if newDirContent.isWritten { - diffs[path] = "*rewrite with same content*" - } else if newDirContent.mTime != oldDirContent.mTime { - diffs[path] = "*mTime changed*" - } else if defaultLibs != nil && defaultLibs.Has(path) && s.fs.defaultLibs != nil && !s.fs.defaultLibs.Has(path) { - // Lib file that was read - diffs[path] = "*Lib*\n" + newDirContent.content - } +func (s *TestSys) baselineFSwithDiff(baseline io.Writer) { + s.fsDiffer.BaselineFSwithDiff(baseline) } -func (s *testSys) writeFileNoError(path string, content string, writeByteOrderMark bool) { +func (s *TestSys) writeFileNoError(path string, content string, writeByteOrderMark bool) { if err := s.fsFromFileMap().WriteFile(path, content, writeByteOrderMark); err != nil { panic(err) } } -func (s *testSys) removeNoError(path string) { +func (s *TestSys) removeNoError(path string) { if err := s.fsFromFileMap().Remove(path); err != nil { panic(err) } } -func (s *testSys) readFileNoError(path string) string { +func (s *TestSys) readFileNoError(path string) string { content, ok := s.fsFromFileMap().ReadFile(path) if !ok { panic("File not found: " + path) @@ -599,29 +539,29 @@ func (s *testSys) readFileNoError(path string) string { return content } -func (s *testSys) renameFileNoError(oldPath string, newPath string) { +func (s *TestSys) renameFileNoError(oldPath string, newPath string) { s.writeFileNoError(newPath, s.readFileNoError(oldPath), false) s.removeNoError(oldPath) } -func (s *testSys) replaceFileText(path string, oldText string, newText string) { +func (s *TestSys) replaceFileText(path string, oldText string, newText string) { content := s.readFileNoError(path) content = strings.Replace(content, oldText, newText, 1) s.writeFileNoError(path, content, false) } -func (s *testSys) replaceFileTextAll(path string, oldText string, newText string) { +func (s *TestSys) replaceFileTextAll(path string, oldText string, newText string) { content := s.readFileNoError(path) content = strings.ReplaceAll(content, oldText, newText) s.writeFileNoError(path, content, false) } -func (s *testSys) appendFile(path string, text string) { +func (s *TestSys) appendFile(path string, text string) { content := s.readFileNoError(path) s.writeFileNoError(path, content+text, false) } -func (s *testSys) prependFile(path string, text string) { +func (s *TestSys) prependFile(path string, text string) { content := s.readFileNoError(path) s.writeFileNoError(path, text+content, false) } diff --git a/internal/execute/tsctests/tsc_test.go b/internal/execute/tsctests/tsc_test.go index 31f0f94911..e618ce7829 100644 --- a/internal/execute/tsctests/tsc_test.go +++ b/internal/execute/tsctests/tsc_test.go @@ -36,6 +36,60 @@ func TestTscCommandline(t *testing.T) { subScenario: "when build not first argument", commandLineArgs: []string{"--verbose", "--build"}, }, + { + subScenario: "Initialized TSConfig with files options", + commandLineArgs: []string{"--init", "file0.st", "file1.ts", "file2.ts"}, + }, + { + subScenario: "Initialized TSConfig with boolean value compiler options", + commandLineArgs: []string{"--init", "--noUnusedLocals"}, + }, + { + subScenario: "Initialized TSConfig with enum value compiler options", + commandLineArgs: []string{"--init", "--target", "es5", "--jsx", "react"}, + }, + { + subScenario: "Initialized TSConfig with list compiler options", + commandLineArgs: []string{"--init", "--types", "jquery,mocha"}, + }, + { + subScenario: "Initialized TSConfig with list compiler options with enum value", + commandLineArgs: []string{"--init", "--lib", "es5,es2015.core"}, + }, + { + subScenario: "Initialized TSConfig with incorrect compiler option", + commandLineArgs: []string{"--init", "--someNonExistOption"}, + }, + { + subScenario: "Initialized TSConfig with incorrect compiler option value", + commandLineArgs: []string{"--init", "--lib", "nonExistLib,es5,es2015.promise"}, + }, + { + subScenario: "Initialized TSConfig with advanced options", + commandLineArgs: []string{"--init", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"}, + }, + { + subScenario: "Initialized TSConfig with --help", + commandLineArgs: []string{"--init", "--help"}, + }, + { + subScenario: "Initialized TSConfig with --watch", + commandLineArgs: []string{"--init", "--watch"}, + }, + { + subScenario: "Initialized TSConfig with tsconfig.json", + commandLineArgs: []string{"--init"}, + files: FileMap{ + "/home/src/workspaces/project/first.ts": `export const a = 1`, + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "strict": true, + "noEmit": true + } + }`), + }, + }, { subScenario: "help", commandLineArgs: []string{"--help"}, @@ -151,6 +205,14 @@ func TestTscCommandline(t *testing.T) { }, commandLineArgs: []string{"-p", "."}, }, + { + subScenario: "locale", + commandLineArgs: []string{"--locale", "cs", "--version"}, + }, + { + subScenario: "bad locale", + commandLineArgs: []string{"--locale", "whoops", "--version"}, + }, } for _, testCase := range testCases { @@ -251,7 +313,7 @@ func TestTscComposite(t *testing.T) { edits: []*tscEdit{ { caption: "convert to modules", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/tsconfig.json", "none", "es2015") }, }, @@ -895,7 +957,7 @@ func TestTscExtends(t *testing.T) { getTscExtendsConfigDirTestCase("", []string{"--b", "-w", "--explainFiles", "--v"}, []*tscEdit{ { caption: "edit extended config file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError( "/home/src/projects/configs/first/tsconfig.json", stringtestutil.Dedent(` @@ -919,6 +981,59 @@ func TestTscExtends(t *testing.T) { } } +func TestTscIgnoreConfig(t *testing.T) { + t.Parallel() + filesWithoutConfig := func() FileMap { + return FileMap{ + "/home/src/workspaces/project/src/a.ts": "export const a = 10;", + "/home/src/workspaces/project/src/b.ts": "export const b = 10;", + "/home/src/workspaces/project/c.ts": "export const c = 10;", + } + } + filesWithConfig := func() FileMap { + files := filesWithoutConfig() + files["/home/src/workspaces/project/tsconfig.json"] = stringtestutil.Dedent(` + { + "include": ["src"], + }`) + return files + } + getScenarios := func(subScenario string, commandLineArgs []string) []*tscInput { + commandLineArgsIgnoreConfig := append(commandLineArgs, "--ignoreConfig") + return []*tscInput{ + { + subScenario: subScenario, + files: filesWithConfig(), + commandLineArgs: commandLineArgs, + }, + { + subScenario: subScenario + " with --ignoreConfig", + files: filesWithConfig(), + commandLineArgs: commandLineArgsIgnoreConfig, + }, + { + subScenario: subScenario + " when config file absent", + files: filesWithoutConfig(), + commandLineArgs: commandLineArgs, + }, + { + subScenario: subScenario + " when config file absent with --ignoreConfig", + files: filesWithoutConfig(), + commandLineArgs: commandLineArgsIgnoreConfig, + }, + } + } + testCases := slices.Concat( + getScenarios("without any options", nil), + getScenarios("specifying files", []string{"src/a.ts"}), + getScenarios("specifying project", []string{"-p", "."}), + getScenarios("mixing project and files", []string{"-p", ".", "src/a.ts", "c.ts"}), + ) + for _, test := range testCases { + test.run(t, "ignoreConfig") + } +} + func TestTscIncremental(t *testing.T) { t.Parallel() getConstEnumTest := func(bdsContents string, changeEnumFile string, testSuffix string) *tscInput { @@ -945,25 +1060,25 @@ func TestTscIncremental(t *testing.T) { edits: []*tscEdit{ { caption: "change enum value", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(changeEnumFile, "1", "2") }, }, { caption: "change enum value again", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(changeEnumFile, "2", "3") }, }, { caption: "something else changes in b.d.ts", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/b.d.ts", "export const randomThing = 10;") }, }, { caption: "something else changes in b.d.ts again", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/b.d.ts", "export const randomThing2 = 10;") }, }, @@ -1048,14 +1163,14 @@ func TestTscIncremental(t *testing.T) { noChange, { caption: "modify public to protected", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "public", "protected") }, }, noChange, { caption: "modify protected to public", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "protected", "public") }, }, @@ -1094,14 +1209,14 @@ func TestTscIncremental(t *testing.T) { noChange, { caption: "modify public to protected", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "public", "protected") }, }, noChange, { caption: "modify protected to public", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/MessageablePerson.ts", "protected", "public") }, }, @@ -1153,7 +1268,7 @@ func TestTscIncremental(t *testing.T) { noChange, { caption: "modify d.ts file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/src/main.d.ts", "export const xy = 100;") }, }, @@ -1185,7 +1300,7 @@ func TestTscIncremental(t *testing.T) { edits: []*tscEdit{ { caption: "tsbuildinfo written has error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string") }, }, @@ -1216,19 +1331,19 @@ func TestTscIncremental(t *testing.T) { noChange, { caption: "Modify main file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `something();`) }, }, { caption: "Modify main file again", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `something();`) }, }, { caption: "Add new file and update main file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/home/src/workspaces/project/src/newFile.ts`, "function foo() { return 20; }", false) sys.prependFile( `/home/src/workspaces/project/src/main.ts`, @@ -1240,13 +1355,13 @@ func TestTscIncremental(t *testing.T) { }, { caption: "Write file that could not be resolved", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/home/src/workspaces/project/src/fileNotFound.ts`, "function something2() { return 20; }", false) }, }, { caption: "Modify main file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile(`/home/src/workspaces/project/src/main.ts`, `something();`) }, }, @@ -1327,7 +1442,7 @@ func TestTscIncremental(t *testing.T) { edits: []*tscEdit{ { caption: "Modify imports used in global file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/constants.ts", "export default 2;", false) }, expectedDiff: "Currently there is issue with d.ts emit for export default = 1 to widen in dts which is why we are not re-computing errors and results in incorrect error reporting", @@ -1353,7 +1468,7 @@ func TestTscIncremental(t *testing.T) { edits: []*tscEdit{ { caption: "Modify imports used in global file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/constants.ts", "export default 2;", false) }, expectedDiff: "Currently there is issue with d.ts emit for export default = 1 to widen in dts which is why we are not re-computing errors and results in incorrect error reporting", @@ -1376,7 +1491,7 @@ func TestTscIncremental(t *testing.T) { edits: []*tscEdit{ { caption: "delete file with imports", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/file2.ts") }, }, @@ -1428,7 +1543,7 @@ func TestTscIncremental(t *testing.T) { edits: []*tscEdit{ { caption: "modify js file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/src/bug.js", `export const something = 1;`) }, }, @@ -1495,7 +1610,7 @@ func TestTscIncremental(t *testing.T) { noChange, { caption: "local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/a.ts", "Local = 1", "Local = 10") }, }, @@ -1517,7 +1632,7 @@ func TestTscIncremental(t *testing.T) { }, { caption: "declarationMap enabling", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/tsconfig.json", `"composite": true,`, `"composite": true, "declarationMap": true`) }, }, @@ -1566,7 +1681,7 @@ func TestTscIncremental(t *testing.T) { }, { caption: "local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/a.ts", "Local = 1", "Local = 10") }, }, @@ -2239,7 +2354,7 @@ func TestTscModuleResolution(t *testing.T) { edits: []*tscEdit{ { caption: "Delete package.json", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/package.json") }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2291,7 +2406,7 @@ func TestTscModuleResolution(t *testing.T) { edits: []*tscEdit{ { caption: "delete the alternateResult in @types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/projects/project/node_modules/@types/bar/index.d.ts") }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2299,7 +2414,7 @@ func TestTscModuleResolution(t *testing.T) { }, { caption: "delete the node10Result in package/types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/projects/project/node_modules/foo/index.d.ts") }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2307,7 +2422,7 @@ func TestTscModuleResolution(t *testing.T) { }, { caption: "add the alternateResult in @types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/@types/bar/index.d.ts", getTscModuleResolutionAlternateResultDts("bar"), false) }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2315,37 +2430,37 @@ func TestTscModuleResolution(t *testing.T) { }, { caption: "add the alternateResult in package/types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/foo/index.d.ts", getTscModuleResolutionAlternateResultDts("foo"), false) }, }, { caption: "update package.json from @types so error is fixed", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/@types/bar/package.json", getTscModuleResolutionAlternateResultAtTypesPackageJson("bar" /*addTypesCondition*/, true), false) }, }, { caption: "update package.json so error is fixed", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/foo/package.json", getTscModuleResolutionAlternateResultPackageJson("foo" /*addTypes*/, true /*addTypesCondition*/, true), false) }, }, { caption: "update package.json from @types so error is introduced", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/@types/bar2/package.json", getTscModuleResolutionAlternateResultAtTypesPackageJson("bar2" /*addTypesCondition*/, false), false) }, }, { caption: "update package.json so error is introduced", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/foo2/package.json", getTscModuleResolutionAlternateResultPackageJson("foo2" /*addTypes*/, true /*addTypesCondition*/, false), false) }, }, { caption: "delete the alternateResult in @types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/projects/project/node_modules/@types/bar2/index.d.ts") }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2353,7 +2468,7 @@ func TestTscModuleResolution(t *testing.T) { }, { caption: "delete the node10Result in package/types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/projects/project/node_modules/foo2/index.d.ts") }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2361,7 +2476,7 @@ func TestTscModuleResolution(t *testing.T) { }, { caption: "add the alternateResult in @types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/@types/bar2/index.d.ts", getTscModuleResolutionAlternateResultDts("bar2"), false) }, // !!! repopulateInfo on diagnostics not yet implemented @@ -2369,7 +2484,7 @@ func TestTscModuleResolution(t *testing.T) { }, { caption: "add the ndoe10Result in package/types", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/node_modules/foo2/index.d.ts", getTscModuleResolutionAlternateResultDts("foo2"), false) }, }, @@ -2416,7 +2531,7 @@ func TestTscModuleResolution(t *testing.T) { edits: []*tscEdit{ { caption: "Append text", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile(`/user/username/projects/myproject/project1/index.ts`, "const bar = 10;") }, }, @@ -2468,27 +2583,27 @@ func TestTscModuleResolution(t *testing.T) { edits: []*tscEdit{ { caption: "reports import errors after change to package file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"module"`, `"commonjs"`) }, expectedDiff: "Package.json watch pending, so no change detected yet", }, { caption: "removes those errors when a package file is changed back", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"commonjs"`, `"module"`) }, }, { caption: "reports import errors after change to package file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"module"`, `"commonjs"`) }, expectedDiff: "Package.json watch pending, so no change detected yet", }, { caption: "removes those errors when a package file is changed to cjs extensions", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `"build/index.js"`, `"build/index.cjs"`) sys.renameFileNoError(`/user/username/projects/myproject/packages/pkg2/index.ts`, `/user/username/projects/myproject/packages/pkg2/index.cts`) }, @@ -2537,14 +2652,14 @@ func TestTscModuleResolution(t *testing.T) { edits: []*tscEdit{ { caption: "reports import errors after change to package file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `index.js`, `other.js`) }, expectedDiff: "Package.json watch pending, so no change detected yet", }, { caption: "removes those errors when a package file is changed back", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `other.js`, `index.js`) }, }, @@ -2626,13 +2741,13 @@ func TestTscNoCheck(t *testing.T) { } fixErrorNoCheck := &tscEdit{ caption: "Fix `a` error with noCheck", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/a.ts", `export const a = "hello";`, false) }, } addErrorNoCheck := &tscEdit{ caption: "Introduce error with noCheck", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/a.ts", scenario.aText, false) }, } @@ -2664,7 +2779,7 @@ func TestTscNoCheck(t *testing.T) { noChangeWithCheck, // Should check errors and update buildInfo { caption: "Add file with error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/c.ts", `export const c: number = "hello";`, false) }, commandLineArgs: commandLineArgs, @@ -2787,7 +2902,7 @@ func TestTscNoEmit(t *testing.T) { noChange, { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/a.ts", fixedATsContent, false) }, }, @@ -2799,7 +2914,7 @@ func TestTscNoEmit(t *testing.T) { noChange, { caption: "Introduce error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/a.ts", scenario.aText, false) }, }, @@ -2824,37 +2939,37 @@ func TestTscNoEmit(t *testing.T) { return []*tscEdit{ { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/a.ts", fixedATsContent, false) }, }, { caption: "Emit after fixing error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/projects/project/tsconfig.json", `"noEmit": true`, `"noEmit": false`) }, }, { caption: "no Emit run after fixing error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/projects/project/tsconfig.json", `"noEmit": false`, `"noEmit": true`) }, }, { caption: "Introduce error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/projects/project/a.ts", scenario.aText, false) }, }, { caption: "Emit when error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/projects/project/tsconfig.json", `"noEmit": true`, `"noEmit": false`) }, }, { caption: "no Emit run when error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/projects/project/tsconfig.json", `"noEmit": false`, `"noEmit": true`) }, }, @@ -2920,10 +3035,10 @@ func TestTscNoEmit(t *testing.T) { caption: "No Change run with emit", commandLineArgs: commandLineArgs, } - introduceError := func(sys *testSys) { + introduceError := func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/src/class.ts", "prop", "prop1") } - fixError := func(sys *testSys) { + fixError := func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/src/class.ts", "prop1", "prop") } testCases := make([]*tscInput, 0, len(noEmitChangesScenarios)) @@ -3025,7 +3140,7 @@ func TestTscNoEmit(t *testing.T) { }, { caption: "Fix the error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/projects/project/a.ts", "private", "public") }, }, @@ -3089,7 +3204,7 @@ func TestTscNoEmit(t *testing.T) { []*tscEdit{ { caption: "Fix the another ", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/projects/project/c.ts", "private", "public") }, commandLineArgs: slices.Concat(commandLineArgs, []string{"--noEmit", "--declaration", "--declarationMap"}), @@ -3118,13 +3233,13 @@ func TestTscNoEmit(t *testing.T) { edits: []*tscEdit{ { caption: "No change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/user/username/projects/myproject/a.js`, sys.readFileNoError(`/user/username/projects/myproject/a.js`), false) }, }, { caption: "change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/user/username/projects/myproject/a.js`, "const x = 10;", false) }, }, @@ -3203,7 +3318,7 @@ func TestTscNoEmitOnError(t *testing.T) { noChange, { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/noEmitOnError/src/main.ts", scenario.fixedErrorContent, false) }, }, @@ -3249,7 +3364,7 @@ func TestTscNoEmitOnError(t *testing.T) { if edits != nil { edits = append(edits, &tscEdit{ caption: scenario.subScenario, - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/user/username/projects/noEmitOnError/src/main.ts`, scenario.mainErrorContent, false) }, }) @@ -3257,19 +3372,19 @@ func TestTscNoEmitOnError(t *testing.T) { edits = append(edits, &tscEdit{ caption: "No Change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFileNoError(`/user/username/projects/noEmitOnError/src/main.ts`), false) }, }, &tscEdit{ caption: "Fix " + scenario.subScenario, - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/noEmitOnError/src/main.ts", scenario.fixedErrorContent, false) }, }, &tscEdit{ caption: "No Change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFileNoError(`/user/username/projects/noEmitOnError/src/main.ts`), false) }, }, @@ -3363,14 +3478,14 @@ func TestTscNoEmitOnError(t *testing.T) { edits: []*tscEdit{ { caption: "error and enable declarationMap", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/a.ts", "x", "x: 20") }, commandLineArgs: []string{"--declarationMap"}, }, { caption: "fix error declarationMap", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/a.ts", "x: 20", "x") }, commandLineArgs: []string{"--declarationMap"}, @@ -3394,7 +3509,7 @@ func TestTscNoEmitOnError(t *testing.T) { edits: []*tscEdit{ { caption: "delete file without error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/file2.ts") }, }, diff --git a/internal/execute/tsctests/tscbuild_test.go b/internal/execute/tsctests/tscbuild_test.go index 5c7a91b293..4c556a459e 100644 --- a/internal/execute/tsctests/tscbuild_test.go +++ b/internal/execute/tsctests/tscbuild_test.go @@ -65,13 +65,13 @@ func TestBuildCommandLine(t *testing.T) { noChange, { caption: "local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/a.ts", "const aa = 10;") }, }, { caption: "non local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/a.ts", "export const aaa = 10;") }, }, @@ -82,26 +82,26 @@ func TestBuildCommandLine(t *testing.T) { noChange, { caption: "js emit with change without emitDeclarationOnly", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/b.ts", "const alocal = 10;") }, commandLineArgs: []string{"--b", "project2/src", "--verbose"}, }, { caption: "local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/b.ts", "const aaaa = 10;") }, }, { caption: "non local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/b.ts", "export const aaaaa = 10;") }, }, { caption: "js emit with change without emitDeclarationOnly", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/b.ts", "export const a2 = 10;") }, commandLineArgs: []string{"--b", "project2/src", "--verbose"}, @@ -117,7 +117,7 @@ func TestBuildCommandLine(t *testing.T) { noChange, { caption: "change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/a.ts", "const aa = 10;") }, }, @@ -132,7 +132,7 @@ func TestBuildCommandLine(t *testing.T) { }, { caption: "js emit with change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/project1/src/b.ts", "const blocal = 10;") }, commandLineArgs: []string{"--b", "project2/src", "--verbose", "--emitDeclarationOnly", "false"}, @@ -148,6 +148,16 @@ func TestBuildCommandLine(t *testing.T) { files: FileMap{}, commandLineArgs: []string{"--build", "--help"}, }, + { + subScenario: "locale", + files: FileMap{}, + commandLineArgs: []string{"--build", "--help", "--locale", "en"}, + }, + { + subScenario: "bad locale", + files: FileMap{}, + commandLineArgs: []string{"--build", "--help", "--locale", "whoops"}, + }, { subScenario: "different options", files: getBuildCommandLineDifferentOptionsMap("composite"), @@ -179,7 +189,7 @@ func TestBuildCommandLine(t *testing.T) { noChange, { caption: "local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/a.ts", "Local = 1", "Local = 10") }, }, @@ -220,7 +230,7 @@ func TestBuildCommandLine(t *testing.T) { noChange, { caption: "local change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/a.ts", "Local = 1", "Local = 10") }, }, @@ -357,20 +367,20 @@ func TestBuildConfigFileErrors(t *testing.T) { edits: []*tscEdit{ { caption: "reports syntax errors after change to config file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/tsconfig.json", ",", `, "declaration": true`) }, }, { caption: "reports syntax errors after change to ts file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/a.ts", "export function fooBar() { }") }, }, noChange, { caption: "builds after fixing config file errors", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", stringtestutil.Dedent(` { "compilerOptions": { @@ -410,25 +420,25 @@ func TestBuildConfigFileErrors(t *testing.T) { edits: []*tscEdit{ { caption: "reports syntax errors after change to config file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/tsconfig.json", ",", `, "declaration": true`) }, }, { caption: "reports syntax errors after change to ts file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/a.ts", "export function fooBar() { }") }, }, { caption: "reports error when there is no change to tsconfig file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/tsconfig.json", "", "") }, }, { caption: "builds after fixing config file errors", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", stringtestutil.Dedent(` { "compilerOptions": { @@ -698,7 +708,7 @@ func TestBuildDemoProject(t *testing.T) { edits: []*tscEdit{ { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/demo/core/tsconfig.json", stringtestutil.Dedent(` { "extends": "../tsconfig-base.json", @@ -724,7 +734,7 @@ func TestBuildDemoProject(t *testing.T) { edits: []*tscEdit{ { caption: "Prepend a line", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.prependFile("/user/username/projects/demo/core/utilities.ts", "\n") }, }, @@ -806,7 +816,7 @@ func TestBuildEmitDeclarationOnly(t *testing.T) { edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/src/a.ts", "b: B;", "b: B; foo: any;") }, }, @@ -823,7 +833,7 @@ func TestBuildEmitDeclarationOnly(t *testing.T) { edits: []*tscEdit{ { caption: "incremental-declaration-doesnt-change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText( "/home/src/workspaces/project/src/a.ts", "export interface A {", @@ -835,7 +845,7 @@ func TestBuildEmitDeclarationOnly(t *testing.T) { }, { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/src/a.ts", "b: B;", "b: B; foo: any;") }, }, @@ -887,7 +897,7 @@ func TestBuildFileDelete(t *testing.T) { edits: []*tscEdit{ { caption: "delete child2 file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/solution/child/child2.ts") sys.removeNoError("/home/src/workspaces/solution/child/child2.js") sys.removeNoError("/home/src/workspaces/solution/child/child2.d.ts") @@ -919,7 +929,7 @@ func TestBuildFileDelete(t *testing.T) { edits: []*tscEdit{ { caption: "delete child2 file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/solution/child/child2.ts") sys.removeNoError("/home/src/workspaces/solution/child/child2.js") }, @@ -999,13 +1009,13 @@ func TestBuildInferredTypeFromTransitiveModule(t *testing.T) { edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "param: string", "") }, }, { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "foobar()", "foobar(param: string)") }, }, @@ -1018,13 +1028,13 @@ func TestBuildInferredTypeFromTransitiveModule(t *testing.T) { edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "param: string", "") }, }, { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "foobar()", "foobar(param: string)") }, }, @@ -1040,25 +1050,25 @@ func TestBuildInferredTypeFromTransitiveModule(t *testing.T) { edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "param: string", "") }, }, { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "foobar()", "foobar(param: string)") }, }, { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/bar.ts", "param: string", "") }, }, { caption: "Fix Error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/lazyIndex.ts", `bar("hello")`, "bar()") }, }, @@ -1295,13 +1305,13 @@ func TestBuildLateBoundSymbol(t *testing.T) { edits: []*tscEdit{ { caption: "incremental-declaration-doesnt-change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/project/src/main.ts", "const x = 10;", "") }, }, { caption: "incremental-declaration-doesnt-change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/src/main.ts", "const x = 10;") }, }, @@ -1675,14 +1685,14 @@ func TestBuildProgramUpdates(t *testing.T) { { caption: "Introduce error", // Change message in library to message2 - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileTextAll("/user/username/projects/sample1/Library/library.ts", "message", "message2") }, }, { caption: "Fix error", // Revert library changes - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileTextAll("/user/username/projects/sample1/Library/library.ts", "message2", "message") }, }, @@ -1710,7 +1720,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/solution/app/fileWithError.ts", "private p = 12", "") }, }, @@ -1738,7 +1748,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Change fileWithoutError", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileTextAll("/user/username/projects/solution/app/fileWithoutError.ts", "myClass", "myClass2") }, }, @@ -1766,7 +1776,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Introduce error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/solution/app/fileWithError.ts", stringtestutil.Dedent(` export var myClassWithError = class { tags() { } @@ -1777,7 +1787,7 @@ func TestBuildProgramUpdates(t *testing.T) { }, { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/solution/app/fileWithError.ts", "private p = 12", "") }, }, @@ -1805,7 +1815,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Introduce error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/solution/app/fileWithError.ts", stringtestutil.Dedent(` export var myClassWithError = class { tags() { } @@ -1816,7 +1826,7 @@ func TestBuildProgramUpdates(t *testing.T) { }, { caption: "Change fileWithoutError", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileTextAll("/user/username/projects/solution/app/fileWithoutError.ts", "myClass", "myClass2") }, }, @@ -1839,7 +1849,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Change tsconfig to set noUnusedParameters to false", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError( `/user/username/projects/myproject/tsconfig.json`, stringtestutil.Dedent(` @@ -1924,7 +1934,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Modify alpha config", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/alpha.tsconfig.json", stringtestutil.Dedent(` { "compilerOptions": { @@ -1935,7 +1945,7 @@ func TestBuildProgramUpdates(t *testing.T) { }, { caption: "change bravo config", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/bravo.tsconfig.json", stringtestutil.Dedent(` { "extends": "./alpha.tsconfig.json", @@ -1945,22 +1955,23 @@ func TestBuildProgramUpdates(t *testing.T) { }, { caption: "project 2 extends alpha", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/project2.tsconfig.json", stringtestutil.Dedent(` { "extends": "./alpha.tsconfig.json", + "files": ["other.ts"] }`), false) }, }, { caption: "update aplha config", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/alpha.tsconfig.json", "{}", false) }, }, { caption: "Modify extendsConfigFile2", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/extendsConfig2.tsconfig.json", stringtestutil.Dedent(` { "compilerOptions": { "strictNullChecks": true } @@ -1969,7 +1980,7 @@ func TestBuildProgramUpdates(t *testing.T) { }, { caption: "Modify project 3", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/project3.tsconfig.json", stringtestutil.Dedent(` { "extends": ["./extendsConfig1.tsconfig.json", "./extendsConfig2.tsconfig.json"], @@ -1980,7 +1991,7 @@ func TestBuildProgramUpdates(t *testing.T) { }, { caption: "Delete extendedConfigFile2 and report error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/user/username/projects/project/extendsConfig2.tsconfig.json") }, }, @@ -2038,7 +2049,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "Remove project2 from base config", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/project/tsconfig.json", stringtestutil.Dedent(` { "references": [ @@ -2083,7 +2094,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "dts doesnt change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/lib/foo.ts", "const Bar = 10;") }, }, @@ -2114,7 +2125,7 @@ func TestBuildProgramUpdates(t *testing.T) { edits: []*tscEdit{ { caption: "dts doesnt change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/project/lib/foo.ts", "const Bar = 10;") }, }, @@ -2167,14 +2178,14 @@ func TestBuildProjectsBuilding(t *testing.T) { edits := []*tscEdit{ { caption: "dts doesn't change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`) }, }, noChange, { caption: "dts change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`) }, }, @@ -2412,13 +2423,13 @@ func TestBuildReexport(t *testing.T) { edits: []*tscEdit{ { caption: "Introduce error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/reexport/src/pure/session.ts`, "// ", "") }, }, { caption: "Fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText(`/user/username/projects/reexport/src/pure/session.ts`, "bar: ", "// bar: ") }, }, @@ -2692,14 +2703,14 @@ func TestBuildRoots(t *testing.T) { noChange, { caption: "edit logging file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/home/src/workspaces/solution/projects/shared/src/logging.ts", "export const x = 10;") }, }, noChange, { caption: "delete random file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/solution/projects/shared/src/random.ts") }, }, @@ -2722,7 +2733,7 @@ func TestBuildRoots(t *testing.T) { edits: []*tscEdit{ { caption: "delete file1", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/file1.ts") sys.removeNoError("/home/src/workspaces/project/file1.js") sys.removeNoError("/home/src/workspaces/project/file1.d.ts") @@ -2747,7 +2758,7 @@ func TestBuildRoots(t *testing.T) { edits: []*tscEdit{ { caption: "delete file1", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/file1.ts") sys.removeNoError("/home/src/workspaces/project/file1.js") sys.removeNoError("/home/src/workspaces/project/file1.d.ts") @@ -2774,7 +2785,7 @@ func TestBuildRoots(t *testing.T) { edits: []*tscEdit{ { caption: "delete file1", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/file1.ts") sys.removeNoError("/home/src/workspaces/project/file1.js") sys.removeNoError("/home/src/workspaces/project/file1.d.ts") @@ -2814,7 +2825,7 @@ func TestBuildRoots(t *testing.T) { edits: []*tscEdit{ { caption: "delete file1", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.removeNoError("/home/src/workspaces/project/file1.ts") sys.removeNoError("/home/src/workspaces/project/file1.js") sys.removeNoError("/home/src/workspaces/project/file1.d.ts") @@ -2947,7 +2958,7 @@ func TestBuildSample(t *testing.T) { []*tscEdit{ { caption: "fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/index.ts", "multiply();", "") }, }, @@ -2979,7 +2990,7 @@ func TestBuildSample(t *testing.T) { []*tscEdit{ { caption: "fix error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/index.ts", "multiply();", "") }, }, @@ -2992,7 +3003,7 @@ func TestBuildSample(t *testing.T) { return []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile( "/user/username/projects/sample1/core/index.ts", ` @@ -3002,7 +3013,7 @@ export class someClass { }`, }, { caption: "incremental-declaration-doesnt-change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile( "/user/username/projects/sample1/core/index.ts", ` @@ -3017,19 +3028,19 @@ class someClass2 { }`, return []*tscEdit{ { caption: "Make change to core", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/user/username/projects/sample1/core/index.ts", "\nexport class someClass { }") }, }, { caption: "Revert core file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/index.ts", "\nexport class someClass { }", "") }, }, { caption: "Make two changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/user/username/projects/sample1/core/index.ts", "\nexport class someClass { }") sys.appendFile("/user/username/projects/sample1/core/index.ts", "\nexport class someClass2 { }") }, @@ -3040,7 +3051,7 @@ class someClass2 { }`, return []*tscEdit{ { caption: "Make local change to core", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/user/username/projects/sample1/core/index.ts", "\nfunction foo() { }") }, }, @@ -3050,13 +3061,13 @@ class someClass2 { }`, return []*tscEdit{ { caption: "Change to new File and build core", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/core/newfile.ts", `export const newFileConst = 30;`, false) }, }, { caption: "Change to new File and build core", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/core/newfile.ts", "\nexport class someClass2 { }", false) }, }, @@ -3090,20 +3101,20 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "change logic", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/user/username/projects/sample1/logic/index.ts", "\nlet y: string = 10;") }, }, { caption: "change core", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/user/username/projects/sample1/core/index.ts", "\nlet x: string = 10;") }, expectedDiff: expectedDiffWithLogicError, }, { caption: "fix error in logic", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/logic/index.ts", "\nlet y: string = 10;", "") }, }, @@ -3203,20 +3214,20 @@ class someClass2 { }`, { // Update a file in the leaf node (tests), only it should rebuild the last one caption: "Only builds the leaf node project", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/tests/index.ts", "const m = 10;", false) }, }, { // Update a file in the parent (without affecting types), should get fast downstream builds caption: "Detects type-only changes in upstream projects", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/index.ts", "HELLO WORLD", "WELCOME PLANET") }, }, { caption: "rebuilds when tsconfig changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es2020"`) }, }, @@ -3230,7 +3241,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "upstream project changes without changing file text", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { err := sys.FS().Chtimes("/user/username/projects/sample1/core/index.ts", time.Time{}, sys.Now()) if err != nil { panic(err) @@ -3247,13 +3258,13 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "Disable declarationMap", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/tsconfig.json", `"declarationMap": true,`, `"declarationMap": false,`) }, }, { caption: "Enable declarationMap", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/tsconfig.json", `"declarationMap": false,`, `"declarationMap": true,`) }, }, @@ -3294,7 +3305,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "tsbuildinfo written has error", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { // This is to ensure the non incremental doesnt crash - as it wont have tsbuildInfo if !sys.forIncrementalCorrectness { sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string") @@ -3312,7 +3323,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "convert tsbuildInfo version to something that is say to previous version", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { // This is to ensure the non incremental doesnt crash - as it wont have tsbuildInfo if !sys.forIncrementalCorrectness { sys.replaceFileText("/user/username/projects/sample1/core/tsconfig.tsbuildinfo", fmt.Sprintf(`"version":"%s"`, harnessutil.FakeTSVersion), fmt.Sprintf(`"version":"%s"`, "FakeTsPreviousVersion")) @@ -3340,7 +3351,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "change extended file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/tests/tsconfig.base.json", stringtestutil.Dedent(` { "compilerOptions": { } @@ -3396,7 +3407,7 @@ class someClass2 { }`, []*tscEdit{ { caption: "when logic config changes declaration dir", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText( "/user/username/projects/sample1/logic/tsconfig.json", `"declaration": true,`, @@ -3440,7 +3451,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/tsconfig.json", `"incremental": true,`, `"incremental": true, "declaration": true,`) }, }, @@ -3468,7 +3479,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/tsconfig.json", `esnext`, `es5`) }, }, @@ -3490,7 +3501,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/core/tsconfig.json", `node18`, `nodenext`) }, }, @@ -3519,7 +3530,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "incremental-declaration-changes", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`) }, }, @@ -3605,7 +3616,7 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "Write logic", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/logic/tsconfig.json", getLogicConfig(), false) }, }, @@ -3622,13 +3633,13 @@ class someClass2 { }`, edits: []*tscEdit{ { caption: "Make non dts change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.appendFile("/user/username/projects/sample1/logic/index.ts", "\nfunction someFn() { }") }, }, { caption: "Make dts change", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/user/username/projects/sample1/logic/index.ts", "\nfunction someFn() { }", "\nexport function someFn() { }") }, }, @@ -3643,7 +3654,7 @@ class someClass2 { }`, noChange, { caption: "Add new file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/core/file3.ts", `export const y = 10;`, false) }, }, @@ -3667,7 +3678,7 @@ class someClass2 { }`, noChange, { caption: "Add new file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.writeFileNoError("/user/username/projects/sample1/core/file3.ts", `export const y = 10;`, false) }, }, @@ -3872,7 +3883,7 @@ func TestBuildSolutionProject(t *testing.T) { edits: []*tscEdit{ { caption: "modify project3 file", - edit: func(sys *testSys) { + edit: func(sys *TestSys) { sys.replaceFileText("/home/src/workspaces/solution/project3/src/c.ts", "c = ", "cc = ") }, }, diff --git a/internal/execute/tsctests/tscwatch_test.go b/internal/execute/tsctests/tscwatch_test.go index 58517bdb35..10344fdf29 100644 --- a/internal/execute/tsctests/tscwatch_test.go +++ b/internal/execute/tsctests/tscwatch_test.go @@ -70,29 +70,29 @@ func noEmitWatchTestInput( "/home/src/workspaces/project/tsconfig.json": tsconfigText, }, edits: []*tscEdit{ - newTscEdit("fix error", func(sys *testSys) { + newTscEdit("fix error", func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/a.ts", `const a = "hello";`, false) }), - newTscEdit("emit after fixing error", func(sys *testSys) { + newTscEdit("emit after fixing error", func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig("", optionString), false) }), - newTscEdit("no emit run after fixing error", func(sys *testSys) { + newTscEdit("no emit run after fixing error", func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig(noEmitOpt, optionString), false) }), - newTscEdit("introduce error", func(sys *testSys) { + newTscEdit("introduce error", func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/a.ts", aText, false) }), - newTscEdit("emit when error", func(sys *testSys) { + newTscEdit("emit when error", func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig("", optionString), false) }), - newTscEdit("no emit run when error", func(sys *testSys) { + newTscEdit("no emit run when error", func(sys *TestSys) { sys.writeFileNoError("/home/src/workspaces/project/tsconfig.json", toTsconfig(noEmitOpt, optionString), false) }), }, } } -func newTscEdit(name string, edit func(sys *testSys)) *tscEdit { +func newTscEdit(name string, edit func(sys *TestSys)) *tscEdit { return &tscEdit{name, []string{}, edit, ""} } diff --git a/internal/execute/watcher.go b/internal/execute/watcher.go index 1c1a97b238..03b19118a6 100644 --- a/internal/execute/watcher.go +++ b/internal/execute/watcher.go @@ -14,12 +14,13 @@ import ( ) type Watcher struct { - sys tsc.System - configFileName string - config *tsoptions.ParsedCommandLine - reportDiagnostic tsc.DiagnosticReporter - reportErrorSummary tsc.DiagnosticsReporter - testing tsc.CommandLineTesting + sys tsc.System + configFileName string + config *tsoptions.ParsedCommandLine + compilerOptionsFromCommandLine *core.CompilerOptions + reportDiagnostic tsc.DiagnosticReporter + reportErrorSummary tsc.DiagnosticsReporter + testing tsc.CommandLineTesting host compiler.CompilerHost program *incremental.Program @@ -29,13 +30,21 @@ type Watcher struct { var _ tsc.Watcher = (*Watcher)(nil) -func createWatcher(sys tsc.System, configParseResult *tsoptions.ParsedCommandLine, reportDiagnostic tsc.DiagnosticReporter, reportErrorSummary tsc.DiagnosticsReporter, testing tsc.CommandLineTesting) *Watcher { +func createWatcher( + sys tsc.System, + configParseResult *tsoptions.ParsedCommandLine, + compilerOptionsFromCommandLine *core.CompilerOptions, + reportDiagnostic tsc.DiagnosticReporter, + reportErrorSummary tsc.DiagnosticsReporter, + testing tsc.CommandLineTesting, +) *Watcher { w := &Watcher{ - sys: sys, - config: configParseResult, - reportDiagnostic: reportDiagnostic, - reportErrorSummary: reportErrorSummary, - testing: testing, + sys: sys, + config: configParseResult, + compilerOptionsFromCommandLine: compilerOptionsFromCommandLine, + reportDiagnostic: reportDiagnostic, + reportErrorSummary: reportErrorSummary, + testing: testing, // reportWatchStatus: createWatchStatusReporter(sys, configParseResult.CompilerOptions().Pretty), } if configParseResult.ConfigFile != nil { @@ -45,7 +54,7 @@ func createWatcher(sys tsc.System, configParseResult *tsoptions.ParsedCommandLin } func (w *Watcher) start() { - w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil, getTraceFromSys(w.sys, w.testing)) + w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil, getTraceFromSys(w.sys, w.config.Locale(), w.testing)) w.program = incremental.ReadBuildInfoProgram(w.config, incremental.NewBuildInfoReader(w.host), w.host) if w.testing == nil { @@ -108,7 +117,7 @@ func (w *Watcher) hasErrorsInTsConfig() bool { extendedConfigCache := &tsc.ExtendedConfigCache{} if w.configFileName != "" { // !!! need to check that this merges compileroptions correctly. This differs from non-watch, since we allow overriding of previous options - configParseResult, errors := tsoptions.GetParsedCommandLineOfConfigFile(w.configFileName, &core.CompilerOptions{}, w.sys, extendedConfigCache) + configParseResult, errors := tsoptions.GetParsedCommandLineOfConfigFile(w.configFileName, w.compilerOptionsFromCommandLine, w.sys, extendedConfigCache) if len(errors) > 0 { for _, e := range errors { w.reportDiagnostic(e) @@ -122,7 +131,7 @@ func (w *Watcher) hasErrorsInTsConfig() bool { } w.config = configParseResult } - w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(w.sys, w.testing)) + w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(w.sys, w.config.Locale(), w.testing)) return false } diff --git a/internal/format/api.go b/internal/format/api.go index f9262cd76b..7acbd9208b 100644 --- a/internal/format/api.go +++ b/internal/format/api.go @@ -146,7 +146,7 @@ func FormatOnSemicolon(ctx context.Context, sourceFile *ast.SourceFile, position } func FormatOnEnter(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange { - line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, position) + line := scanner.GetECMALineOfPosition(sourceFile, position) if line == 0 { return nil } diff --git a/internal/format/comment_test.go b/internal/format/comment_test.go index b7063bfe5d..f94799d82d 100644 --- a/internal/format/comment_test.go +++ b/internal/format/comment_test.go @@ -47,9 +47,9 @@ func TestCommentFormatting(t *testing.T) { firstFormatted := applyBulkEdits(originalText, edits) // Check that the asterisk is not corrupted - assert.Check(t, !contains(firstFormatted, "*/\n /"), "should not corrupt */ to /") - assert.Check(t, contains(firstFormatted, "*/"), "should preserve */ token") - assert.Check(t, contains(firstFormatted, "async"), "should preserve async keyword") + assert.Check(t, !strings.Contains(firstFormatted, "*/\n /"), "should not corrupt */ to /") + assert.Check(t, strings.Contains(firstFormatted, "*/"), "should preserve */ token") + assert.Check(t, strings.Contains(firstFormatted, "async"), "should preserve async keyword") // Apply formatting a second time to test stability sourceFile2 := parser.ParseSourceFile(ast.SourceFileParseOptions{ @@ -61,11 +61,183 @@ func TestCommentFormatting(t *testing.T) { secondFormatted := applyBulkEdits(firstFormatted, edits2) // Check that second formatting doesn't introduce corruption - assert.Check(t, !contains(secondFormatted, " sync x()"), "should not corrupt async to sync") - assert.Check(t, contains(secondFormatted, "async"), "should preserve async keyword on second pass") + assert.Check(t, !strings.Contains(secondFormatted, " sync x()"), "should not corrupt async to sync") + assert.Check(t, strings.Contains(secondFormatted, "async"), "should preserve async keyword on second pass") + }) + + t.Run("format JSDoc with tab indentation", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Original code with tab indentation (tabs represented as \t) + originalText := "class Foo {\n\t/**\n\t * @param {string} argument - This is a param description.\n\t */\n\texample(argument) {\nconsole.log(argument);\n\t}\n}" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // Check that tabs come before spaces (not spaces before tabs) + // The comment lines should have format: tab followed by space and asterisk + // NOT: space followed by tab and asterisk + assert.Check(t, !strings.Contains(formatted, " \t*"), "should not have space before tab before asterisk") + assert.Check(t, strings.Contains(formatted, "\t *"), "should have tab before space before asterisk") + + // Verify console.log is properly indented with tabs + assert.Check(t, strings.Contains(formatted, "\t\tconsole.log"), "console.log should be indented with two tabs") + }) + + t.Run("format comment inside multi-line argument list", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Original code with proper indentation + originalText := "console.log(\n\t\"a\",\n\t// the second arg\n\t\"b\"\n);" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // The comment should remain indented with a tab + assert.Check(t, strings.Contains(formatted, "\t// the second arg"), "comment should be indented with tab") + // The comment should not lose its indentation + assert.Check(t, !strings.Contains(formatted, "\n// the second arg"), "comment should not lose indentation") + }) + + t.Run("format comment in chained method calls", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Original code with proper indentation + originalText := "foo\n\t.bar()\n\t// A second call\n\t.baz();" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // The comment should remain indented + assert.Check(t, strings.Contains(formatted, "\t// A second call") || strings.Contains(formatted, " // A second call"), "comment should be indented") + // The comment should not lose its indentation + assert.Check(t, !strings.Contains(formatted, "\n// A second call"), "comment should not lose indentation") + }) + + // Regression test for issue #1928 - panic when formatting chained method call with comment + t.Run("format chained method call with comment (issue #1928)", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // This code previously caused a panic with "strings: negative Repeat count" + // because tokenIndentation was -1 and was being used directly for indentation + originalText := "foo\n\t.bar()\n\t// A second call\n\t.baz();" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting - should not panic + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // Verify the comment maintains proper indentation and doesn't lose it + assert.Check(t, strings.Contains(formatted, "\t// A second call") || strings.Contains(formatted, " // A second call"), "comment should be indented") + assert.Check(t, !strings.Contains(formatted, "\n// A second call"), "comment should not be at column 0") }) } -func contains(s, substr string) bool { - return len(substr) > 0 && strings.Contains(s, substr) +func TestSliceBoundsPanic(t *testing.T) { + t.Parallel() + + t.Run("format code with trailing semicolon should not panic", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: true, + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Code from the issue that causes slice bounds panic + originalText := `const _enableDisposeWithListenerWarning = false + // || Boolean("TRUE") // causes a linter warning so that it cannot be pushed + ; +` + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // This should not panic + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // Basic sanity checks + assert.Check(t, len(formatted) > 0, "formatted text should not be empty") + assert.Check(t, strings.Contains(formatted, "_enableDisposeWithListenerWarning"), "should preserve variable name") + }) } diff --git a/internal/format/context.go b/internal/format/context.go index aae5b935bf..bb059e45a4 100644 --- a/internal/format/context.go +++ b/internal/format/context.go @@ -85,7 +85,7 @@ func GetDefaultFormatCodeSettings(newLineCharacter string) *FormatCodeSettings { } } -type formattingContext struct { +type FormattingContext struct { currentTokenSpan TextRangeWithKind nextTokenSpan TextRangeWithKind contextNode *ast.Node @@ -105,8 +105,8 @@ type formattingContext struct { scanner *scanner.Scanner } -func NewFormattingContext(file *ast.SourceFile, kind FormatRequestKind, options *FormatCodeSettings) *formattingContext { - res := &formattingContext{ +func NewFormattingContext(file *ast.SourceFile, kind FormatRequestKind, options *FormatCodeSettings) *FormattingContext { + res := &FormattingContext{ SourceFile: file, FormattingRequestKind: kind, Options: options, @@ -117,7 +117,7 @@ func NewFormattingContext(file *ast.SourceFile, kind FormatRequestKind, options return res } -func (this *formattingContext) UpdateContext(cur TextRangeWithKind, curParent *ast.Node, next TextRangeWithKind, nextParent *ast.Node, commonParent *ast.Node) { +func (this *FormattingContext) UpdateContext(cur TextRangeWithKind, curParent *ast.Node, next TextRangeWithKind, nextParent *ast.Node, commonParent *ast.Node) { if curParent == nil { panic("nil current range node parent in update context") } @@ -141,14 +141,14 @@ func (this *formattingContext) UpdateContext(cur TextRangeWithKind, curParent *a this.nextNodeBlockIsOnOneLine = core.TSUnknown } -func (this *formattingContext) rangeIsOnOneLine(node core.TextRange) core.Tristate { +func (this *FormattingContext) rangeIsOnOneLine(node core.TextRange) core.Tristate { if rangeIsOnOneLine(node, this.SourceFile) { return core.TSTrue } return core.TSFalse } -func (this *formattingContext) nodeIsOnOneLine(node *ast.Node) core.Tristate { +func (this *FormattingContext) nodeIsOnOneLine(node *ast.Node) core.Tristate { return this.rangeIsOnOneLine(withTokenStart(node, this.SourceFile)) } @@ -157,7 +157,7 @@ func withTokenStart(loc *ast.Node, file *ast.SourceFile) core.TextRange { return core.NewTextRange(startPos, loc.End()) } -func (this *formattingContext) blockIsOnOneLine(node *ast.Node) core.Tristate { +func (this *FormattingContext) blockIsOnOneLine(node *ast.Node) core.Tristate { // In strada, this relies on token child manifesting - we just use the scanner here, // so this will have a differing performance profile. Is this OK? Needs profiling to know. this.scanner.ResetPos(node.Pos()) @@ -179,35 +179,35 @@ func (this *formattingContext) blockIsOnOneLine(node *ast.Node) core.Tristate { return core.TSFalse } -func (this *formattingContext) ContextNodeAllOnSameLine() bool { +func (this *FormattingContext) ContextNodeAllOnSameLine() bool { if this.contextNodeAllOnSameLine == core.TSUnknown { this.contextNodeAllOnSameLine = this.nodeIsOnOneLine(this.contextNode) } return this.contextNodeAllOnSameLine == core.TSTrue } -func (this *formattingContext) NextNodeAllOnSameLine() bool { +func (this *FormattingContext) NextNodeAllOnSameLine() bool { if this.nextNodeAllOnSameLine == core.TSUnknown { this.nextNodeAllOnSameLine = this.nodeIsOnOneLine(this.nextTokenParent) } return this.nextNodeAllOnSameLine == core.TSTrue } -func (this *formattingContext) TokensAreOnSameLine() bool { +func (this *FormattingContext) TokensAreOnSameLine() bool { if this.tokensAreOnSameLine == core.TSUnknown { this.tokensAreOnSameLine = this.rangeIsOnOneLine(core.NewTextRange(this.currentTokenSpan.Loc.Pos(), this.nextTokenSpan.Loc.End())) } return this.tokensAreOnSameLine == core.TSTrue } -func (this *formattingContext) ContextNodeBlockIsOnOneLine() bool { +func (this *FormattingContext) ContextNodeBlockIsOnOneLine() bool { if this.contextNodeBlockIsOnOneLine == core.TSUnknown { this.contextNodeBlockIsOnOneLine = this.blockIsOnOneLine(this.contextNode) } return this.contextNodeBlockIsOnOneLine == core.TSTrue } -func (this *formattingContext) NextNodeBlockIsOnOneLine() bool { +func (this *FormattingContext) NextNodeBlockIsOnOneLine() bool { if this.nextNodeBlockIsOnOneLine == core.TSUnknown { this.nextNodeBlockIsOnOneLine = this.blockIsOnOneLine(this.nextTokenParent) } diff --git a/internal/format/format_test.go b/internal/format/format_test.go new file mode 100644 index 0000000000..1bf7945076 --- /dev/null +++ b/internal/format/format_test.go @@ -0,0 +1,60 @@ +package format_test + +import ( + "strings" + "testing" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/parser" + "gotest.tools/v3/assert" +) + +func TestFormatNoTrailingNewline(t *testing.T) { + t.Parallel() + // Issue: Formatter adds extra space at end of line + // When formatting a file that has content "1;" with no trailing newline, + // an extra space should NOT be added at the end of the line + + testCases := []struct { + name string + text string + }{ + {"simple statement without trailing newline", "1;"}, + {"function call without trailing newline", "console.log('hello');"}, + {"variable declaration without trailing newline", "const x = 1;"}, + {"multiple statements without trailing newline", "const x = 1;\nconst y = 2;"}, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: true, + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + }, "\n") + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, tc.text, core.ScriptKindTS) + edits := format.FormatDocument(ctx, sourceFile) + newText := applyBulkEdits(tc.text, edits) + + // The formatted text should not add extra space at the end + // It may add proper spacing within the code, but not after the last character + assert.Assert(t, !strings.HasSuffix(newText, " "), "Formatter should not add trailing space") + // Also check that no space was added at EOF position if text didn't end with newline + if !strings.HasSuffix(tc.text, "\n") { + assert.Assert(t, !strings.HasSuffix(newText, " "), "Formatter should not add space before EOF") + } + }) + } +} diff --git a/internal/format/indent.go b/internal/format/indent.go index ee8649fe7a..d5ccb949a3 100644 --- a/internal/format/indent.go +++ b/internal/format/indent.go @@ -66,8 +66,11 @@ func getIndentationForNodeWorker( // }, { itself contributes nothing. // prop: 1 L3 - The indentation of the second object literal is best understood by // }) looking at the relationship between the list and *first* list item. - listLine, _ := getStartLineAndCharacterForNode(firstListChild, sourceFile) - listIndentsChild := firstListChild != nil && listLine > containingListOrParentStartLine + var listIndentsChild bool + if firstListChild != nil { + listLine := getStartLineForNode(firstListChild, sourceFile) + listIndentsChild = listLine > containingListOrParentStartLine + } actualIndentation := getActualIndentationForListItem(current, sourceFile, options, listIndentsChild) if actualIndentation != -1 { return actualIndentation + indentationDelta @@ -127,11 +130,11 @@ func getActualIndentationForNode(current *ast.Node, parent *ast.Node, cuurentLin } func isArgumentAndStartLineOverlapsExpressionBeingCalled(parent *ast.Node, child *ast.Node, childStartLine int, sourceFile *ast.SourceFile) bool { - if !(ast.IsCallExpression(child) && slices.Contains(parent.AsCallExpression().Arguments.Nodes, child)) { + if !(ast.IsCallExpression(parent) && slices.Contains(parent.Arguments(), child)) { return false } expressionOfCallExpressionEnd := parent.Expression().End() - expressionOfCallExpressionEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, expressionOfCallExpressionEnd) + expressionOfCallExpressionEndLine := scanner.GetECMALineOfPosition(sourceFile, expressionOfCallExpressionEnd) return expressionOfCallExpressionEndLine == childStartLine } @@ -185,7 +188,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile * continue } // skip list items that ends on the same line with the current list element - prevEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, list.Nodes[i].End()) + prevEndLine := scanner.GetECMALineOfPosition(sourceFile, list.Nodes[i].End()) if prevEndLine != line { return findColumnForFirstNonWhitespaceCharacterInLine(line, char, sourceFile, options) } @@ -240,7 +243,7 @@ func childStartsOnTheSameLineWithElseInIfStatement(parent *ast.Node, child *ast. if parent.Kind == ast.KindIfStatement && parent.AsIfStatement().ElseStatement == child { elseKeyword := astnav.FindPrecedingToken(sourceFile, child.Pos()) debug.AssertIsDefined(elseKeyword) - elseKeywordStartLine, _ := getStartLineAndCharacterForNode(elseKeyword, sourceFile) + elseKeywordStartLine := getStartLineForNode(elseKeyword, sourceFile) return elseKeywordStartLine == childStartLine } return false @@ -250,6 +253,10 @@ func getStartLineAndCharacterForNode(n *ast.Node, sourceFile *ast.SourceFile) (l return scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) } +func getStartLineForNode(n *ast.Node, sourceFile *ast.SourceFile) int { + return scanner.GetECMALineOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) +} + func GetContainingList(node *ast.Node, sourceFile *ast.SourceFile) *ast.NodeList { if node.Parent == nil { return nil @@ -268,13 +275,13 @@ func getListByRange(start int, end int, node *ast.Node, sourceFile *ast.SourceFi r := core.NewTextRange(start, end) switch node.Kind { case ast.KindTypeReference: - return getList(node.AsTypeReferenceNode().TypeArguments, r, node, sourceFile) + return getList(node.TypeArgumentList(), r, node, sourceFile) case ast.KindObjectLiteralExpression: - return getList(node.AsObjectLiteralExpression().Properties, r, node, sourceFile) + return getList(node.PropertyList(), r, node, sourceFile) case ast.KindArrayLiteralExpression: - return getList(node.AsArrayLiteralExpression().Elements, r, node, sourceFile) + return getList(node.ElementList(), r, node, sourceFile) case ast.KindTypeLiteral: - return getList(node.AsTypeLiteralNode().Members, r, node, sourceFile) + return getList(node.MemberList(), r, node, sourceFile) case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, @@ -305,12 +312,8 @@ func getListByRange(start int, end int, node *ast.Node, sourceFile *ast.SourceFi return getList(node.ArgumentList(), r, node, sourceFile) case ast.KindVariableDeclarationList: return getList(node.AsVariableDeclarationList().Declarations, r, node, sourceFile) - case ast.KindNamedImports: - return getList(node.AsNamedImports().Elements, r, node, sourceFile) - case ast.KindNamedExports: - return getList(node.AsNamedExports().Elements, r, node, sourceFile) - case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern: - return getList(node.AsBindingPattern().Elements, r, node, sourceFile) + case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern, ast.KindNamedImports, ast.KindNamedExports: + return getList(node.ElementList(), r, node, sourceFile) } return nil // TODO: should this be a panic? It isn't in strada. } @@ -439,8 +442,8 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child * return rangeIsOnOneLine(child.Loc, sourceFile) } if parent.Kind == ast.KindBinaryExpression && sourceFile != nil && childKind == ast.KindJsxElement { - parentStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), parent.Pos())) - childStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), child.Pos())) + parentStartLine := scanner.GetECMALineOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), parent.Pos())) + childStartLine := scanner.GetECMALineOfPosition(sourceFile, scanner.SkipTrivia(sourceFile.Text(), child.Pos())) return parentStartLine != childStartLine } if parent.Kind != ast.KindBinaryExpression { @@ -516,7 +519,7 @@ func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child * // branch beginning on the line that the whenTrue branch ends. func childIsUnindentedBranchOfConditionalExpression(parent *ast.Node, child *ast.Node, childStartLine int, sourceFile *ast.SourceFile) bool { if parent.Kind == ast.KindConditionalExpression && (child == parent.AsConditionalExpression().WhenTrue || child == parent.AsConditionalExpression().WhenFalse) { - conditionEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, parent.AsConditionalExpression().Condition.End()) + conditionEndLine := scanner.GetECMALineOfPosition(sourceFile, parent.AsConditionalExpression().Condition.End()) if child == parent.AsConditionalExpression().WhenTrue { return childStartLine == conditionEndLine } else { @@ -527,8 +530,8 @@ func childIsUnindentedBranchOfConditionalExpression(parent *ast.Node, child *ast // ? 1 : ( L1: whenTrue indented because it's on a new line // 0 L2: indented two stops, one because whenTrue was indented // ); and one because of the parentheses spanning multiple lines - trueStartLine, _ := getStartLineAndCharacterForNode(parent.AsConditionalExpression().WhenTrue, sourceFile) - trueEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, parent.AsConditionalExpression().WhenTrue.End()) + trueStartLine := getStartLineForNode(parent.AsConditionalExpression().WhenTrue, sourceFile) + trueEndLine := scanner.GetECMALineOfPosition(sourceFile, parent.AsConditionalExpression().WhenTrue.End()) return conditionEndLine == trueStartLine && trueEndLine == childStartLine } } @@ -550,7 +553,7 @@ func argumentStartsOnSameLineAsPreviousArgument(parent *ast.Node, child *ast.Nod } previousNode := parent.Arguments()[currentIndex-1] - lineOfPreviousNode, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, previousNode.End()) + lineOfPreviousNode := scanner.GetECMALineOfPosition(sourceFile, previousNode.End()) if childStartLine == lineOfPreviousNode { return true } diff --git a/internal/format/rule.go b/internal/format/rule.go index 87e7f8f426..b61e883661 100644 --- a/internal/format/rule.go +++ b/internal/format/rule.go @@ -80,7 +80,7 @@ func toTokenRange(e any) tokenRange { panic("Unknown argument type passed to toTokenRange - only ast.Kind, []ast.Kind, and tokenRange supported") } -type contextPredicate = func(ctx *formattingContext) bool +type contextPredicate = func(ctx *FormattingContext) bool var anyContext = []contextPredicate{} diff --git a/internal/format/rulecontext.go b/internal/format/rulecontext.go index 7b91c7bfff..ca276c3976 100644 --- a/internal/format/rulecontext.go +++ b/internal/format/rulecontext.go @@ -6,7 +6,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/lsutil" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/scanner" ) @@ -97,7 +97,7 @@ func indentSwitchCaseOption(options *FormatCodeSettings) core.Tristate { } func optionEquals[T comparable](optionName anyOptionSelector[T], optionValue T) contextPredicate { - return func(context *formattingContext) bool { + return func(context *FormattingContext) bool { if context.Options == nil { return false } @@ -106,7 +106,7 @@ func optionEquals[T comparable](optionName anyOptionSelector[T], optionValue T) } func isOptionEnabled(optionName optionSelector) contextPredicate { - return func(context *formattingContext) bool { + return func(context *FormattingContext) bool { if context.Options == nil { return false } @@ -115,7 +115,7 @@ func isOptionEnabled(optionName optionSelector) contextPredicate { } func isOptionDisabled(optionName optionSelector) contextPredicate { - return func(context *formattingContext) bool { + return func(context *FormattingContext) bool { if context.Options == nil { return true } @@ -124,7 +124,7 @@ func isOptionDisabled(optionName optionSelector) contextPredicate { } func isOptionDisabledOrUndefined(optionName optionSelector) contextPredicate { - return func(context *formattingContext) bool { + return func(context *FormattingContext) bool { if context.Options == nil { return true } @@ -133,7 +133,7 @@ func isOptionDisabledOrUndefined(optionName optionSelector) contextPredicate { } func isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName optionSelector) contextPredicate { - return func(context *formattingContext) bool { + return func(context *FormattingContext) bool { if context.Options == nil { return true } @@ -142,7 +142,7 @@ func isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName optionSelector) co } func isOptionEnabledOrUndefined(optionName optionSelector) contextPredicate { - return func(context *formattingContext) bool { + return func(context *FormattingContext) bool { if context.Options == nil { return true } @@ -150,15 +150,15 @@ func isOptionEnabledOrUndefined(optionName optionSelector) contextPredicate { } } -func isForContext(context *formattingContext) bool { +func isForContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindForStatement } -func isNotForContext(context *formattingContext) bool { +func isNotForContext(context *FormattingContext) bool { return !isForContext(context) } -func isBinaryOpContext(context *formattingContext) bool { +func isBinaryOpContext(context *FormattingContext) bool { switch context.contextNode.Kind { case ast.KindBinaryExpression: return context.contextNode.AsBinaryExpression().OperatorToken.Kind != ast.KindCommaToken @@ -207,15 +207,15 @@ func isBinaryOpContext(context *formattingContext) bool { return false } -func isNotBinaryOpContext(context *formattingContext) bool { +func isNotBinaryOpContext(context *FormattingContext) bool { return !isBinaryOpContext(context) } -func isNotTypeAnnotationContext(context *formattingContext) bool { +func isNotTypeAnnotationContext(context *FormattingContext) bool { return !isTypeAnnotationContext(context) } -func isTypeAnnotationContext(context *formattingContext) bool { +func isTypeAnnotationContext(context *FormattingContext) bool { contextKind := context.contextNode.Kind return contextKind == ast.KindPropertyDeclaration || contextKind == ast.KindPropertySignature || @@ -224,47 +224,47 @@ func isTypeAnnotationContext(context *formattingContext) bool { ast.IsFunctionLikeKind(contextKind) } -func isOptionalPropertyContext(context *formattingContext) bool { - return ast.IsPropertyDeclaration(context.contextNode) && context.contextNode.AsPropertyDeclaration().PostfixToken != nil && context.contextNode.AsPropertyDeclaration().PostfixToken.Kind == ast.KindQuestionToken +func isOptionalPropertyContext(context *FormattingContext) bool { + return ast.IsPropertyDeclaration(context.contextNode) && ast.HasQuestionToken(context.contextNode) } -func isNonOptionalPropertyContext(context *formattingContext) bool { +func isNonOptionalPropertyContext(context *FormattingContext) bool { return !isOptionalPropertyContext(context) } -func isConditionalOperatorContext(context *formattingContext) bool { +func isConditionalOperatorContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindConditionalExpression || context.contextNode.Kind == ast.KindConditionalType } -func isSameLineTokenOrBeforeBlockContext(context *formattingContext) bool { +func isSameLineTokenOrBeforeBlockContext(context *FormattingContext) bool { return context.TokensAreOnSameLine() || isBeforeBlockContext(context) } -func isBraceWrappedContext(context *formattingContext) bool { +func isBraceWrappedContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindObjectBindingPattern || context.contextNode.Kind == ast.KindMappedType || isSingleLineBlockContext(context) } // This check is done before an open brace in a control construct, a function, or a typescript block declaration -func isBeforeMultilineBlockContext(context *formattingContext) bool { +func isBeforeMultilineBlockContext(context *FormattingContext) bool { return isBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()) } -func isMultilineBlockContext(context *formattingContext) bool { +func isMultilineBlockContext(context *FormattingContext) bool { return isBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()) } -func isSingleLineBlockContext(context *formattingContext) bool { +func isSingleLineBlockContext(context *FormattingContext) bool { return isBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()) } -func isBlockContext(context *formattingContext) bool { +func isBlockContext(context *FormattingContext) bool { return nodeIsBlockContext(context.contextNode) } -func isBeforeBlockContext(context *formattingContext) bool { +func isBeforeBlockContext(context *FormattingContext) bool { return nodeIsBlockContext(context.nextTokenParent) } @@ -286,7 +286,7 @@ func nodeIsBlockContext(node *ast.Node) bool { return false } -func isFunctionDeclContext(context *formattingContext) bool { +func isFunctionDeclContext(context *FormattingContext) bool { switch context.contextNode.Kind { case ast.KindFunctionDeclaration, ast.KindMethodDeclaration, @@ -312,15 +312,15 @@ func isFunctionDeclContext(context *formattingContext) bool { return false } -func isNotFunctionDeclContext(context *formattingContext) bool { +func isNotFunctionDeclContext(context *FormattingContext) bool { return !isFunctionDeclContext(context) } -func isFunctionDeclarationOrFunctionExpressionContext(context *formattingContext) bool { +func isFunctionDeclarationOrFunctionExpressionContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindFunctionDeclaration || context.contextNode.Kind == ast.KindFunctionExpression } -func isTypeScriptDeclWithBlockContext(context *formattingContext) bool { +func isTypeScriptDeclWithBlockContext(context *FormattingContext) bool { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode) } @@ -342,7 +342,7 @@ func nodeIsTypeScriptDeclWithBlockContext(node *ast.Node) bool { return false } -func isAfterCodeBlockContext(context *formattingContext) bool { +func isAfterCodeBlockContext(context *FormattingContext) bool { switch context.currentTokenParent.Kind { case ast.KindClassDeclaration, ast.KindModuleDeclaration, @@ -361,7 +361,7 @@ func isAfterCodeBlockContext(context *formattingContext) bool { return false } -func isControlDeclContext(context *formattingContext) bool { +func isControlDeclContext(context *FormattingContext) bool { switch context.contextNode.Kind { case ast.KindIfStatement, ast.KindSwitchStatement, @@ -383,83 +383,83 @@ func isControlDeclContext(context *formattingContext) bool { } } -func isObjectContext(context *formattingContext) bool { +func isObjectContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindObjectLiteralExpression } -func isFunctionCallContext(context *formattingContext) bool { +func isFunctionCallContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindCallExpression } -func isNewContext(context *formattingContext) bool { +func isNewContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindNewExpression } -func isFunctionCallOrNewContext(context *formattingContext) bool { +func isFunctionCallOrNewContext(context *FormattingContext) bool { return isFunctionCallContext(context) || isNewContext(context) } -func isPreviousTokenNotComma(context *formattingContext) bool { +func isPreviousTokenNotComma(context *FormattingContext) bool { return context.currentTokenSpan.Kind != ast.KindCommaToken } -func isNextTokenNotCloseBracket(context *formattingContext) bool { +func isNextTokenNotCloseBracket(context *FormattingContext) bool { return context.nextTokenSpan.Kind != ast.KindCloseBracketToken } -func isNextTokenNotCloseParen(context *formattingContext) bool { +func isNextTokenNotCloseParen(context *FormattingContext) bool { return context.nextTokenSpan.Kind != ast.KindCloseParenToken } -func isArrowFunctionContext(context *formattingContext) bool { +func isArrowFunctionContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindArrowFunction } -func isImportTypeContext(context *formattingContext) bool { +func isImportTypeContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindImportType } -func isNonJsxSameLineTokenContext(context *formattingContext) bool { +func isNonJsxSameLineTokenContext(context *FormattingContext) bool { return context.TokensAreOnSameLine() && context.contextNode.Kind != ast.KindJsxText } -func isNonJsxTextContext(context *formattingContext) bool { +func isNonJsxTextContext(context *FormattingContext) bool { return context.contextNode.Kind != ast.KindJsxText } -func isNonJsxElementOrFragmentContext(context *formattingContext) bool { +func isNonJsxElementOrFragmentContext(context *FormattingContext) bool { return context.contextNode.Kind != ast.KindJsxElement && context.contextNode.Kind != ast.KindJsxFragment } -func isJsxExpressionContext(context *formattingContext) bool { +func isJsxExpressionContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindJsxExpression || context.contextNode.Kind == ast.KindJsxSpreadAttribute } -func isNextTokenParentJsxAttribute(context *formattingContext) bool { +func isNextTokenParentJsxAttribute(context *FormattingContext) bool { return context.nextTokenParent.Kind == ast.KindJsxAttribute || (context.nextTokenParent.Kind == ast.KindJsxNamespacedName && context.nextTokenParent.Parent.Kind == ast.KindJsxAttribute) } -func isJsxAttributeContext(context *formattingContext) bool { +func isJsxAttributeContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindJsxAttribute } -func isNextTokenParentNotJsxNamespacedName(context *formattingContext) bool { +func isNextTokenParentNotJsxNamespacedName(context *FormattingContext) bool { return context.nextTokenParent.Kind != ast.KindJsxNamespacedName } -func isNextTokenParentJsxNamespacedName(context *formattingContext) bool { +func isNextTokenParentJsxNamespacedName(context *FormattingContext) bool { return context.nextTokenParent.Kind == ast.KindJsxNamespacedName } -func isJsxSelfClosingElementContext(context *formattingContext) bool { +func isJsxSelfClosingElementContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindJsxSelfClosingElement } -func isNotBeforeBlockInFunctionDeclarationContext(context *formattingContext) bool { +func isNotBeforeBlockInFunctionDeclarationContext(context *FormattingContext) bool { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context) } -func isEndOfDecoratorContextOnSameLine(context *formattingContext) bool { +func isEndOfDecoratorContextOnSameLine(context *FormattingContext) bool { return context.TokensAreOnSameLine() && ast.HasDecorators(context.contextNode) && nodeIsInDecoratorContext(context.currentTokenParent) && @@ -473,24 +473,24 @@ func nodeIsInDecoratorContext(node *ast.Node) bool { return node != nil && node.Kind == ast.KindDecorator } -func isStartOfVariableDeclarationList(context *formattingContext) bool { +func isStartOfVariableDeclarationList(context *FormattingContext) bool { return context.currentTokenParent.Kind == ast.KindVariableDeclarationList && scanner.GetTokenPosOfNode(context.currentTokenParent, context.SourceFile, false) == context.currentTokenSpan.Loc.Pos() } -func isNotFormatOnEnter(context *formattingContext) bool { +func isNotFormatOnEnter(context *FormattingContext) bool { return context.FormattingRequestKind != FormatRequestKindFormatOnEnter } -func isModuleDeclContext(context *formattingContext) bool { +func isModuleDeclContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindModuleDeclaration } -func isObjectTypeContext(context *formattingContext) bool { +func isObjectTypeContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindTypeLiteral // && context.contextNode.parent.Kind != ast.KindInterfaceDeclaration; } -func isConstructorSignatureContext(context *formattingContext) bool { +func isConstructorSignatureContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindConstructSignature } @@ -521,36 +521,36 @@ func isTypeArgumentOrParameterOrAssertion(token TextRangeWithKind, parent *ast.N } } -func isTypeArgumentOrParameterOrAssertionContext(context *formattingContext) bool { +func isTypeArgumentOrParameterOrAssertionContext(context *FormattingContext) bool { return isTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent) } -func isTypeAssertionContext(context *formattingContext) bool { +func isTypeAssertionContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindTypeAssertionExpression } -func isNonTypeAssertionContext(context *formattingContext) bool { +func isNonTypeAssertionContext(context *FormattingContext) bool { return !isTypeAssertionContext(context) } -func isVoidOpContext(context *formattingContext) bool { +func isVoidOpContext(context *FormattingContext) bool { return context.currentTokenSpan.Kind == ast.KindVoidKeyword && context.currentTokenParent.Kind == ast.KindVoidExpression } -func isYieldOrYieldStarWithOperand(context *formattingContext) bool { - return context.contextNode.Kind == ast.KindYieldExpression && context.contextNode.AsYieldExpression().Expression != nil +func isYieldOrYieldStarWithOperand(context *FormattingContext) bool { + return context.contextNode.Kind == ast.KindYieldExpression && context.contextNode.Expression() != nil } -func isNonNullAssertionContext(context *formattingContext) bool { +func isNonNullAssertionContext(context *FormattingContext) bool { return context.contextNode.Kind == ast.KindNonNullExpression } -func isNotStatementConditionContext(context *formattingContext) bool { +func isNotStatementConditionContext(context *FormattingContext) bool { return !isStatementConditionContext(context) } -func isStatementConditionContext(context *formattingContext) bool { +func isStatementConditionContext(context *FormattingContext) bool { switch context.contextNode.Kind { case ast.KindIfStatement, ast.KindForStatement, @@ -565,7 +565,7 @@ func isStatementConditionContext(context *formattingContext) bool { } } -func isSemicolonDeletionContext(context *formattingContext) bool { +func isSemicolonDeletionContext(context *FormattingContext) bool { nextTokenKind := context.nextTokenSpan.Kind nextTokenStart := context.nextTokenSpan.Loc.Pos() if ast.IsTrivia(nextTokenKind) { @@ -584,8 +584,8 @@ func isSemicolonDeletionContext(context *formattingContext) bool { nextTokenStart = scanner.GetTokenPosOfNode(nextRealToken, context.SourceFile, false) } - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(context.SourceFile, context.currentTokenSpan.Loc.Pos()) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(context.SourceFile, nextTokenStart) + startLine := scanner.GetECMALineOfPosition(context.SourceFile, context.currentTokenSpan.Loc.Pos()) + endLine := scanner.GetECMALineOfPosition(context.SourceFile, nextTokenStart) if startLine == endLine { return nextTokenKind == ast.KindCloseBraceToken || nextTokenKind == ast.KindEndOfFile } @@ -633,11 +633,11 @@ func isSemicolonDeletionContext(context *formattingContext) bool { nextTokenKind != ast.KindDotToken } -func isSemicolonInsertionContext(context *formattingContext) bool { +func isSemicolonInsertionContext(context *FormattingContext) bool { return lsutil.PositionIsASICandidate(context.currentTokenSpan.Loc.End(), context.currentTokenParent, context.SourceFile) } -func isNotPropertyAccessOnIntegerLiteral(context *formattingContext) bool { +func isNotPropertyAccessOnIntegerLiteral(context *FormattingContext) bool { return !ast.IsPropertyAccessExpression(context.contextNode) || !ast.IsNumericLiteral(context.contextNode.Expression()) || strings.Contains(context.contextNode.Expression().Text(), ".") diff --git a/internal/format/rules.go b/internal/format/rules.go index c8b31a247e..07af86ef99 100644 --- a/internal/format/rules.go +++ b/internal/format/rules.go @@ -9,7 +9,9 @@ import ( func getAllRules() []ruleSpec { allTokens := make([]ast.Kind, 0, ast.KindLastToken-ast.KindFirstToken+1) for token := ast.KindFirstToken; token <= ast.KindLastToken; token++ { - allTokens = append(allTokens, token) + if token != ast.KindEndOfFile { + allTokens = append(allTokens, token) + } } anyTokenExcept := func(tokens ...ast.Kind) tokenRange { diff --git a/internal/format/rulesmap.go b/internal/format/rulesmap.go index c511ddc19e..9d3ea50ae6 100644 --- a/internal/format/rulesmap.go +++ b/internal/format/rulesmap.go @@ -8,7 +8,7 @@ import ( "github.com/microsoft/typescript-go/internal/debug" ) -func getRules(context *formattingContext, rules []*ruleImpl) []*ruleImpl { +func getRules(context *FormattingContext, rules []*ruleImpl) []*ruleImpl { bucket := getRulesMap()[getRuleBucketIndex(context.currentTokenSpan.Kind, context.nextTokenSpan.Kind)] if len(bucket) > 0 { ruleActionMask := ruleActionNone diff --git a/internal/format/span.go b/internal/format/span.go index 4657949f7e..f8d73d40b6 100644 --- a/internal/format/span.go +++ b/internal/format/span.go @@ -85,7 +85,7 @@ func getOwnOrInheritedDelta(n *ast.Node, options *FormatCodeSettings, sourceFile previousLine := -1 var child *ast.Node for n != nil { - line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, withTokenStart(n, sourceFile).Pos()) + line := scanner.GetECMALineOfPosition(sourceFile, withTokenStart(n, sourceFile).Pos()) if previousLine != -1 && line != previousLine { break } @@ -159,7 +159,7 @@ type formatSpanWorker struct { ctx context.Context formattingScanner *formattingScanner - formattingContext *formattingContext + formattingContext *FormattingContext edits []core.TextChange previousRange TextRangeWithKind @@ -206,7 +206,7 @@ func newFormatSpanWorker( func getNonDecoratorTokenPosOfNode(node *ast.Node, file *ast.SourceFile) int { var lastDecorator *ast.Node if ast.HasDecorators(node) { - lastDecorator = core.FindLast(node.Modifiers().Nodes, ast.IsDecorator) + lastDecorator = core.FindLast(node.ModifierNodes(), ast.IsDecorator) } if file == nil { file = ast.GetSourceFileOfNode(node) @@ -242,10 +242,10 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange { w.formattingScanner.advance() if w.formattingScanner.isOnToken() { - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, withTokenStart(w.enclosingNode, w.sourceFile).Pos()) + startLine := scanner.GetECMALineOfPosition(w.sourceFile, withTokenStart(w.enclosingNode, w.sourceFile).Pos()) undecoratedStartLine := startLine if ast.HasDecorators(w.enclosingNode) { - undecoratedStartLine, _ = scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(w.enclosingNode, w.sourceFile)) + undecoratedStartLine = scanner.GetECMALineOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(w.enclosingNode, w.sourceFile)) } w.processNode(w.enclosingNode, w.enclosingNode, startLine, undecoratedStartLine, w.initialIndentation, w.delta) @@ -305,7 +305,7 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange { if parent == nil { parent = w.previousParent } - line, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, tokenInfo.Loc.Pos()) + line := scanner.GetECMALineOfPosition(w.sourceFile, tokenInfo.Loc.Pos()) w.processPair( tokenInfo, line, @@ -343,11 +343,11 @@ func (w *formatSpanWorker) processChildNode( } childStartPos := scanner.GetTokenPosOfNode(child, w.sourceFile, false) - childStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, childStartPos) + childStartLine := scanner.GetECMALineOfPosition(w.sourceFile, childStartPos) undecoratedChildStartLine := childStartLine if ast.HasDecorators(child) { - undecoratedChildStartLine, _ = scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(child, w.sourceFile)) + undecoratedChildStartLine = scanner.GetECMALineOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(child, w.sourceFile)) } // if child is a list item - try to get its indentation, only if parent is within the original range. @@ -457,7 +457,7 @@ func (w *formatSpanWorker) processChildNodes( break } else if tokenInfo.token.Kind == listStartToken { // consume list start token - startLine, _ = scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, tokenInfo.token.Loc.Pos()) + startLine = scanner.GetECMALineOfPosition(w.sourceFile, tokenInfo.token.Loc.Pos()) w.consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent, false) @@ -578,7 +578,7 @@ func (w *formatSpanWorker) tryComputeIndentationForListItem(startPos int, endPos return inheritedIndentation } } else { - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, startPos) + startLine := scanner.GetECMALineOfPosition(w.sourceFile, startPos) startLinePosition := GetLineStartPositionForPosition(startPos, w.sourceFile) column := FindFirstNonWhitespaceColumn(startLinePosition, startPos, w.sourceFile, w.formattingContext.Options) if startLine != parentStartLine || startPos == column { @@ -747,7 +747,7 @@ func (w *formatSpanWorker) processRange(r TextRangeWithKind, rangeStartLine int, if !rangeHasError { if w.previousRange == NewTextRangeWithKind(0, 0, 0) { // trim whitespaces starting from the beginning of the span up to the current line - originalStartLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, w.originalRange.Pos()) + originalStartLine := scanner.GetECMALineOfPosition(w.sourceFile, w.originalRange.Pos()) w.trimTrailingWhitespacesForLines(originalStartLine, rangeStartLine, NewTextRangeWithKind(0, 0, 0)) } else { lineAction = w.processPair(r, rangeStartLine, parent, w.previousRange, w.previousRangeStartLine, w.previousParent, contextNode, dynamicIndentation) @@ -797,8 +797,8 @@ func (w *formatSpanWorker) trimTrailingWhitespacesForRemainingRange(trivias []Te } func (w *formatSpanWorker) trimTrailingWitespacesForPositions(startPos int, endPos int, previousRange TextRangeWithKind) { - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, startPos) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, endPos) + startLine := scanner.GetECMALineOfPosition(w.sourceFile, startPos) + endLine := scanner.GetECMALineOfPosition(w.sourceFile, endPos) w.trimTrailingWhitespacesForLines(startLine, endLine+1, previousRange) } @@ -909,8 +909,8 @@ func (w *formatSpanWorker) indentTriviaItems(trivia []TextRangeWithKind, comment func (w *formatSpanWorker) indentMultilineComment(commentRange core.TextRange, indentation int, firstLineIsIndented bool, indentFinalLine bool) { // split comment in lines - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, commentRange.Pos()) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, commentRange.End()) + startLine := scanner.GetECMALineOfPosition(w.sourceFile, commentRange.Pos()) + endLine := scanner.GetECMALineOfPosition(w.sourceFile, commentRange.End()) if startLine == endLine { if !firstLineIsIndented { @@ -975,7 +975,7 @@ func getIndentationString(indentation int, options *FormatCodeSettings) string { spaces := indentation - (tabs * options.TabSize) res := strings.Repeat("\t", tabs) if spaces > 0 { - res = strings.Repeat(" ", spaces) + res + res = res + strings.Repeat(" ", spaces) } return res @@ -1033,7 +1033,7 @@ func (w *formatSpanWorker) consumeTokenAndAdvanceScanner(currentTokenInfo tokenI if lineAction == LineActionNone { // indent token only if end line of previous range does not match start line of the token if savePreviousRange != NewTextRangeWithKind(0, 0, 0) { - prevEndLine, _ := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, savePreviousRange.Loc.End()) + prevEndLine := scanner.GetECMALineOfPosition(w.sourceFile, savePreviousRange.Loc.End()) indentToken = lastTriviaWasNewLine && tokenStartLine != prevEndLine } } else { @@ -1093,6 +1093,9 @@ func (i *dynamicIndenter) getIndentationForComment(kind ast.Kind, tokenIndentati case ast.KindCloseBraceToken, ast.KindCloseBracketToken, ast.KindCloseParenToken: return i.indentation + i.getDelta(container) } + if tokenIndentation != -1 { + return tokenIndentation + } return i.indentation } @@ -1168,7 +1171,7 @@ func (i *dynamicIndenter) shouldAddDelta(line int, kind ast.Kind, container *ast func getFirstNonDecoratorTokenOfNode(node *ast.Node) ast.Kind { if ast.CanHaveModifiers(node) { - modifier := core.Find(node.Modifiers().Nodes[core.FindIndex(node.Modifiers().Nodes, ast.IsDecorator):], ast.IsModifier) + modifier := core.Find(node.ModifierNodes()[core.FindIndex(node.ModifierNodes(), ast.IsDecorator):], ast.IsModifier) if modifier != nil { return modifier.Kind } diff --git a/internal/format/util.go b/internal/format/util.go index 0bf8bc7048..93ddd84dab 100644 --- a/internal/format/util.go +++ b/internal/format/util.go @@ -10,8 +10,8 @@ import ( ) func rangeIsOnOneLine(node core.TextRange, file *ast.SourceFile) bool { - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, node.Pos()) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, node.End()) + startLine := scanner.GetECMALineOfPosition(file, node.Pos()) + endLine := scanner.GetECMALineOfPosition(file, node.End()) return startLine == endLine } @@ -77,7 +77,7 @@ func getCloseTokenForOpenToken(kind ast.Kind) ast.Kind { func GetLineStartPositionForPosition(position int, sourceFile *ast.SourceFile) int { lineStarts := scanner.GetECMALineStarts(sourceFile) - line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, position) + line := scanner.GetECMALineOfPosition(sourceFile, position) return int(lineStarts[line]) } @@ -90,10 +90,10 @@ func isGrammarError(parent *ast.Node, child *ast.Node) bool { return child == parent.AsTypeParameter().Expression } if ast.IsPropertySignatureDeclaration(parent) { - return child == parent.AsPropertySignatureDeclaration().Initializer + return child == parent.Initializer() } if ast.IsPropertyDeclaration(parent) { - return ast.IsAutoAccessorPropertyDeclaration(parent) && child == parent.AsPropertyDeclaration().PostfixToken && child.Kind == ast.KindQuestionToken + return ast.IsAutoAccessorPropertyDeclaration(parent) && child == parent.PostfixToken() && child.Kind == ast.KindQuestionToken } if ast.IsPropertyAssignment(parent) { pa := parent.AsPropertyAssignment() @@ -106,16 +106,16 @@ func isGrammarError(parent *ast.Node, child *ast.Node) bool { return child == sp.EqualsToken || child == sp.PostfixToken || (mods != nil && isGrammarErrorElement(&mods.NodeList, child, ast.IsModifierLike)) } if ast.IsMethodDeclaration(parent) { - return child == parent.AsMethodDeclaration().PostfixToken && child.Kind == ast.KindExclamationToken + return child == parent.PostfixToken() && child.Kind == ast.KindExclamationToken } if ast.IsConstructorDeclaration(parent) { - return child == parent.AsConstructorDeclaration().Type || isGrammarErrorElement(parent.AsConstructorDeclaration().TypeParameters, child, ast.IsTypeParameterDeclaration) + return child == parent.AsConstructorDeclaration().Type || isGrammarErrorElement(parent.TypeParameterList(), child, ast.IsTypeParameterDeclaration) } if ast.IsGetAccessorDeclaration(parent) { - return isGrammarErrorElement(parent.AsGetAccessorDeclaration().TypeParameters, child, ast.IsTypeParameterDeclaration) + return isGrammarErrorElement(parent.TypeParameterList(), child, ast.IsTypeParameterDeclaration) } if ast.IsSetAccessorDeclaration(parent) { - return child == parent.AsSetAccessorDeclaration().Type || isGrammarErrorElement(parent.AsSetAccessorDeclaration().TypeParameters, child, ast.IsTypeParameterDeclaration) + return child == parent.AsSetAccessorDeclaration().Type || isGrammarErrorElement(parent.TypeParameterList(), child, ast.IsTypeParameterDeclaration) } if ast.IsNamespaceExportDeclaration(parent) { mods := parent.AsNamespaceExportDeclaration().Modifiers() diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 0b461efff6..d4dc96c952 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -65,8 +65,9 @@ function parseTypeScriptFiles(failingTests: Set, manualTests: Set arg.getText()).join(", ")}`); + return undefined; + } + if (!ts.isStringLiteralLike(args[0]) && args[0].getText() !== "undefined") { + console.error(`Expected string literal or "undefined" in verify.applyCodeActionFromCompletion, got ${args[0].getText()}`); + return undefined; + } + const markerName = getStringLiteralLike(args[0])?.text; + const marker = markerName === undefined ? "nil" : `PtrTo(${getGoStringLiteral(markerName)})`; + const options = parseVerifyApplyCodeActionArgs(args[1]); + if (options === undefined) { + return undefined; + } + + cmds.push({ kind: "verifyApplyCodeActionFromCompletion", marker, options }); + return cmds; +} + +function parseVerifyApplyCodeActionArgs(arg: ts.Expression): string | undefined { + const obj = getObjectLiteralExpression(arg); + if (!obj) { + console.error(`Expected object literal for verify.applyCodeActionFromCompletion options, got ${arg.getText()}`); + return undefined; + } + let nameInit, sourceInit, descInit, dataInit; + const props: string[] = []; + for (const prop of obj.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + if (ts.isShorthandPropertyAssignment(prop) && prop.name.text === "preferences") { + continue; // !!! parse once preferences are supported in fourslash + } + console.error(`Expected property assignment with identifier name in verify.applyCodeActionFromCompletion options, got ${prop.getText()}`); + return undefined; + } + const propName = prop.name.text; + const init = prop.initializer; + switch (propName) { + case "name": + nameInit = getStringLiteralLike(init); + if (!nameInit) { + console.error(`Expected string literal for name in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`Name: ${getGoStringLiteral(nameInit.text)},`); + break; + case "source": + sourceInit = getStringLiteralLike(init); + if (!sourceInit) { + console.error(`Expected string literal for source in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`Source: ${getGoStringLiteral(sourceInit.text)},`); + break; + case "data": + dataInit = getObjectLiteralExpression(init); + if (!dataInit) { + console.error(`Expected object literal for data in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + const dataProps: string[] = []; + for (const dataProp of dataInit.properties) { + if (!ts.isPropertyAssignment(dataProp) || !ts.isIdentifier(dataProp.name)) { + console.error(`Expected property assignment with identifier name in verify.applyCodeActionFromCompletion data, got ${dataProp.getText()}`); + return undefined; + } + const dataPropName = dataProp.name.text; + switch (dataPropName) { + case "moduleSpecifier": + const moduleSpecifierInit = getStringLiteralLike(dataProp.initializer); + if (!moduleSpecifierInit) { + console.error(`Expected string literal for moduleSpecifier in verify.applyCodeActionFromCompletion data, got ${dataProp.initializer.getText()}`); + return undefined; + } + dataProps.push(`ModuleSpecifier: ${getGoStringLiteral(moduleSpecifierInit.text)},`); + break; + case "exportName": + const exportNameInit = getStringLiteralLike(dataProp.initializer); + if (!exportNameInit) { + console.error(`Expected string literal for exportName in verify.applyCodeActionFromCompletion data, got ${dataProp.initializer.getText()}`); + return undefined; + } + dataProps.push(`ExportName: ${getGoStringLiteral(exportNameInit.text)},`); + break; + case "fileName": + const fileNameInit = getStringLiteralLike(dataProp.initializer); + if (!fileNameInit) { + console.error(`Expected string literal for fileName in verify.applyCodeActionFromCompletion data, got ${dataProp.initializer.getText()}`); + return undefined; + } + dataProps.push(`FileName: ${getGoStringLiteral(fileNameInit.text)},`); + break; + default: + console.error(`Unrecognized property in verify.applyCodeActionFromCompletion data: ${dataProp.getText()}`); + return undefined; + } + } + props.push(`AutoImportData: &lsproto.AutoImportData{\n${dataProps.join("\n")}\n},`); + break; + case "description": + descInit = getStringLiteralLike(init); + if (!descInit) { + console.error(`Expected string literal for description in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`Description: ${getGoStringLiteral(descInit.text)},`); + break; + case "newFileContent": + const newFileContentInit = getStringLiteralLike(init); + if (!newFileContentInit) { + console.error(`Expected string literal for newFileContent in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`NewFileContent: PtrTo(${getGoMultiLineStringLiteral(newFileContentInit.text)}),`); + break; + case "newRangeContent": + const newRangeContentInit = getStringLiteralLike(init); + if (!newRangeContentInit) { + console.error(`Expected string literal for newRangeContent in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`NewRangeContent: PtrTo(${getGoMultiLineStringLiteral(newRangeContentInit.text)}),`); + break; + case "preferences": + // Few if any tests use non-default preferences + break; + default: + console.error(`Unrecognized property in verify.applyCodeActionFromCompletion options: ${prop.getText()}`); + return undefined; + } + } + if (!nameInit) { + console.error(`Expected name property in verify.applyCodeActionFromCompletion options`); + return undefined; + } + if (!sourceInit && !dataInit) { + console.error(`Expected source property in verify.applyCodeActionFromCompletion options`); + return undefined; + } + if (!descInit) { + console.error(`Expected description property in verify.applyCodeActionFromCompletion options`); + return undefined; + } + return `&fourslash.ApplyCodeActionFromCompletionOptions{\n${props.join("\n")}\n}`; +} + +function parseImportFixAtPositionArgs(args: readonly ts.Expression[]): VerifyImportFixAtPositionCmd[] | undefined { + if (args.length < 1 || args.length > 3) { + console.error(`Expected 1-3 arguments in verify.importFixAtPosition, got ${args.map(arg => arg.getText()).join(", ")}`); + return undefined; + } + const arrayArg = getArrayLiteralExpression(args[0]); + if (!arrayArg) { + console.error(`Expected array literal for first argument in verify.importFixAtPosition, got ${args[0].getText()}`); + return undefined; + } + const expectedTexts: string[] = []; + for (const elem of arrayArg.elements) { + const strElem = getStringLiteralLike(elem); + if (!strElem) { + console.error(`Expected string literal in verify.importFixAtPosition array, got ${elem.getText()}`); + return undefined; + } + expectedTexts.push(getGoMultiLineStringLiteral(strElem.text)); + } + + // If the array is empty, we should still generate valid Go code + if (expectedTexts.length === 0) { + expectedTexts.push(""); // This will be handled specially in code generation + } + + let preferences: string | undefined; + if (args.length > 2 && ts.isObjectLiteralExpression(args[2])) { + preferences = parseUserPreferences(args[2]); + if (!preferences) { + console.error(`Unrecognized user preferences in verify.importFixAtPosition: ${args[2].getText()}`); + return undefined; + } + } + return [{ + kind: "verifyImportFixAtPosition", + expectedTexts, + preferences: preferences || "nil /*preferences*/", + }]; +} + const completionConstants = new Map([ ["completion.globals", "CompletionGlobals"], ["completion.globalTypes", "CompletionGlobalTypes"], @@ -394,7 +620,7 @@ const completionPlus = new Map([ ["completion.typeKeywordsPlus", "CompletionTypeKeywordsPlus"], ]); -function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | undefined { +function parseVerifyCompletionArg(arg: ts.Expression, codeActionArgs?: VerifyApplyCodeActionArgs): VerifyCompletionsCmd | undefined { let marker: string | undefined; let goArgs: VerifyCompletionsArgs | undefined; const obj = getObjectLiteralExpression(arg); @@ -405,6 +631,9 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un let isNewIdentifierLocation: true | undefined; for (const prop of obj.properties) { if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + if (ts.isShorthandPropertyAssignment(prop) && prop.name.text === "preferences") { + continue; // !!! parse once preferences are supported in fourslash + } console.error(`Expected property assignment with identifier name, got ${prop.getText()}`); return undefined; } @@ -475,7 +704,7 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un } expected = `${funcName}(\n[]fourslash.CompletionsExpectedItem{`; for (const elem of items.elements) { - const result = parseExpectedCompletionItem(elem); + const result = parseExpectedCompletionItem(elem, codeActionArgs); if (!result) { return undefined; } @@ -586,7 +815,7 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un }; } -function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { +function parseExpectedCompletionItem(expr: ts.Expression, codeActionArgs?: VerifyApplyCodeActionArgs): string | undefined { if (completionConstants.has(expr.getText())) { return completionConstants.get(expr.getText())!; } @@ -597,6 +826,7 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { if (strExpr = getObjectLiteralExpression(expr)) { let isDeprecated = false; // !!! let isOptional = false; + let sourceInit: ts.StringLiteralLike | undefined; let extensions: string[] = []; // !!! let itemProps: string[] = []; let name: string | undefined; @@ -705,6 +935,33 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { } case "isFromUncheckedFile": break; // Ignored + case "hasAction": + itemProps.push("AdditionalTextEdits: fourslash.AnyTextEdits,"); + break; + case "source": + case "sourceDisplay": + if (sourceInit !== undefined) { + break; + } + if (sourceInit = getStringLiteralLike(init)) { + if (propName === "source" && sourceInit.text.endsWith("/")) { + // source: "ClassMemberSnippet/" + itemProps.push(`Data: &lsproto.CompletionItemData{ + Source: ${getGoStringLiteral(sourceInit.text)}, + },`); + break; + } + itemProps.push(`Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: ${getGoStringLiteral(sourceInit.text)}, + }, + },`); + } + else { + console.error(`Expected string literal for source/sourceDisplay, got ${init.getText()}`); + return undefined; + } + break; case "commitCharacters": // !!! support these later break; @@ -729,6 +986,11 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { if (!name) { return undefined; // Shouldn't happen } + if (codeActionArgs && codeActionArgs.name === name && codeActionArgs.source === sourceInit?.text) { + itemProps.push(`LabelDetails: &lsproto.CompletionItemLabelDetails{ + Description: PtrTo(${getGoStringLiteral(codeActionArgs.source)}), + },`); + } if (replacementSpanIdx) { itemProps.push(`TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ TextEdit: &lsproto.TextEdit{ @@ -751,6 +1013,60 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { return undefined; // Unsupported expression type } +function parseAndApplyCodeActionArg(arg: ts.Expression): VerifyApplyCodeActionArgs | undefined { + const obj = getObjectLiteralExpression(arg); + if (!obj) { + console.error(`Expected object literal for code action argument, got ${arg.getText()}`); + return undefined; + } + const nameProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "name" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!nameProperty) { + console.error(`Expected name property in code action argument, got ${obj.getText()}`); + return undefined; + } + const sourceProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "source" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!sourceProperty) { + console.error(`Expected source property in code action argument, got ${obj.getText()}`); + return undefined; + } + const descriptionProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "description" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!descriptionProperty) { + console.error(`Expected description property in code action argument, got ${obj.getText()}`); + return undefined; + } + const newFileContentProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "newFileContent" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!newFileContentProperty) { + console.error(`Expected newFileContent property in code action argument, got ${obj.getText()}`); + return undefined; + } + return { + name: (nameProperty.initializer as ts.StringLiteralLike).text, + source: (sourceProperty.initializer as ts.StringLiteralLike).text, + description: (descriptionProperty.initializer as ts.StringLiteralLike).text, + newFileContent: (newFileContentProperty.initializer as ts.StringLiteralLike).text, + }; +} + function parseBaselineFindAllReferencesArgs(args: readonly ts.Expression[]): [VerifyBaselineFindAllReferencesCmd] | undefined { const newArgs = []; for (const arg of args) { @@ -817,7 +1133,27 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V }]; } -function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [VerifyBaselineGoToDefinitionCmd] | undefined { +function parseBaselineGoToDefinitionArgs( + funcName: "baselineGoToDefinition" | "baselineGoToType" | "baselineGetDefinitionAtPosition" | "baselineGoToImplementation", + args: readonly ts.Expression[], +): [VerifyBaselineGoToDefinitionCmd] | undefined { + let boundSpan: true | undefined; + if (funcName === "baselineGoToDefinition") { + boundSpan = true; + } + let kind: "verifyBaselineGoToDefinition" | "verifyBaselineGoToType" | "verifyBaselineGoToImplementation"; + switch (funcName) { + case "baselineGoToDefinition": + case "baselineGetDefinitionAtPosition": + kind = "verifyBaselineGoToDefinition"; + break; + case "baselineGoToType": + kind = "verifyBaselineGoToType"; + break; + case "baselineGoToImplementation": + kind = "verifyBaselineGoToImplementation"; + break; + } const newArgs = []; for (const arg of args) { let strArg; @@ -829,20 +1165,22 @@ function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [Verif } else if (arg.getText() === "...test.ranges()") { return [{ - kind: "verifyBaselineGoToDefinition", + kind, markers: [], ranges: true, + boundSpan, }]; } else { - console.error(`Unrecognized argument in verify.baselineGoToDefinition: ${arg.getText()}`); + console.error(`Unrecognized argument in verify.${funcName}: ${arg.getText()}`); return undefined; } } return [{ - kind: "verifyBaselineGoToDefinition", + kind, markers: newArgs, + boundSpan, }]; } @@ -911,6 +1249,131 @@ function parseBaselineRenameArgs(funcName: string, args: readonly ts.Expression[ }]; } +function parseBaselineInlayHints(args: readonly ts.Expression[]): [VerifyBaselineInlayHintsCmd] | undefined { + let preferences: string | undefined; + // Parse span + if (args.length > 0) { + if (args[0].getText() !== "undefined") { + console.error(`Unsupported span argument in verify.baselineInlayHints: ${args[0].getText()}`); + return undefined; + } + } + // Parse preferences + if (args.length > 1) { + if (ts.isObjectLiteralExpression(args[1])) { + preferences = parseUserPreferences(args[1]); + if (!preferences) { + console.error(`Unrecognized user preferences in verify.baselineInlayHints: ${args[1].getText()}`); + return undefined; + } + } + } + return [{ + kind: "verifyBaselineInlayHints", + span: "nil /*span*/", // Only supporteed manually + preferences: preferences ? preferences : "nil /*preferences*/", + }]; +} + +function parseVerifyDiagnostics(funcName: string, args: readonly ts.Expression[]): [VerifyDiagnosticsCmd] | undefined { + if (!args[0] || !ts.isArrayLiteralExpression(args[0])) { + console.error(`Expected an array literal argument in verify.${funcName}`); + return undefined; + } + const goArgs: string[] = []; + for (const expr of args[0].elements) { + const diag = parseExpectedDiagnostic(expr); + if (diag === undefined) { + return undefined; + } + goArgs.push(diag); + } + return [{ + kind: "verifyDiagnostics", + arg: goArgs.length > 0 ? `[]*lsproto.Diagnostic{\n${goArgs.join(",\n")},\n}` : "nil", + isSuggestion: funcName === "getSuggestionDiagnostics", + }]; +} + +function parseExpectedDiagnostic(expr: ts.Expression): string | undefined { + if (!ts.isObjectLiteralExpression(expr)) { + console.error(`Expected object literal expression for expected diagnostic, got ${expr.getText()}`); + return undefined; + } + + const diagnosticProps: string[] = []; + + for (const prop of expr.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Expected property assignment with identifier name for expected diagnostic, got ${prop.getText()}`); + return undefined; + } + + const propName = prop.name.text; + const init = prop.initializer; + + switch (propName) { + case "message": { + let messageInit; + if (messageInit = getStringLiteralLike(init)) { + messageInit.text = messageInit.text.replace("/tests/cases/fourslash", ""); + diagnosticProps.push(`Message: ${getGoStringLiteral(messageInit.text)},`); + } + else { + console.error(`Expected string literal for diagnostic message, got ${init.getText()}`); + return undefined; + } + break; + } + case "code": { + let codeInit; + if (codeInit = getNumericLiteral(init)) { + diagnosticProps.push(`Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](${codeInit.text})},`); + } + else { + console.error(`Expected numeric literal for diagnostic code, got ${init.getText()}`); + return undefined; + } + break; + } + case "range": { + // Handle range references like ranges[0] + const rangeArg = parseBaselineMarkerOrRangeArg(init); + if (rangeArg) { + diagnosticProps.push(`Range: ${rangeArg}.LSRange,`); + } + else { + console.error(`Expected range reference for diagnostic range, got ${init.getText()}`); + return undefined; + } + break; + } + case "reportsDeprecated": { + if (init.kind === ts.SyntaxKind.TrueKeyword) { + diagnosticProps.push(`Tags: &[]lsproto.DiagnosticTag{lsproto.DiagnosticTagDeprecated},`); + } + break; + } + case "reportsUnnecessary": { + if (init.kind === ts.SyntaxKind.TrueKeyword) { + diagnosticProps.push(`Tags: &[]lsproto.DiagnosticTag{lsproto.DiagnosticTagUnnecessary},`); + } + break; + } + default: + console.error(`Unrecognized property in expected diagnostic: ${propName}`); + return undefined; + } + } + + if (diagnosticProps.length === 0) { + console.error(`No valid properties found in diagnostic object`); + return undefined; + } + + return `&lsproto.Diagnostic{\n${diagnosticProps.join("\n")}\n}`; +} + function stringToTristate(s: string): string { switch (s) { case "true": @@ -932,7 +1395,64 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefin preferences.push(`UseAliasesForRename: ${stringToTristate(prop.initializer.getText())}`); break; case "quotePreference": - preferences.push(`QuotePreference: ls.QuotePreference(${prop.initializer.getText()})`); + preferences.push(`QuotePreference: lsutil.QuotePreference(${prop.initializer.getText()})`); + break; + case "autoImportFileExcludePatterns": + const arrayArg = getArrayLiteralExpression(prop.initializer); + if (!arrayArg) { + return undefined; + } + const patterns: string[] = []; + for (const elem of arrayArg.elements) { + const strElem = getStringLiteralLike(elem); + if (!strElem) { + return undefined; + } + patterns.push(getGoStringLiteral(strElem.text)); + } + preferences.push(`AutoImportFileExcludePatterns: []string{${patterns.join(", ")}}`); + break; + case "includeInlayParameterNameHints": + let paramHint; + if (!ts.isStringLiteralLike(prop.initializer)) { + return undefined; + } + switch (prop.initializer.text) { + case "none": + paramHint = "lsutil.IncludeInlayParameterNameHintsNone"; + break; + case "literals": + paramHint = "lsutil.IncludeInlayParameterNameHintsLiterals"; + break; + case "all": + paramHint = "lsutil.IncludeInlayParameterNameHintsAll"; + break; + } + preferences.push(`IncludeInlayParameterNameHints: ${paramHint}`); + break; + case "includeInlayParameterNameHintsWhenArgumentMatchesName": + preferences.push(`IncludeInlayParameterNameHintsWhenArgumentMatchesName: ${prop.initializer.getText()}`); + break; + case "includeInlayFunctionParameterTypeHints": + preferences.push(`IncludeInlayFunctionParameterTypeHints: ${prop.initializer.getText()}`); + break; + case "includeInlayVariableTypeHints": + preferences.push(`IncludeInlayVariableTypeHints: ${prop.initializer.getText()}`); + break; + case "includeInlayVariableTypeHintsWhenTypeMatchesName": + preferences.push(`IncludeInlayVariableTypeHintsWhenTypeMatchesName: ${prop.initializer.getText()}`); + break; + case "includeInlayPropertyDeclarationTypeHints": + preferences.push(`IncludeInlayPropertyDeclarationTypeHints: ${prop.initializer.getText()}`); + break; + case "includeInlayFunctionLikeReturnTypeHints": + preferences.push(`IncludeInlayFunctionLikeReturnTypeHints: ${prop.initializer.getText()}`); + break; + case "includeInlayEnumMemberValueHints": + preferences.push(`IncludeInlayEnumMemberValueHints: ${prop.initializer.getText()}`); + break; + case "interactiveInlayHints": + // Ignore, deprecated break; } } @@ -943,7 +1463,7 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefin if (preferences.length === 0) { return "nil /*preferences*/"; } - return `&ls.UserPreferences{${preferences.join(",")}}`; + return `&lsutil.UserPreferences{${preferences.join(",")}}`; } function parseBaselineMarkerOrRangeArg(arg: ts.Expression): string | undefined { @@ -951,29 +1471,9 @@ function parseBaselineMarkerOrRangeArg(arg: ts.Expression): string | undefined { return getGoStringLiteral(arg.text); } else if (ts.isIdentifier(arg) || (ts.isElementAccessExpression(arg) && ts.isIdentifier(arg.expression))) { - const argName = ts.isIdentifier(arg) ? arg.text : (arg.expression as ts.Identifier).text; - const file = arg.getSourceFile(); - const varStmts = file.statements.filter(ts.isVariableStatement); - for (const varStmt of varStmts) { - for (const decl of varStmt.declarationList.declarations) { - if (ts.isArrayBindingPattern(decl.name) && decl.initializer?.getText().includes("ranges")) { - for (let i = 0; i < decl.name.elements.length; i++) { - const elem = decl.name.elements[i]; - if (ts.isBindingElement(elem) && ts.isIdentifier(elem.name) && elem.name.text === argName) { - // `const [range_0, ..., range_n, ...] = test.ranges();` and arg is `range_n` - if (elem.dotDotDotToken === undefined) { - return `f.Ranges()[${i}]`; - } - // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest[n]` - if (ts.isElementAccessExpression(arg)) { - return `f.Ranges()[${i + parseInt(arg.argumentExpression!.getText())}]`; - } - // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest` - return `ToAny(f.Ranges()[${i}:])...`; - } - } - } - } + const result = parseRangeVariable(arg); + if (result) { + return result; } const init = getNodeOfKind(arg, ts.isCallExpression); if (init) { @@ -993,6 +1493,34 @@ function parseBaselineMarkerOrRangeArg(arg: ts.Expression): string | undefined { return undefined; } +function parseRangeVariable(arg: ts.Identifier | ts.ElementAccessExpression): string | undefined { + const argName = ts.isIdentifier(arg) ? arg.text : (arg.expression as ts.Identifier).text; + const file = arg.getSourceFile(); + const varStmts = file.statements.filter(ts.isVariableStatement); + for (const varStmt of varStmts) { + for (const decl of varStmt.declarationList.declarations) { + if (ts.isArrayBindingPattern(decl.name) && decl.initializer?.getText().includes("ranges")) { + for (let i = 0; i < decl.name.elements.length; i++) { + const elem = decl.name.elements[i]; + if (ts.isBindingElement(elem) && ts.isIdentifier(elem.name) && elem.name.text === argName) { + // `const [range_0, ..., range_n, ...] = test.ranges();` and arg is `range_n` + if (elem.dotDotDotToken === undefined) { + return `f.Ranges()[${i}]`; + } + // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest[n]` + if (ts.isElementAccessExpression(arg)) { + return `f.Ranges()[${i + parseInt(arg.argumentExpression!.getText())}]`; + } + // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest` + return `ToAny(f.Ranges()[${i}:])...`; + } + } + } + } + } + return undefined; +} + function getRangesByTextArg(arg: ts.CallExpression): string | undefined { if (arg.getText().startsWith("test.rangesByText()")) { if (ts.isStringLiteralLike(arg.arguments[0])) { @@ -1151,6 +1679,16 @@ function parseBaselineSignatureHelp(args: ts.NodeArray): Cmd { }; } +function parseBaselineSmartSelection(args: ts.NodeArray): Cmd { + if (args.length !== 0) { + // All calls are currently empty! + throw new Error("Expected no arguments in verify.baselineSmartSelection"); + } + return { + kind: "verifyBaselineSmartSelection", + }; +} + function parseKind(expr: ts.Expression): string | undefined { if (!ts.isStringLiteral(expr)) { console.error(`Expected string literal for kind, got ${expr.getText()}`); @@ -1266,11 +1804,218 @@ function parseSortText(expr: ts.Expression): string | undefined { } } +function parseVerifyNavigateTo(args: ts.NodeArray): [VerifyNavToCmd] | undefined { + const goArgs = []; + for (const arg of args) { + const result = parseVerifyNavigateToArg(arg); + if (!result) { + return undefined; + } + goArgs.push(result); + } + return [{ + kind: "verifyNavigateTo", + args: goArgs, + }]; +} + +function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { + if (!ts.isObjectLiteralExpression(arg)) { + console.error(`Expected object literal expression for verify.navigateTo argument, got ${arg.getText()}`); + return undefined; + } + let prefs; + const items = []; + let pattern: string | undefined; + for (const prop of arg.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Expected property assignment with identifier name for verify.navigateTo argument, got ${prop.getText()}`); + return undefined; + } + const propName = prop.name.text; + switch (propName) { + case "pattern": { + let patternInit = getStringLiteralLike(prop.initializer); + if (!patternInit) { + console.error(`Expected string literal for pattern in verify.navigateTo argument, got ${prop.initializer.getText()}`); + return undefined; + } + pattern = getGoStringLiteral(patternInit.text); + break; + } + case "fileName": + // no longer supported + continue; + case "expected": { + const init = prop.initializer; + if (!ts.isArrayLiteralExpression(init)) { + console.error(`Expected array literal expression for expected property in verify.navigateTo argument, got ${init.getText()}`); + return undefined; + } + for (const elem of init.elements) { + const result = parseNavToItem(elem); + if (!result) { + return undefined; + } + items.push(result); + } + break; + } + case "excludeLibFiles": { + if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) { + prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}`; + } + } + } + } + if (!prefs) { + prefs = "nil"; + } + return `{ + Pattern: ${pattern ? pattern : '""'}, + Preferences: ${prefs}, + Exact: PtrTo([]*lsproto.SymbolInformation{${items.length ? items.join(",\n") + ",\n" : ""}}), + }`; +} + +function parseNavToItem(arg: ts.Expression): string | undefined { + let item = getNodeOfKind(arg, ts.isObjectLiteralExpression); + if (!item) { + console.error(`Expected object literal expression for navigateTo item, got ${arg.getText()}`); + return undefined; + } + const itemProps: string[] = []; + for (const prop of item.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Expected property assignment with identifier name for navigateTo item, got ${prop.getText()}`); + return undefined; + } + const propName = prop.name.text; + const init = prop.initializer; + switch (propName) { + case "name": { + let nameInit; + if (!(nameInit = getStringLiteralLike(init))) { + console.error(`Expected string literal for name in navigateTo item, got ${init.getText()}`); + return undefined; + } + itemProps.push(`Name: ${getGoStringLiteral(nameInit.text)}`); + break; + } + case "kind": { + const goKind = getSymbolKind(init); + if (!goKind) { + return undefined; + } + itemProps.push(`Kind: lsproto.${goKind}`); + break; + } + case "kindModifiers": { + if (init.getText().includes("deprecated")) { + itemProps.push(`Tags: &[]lsproto.SymbolTag{lsproto.SymbolTagDeprecated}`); + } + break; + } + case "range": { + if (ts.isIdentifier(init) || (ts.isElementAccessExpression(init) && ts.isIdentifier(init.expression))) { + let parsedRange = parseRangeVariable(init); + if (parsedRange) { + itemProps.push(`Location: ${parsedRange}.LSLocation()`); + continue; + } + } + if (ts.isElementAccessExpression(init) && init.expression.getText() === "test.ranges()") { + itemProps.push(`Location: f.Ranges()[${parseInt(init.argumentExpression.getText())}].LSLocation()`); + continue; + } + console.error(`Expected range variable for range in navigateTo item, got ${init.getText()}`); + return undefined; + } + case "containerName": { + let nameInit; + if (!(nameInit = getStringLiteralLike(init))) { + console.error(`Expected string literal for container name in navigateTo item, got ${init.getText()}`); + return undefined; + } + itemProps.push(`ContainerName: PtrTo(${getGoStringLiteral(nameInit.text)})`); + break; + } + default: + // ignore other properties + } + } + return `{\n${itemProps.join(",\n")},\n}`; +} + +function getSymbolKind(kind: ts.Expression): string | undefined { + let result; + if (!(result = getStringLiteralLike(kind))) { + console.error(`Expected string literal for symbol kind, got ${kind.getText()}`); + return undefined; + } + switch (result.text) { + case "script": + return "SymbolKindFile"; + case "module": + return "SymbolKindModule"; + case "class": + case "local class": + return "SymbolKindClass"; + case "interface": + return "SymbolKindInterface"; + case "type": + return "SymbolKindClass"; + case "enum": + return "SymbolKindEnum"; + case "enum member": + return "SymbolKindEnumMember"; + case "var": + case "local var": + case "using": + case "await using": + return "SymbolKindVariable"; + case "function": + case "local function": + return "SymbolKindFunction"; + case "method": + return "SymbolKindMethod"; + case "getter": + case "setter": + case "property": + case "accessor": + return "SymbolKindProperty"; + case "constructor": + case "construct": + return "SymbolKindConstructor"; + case "call": + case "index": + return "SymbolKindFunction"; + case "parameter": + return "SymbolKindVariable"; + case "type parameter": + return "SymbolKindTypeParameter"; + case "primitive type": + return "SymbolKindObject"; + case "const": + case "let": + return "SymbolKindVariable"; + case "directory": + return "SymbolKindPackage"; + case "external module name": + return "SymbolKindModule"; + case "string": + return "SymbolKindString"; + default: + return "SymbolKindVariable"; + } +} + interface VerifyCompletionsCmd { kind: "verifyCompletions"; marker: string; isNewIdentifierLocation?: true; args?: VerifyCompletionsArgs | "nil"; + andApplyCodeActionArgs?: VerifyApplyCodeActionArgs; } interface VerifyCompletionsArgs { @@ -1280,10 +2025,17 @@ interface VerifyCompletionsArgs { unsorted?: string; } -interface VerifyBaselineFindAllReferencesCmd { - kind: "verifyBaselineFindAllReferences"; - markers: string[]; - ranges?: boolean; +interface VerifyApplyCodeActionArgs { + name: string; + source: string; + description: string; + newFileContent: string; +} + +interface VerifyApplyCodeActionFromCompletionCmd { + kind: "verifyApplyCodeActionFromCompletion"; + marker: string; + options: string; } interface VerifyBaselineFindAllReferencesCmd { @@ -1293,8 +2045,9 @@ interface VerifyBaselineFindAllReferencesCmd { } interface VerifyBaselineGoToDefinitionCmd { - kind: "verifyBaselineGoToDefinition"; + kind: "verifyBaselineGoToDefinition" | "verifyBaselineGoToType" | "verifyBaselineGoToImplementation"; markers: string[]; + boundSpan?: true; ranges?: boolean; } @@ -1306,6 +2059,10 @@ interface VerifyBaselineSignatureHelpCmd { kind: "verifyBaselineSignatureHelp"; } +interface VerifyBaselineSmartSelection { + kind: "verifyBaselineSmartSelection"; +} + interface VerifyBaselineRenameCmd { kind: "verifyBaselineRename" | "verifyBaselineRenameAtRangesWithText"; args: string[]; @@ -1318,6 +2075,18 @@ interface VerifyBaselineDocumentHighlightsCmd { preferences: string; } +interface VerifyBaselineInlayHintsCmd { + kind: "verifyBaselineInlayHints"; + span: string; + preferences: string; +} + +interface VerifyImportFixAtPositionCmd { + kind: "verifyImportFixAtPosition"; + expectedTexts: string[]; + preferences: string; +} + interface GoToCmd { kind: "goTo"; // !!! `selectRange` and `rangeStart` require parsing variables and `test.ranges()[n]` @@ -1342,20 +2111,42 @@ interface VerifyRenameInfoCmd { preferences: string; } +interface VerifyDiagnosticsCmd { + kind: "verifyDiagnostics"; + arg: string; + isSuggestion: boolean; +} + +interface VerifyBaselineDiagnosticsCmd { + kind: "verifyBaselineDiagnostics"; +} + +interface VerifyNavToCmd { + kind: "verifyNavigateTo"; + args: string[]; +} + type Cmd = | VerifyCompletionsCmd + | VerifyApplyCodeActionFromCompletionCmd | VerifyBaselineFindAllReferencesCmd | VerifyBaselineDocumentHighlightsCmd | VerifyBaselineGoToDefinitionCmd | VerifyBaselineQuickInfoCmd | VerifyBaselineSignatureHelpCmd + | VerifyBaselineSmartSelection | GoToCmd | EditCmd | VerifyQuickInfoCmd | VerifyBaselineRenameCmd - | VerifyRenameInfoCmd; - -function generateVerifyCompletions({ marker, args, isNewIdentifierLocation }: VerifyCompletionsCmd): string { + | VerifyRenameInfoCmd + | VerifyNavToCmd + | VerifyBaselineInlayHintsCmd + | VerifyImportFixAtPositionCmd + | VerifyDiagnosticsCmd + | VerifyBaselineDiagnosticsCmd; + +function generateVerifyCompletions({ marker, args, isNewIdentifierLocation, andApplyCodeActionArgs }: VerifyCompletionsCmd): string { let expectedList: string; if (args === "nil") { expectedList = "nil"; @@ -1379,7 +2170,21 @@ function generateVerifyCompletions({ marker, args, isNewIdentifierLocation }: Ve }, }`; } - return `f.VerifyCompletions(t, ${marker}, ${expectedList})`; + + const call = `f.VerifyCompletions(t, ${marker}, ${expectedList})`; + if (andApplyCodeActionArgs) { + return `${call}.AndApplyCodeAction(t, &fourslash.CompletionsExpectedCodeAction{ + Name: ${getGoStringLiteral(andApplyCodeActionArgs.name)}, + Source: ${getGoStringLiteral(andApplyCodeActionArgs.source)}, + Description: ${getGoStringLiteral(andApplyCodeActionArgs.description)}, + NewFileContent: ${getGoMultiLineStringLiteral(andApplyCodeActionArgs.newFileContent)}, + })`; + } + return call; +} + +function generateVerifyApplyCodeActionFromCompletion({ marker, options }: VerifyApplyCodeActionFromCompletionCmd): string { + return `f.VerifyApplyCodeActionFromCompletion(t, ${marker}, ${options})`; } function generateBaselineFindAllReferences({ markers, ranges }: VerifyBaselineFindAllReferencesCmd): string { @@ -1393,11 +2198,25 @@ function generateBaselineDocumentHighlights({ args, preferences }: VerifyBaselin return `f.VerifyBaselineDocumentHighlights(t, ${preferences}, ${args.join(", ")})`; } -function generateBaselineGoToDefinition({ markers, ranges }: VerifyBaselineGoToDefinitionCmd): string { - if (ranges || markers.length === 0) { - return `f.VerifyBaselineGoToDefinition(t)`; +function generateBaselineGoToDefinition({ markers, ranges, kind, boundSpan }: VerifyBaselineGoToDefinitionCmd): string { + const originalSelectionRange = boundSpan ? "true" : "false"; + switch (kind) { + case "verifyBaselineGoToDefinition": + if (ranges || markers.length === 0) { + return `f.VerifyBaselineGoToDefinition(t, ${originalSelectionRange})`; + } + return `f.VerifyBaselineGoToDefinition(t, ${originalSelectionRange}, ${markers.join(", ")})`; + case "verifyBaselineGoToType": + if (ranges || markers.length === 0) { + return `f.VerifyBaselineGoToTypeDefinition(t)`; + } + return `f.VerifyBaselineGoToTypeDefinition(t, ${markers.join(", ")})`; + case "verifyBaselineGoToImplementation": + if (ranges || markers.length === 0) { + return `f.VerifyBaselineGoToImplementation(t)`; + } + return `f.VerifyBaselineGoToImplementation(t, ${markers.join(", ")})`; } - return `f.VerifyBaselineGoToDefinition(t, ${markers.join(", ")})`; } function generateGoToCommand({ funcName, args }: GoToCmd): string { @@ -1427,21 +2246,43 @@ function generateBaselineRename({ kind, args, preferences }: VerifyBaselineRenam } } +function generateBaselineInlayHints({ span, preferences }: VerifyBaselineInlayHintsCmd): string { + return `f.VerifyBaselineInlayHints(t, ${span}, ${preferences})`; +} + +function generateImportFixAtPosition({ expectedTexts, preferences }: VerifyImportFixAtPositionCmd): string { + // Handle empty array case + if (expectedTexts.length === 1 && expectedTexts[0] === "") { + return `f.VerifyImportFixAtPosition(t, []string{}, ${preferences})`; + } + return `f.VerifyImportFixAtPosition(t, []string{\n${expectedTexts.join(",\n")},\n}, ${preferences})`; +} + +function generateNavigateTo({ args }: VerifyNavToCmd): string { + return `f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{\n${args.join(", ")}})`; +} + function generateCmd(cmd: Cmd): string { switch (cmd.kind) { case "verifyCompletions": return generateVerifyCompletions(cmd); + case "verifyApplyCodeActionFromCompletion": + return generateVerifyApplyCodeActionFromCompletion(cmd); case "verifyBaselineFindAllReferences": return generateBaselineFindAllReferences(cmd); case "verifyBaselineDocumentHighlights": return generateBaselineDocumentHighlights(cmd); case "verifyBaselineGoToDefinition": + case "verifyBaselineGoToType": + case "verifyBaselineGoToImplementation": return generateBaselineGoToDefinition(cmd); case "verifyBaselineQuickInfo": // Quick Info -> Hover return `f.VerifyBaselineHover(t)`; case "verifyBaselineSignatureHelp": return `f.VerifyBaselineSignatureHelp(t)`; + case "verifyBaselineSmartSelection": + return `f.VerifyBaselineSelectionRanges(t)`; case "goTo": return generateGoToCommand(cmd); case "edit": @@ -1458,6 +2299,17 @@ function generateCmd(cmd: Cmd): string { return `f.VerifyRenameSucceeded(t, ${cmd.preferences})`; case "renameInfoFailed": return `f.VerifyRenameFailed(t, ${cmd.preferences})`; + case "verifyBaselineInlayHints": + return generateBaselineInlayHints(cmd); + case "verifyImportFixAtPosition": + return generateImportFixAtPosition(cmd); + case "verifyDiagnostics": + const funcName = cmd.isSuggestion ? "VerifySuggestionDiagnostics" : "VerifyNonSuggestionDiagnostics"; + return `f.${funcName}(t, ${cmd.arg})`; + case "verifyBaselineDiagnostics": + return `f.VerifyBaselineNonSuggestionDiagnostics(t)`; + case "verifyNavigateTo": + return generateNavigateTo(cmd); default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`); @@ -1470,8 +2322,8 @@ interface GoTest { commands: Cmd[]; } -function generateGoTest(failingTests: Set, test: GoTest): string { - const testName = (test.name[0].toUpperCase() + test.name.substring(1)).replaceAll("-", "_"); +function generateGoTest(failingTests: Set, test: GoTest, isServer: boolean): string { + const testName = (test.name[0].toUpperCase() + test.name.substring(1)).replaceAll("-", "_").replaceAll(/[^a-zA-Z0-9_]/g, ""); const content = test.content; const commands = test.commands.map(cmd => generateCmd(cmd)).join("\n"); const imports = [`"github.com/microsoft/typescript-go/internal/fourslash"`]; @@ -1482,6 +2334,9 @@ function generateGoTest(failingTests: Set, test: GoTest): string { if (commands.includes("ls.")) { imports.push(`"github.com/microsoft/typescript-go/internal/ls"`); } + if (commands.includes("lsutil.")) { + imports.push(`"github.com/microsoft/typescript-go/internal/ls/lsutil"`); + } if (commands.includes("lsproto.")) { imports.push(`"github.com/microsoft/typescript-go/internal/lsp/lsproto"`); } @@ -1503,7 +2358,7 @@ func Test${testName}(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = ${content} f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - ${commands} + ${isServer ? `f.MarkTestAsStradaServer()\n` : ""}${commands} }`; return template; } diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index a3851e759e..bb01a0e577 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -3,6 +3,44 @@ TestAmbientShorthandGotoDefinition TestArgumentsAreAvailableAfterEditsAtEndOfFunction TestAugmentedTypesClass1 TestAugmentedTypesClass3Fourslash +TestAutoImportCompletionAmbientMergedModule1 +TestAutoImportCompletionExportListAugmentation1 +TestAutoImportCompletionExportListAugmentation2 +TestAutoImportCompletionExportListAugmentation3 +TestAutoImportCompletionExportListAugmentation4 +TestAutoImportCrossProject_symlinks_stripSrc +TestAutoImportCrossProject_symlinks_toDist +TestAutoImportCrossProject_symlinks_toSrc +TestAutoImportFileExcludePatterns3 +TestAutoImportJsDocImport1 +TestAutoImportModuleNone1 +TestAutoImportNodeNextJSRequire +TestAutoImportPathsAliasesAndBarrels +TestAutoImportPnpm +TestAutoImportProvider_exportMap1 +TestAutoImportProvider_exportMap2 +TestAutoImportProvider_exportMap3 +TestAutoImportProvider_exportMap4 +TestAutoImportProvider_exportMap5 +TestAutoImportProvider_exportMap6 +TestAutoImportProvider_exportMap7 +TestAutoImportProvider_exportMap8 +TestAutoImportProvider_exportMap9 +TestAutoImportProvider_globalTypingsCache +TestAutoImportProvider_namespaceSameNameAsIntrinsic +TestAutoImportProvider_pnpm +TestAutoImportProvider_wildcardExports1 +TestAutoImportProvider_wildcardExports2 +TestAutoImportProvider_wildcardExports3 +TestAutoImportProvider4 +TestAutoImportSortCaseSensitivity1 +TestAutoImportSymlinkCaseSensitive +TestAutoImportTypeImport1 +TestAutoImportTypeImport2 +TestAutoImportTypeImport3 +TestAutoImportTypeImport4 +TestAutoImportTypeOnlyPreferred2 +TestAutoImportVerbatimTypeOnly1 TestBestCommonTypeObjectLiterals TestBestCommonTypeObjectLiterals1 TestCodeCompletionEscaping @@ -16,12 +54,22 @@ TestCompletionEntryClassMembersWithInferredFunctionReturnType1 TestCompletionEntryForArgumentConstrainedToString TestCompletionEntryForArrayElementConstrainedToString TestCompletionEntryForArrayElementConstrainedToString2 -TestCompletionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved TestCompletionEntryForUnionProperty TestCompletionEntryForUnionProperty2 TestCompletionForComputedStringProperties TestCompletionForMetaProperty +TestCompletionForObjectProperty TestCompletionForStringLiteral +TestCompletionForStringLiteral_details +TestCompletionForStringLiteral_quotePreference +TestCompletionForStringLiteral_quotePreference1 +TestCompletionForStringLiteral_quotePreference2 +TestCompletionForStringLiteral_quotePreference3 +TestCompletionForStringLiteral_quotePreference4 +TestCompletionForStringLiteral_quotePreference5 +TestCompletionForStringLiteral_quotePreference6 +TestCompletionForStringLiteral_quotePreference7 +TestCompletionForStringLiteral_quotePreference8 TestCompletionForStringLiteral4 TestCompletionForStringLiteralExport TestCompletionForStringLiteralImport1 @@ -34,7 +82,6 @@ TestCompletionForStringLiteralNonrelativeImport18 TestCompletionForStringLiteralNonrelativeImport2 TestCompletionForStringLiteralNonrelativeImport3 TestCompletionForStringLiteralNonrelativeImport4 -TestCompletionForStringLiteralNonrelativeImport7 TestCompletionForStringLiteralNonrelativeImport8 TestCompletionForStringLiteralNonrelativeImport9 TestCompletionForStringLiteralNonrelativeImportTypings1 @@ -44,16 +91,6 @@ TestCompletionForStringLiteralRelativeImport4 TestCompletionForStringLiteralRelativeImport6 TestCompletionForStringLiteralRelativeImportAllowJSTrue TestCompletionForStringLiteralWithDynamicImport -TestCompletionForStringLiteral_details -TestCompletionForStringLiteral_quotePreference -TestCompletionForStringLiteral_quotePreference1 -TestCompletionForStringLiteral_quotePreference2 -TestCompletionForStringLiteral_quotePreference3 -TestCompletionForStringLiteral_quotePreference4 -TestCompletionForStringLiteral_quotePreference5 -TestCompletionForStringLiteral_quotePreference6 -TestCompletionForStringLiteral_quotePreference7 -TestCompletionForStringLiteral_quotePreference8 TestCompletionImportMeta TestCompletionImportMetaWithGlobalDeclaration TestCompletionImportModuleSpecifierEndingDts @@ -66,16 +103,13 @@ TestCompletionImportModuleSpecifierEndingUnsupportedExtension TestCompletionInChecks1 TestCompletionInFunctionLikeBody_includesPrimitiveTypes TestCompletionInJsDoc -TestCompletionInNamedImportLocation TestCompletionInUncheckedJSFile TestCompletionListBuilderLocations_VariableDeclarations TestCompletionListForDerivedType1 -TestCompletionListForTransitivelyExportedMembers04 TestCompletionListFunctionExpression TestCompletionListInArrowFunctionInUnclosedCallSite01 TestCompletionListInClassExpressionWithTypeParameter TestCompletionListInClassStaticBlocks -TestCompletionListInImportClause01 TestCompletionListInImportClause05 TestCompletionListInImportClause06 TestCompletionListInNamedClassExpression @@ -94,17 +128,16 @@ TestCompletionListInUnclosedTaggedTemplate02 TestCompletionListInUnclosedTemplate01 TestCompletionListInUnclosedTemplate02 TestCompletionListInvalidMemberNames -TestCompletionListInvalidMemberNames2 TestCompletionListInvalidMemberNames_escapeQuote TestCompletionListInvalidMemberNames_startWithSpace TestCompletionListInvalidMemberNames_withExistingIdentifier -TestCompletionListObjectMembersInTypeLocationWithTypeof +TestCompletionListInvalidMemberNames2 TestCompletionListOfGenericSymbol TestCompletionListOnAliases +TestCompletionListsStringLiteralTypeAsIndexedAccessTypeObject TestCompletionListStringParenthesizedExpression TestCompletionListStringParenthesizedType TestCompletionListWithoutVariableinitializer -TestCompletionListsStringLiteralTypeAsIndexedAccessTypeObject TestCompletionNoAutoInsertQuestionDotForThis TestCompletionNoAutoInsertQuestionDotForTypeParameter TestCompletionNoAutoInsertQuestionDotWithUserPreferencesOff @@ -116,12 +149,38 @@ TestCompletionOfAwaitPromise6 TestCompletionOfAwaitPromise7 TestCompletionOfInterfaceAndVar TestCompletionPreferredSuggestions1 -TestCompletionWithConditionalOperatorMissingColon TestCompletionsAfterJSDoc TestCompletionsBeforeRestArg1 +TestCompletionsClassMemberImportTypeNodeParameter1 +TestCompletionsClassMemberImportTypeNodeParameter2 +TestCompletionsClassMemberImportTypeNodeParameter3 +TestCompletionsClassMemberImportTypeNodeParameter4 TestCompletionsElementAccessNumeric TestCompletionsExportImport TestCompletionsGenericTypeWithMultipleBases1 +TestCompletionsImport_default_alreadyExistedWithRename +TestCompletionsImport_default_anonymous +TestCompletionsImport_details_withMisspelledName +TestCompletionsImport_exportEquals_global +TestCompletionsImport_filteredByInvalidPackageJson_direct +TestCompletionsImport_filteredByPackageJson_direct +TestCompletionsImport_filteredByPackageJson_nested +TestCompletionsImport_filteredByPackageJson_peerDependencies +TestCompletionsImport_filteredByPackageJson_typesImplicit +TestCompletionsImport_filteredByPackageJson_typesOnly +TestCompletionsImport_jsxOpeningTagImportDefault +TestCompletionsImport_mergedReExport +TestCompletionsImport_named_didNotExistBefore +TestCompletionsImport_noSemicolons +TestCompletionsImport_packageJsonImportsPreference +TestCompletionsImport_quoteStyle +TestCompletionsImport_reExport_wrongName +TestCompletionsImport_reExportDefault2 +TestCompletionsImport_require_addToExisting +TestCompletionsImport_typeOnly +TestCompletionsImport_umdDefaultNoCrash1 +TestCompletionsImport_uriStyleNodeCoreModules2 +TestCompletionsImport_windowsPathsProjectRelative TestCompletionsImportOrExportSpecifier TestCompletionsInExport TestCompletionsInExport_moduleBlock @@ -147,20 +206,24 @@ TestCompletionsOverridingMethod4 TestCompletionsOverridingMethod9 TestCompletionsOverridingMethodCrash1 TestCompletionsOverridingProperties1 -TestCompletionsPathsJsonModule -TestCompletionsPathsRelativeJsonModule TestCompletionsPaths_importType TestCompletionsPaths_kinds TestCompletionsPaths_pathMapping TestCompletionsPaths_pathMapping_nonTrailingWildcard1 TestCompletionsPaths_pathMapping_parentDirectory +TestCompletionsPathsJsonModule +TestCompletionsPathsRelativeJsonModule +TestCompletionsRecommended_namespace TestCompletionsRecommended_union TestCompletionsRedeclareModuleAsGlobal TestCompletionsStringsWithTriggerCharacter TestCompletionsSymbolMembers TestCompletionsTriggerCharacter TestCompletionsTuple +TestCompletionsUniqueSymbol_import TestCompletionsUniqueSymbol1 +TestCompletionsWithDeprecatedTag10 +TestCompletionWithConditionalOperatorMissingColon TestConstEnumQuickInfoAndCompletionList TestConstQuickInfoAndCompletionList TestContextuallyTypedFunctionExpressionGeneric1 @@ -168,13 +231,10 @@ TestDoubleUnderscoreCompletions TestEditJsdocType TestExportDefaultClass TestExportDefaultFunction -TestFindAllRefsForDefaultExport03 -TestFindAllRefsForModule -TestFindAllRefsModuleDotExports TestFindReferencesBindingPatternInJsdocNoCrash1 TestFindReferencesBindingPatternInJsdocNoCrash2 -TestGenericCombinatorWithConstraints1 TestGenericCombinators3 +TestGenericCombinatorWithConstraints1 TestGenericFunctionWithGenericParams1 TestGenericInterfacesWithConstraints1 TestGenericTypeWithMultipleBases1MultiFile @@ -182,7 +242,6 @@ TestGetJavaScriptCompletions10 TestGetJavaScriptCompletions12 TestGetJavaScriptCompletions13 TestGetJavaScriptCompletions15 -TestGetJavaScriptCompletions18 TestGetJavaScriptCompletions20 TestGetJavaScriptCompletions8 TestGetJavaScriptCompletions9 @@ -197,33 +256,78 @@ TestGetJavaScriptQuickInfo7 TestGetJavaScriptQuickInfo8 TestGetJavaScriptSyntacticDiagnostics24 TestGetOccurrencesIfElseBroken -TestGetQuickInfoForIntersectionTypes TestHoverOverComment +TestImportCompletions_importsMap1 +TestImportCompletions_importsMap2 +TestImportCompletions_importsMap3 +TestImportCompletions_importsMap4 +TestImportCompletions_importsMap5 TestImportCompletionsPackageJsonExportsSpecifierEndsInTs TestImportCompletionsPackageJsonExportsTrailingSlash1 +TestImportCompletionsPackageJsonImports_ts TestImportCompletionsPackageJsonImportsConditions1 TestImportCompletionsPackageJsonImportsLength1 TestImportCompletionsPackageJsonImportsLength2 TestImportCompletionsPackageJsonImportsPattern -TestImportCompletionsPackageJsonImportsPattern2 TestImportCompletionsPackageJsonImportsPattern_capsInPath1 TestImportCompletionsPackageJsonImportsPattern_capsInPath2 TestImportCompletionsPackageJsonImportsPattern_js_ts TestImportCompletionsPackageJsonImportsPattern_ts TestImportCompletionsPackageJsonImportsPattern_ts_ts -TestImportCompletionsPackageJsonImports_ts -TestImportCompletions_importsMap1 -TestImportCompletions_importsMap2 -TestImportCompletions_importsMap3 -TestImportCompletions_importsMap4 -TestImportCompletions_importsMap5 +TestImportCompletionsPackageJsonImportsPattern2 +TestImportFixesGlobalTypingsCache +TestImportNameCodeFix_avoidRelativeNodeModules +TestImportNameCodeFix_fileWithNoTrailingNewline +TestImportNameCodeFix_HeaderComment1 +TestImportNameCodeFix_HeaderComment2 +TestImportNameCodeFix_importType1 +TestImportNameCodeFix_importType2 +TestImportNameCodeFix_importType4 +TestImportNameCodeFix_importType7 +TestImportNameCodeFix_importType8 +TestImportNameCodeFix_jsx1 +TestImportNameCodeFix_order +TestImportNameCodeFix_order2 +TestImportNameCodeFix_pnpm1 +TestImportNameCodeFix_preferBaseUrl +TestImportNameCodeFix_reExportDefault +TestImportNameCodeFix_symlink +TestImportNameCodeFix_trailingComma +TestImportNameCodeFix_withJson +TestImportNameCodeFixConvertTypeOnly1 +TestImportNameCodeFixExistingImport10 +TestImportNameCodeFixExistingImport11 +TestImportNameCodeFixExistingImport8 +TestImportNameCodeFixExistingImport9 +TestImportNameCodeFixExistingImportEquals0 +TestImportNameCodeFixExportAsDefault +TestImportNameCodeFixNewImportAmbient1 +TestImportNameCodeFixNewImportAmbient3 +TestImportNameCodeFixNewImportBaseUrl0 +TestImportNameCodeFixNewImportBaseUrl1 +TestImportNameCodeFixNewImportBaseUrl2 +TestImportNameCodeFixNewImportFile2 +TestImportNameCodeFixNewImportFileQuoteStyle0 +TestImportNameCodeFixNewImportFileQuoteStyle1 +TestImportNameCodeFixNewImportFileQuoteStyle2 +TestImportNameCodeFixNewImportFileQuoteStyleMixed0 +TestImportNameCodeFixNewImportFileQuoteStyleMixed1 +TestImportNameCodeFixNewImportRootDirs0 +TestImportNameCodeFixNewImportTypeRoots1 +TestImportTypeCompletions1 +TestImportTypeCompletions3 +TestImportTypeCompletions4 +TestImportTypeCompletions6 +TestImportTypeCompletions7 +TestImportTypeCompletions8 +TestImportTypeCompletions9 TestIndexerReturnTypes1 TestIndirectClassInstantiation TestInstanceTypesForGenericType1 TestJavascriptModules20 -TestJavascriptModules21 -TestJavascriptModulesTypeImport TestJsDocAugments +TestJsDocAugmentsAndExtends +TestJsdocCallbackTag TestJsDocExtends TestJsDocFunctionSignatures10 TestJsDocFunctionSignatures11 @@ -233,6 +337,9 @@ TestJsDocFunctionSignatures7 TestJsDocFunctionSignatures8 TestJsDocGenerics2 TestJsDocInheritDoc +TestJsdocLink2 +TestJsdocLink3 +TestJsdocLink6 TestJsDocPropertyDescription1 TestJsDocPropertyDescription10 TestJsDocPropertyDescription11 @@ -245,29 +352,29 @@ TestJsDocPropertyDescription6 TestJsDocPropertyDescription7 TestJsDocPropertyDescription8 TestJsDocPropertyDescription9 +TestJsDocServices TestJsDocTagsWithHyphen -TestJsQuickInfoGenerallyAcceptableSize -TestJsRequireQuickInfo -TestJsdocCallbackTag -TestJsdocLink2 -TestJsdocLink3 -TestJsdocLink6 TestJsdocTemplatePrototypeCompletions TestJsdocThrowsTagCompletion TestJsdocTypedefTag TestJsdocTypedefTag2 TestJsdocTypedefTagNamespace TestJsdocTypedefTagServices +TestJsFileImportNoTypes2 +TestJsQuickInfoGenerallyAcceptableSize +TestJsRequireQuickInfo TestLetQuickInfoAndCompletionList TestLocalFunction TestMemberListInReopenedEnum TestMemberListInWithBlock TestMemberListOfExportedClass TestMemberListOnContextualThis +TestModuleNodeNextAutoImport2 +TestModuleNodeNextAutoImport3 TestNgProxy1 +TestNodeModulesImportCompletions1 TestNoQuickInfoForLabel TestNoQuickInfoInWhitespace -TestNodeModulesImportCompletions1 TestNumericPropertyNames TestOverloadQuickInfo TestParameterWithDestructuring @@ -321,12 +428,14 @@ TestPathCompletionsTypesVersionsWildcard4 TestPathCompletionsTypesVersionsWildcard5 TestPathCompletionsTypesVersionsWildcard6 TestProtoVarVisibleWithOuterScopeUnderscoreProto +TestQuickInfo_notInsideComment +TestQuickinfo01 TestQuickInfoAlias TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 TestQuickInfoClassKeyword -TestQuickInfoContextualTyping TestQuickInfoContextuallyTypedSignatureOptionalParameterFromIntersection1 +TestQuickInfoContextualTyping TestQuickInfoDisplayPartsIife TestQuickInfoElementAccessDeclaration TestQuickInfoForConstTypeReference @@ -339,14 +448,15 @@ TestQuickInfoForGenericTaggedTemplateExpression TestQuickInfoForGetterAndSetter TestQuickInfoForIndexerResultWithConstraint TestQuickInfoForNamedTupleMember +TestQuickinfoForNamespaceMergeWithClassConstrainedToSelf TestQuickInfoForObjectBindingElementPropertyName04 TestQuickInfoForShorthandProperty TestQuickInfoForSyntaxErrorNoError +TestQuickInfoForTypeofParameter TestQuickInfoForTypeParameterInTypeAlias1 TestQuickInfoForTypeParameterInTypeAlias2 -TestQuickInfoForTypeofParameter TestQuickInfoForUMDModuleAlias -TestQuickInfoFromContextualType +TestQuickinfoForUnionProperty TestQuickInfoFunctionKeyword TestQuickInfoGenerics TestQuickInfoGetterSetter @@ -357,14 +467,12 @@ TestQuickInfoInWithBlock TestQuickInfoJSDocBackticks TestQuickInfoJSDocFunctionNew TestQuickInfoJSDocFunctionThis -TestQuickInfoJSExport TestQuickInfoJsDocGetterSetterNoCrash1 TestQuickInfoJsDocNonDiscriminatedUnionSharedProp -TestQuickInfoJsPropertyAssignedAfterMethodDeclaration TestQuickInfoJsdocTypedefMissingType +TestQuickInfoJSExport TestQuickInfoMappedSpreadTypes TestQuickInfoMappedType -TestQuickInfoMappedTypeMethods TestQuickInfoMappedTypeRecursiveInference TestQuickInfoModuleVariables TestQuickInfoNarrowedTypeOfAliasSymbol @@ -387,7 +495,6 @@ TestQuickInfoOnGenericWithConstraints1 TestQuickInfoOnInternalAliases TestQuickInfoOnJsxNamespacedNameWithDoc1 TestQuickInfoOnMethodOfImportEquals -TestQuickInfoOnNarrowedType TestQuickInfoOnNarrowedTypeInModule TestQuickInfoOnNewKeyword01 TestQuickInfoOnObjectLiteralWithAccessors @@ -407,6 +514,7 @@ TestQuickInfoOnUndefined TestQuickInfoOnVarInArrowExpression TestQuickInfoPrivateIdentifierInTypeReferenceNoCrash1 TestQuickInfoPropertyTag +TestQuickInforForSucessiveInferencesIsNotAny TestQuickInfoSignatureOptionalParameterFromUnion1 TestQuickInfoSignatureRestParameterFromUnion1 TestQuickInfoSignatureRestParameterFromUnion2 @@ -420,16 +528,9 @@ TestQuickInfoTypeError TestQuickInfoTypeOfThisInStatics TestQuickInfoTypeOnlyNamespaceAndClass TestQuickInfoUnionOfNamespaces -TestQuickInfoUnion_discriminated TestQuickInfoWidenedTypes -TestQuickInfo_notInsideComment -TestQuickInforForSucessiveInferencesIsNotAny -TestQuickinfo01 -TestQuickinfoForNamespaceMergeWithClassConstrainedToSelf -TestQuickinfoForUnionProperty TestQuickinfoWrongComment TestRecursiveInternalModuleImport -TestReferencesForStatementKeywords TestReferencesInEmptyFile TestRegexDetection TestRenameForAliasingExport02 @@ -455,8 +556,6 @@ TestTripleSlashRefPathCompletionExtensionsAllowJSFalse TestTripleSlashRefPathCompletionExtensionsAllowJSTrue TestTripleSlashRefPathCompletionHiddenFile TestTripleSlashRefPathCompletionRootdirs -TestTsxCompletion14 -TestTsxCompletion15 TestTsxCompletionNonTagLessThan TestTsxQuickInfo1 TestTsxQuickInfo4 diff --git a/internal/fourslash/_scripts/makeManual.mts b/internal/fourslash/_scripts/makeManual.mts index 09beb81cac..dea3584c83 100644 --- a/internal/fourslash/_scripts/makeManual.mts +++ b/internal/fourslash/_scripts/makeManual.mts @@ -56,7 +56,7 @@ function main() { if (!manualTests.includes(testName)) { manualTests.push(testName); - manualTests.sort(); + manualTests.sort((a, b) => a.localeCompare(b, "en-US")); fs.writeFileSync(manualTestsPath, [...manualTests, ""].join("\n"), "utf-8"); } } diff --git a/internal/fourslash/_scripts/manualTests.txt b/internal/fourslash/_scripts/manualTests.txt index 492d95e520..1dfd6557eb 100644 --- a/internal/fourslash/_scripts/manualTests.txt +++ b/internal/fourslash/_scripts/manualTests.txt @@ -2,6 +2,14 @@ completionListInClosedFunction05 completionsAtIncompleteObjectLiteralProperty completionsSelfDeclaring1 completionsWithDeprecatedTag4 +navigationItemsExactMatch2 +navigationItemsSpecialPropertyAssignment +navto_excludeLib1 +navto_excludeLib2 +navto_excludeLib4 +navto_serverExcludeLib +parserCorruptionAfterMapInClass +quickInfoForOverloadOnConst1 renameDefaultKeyword renameForDefaultExport01 tsxCompletion12 diff --git a/internal/fourslash/_scripts/updateFailing.mts b/internal/fourslash/_scripts/updateFailing.mts index 85de8e8cf1..5ddf655859 100644 --- a/internal/fourslash/_scripts/updateFailing.mts +++ b/internal/fourslash/_scripts/updateFailing.mts @@ -13,7 +13,7 @@ function main() { const go = which.sync("go"); let testOutput: string; try { - testOutput = cp.execFileSync(go, ["test", "./internal/fourslash/tests/gen"], { encoding: "utf-8" }); + testOutput = cp.execFileSync(go, ["test", "-v", "./internal/fourslash/tests/gen"], { encoding: "utf-8" }); } catch (error) { testOutput = (error as { stdout: string; }).stdout as string; @@ -21,7 +21,7 @@ function main() { const panicRegex = /^panic/m; if (panicRegex.test(testOutput)) { fs.writeFileSync(failingTestsPath, oldFailingTests, "utf-8"); - throw new Error("Unrecovered panic detected in tests"); + throw new Error("Unrecovered panic detected in tests\n" + testOutput); } const failRegex = /--- FAIL: ([\S]+)/gm; const failingTests: string[] = []; @@ -31,7 +31,7 @@ function main() { failingTests.push(match[1]); } - fs.writeFileSync(failingTestsPath, failingTests.sort().join("\n") + "\n", "utf-8"); + fs.writeFileSync(failingTestsPath, failingTests.sort((a, b) => a.localeCompare(b, "en-US")).join("\n") + "\n", "utf-8"); convertFourslash(); } diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index 83e683b1d4..b49fb6b28b 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -13,26 +13,48 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/vfs" ) -func (f *FourslashTest) addResultToBaseline(t *testing.T, command string, actual string) { - b, ok := f.baselines[command] - if !ok { +const ( + autoImportsCmd baselineCommand = "Auto Imports" + documentHighlightsCmd baselineCommand = "documentHighlights" + findAllReferencesCmd baselineCommand = "findAllReferences" + goToDefinitionCmd baselineCommand = "goToDefinition" + goToImplementationCmd baselineCommand = "goToImplementation" + goToTypeDefinitionCmd baselineCommand = "goToType" + inlayHintsCmd baselineCommand = "Inlay Hints" + nonSuggestionDiagnosticsCmd baselineCommand = "Syntax and Semantic Diagnostics" + quickInfoCmd baselineCommand = "QuickInfo" + renameCmd baselineCommand = "findRenameLocations" + signatureHelpCmd baselineCommand = "SignatureHelp" + smartSelectionCmd baselineCommand = "Smart Selection" +) + +type baselineCommand string + +func (f *FourslashTest) addResultToBaseline(t *testing.T, command baselineCommand, actual string) { + var b *strings.Builder + if f.testData.isStateBaseliningEnabled() { + // Single baseline for all commands + b = &f.stateBaseline.baseline + } else if builder, ok := f.baselines[command]; ok { + b = builder + } else { f.baselines[command] = &strings.Builder{} b = f.baselines[command] } if b.Len() != 0 { b.WriteString("\n\n\n\n") } - b.WriteString(`// === ` + command + " ===\n" + actual) + b.WriteString(`// === ` + string(command) + " ===\n" + actual) } -func (f *FourslashTest) writeToBaseline(command string, content string) { +func (f *FourslashTest) writeToBaseline(command baselineCommand, content string) { b, ok := f.baselines[command] if !ok { f.baselines[command] = &strings.Builder{} @@ -41,27 +63,35 @@ func (f *FourslashTest) writeToBaseline(command string, content string) { b.WriteString(content) } -func getBaselineFileName(t *testing.T, command string) string { +func getBaselineFileName(t *testing.T, command baselineCommand) string { return getBaseFileNameFromTest(t) + "." + getBaselineExtension(command) } -func getBaselineExtension(command string) string { +func getBaselineExtension(command baselineCommand) string { switch command { - case "QuickInfo", "SignatureHelp": + case quickInfoCmd, signatureHelpCmd, smartSelectionCmd, inlayHintsCmd, nonSuggestionDiagnosticsCmd: return "baseline" - case "Auto Imports": + case autoImportsCmd: return "baseline.md" - case "findAllReferences", "goToDefinition", "findRenameLocations": - return "baseline.jsonc" default: return "baseline.jsonc" } } -func getBaselineOptions(command string) baseline.Options { - subfolder := "fourslash/" + normalizeCommandName(command) +func (f *FourslashTest) getBaselineOptions(command baselineCommand, testPath string) baseline.Options { + subfolder := "fourslash/" + normalizeCommandName(string(command)) + if !isSubmoduleTest(testPath) { + return baseline.Options{ + Subfolder: subfolder, + } + } switch command { - case "findRenameLocations": + case smartSelectionCmd: + return baseline.Options{ + Subfolder: subfolder, + IsSubmodule: true, + } + case renameCmd: return baseline.Options{ Subfolder: subfolder, IsSubmodule: true, @@ -90,18 +120,187 @@ func getBaselineOptions(command string) baseline.Options { matches := commandPrefix.FindStringSubmatch(line) if len(matches) > 0 { commandName := matches[1] - if commandName == command { + if commandName == string(command) { + isInCommand = true + } else { + isInCommand = false + } + } + if isInCommand { + fixedLine := replacer.Replace(line) + commandLines = append(commandLines, fixedLine) + } + } + return strings.Join(dropTrailingEmptyLines(commandLines), "\n") + }, + } + case inlayHintsCmd: + return baseline.Options{ + Subfolder: subfolder, + IsSubmodule: true, + DiffFixupOld: func(s string) string { + var commandLines []string + commandPrefix := regexp.MustCompile(`^// === ([a-z\sA-Z]*) ===`) + lines := strings.Split(s, "\n") + var isInCommand bool + replacer := strings.NewReplacer( + `"whitespaceAfter"`, `"paddingRight"`, + `"whitespaceBefore"`, `"paddingLeft"`, + ) + hintStart := -1 + for i := 0; i < len(lines); i++ { + line := lines[i] + matches := commandPrefix.FindStringSubmatch(line) + if len(matches) > 0 { + commandName := matches[1] + if commandName == string(command) { isInCommand = true } else { isInCommand = false } } if isInCommand { + if line == "{" { + hintStart = len(commandLines) + } + if line == "}" && strings.HasSuffix(commandLines[len(commandLines)-1], ",") { + commandLines[len(commandLines)-1] = strings.TrimSuffix(commandLines[len(commandLines)-1], ",") + } + trimmedLine := strings.TrimSpace(line) + // Ignore position, already verified via caret. + if strings.HasPrefix(trimmedLine, `"position": `) { + continue + } + if strings.HasPrefix(trimmedLine, `"text": `) { + if trimmedLine == `"text": "",` { + continue + } + line = strings.Replace(line, `"text":`, `"label":`, 1) + } + if strings.HasPrefix(trimmedLine, `"kind": `) { + switch trimmedLine { + case `"kind": "Parameter",`: + line = strings.Replace(line, `"kind": "Parameter",`, `"kind": 2,`, 1) + case `"kind": "Type",`: + line = strings.Replace(line, `"kind": "Type",`, `"kind": 1,`, 1) + default: + continue + } + } + // Compare only text/value of display parts. + // Record the presence of a span but not its details. + if strings.HasPrefix(trimmedLine, `"displayParts": `) { + var displayPartLines []string + displayPartLines = append(displayPartLines, strings.Replace(line, "displayParts", "label", 1)) + var j int + for j = i + 1; j < len(lines); j++ { + line := lines[j] + trimmedLine := strings.TrimSpace(line) + if strings.HasPrefix(trimmedLine, `"text": `) { + line = strings.Replace(line, `"text":`, `"value":`, 1) + } else if strings.HasPrefix(trimmedLine, `"span": `) { + displayPartLines = append(displayPartLines, strings.Replace(line, "span", "location", 1)+"},") + j = j + 3 + continue + } else if strings.HasPrefix(trimmedLine, `"file": `) { + continue + } + if trimmedLine == "]" || trimmedLine == "]," { + fixedLine := line + if trimmedLine == "]" { + fixedLine += "," + } + displayPartLines = append(displayPartLines, fixedLine) + break + } + displayPartLines = append(displayPartLines, line) + } + // Add display parts at beginning of hint. + commandLines = slices.Insert(commandLines, hintStart+1, displayPartLines...) + i = j + continue + } + fixedLine := replacer.Replace(line) commandLines = append(commandLines, fixedLine) } } - return strings.Join(commandLines, "\n") + return strings.Join(dropTrailingEmptyLines(commandLines), "\n") + }, + DiffFixupNew: func(s string) string { + lines := strings.Split(s, "\n") + var fixedLines []string + for i := 0; i < len(lines); i++ { + line := lines[i] + trimmedLine := strings.TrimSpace(line) + if strings.HasPrefix(trimmedLine, `"position": `) { + i = i + 3 + continue + } + if strings.HasPrefix(trimmedLine, `"location": `) { + fixedLines = append(fixedLines, line+"},") + i = i + 12 + continue + } + fixedLines = append(fixedLines, line) + } + return strings.Join(fixedLines, "\n") + }, + } + case goToDefinitionCmd, goToTypeDefinitionCmd, goToImplementationCmd: + return baseline.Options{ + Subfolder: subfolder, + IsSubmodule: true, + DiffFixupOld: func(s string) string { + var commandLines []string + commandPrefix := regexp.MustCompile(`^// === ([a-z\sA-Z]*) ===`) + testFilePrefix := "/tests/cases/fourslash" + serverTestFilePrefix := "/server" + oldGoToDefCommand := "getDefinitionAtPosition" + oldGoToDefComment := "/*GOTO DEF POS*/" + replacer := strings.NewReplacer( + testFilePrefix, "", + serverTestFilePrefix, "", + oldGoToDefCommand, string(goToDefinitionCmd), + oldGoToDefComment, "/*GOTO DEF*/", + ) + objectRangeRegex := regexp.MustCompile(`{\| [^|]* \|}`) + detailsStr := "// === Details ===" + lines := strings.Split(s, "\n") + var isInCommand bool + var isInDetails bool + for _, line := range lines { + matches := commandPrefix.FindStringSubmatch(line) + if len(matches) > 0 { + isInDetails = false + commandName := matches[1] + if commandName == string(command) || + command == goToDefinitionCmd && commandName == oldGoToDefCommand { + isInCommand = true + } else { + isInCommand = false + } + } + if isInCommand { + if strings.Contains(line, detailsStr) { + // Drop blank line before details + commandLines = commandLines[:len(commandLines)-1] + isInDetails = true + } + // We don't diff the details section, since the structure of responses is different. + if !isInDetails { + fixedLine := replacer.Replace(line) + fixedLine = objectRangeRegex.ReplaceAllString(fixedLine, "") + commandLines = append(commandLines, fixedLine) + } else if line == " ]" { + isInDetails = false + } + } + } + return strings.Join(dropTrailingEmptyLines(commandLines), "\n") + }, + DiffFixupNew: func(s string) string { + return strings.ReplaceAll(s, "bundled:///libs/", "") }, } default: @@ -111,12 +310,26 @@ func getBaselineOptions(command string) baseline.Options { } } +func dropTrailingEmptyLines(ss []string) []string { + return ss[:core.FindLastIndex(ss, func(s string) bool { return s != "" })+1] +} + +func isSubmoduleTest(testPath string) bool { + return strings.Contains(testPath, "fourslash/tests/gen") || strings.Contains(testPath, "fourslash/tests/manual") +} + func normalizeCommandName(command string) string { words := strings.Fields(command) command = strings.Join(words, "") return stringutil.LowerFirstChar(command) } +type documentSpan struct { + uri lsproto.DocumentUri + textSpan lsproto.Range + contextSpan *lsproto.Range +} + type baselineFourslashLocationsOptions struct { // markerInfo marker MarkerOrRange // location @@ -124,32 +337,45 @@ type baselineFourslashLocationsOptions struct { endMarker string - startMarkerPrefix func(span lsproto.Location) *string - endMarkerSuffix func(span lsproto.Location) *string + startMarkerPrefix func(span documentSpan) *string + endMarkerSuffix func(span documentSpan) *string + getLocationData func(span documentSpan) string + + additionalSpan *documentSpan } -func (f *FourslashTest) getBaselineForLocationsWithFileContents(spans []lsproto.Location, options baselineFourslashLocationsOptions) string { - locationsByFile := collections.GroupBy(spans, func(span lsproto.Location) lsproto.DocumentUri { return span.Uri }) - rangesByFile := collections.MultiMap[lsproto.DocumentUri, lsproto.Range]{} - for file, locs := range locationsByFile.M { - for _, loc := range locs { - rangesByFile.Add(file, loc.Range) - } +func locationToSpan(loc lsproto.Location) documentSpan { + return documentSpan{ + uri: loc.Uri, + textSpan: loc.Range, } - return f.getBaselineForGroupedLocationsWithFileContents( - &rangesByFile, +} + +func (f *FourslashTest) getBaselineForLocationsWithFileContents(locations []lsproto.Location, options baselineFourslashLocationsOptions) string { + return f.getBaselineForSpansWithFileContents( + core.Map(locations, locationToSpan), + options, + ) +} + +func (f *FourslashTest) getBaselineForSpansWithFileContents(spans []documentSpan, options baselineFourslashLocationsOptions) string { + spansByFile := collections.GroupBy(spans, func(span documentSpan) lsproto.DocumentUri { return span.uri }) + return f.getBaselineForGroupedSpansWithFileContents( + spansByFile, options, ) } -func (f *FourslashTest) getBaselineForGroupedLocationsWithFileContents(groupedRanges *collections.MultiMap[lsproto.DocumentUri, lsproto.Range], options baselineFourslashLocationsOptions) string { +func (f *FourslashTest) getBaselineForGroupedSpansWithFileContents(groupedRanges *collections.MultiMap[lsproto.DocumentUri, documentSpan], options baselineFourslashLocationsOptions) string { // We must always print the file containing the marker, // but don't want to print it twice at the end if it already // found in a file with ranges. foundMarker := false + foundAdditionalLocation := false + spanToContextId := map[documentSpan]int{} baselineEntries := []string{} - err := f.vfs.WalkDir("/", func(path string, d vfs.DirEntry, e error) error { + walkDirFn := func(path string, d vfs.DirEntry, e error) error { if e != nil { return e } @@ -158,13 +384,13 @@ func (f *FourslashTest) getBaselineForGroupedLocationsWithFileContents(groupedRa return nil } - fileName := ls.FileNameToDocumentURI(path) + fileName := lsconv.FileNameToDocumentURI(path) ranges := groupedRanges.Get(fileName) if len(ranges) == 0 { return nil } - content, ok := f.vfs.ReadFile(path) + content, ok := f.textOfFile(path) if !ok { // !!! error? return nil @@ -174,70 +400,132 @@ func (f *FourslashTest) getBaselineForGroupedLocationsWithFileContents(groupedRa foundMarker = true } - baselineEntries = append(baselineEntries, f.getBaselineContentForFile(path, content, ranges, nil, options)) + if options.additionalSpan != nil && options.additionalSpan.uri == fileName { + foundAdditionalLocation = true + } + + baselineEntries = append(baselineEntries, f.getBaselineContentForFile(path, content, ranges, spanToContextId, options)) return nil - }) + } + + err := f.vfs.WalkDir("/", walkDirFn) + if err != nil && !errors.Is(err, fs.ErrNotExist) { + panic("walkdir error during fourslash baseline: " + err.Error()) + } + err = f.vfs.WalkDir("bundled:///", walkDirFn) if err != nil && !errors.Is(err, fs.ErrNotExist) { panic("walkdir error during fourslash baseline: " + err.Error()) } + // In Strada, there is a bug where we only ever add additional spans to baselines if we haven't + // already added the file to the baseline. + if options.additionalSpan != nil && !foundAdditionalLocation { + fileName := options.additionalSpan.uri.FileName() + if content, ok := f.textOfFile(fileName); ok { + baselineEntries = append( + baselineEntries, + f.getBaselineContentForFile(fileName, content, []documentSpan{*options.additionalSpan}, spanToContextId, options), + ) + if options.marker != nil && options.marker.FileName() == fileName { + foundMarker = true + } + } + } + if !foundMarker && options.marker != nil { // If we didn't find the marker in any file, we need to add it. markerFileName := options.marker.FileName() - if content, ok := f.vfs.ReadFile(markerFileName); ok { - baselineEntries = append(baselineEntries, f.getBaselineContentForFile(markerFileName, content, nil, nil, options)) + if content, ok := f.textOfFile(markerFileName); ok { + baselineEntries = append(baselineEntries, f.getBaselineContentForFile(markerFileName, content, nil, spanToContextId, options)) } } - // !!! foundAdditionalSpan // !!! skipDocumentContainingOnlyMarker return strings.Join(baselineEntries, "\n\n") } +func (f *FourslashTest) textOfFile(fileName string) (string, bool) { + if _, ok := f.openFiles[fileName]; ok { + return f.getScriptInfo(fileName).content, true + } + return f.vfs.ReadFile(fileName) +} + type baselineDetail struct { pos lsproto.Position positionMarker string - span *lsproto.Range + span *documentSpan kind string } func (f *FourslashTest) getBaselineContentForFile( fileName string, content string, - spansInFile []lsproto.Range, - spanToContextId map[lsproto.Range]int, + spansInFile []documentSpan, + spanToContextId map[documentSpan]int, options baselineFourslashLocationsOptions, ) string { details := []*baselineDetail{} detailPrefixes := map[*baselineDetail]string{} detailSuffixes := map[*baselineDetail]string{} canDetermineContextIdInline := true - uri := ls.FileNameToDocumentURI(fileName) if options.marker != nil && options.marker.FileName() == fileName { details = append(details, &baselineDetail{pos: options.marker.LSPos(), positionMarker: options.markerName}) } for _, span := range spansInFile { + contextSpanIndex := len(details) + + // Add context span markers if present + if span.contextSpan != nil { + details = append(details, &baselineDetail{ + pos: span.contextSpan.Start, + positionMarker: "<|", + span: &span, + kind: "contextStart", + }) + + // Check if context span starts after text span + if lsproto.ComparePositions(span.contextSpan.Start, span.textSpan.Start) > 0 { + canDetermineContextIdInline = false + } + } + textSpanIndex := len(details) + startMarker := "[|" + if options.getLocationData != nil { + startMarker += options.getLocationData(span) + } details = append(details, - &baselineDetail{pos: span.Start, positionMarker: "[|", span: &span, kind: "textStart"}, - &baselineDetail{pos: span.End, positionMarker: core.OrElse(options.endMarker, "|]"), span: &span, kind: "textEnd"}, + &baselineDetail{pos: span.textSpan.Start, positionMarker: startMarker, span: &span, kind: "textStart"}, + &baselineDetail{pos: span.textSpan.End, positionMarker: core.OrElse(options.endMarker, "|]"), span: &span, kind: "textEnd"}, ) + if span.contextSpan != nil { + details = append(details, &baselineDetail{ + pos: span.contextSpan.End, + positionMarker: "|>", + span: &span, + kind: "contextEnd", + }) + } + if options.startMarkerPrefix != nil { - startPrefix := options.startMarkerPrefix(lsproto.Location{Uri: uri, Range: span}) + startPrefix := options.startMarkerPrefix(span) if startPrefix != nil { // Special case: if this span starts at the same position as the provided marker, // we want the span's prefix to appear before the marker name. // i.e. We want `/*START PREFIX*/A: /*RENAME*/[|ARENAME|]`, // not `/*RENAME*//*START PREFIX*/A: [|ARENAME|]` - if options.marker != nil && fileName == options.marker.FileName() && span.Start == options.marker.LSPos() { + if options.marker != nil && fileName == options.marker.FileName() && span.textSpan.Start == options.marker.LSPos() { _, ok := detailPrefixes[details[0]] debug.Assert(!ok, "Expected only single prefix at marker location") detailPrefixes[details[0]] = *startPrefix + } else if span.contextSpan != nil && span.contextSpan.Start == span.textSpan.Start { + detailPrefixes[details[contextSpanIndex]] = *startPrefix } else { detailPrefixes[details[textSpanIndex]] = *startPrefix } @@ -245,15 +533,22 @@ func (f *FourslashTest) getBaselineContentForFile( } if options.endMarkerSuffix != nil { - endSuffix := options.endMarkerSuffix(lsproto.Location{Uri: uri, Range: span}) + endSuffix := options.endMarkerSuffix(span) if endSuffix != nil { - detailSuffixes[details[textSpanIndex+1]] = *endSuffix + // Same as above for suffixes: + if options.marker != nil && fileName == options.marker.FileName() && span.textSpan.End == options.marker.LSPos() { + detailSuffixes[details[0]] = *endSuffix + } else if span.contextSpan != nil && span.contextSpan.End == span.textSpan.End { + detailSuffixes[details[textSpanIndex+2]] = *endSuffix + } else { + detailSuffixes[details[textSpanIndex+1]] = *endSuffix + } } } } slices.SortStableFunc(details, func(d1, d2 *baselineDetail) int { - return ls.ComparePositions(d1.pos, d2.pos) + return lsproto.ComparePositions(d1.pos, d2.pos) }) // !!! if canDetermineContextIdInline @@ -357,20 +652,20 @@ type textWithContext struct { isLibFile bool fileName string content string // content of the original file - lineStarts *ls.LSPLineMap - converters *ls.Converters + lineStarts *lsconv.LSPLineMap + converters *lsconv.Converters // posLineInfo posInfo *lsproto.Position lineInfo int } -// implements ls.Script +// implements lsconv.Script func (t *textWithContext) FileName() string { return t.fileName } -// implements ls.Script +// implements lsconv.Script func (t *textWithContext) Text() string { return t.content } @@ -381,15 +676,15 @@ func newTextWithContext(fileName string, content string) *textWithContext { readableContents: &strings.Builder{}, - isLibFile: regexp.MustCompile(`lib.*\.d\.ts$`).MatchString(fileName), + isLibFile: isLibFile(fileName), newContent: &strings.Builder{}, pos: lsproto.Position{Line: 0, Character: 0}, fileName: fileName, content: content, - lineStarts: ls.ComputeLSPLineStarts(content), + lineStarts: lsconv.ComputeLSPLineStarts(content), } - t.converters = ls.NewConverters(lsproto.PositionEncodingKindUTF8, func(_ string) *ls.LSPLineMap { + t.converters = lsconv.NewConverters(lsproto.PositionEncodingKindUTF8, func(_ string) *lsconv.LSPLineMap { return t.lineStarts }) t.readableContents.WriteString("// === " + fileName + " ===") @@ -428,7 +723,7 @@ func (t *textWithContext) add(detail *baselineDetail) { if t.isLibFile { skippedString = "--- (line: --) skipped ---\n" } else { - skippedString = fmt.Sprintf(`// --- (line: %v) skipped ---`, posLineIndex+t.nLinesContext+1) + skippedString = fmt.Sprintf(`--- (line: %v) skipped ---`, posLineIndex+t.nLinesContext+1) } t.readableContents.WriteString("\n") @@ -586,7 +881,7 @@ func (t *textWithContext) sliceOfContent(start *int, end *int) string { return t.content[*start:*end] } -func (t *textWithContext) getIndex(i interface{}) *int { +func (t *textWithContext) getIndex(i any) *int { switch i := i.(type) { case *int: return i @@ -607,3 +902,7 @@ func (t *textWithContext) getIndex(i interface{}) *int { func codeFence(lang string, code string) string { return "```" + lang + "\n" + code + "\n```" } + +func symbolInformationToData(symbol *lsproto.SymbolInformation) string { + return fmt.Sprintf("{| name: %s, kind: %s |}", symbol.Name, symbol.Kind.String()) +} diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index a488f7d2c5..90a701b36c 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1,9 +1,11 @@ package fourslash import ( + "context" "fmt" "io" "maps" + "runtime" "slices" "strings" "testing" @@ -14,7 +16,13 @@ import ( "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/diagnosticwriter" + "github.com/microsoft/typescript-go/internal/execute/tsctests" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project" @@ -22,8 +30,10 @@ import ( "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/testutil/harnessutil" + "github.com/microsoft/typescript-go/internal/testutil/tsbaseline" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" + "github.com/microsoft/typescript-go/internal/vfs/iovfs" "github.com/microsoft/typescript-go/internal/vfs/vfstest" "gotest.tools/v3/assert" ) @@ -35,23 +45,28 @@ type FourslashTest struct { id int32 vfs vfs.FS - testData *TestData // !!! consolidate test files from test data and script info - baselines map[string]*strings.Builder - rangesByText *collections.MultiMap[string, *RangeMarker] + testData *TestData // !!! consolidate test files from test data and script info + baselines map[baselineCommand]*strings.Builder + rangesByText *collections.MultiMap[string, *RangeMarker] + openFiles map[string]struct{} + stateBaseline *stateBaseline scriptInfos map[string]*scriptInfo - converters *ls.Converters + converters *lsconv.Converters + userPreferences *lsutil.UserPreferences currentCaretPosition lsproto.Position lastKnownMarkerName *string activeFilename string selectionEnd *lsproto.Position + + isStradaServer bool // Whether this is a fourslash server test in Strada. !!! Remove once we don't need to diff baselines. } type scriptInfo struct { fileName string content string - lineMap *ls.LSPLineMap + lineMap *lsconv.LSPLineMap version int32 } @@ -59,14 +74,14 @@ func newScriptInfo(fileName string, content string) *scriptInfo { return &scriptInfo{ fileName: fileName, content: content, - lineMap: ls.ComputeLSPLineStarts(content), + lineMap: lsconv.ComputeLSPLineStarts(content), version: 1, } } func (s *scriptInfo) editContent(start int, end int, newText string) { s.content = s.content[:start] + newText + s.content[end:] - s.lineMap = ls.ComputeLSPLineStarts(s.content) + s.lineMap = lsconv.ComputeLSPLineStarts(s.content) s.version++ } @@ -129,7 +144,7 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten t.Skip("bundled files are not embedded") } fileName := getBaseFileNameFromTest(t) + tspath.ExtensionTs - testfs := make(map[string]string) + testfs := make(map[string]any) scriptInfos := make(map[string]*scriptInfo) testData := ParseTestData(t, content, fileName) for _, file := range testData.Files { @@ -138,14 +153,49 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten scriptInfos[filePath] = newScriptInfo(filePath, file.Content) } + for link, target := range testData.Symlinks { + filePath := tspath.GetNormalizedAbsolutePath(link, rootDir) + testfs[filePath] = vfstest.Symlink(tspath.GetNormalizedAbsolutePath(target, rootDir)) + } + compilerOptions := &core.CompilerOptions{ SkipDefaultLibCheck: core.TSTrue, } harnessutil.SetCompilerOptionsFromTestConfig(t, testData.GlobalOptions, compilerOptions, rootDir) + if commandLines := testData.GlobalOptions["tsc"]; commandLines != "" { + for commandLine := range strings.SplitSeq(commandLines, ",") { + tsctests.GetFileMapWithBuild(testfs, strings.Split(commandLine, " ")) + } + } + + // Skip tests with deprecated/removed compiler options + if compilerOptions.BaseUrl != "" { + t.Skipf("Test uses deprecated 'baseUrl' option") + } + if compilerOptions.OutFile != "" { + t.Skipf("Test uses deprecated 'outFile' option") + } + if compilerOptions.Module == core.ModuleKindAMD { + t.Skipf("Test uses deprecated 'module: AMD' option") + } + if compilerOptions.Module == core.ModuleKindSystem { + t.Skipf("Test uses deprecated 'module: System' option") + } + if compilerOptions.Module == core.ModuleKindUMD { + t.Skipf("Test uses deprecated 'module: UMD' option") + } + if compilerOptions.ModuleResolution == core.ModuleResolutionKindClassic { + t.Skipf("Test uses deprecated 'moduleResolution: Classic' option") + } + if compilerOptions.AllowSyntheticDefaultImports == core.TSFalse { + t.Skipf("Test uses unsupported 'allowSyntheticDefaultImports: false' option") + } inputReader, inputWriter := newLSPPipe() outputReader, outputWriter := newLSPPipe() - fs := bundled.WrapFS(vfstest.FromMap(testfs, true /*useCaseSensitiveFileNames*/)) + + fsFromMap := vfstest.FromMap(testfs, true /*useCaseSensitiveFileNames*/) + fs := bundled.WrapFS(fsFromMap) var err strings.Builder server := lsp.NewServer(&lsp.ServerOptions{ @@ -164,13 +214,13 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten defer func() { outputWriter.Close() }() - err := server.Run() + err := server.Run(context.TODO()) if err != nil { t.Error("server error:", err) } }() - converters := ls.NewConverters(lsproto.PositionEncodingKindUTF8, func(fileName string) *ls.LSPLineMap { + converters := lsconv.NewConverters(lsproto.PositionEncodingKindUTF8, func(fileName string) *lsconv.LSPLineMap { scriptInfo, ok := scriptInfos[fileName] if !ok { return nil @@ -179,34 +229,45 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten }) f := &FourslashTest{ - server: server, - in: inputWriter, - out: outputReader, - testData: &testData, - vfs: fs, - scriptInfos: scriptInfos, - converters: converters, - baselines: make(map[string]*strings.Builder), + server: server, + in: inputWriter, + out: outputReader, + testData: &testData, + userPreferences: lsutil.NewDefaultUserPreferences(), // !!! parse default preferences for fourslash case? + vfs: fs, + scriptInfos: scriptInfos, + converters: converters, + baselines: make(map[baselineCommand]*strings.Builder), + openFiles: make(map[string]struct{}), } // !!! temporary; remove when we have `handleDidChangeConfiguration`/implicit project config support // !!! replace with a proper request *after initialize* f.server.SetCompilerOptionsForInferredProjects(t.Context(), compilerOptions) f.initialize(t, capabilities) - for _, file := range testData.Files { - f.openFile(t, file.fileName) + + if testData.isStateBaseliningEnabled() { + // Single baseline, so initialize project state baseline too + f.stateBaseline = newStateBaseline(fsFromMap.(iovfs.FsWithSys)) + } else { + for _, file := range testData.Files { + f.openFile(t, file.fileName) + } + f.activeFilename = f.testData.Files[0].fileName } - f.activeFilename = f.testData.Files[0].fileName + _, testPath, _, _ := runtime.Caller(1) t.Cleanup(func() { inputWriter.Close() - f.verifyBaselines(t) + f.verifyBaselines(t, testPath) }) return f } func getBaseFileNameFromTest(t *testing.T) string { - name := strings.TrimPrefix(t.Name(), "Test") + name := t.Name() + name = core.LastOrNil(strings.Split(name, "/")) + name = strings.TrimPrefix(name, "Test") return stringutil.LowerFirstChar(name) } @@ -219,11 +280,16 @@ func (f *FourslashTest) nextID() int32 { func (f *FourslashTest) initialize(t *testing.T, capabilities *lsproto.ClientCapabilities) { params := &lsproto.InitializeParams{ Locale: ptrTo("en-US"), + InitializationOptions: &lsproto.InitializationOptions{ + // Hack: disable push diagnostics entirely, since the fourslash runner does not + // yet gracefully handle non-request messages. + DisablePushDiagnostics: ptrTo(true), + }, } params.Capabilities = getCapabilitiesWithDefaults(capabilities) // !!! check for errors? - sendRequest(t, f, lsproto.InitializeInfo, params) - sendNotification(t, f, lsproto.InitializedInfo, &lsproto.InitializedParams{}) + sendRequestWorker(t, f, lsproto.InitializeInfo, params) + sendNotificationWorker(t, f, lsproto.InitializedInfo, &lsproto.InitializedParams{}) } var ( @@ -235,11 +301,24 @@ var ( PreselectSupport: ptrTrue, LabelDetailsSupport: ptrTrue, InsertReplaceSupport: ptrTrue, + DocumentationFormat: &[]lsproto.MarkupKind{lsproto.MarkupKindMarkdown, lsproto.MarkupKindPlainText}, }, CompletionList: &lsproto.CompletionListCapabilities{ ItemDefaults: &[]string{"commitCharacters", "editRange"}, }, } + defaultDefinitionCapabilities = &lsproto.DefinitionClientCapabilities{ + LinkSupport: ptrTrue, + } + defaultTypeDefinitionCapabilities = &lsproto.TypeDefinitionClientCapabilities{ + LinkSupport: ptrTrue, + } + defaultImplementationCapabilities = &lsproto.ImplementationClientCapabilities{ + LinkSupport: ptrTrue, + } + defaultHoverCapabilities = &lsproto.HoverClientCapabilities{ + ContentFormat: &[]lsproto.MarkupKind{lsproto.MarkupKindMarkdown, lsproto.MarkupKindPlainText}, + } ) func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lsproto.ClientCapabilities { @@ -256,18 +335,97 @@ func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lspr if capabilitiesWithDefaults.TextDocument.Completion == nil { capabilitiesWithDefaults.TextDocument.Completion = defaultCompletionCapabilities } + if capabilitiesWithDefaults.TextDocument.Diagnostic == nil { + capabilitiesWithDefaults.TextDocument.Diagnostic = &lsproto.DiagnosticClientCapabilities{ + RelatedInformation: ptrTrue, + TagSupport: &lsproto.ClientDiagnosticsTagOptions{ + ValueSet: []lsproto.DiagnosticTag{ + lsproto.DiagnosticTagUnnecessary, + lsproto.DiagnosticTagDeprecated, + }, + }, + } + } + if capabilitiesWithDefaults.TextDocument.PublishDiagnostics == nil { + capabilitiesWithDefaults.TextDocument.PublishDiagnostics = &lsproto.PublishDiagnosticsClientCapabilities{ + RelatedInformation: ptrTrue, + TagSupport: &lsproto.ClientDiagnosticsTagOptions{ + ValueSet: []lsproto.DiagnosticTag{ + lsproto.DiagnosticTagUnnecessary, + lsproto.DiagnosticTagDeprecated, + }, + }, + } + } + if capabilitiesWithDefaults.Workspace == nil { + capabilitiesWithDefaults.Workspace = &lsproto.WorkspaceClientCapabilities{} + } + if capabilitiesWithDefaults.Workspace.Configuration == nil { + capabilitiesWithDefaults.Workspace.Configuration = ptrTrue + } + if capabilitiesWithDefaults.TextDocument.Definition == nil { + capabilitiesWithDefaults.TextDocument.Definition = defaultDefinitionCapabilities + } + if capabilitiesWithDefaults.TextDocument.TypeDefinition == nil { + capabilitiesWithDefaults.TextDocument.TypeDefinition = defaultTypeDefinitionCapabilities + } + if capabilitiesWithDefaults.TextDocument.Implementation == nil { + capabilitiesWithDefaults.TextDocument.Implementation = defaultImplementationCapabilities + } + if capabilitiesWithDefaults.TextDocument.Hover == nil { + capabilitiesWithDefaults.TextDocument.Hover = defaultHoverCapabilities + } + if capabilitiesWithDefaults.TextDocument.SignatureHelp == nil { + capabilitiesWithDefaults.TextDocument.SignatureHelp = &lsproto.SignatureHelpClientCapabilities{ + SignatureInformation: &lsproto.ClientSignatureInformationOptions{ + DocumentationFormat: &[]lsproto.MarkupKind{lsproto.MarkupKindMarkdown, lsproto.MarkupKindPlainText}, + ParameterInformation: &lsproto.ClientSignatureParameterInformationOptions{ + LabelOffsetSupport: ptrTrue, + }, + ActiveParameterSupport: ptrTrue, + }, + ContextSupport: ptrTrue, + } + } return &capabilitiesWithDefaults } -func sendRequest[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto.RequestInfo[Params, Resp], params Params) (*lsproto.Message, Resp, bool) { +func sendRequestWorker[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto.RequestInfo[Params, Resp], params Params) (*lsproto.Message, Resp, bool) { id := f.nextID() - req := lsproto.NewRequestMessage( - info.Method, + req := info.NewRequestMessage( lsproto.NewID(lsproto.IntegerOrString{Integer: &id}), params, ) f.writeMsg(t, req.Message()) resp := f.readMsg(t) + if resp == nil { + return nil, *new(Resp), false + } + + // currently, the only request that may be sent by the server during a client request is one `config` request + // !!! remove if `config` is handled in initialization and there are no other server-initiated requests + if resp.Kind == lsproto.MessageKindRequest { + req := resp.AsRequest() + + assert.Equal(t, req.Method, lsproto.MethodWorkspaceConfiguration, "Unexpected request received: %s", req.Method) + res := lsproto.ResponseMessage{ + ID: req.ID, + JSONRPC: req.JSONRPC, + Result: []any{f.userPreferences}, + } + f.writeMsg(t, res.Message()) + req = f.readMsg(t).AsRequest() + + assert.Equal(t, req.Method, lsproto.MethodClientRegisterCapability, "Unexpected request received: %s", req.Method) + res = lsproto.ResponseMessage{ + ID: req.ID, + JSONRPC: req.JSONRPC, + Result: lsproto.Null{}, + } + f.writeMsg(t, res.Message()) + resp = f.readMsg(t) + } + if resp == nil { return nil, *new(Resp), false } @@ -275,9 +433,8 @@ func sendRequest[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto. return resp, result, ok } -func sendNotification[Params any](t *testing.T, f *FourslashTest, info lsproto.NotificationInfo[Params], params Params) { - notification := lsproto.NewNotificationMessage( - info.Method, +func sendNotificationWorker[Params any](t *testing.T, f *FourslashTest, info lsproto.NotificationInfo[Params], params Params) { + notification := info.NewNotificationMessage( params, ) f.writeMsg(t, notification.Message()) @@ -300,6 +457,61 @@ func (f *FourslashTest) readMsg(t *testing.T) *lsproto.Message { return msg } +func sendRequest[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto.RequestInfo[Params, Resp], params Params) Resp { + t.Helper() + prefix := f.getCurrentPositionPrefix() + f.baselineState(t) + f.baselineRequestOrNotification(t, info.Method, params) + resMsg, result, resultOk := sendRequestWorker(t, f, info, params) + f.baselineState(t) + if resMsg == nil { + t.Fatalf(prefix+"Nil response received for %s request", info.Method) + } + if !resultOk { + t.Fatalf(prefix+"Unexpected %s response type: %T", info.Method, resMsg.AsResponse().Result) + } + return result +} + +func sendNotification[Params any](t *testing.T, f *FourslashTest, info lsproto.NotificationInfo[Params], params Params) { + t.Helper() + f.baselineState(t) + f.updateState(info.Method, params) + f.baselineRequestOrNotification(t, info.Method, params) + sendNotificationWorker(t, f, info, params) +} + +func (f *FourslashTest) updateState(method lsproto.Method, params any) { + switch method { + case lsproto.MethodTextDocumentDidOpen: + f.openFiles[params.(*lsproto.DidOpenTextDocumentParams).TextDocument.Uri.FileName()] = struct{}{} + case lsproto.MethodTextDocumentDidClose: + delete(f.openFiles, params.(*lsproto.DidCloseTextDocumentParams).TextDocument.Uri.FileName()) + } +} + +func (f *FourslashTest) Configure(t *testing.T, config *lsutil.UserPreferences) { + // !!! + // Callers to this function may need to consider + // sending a more specific configuration for 'javascript' + // or 'js/ts' as well. For now, we only send 'typescript', + // and most tests probably just want this. + f.userPreferences = config + sendNotification(t, f, lsproto.WorkspaceDidChangeConfigurationInfo, &lsproto.DidChangeConfigurationParams{ + Settings: map[string]any{ + "typescript": config, + }, + }) +} + +func (f *FourslashTest) ConfigureWithReset(t *testing.T, config *lsutil.UserPreferences) (reset func()) { + originalConfig := f.userPreferences.Copy() + f.Configure(t, config) + return func() { + f.Configure(t, originalConfig) + } +} + func (f *FourslashTest) GoToMarkerOrRange(t *testing.T, markerOrRange MarkerOrRange) { f.goToMarker(t, markerOrRange) } @@ -421,29 +633,74 @@ func (f *FourslashTest) MarkerNames() []string { }) } +func (f *FourslashTest) MarkerByName(t *testing.T, name string) *Marker { + return f.testData.MarkerPositions[name] +} + func (f *FourslashTest) Ranges() []*RangeMarker { return f.testData.Ranges } +func (f *FourslashTest) getRangesInFile(fileName string) []*RangeMarker { + var rangesInFile []*RangeMarker + for _, rangeMarker := range f.testData.Ranges { + if rangeMarker.FileName() == fileName { + rangesInFile = append(rangesInFile, rangeMarker) + } + } + return rangesInFile +} + func (f *FourslashTest) ensureActiveFile(t *testing.T, filename string) { if f.activeFilename != filename { - f.openFile(t, filename) + if _, ok := f.openFiles[filename]; !ok { + f.openFile(t, filename) + } else { + f.activeFilename = filename + } } } +func (f *FourslashTest) CloseFileOfMarker(t *testing.T, markerName string) { + marker, ok := f.testData.MarkerPositions[markerName] + if !ok { + t.Fatalf("Marker '%s' not found", markerName) + } + if f.activeFilename == marker.FileName() { + f.activeFilename = "" + } + if index := slices.IndexFunc(f.testData.Files, func(f *TestFileInfo) bool { return f.fileName == marker.FileName() }); index >= 0 { + testFile := f.testData.Files[index] + f.scriptInfos[testFile.fileName] = newScriptInfo(testFile.fileName, testFile.Content) + } else { + delete(f.scriptInfos, marker.FileName()) + } + sendNotification(t, f, lsproto.TextDocumentDidCloseInfo, &lsproto.DidCloseTextDocumentParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(marker.FileName()), + }, + }) +} + func (f *FourslashTest) openFile(t *testing.T, filename string) { script := f.getScriptInfo(filename) if script == nil { - t.Fatalf("File %s not found in test data", filename) + if content, ok := f.vfs.ReadFile(filename); ok { + script = newScriptInfo(filename, content) + f.scriptInfos[filename] = script + } else { + t.Fatalf("File %s not found in test data", filename) + } } f.activeFilename = filename sendNotification(t, f, lsproto.TextDocumentDidOpenInfo, &lsproto.DidOpenTextDocumentParams{ TextDocument: &lsproto.TextDocumentItem{ - Uri: ls.FileNameToDocumentURI(filename), + Uri: lsconv.FileNameToDocumentURI(filename), LanguageId: getLanguageKind(filename), Text: script.content, }, }) + f.baselineProjectsAfterNotification(t, filename) } func getLanguageKind(filename string) lsproto.LanguageKind { @@ -474,7 +731,7 @@ type CompletionsExpectedList struct { IsIncomplete bool ItemDefaults *CompletionsExpectedItemDefaults Items *CompletionsExpectedItems - UserPreferences *ls.UserPreferences // !!! allow user preferences in fourslash + UserPreferences *lsutil.UserPreferences // !!! allow user preferences in fourslash } type Ignored = struct{} @@ -502,19 +759,31 @@ type CompletionsExpectedItems struct { Unsorted []CompletionsExpectedItem } +type CompletionsExpectedCodeAction struct { + Name string + Source string + Description string + NewFileContent string +} + +type VerifyCompletionsResult struct { + AndApplyCodeAction func(t *testing.T, expectedAction *CompletionsExpectedCodeAction) +} + // string | *Marker | []string | []*Marker type MarkerInput = any // !!! user preferences param // !!! completion context param -func (f *FourslashTest) VerifyCompletions(t *testing.T, markerInput MarkerInput, expected *CompletionsExpectedList) { +func (f *FourslashTest) VerifyCompletions(t *testing.T, markerInput MarkerInput, expected *CompletionsExpectedList) VerifyCompletionsResult { + var list *lsproto.CompletionList switch marker := markerInput.(type) { case string: f.GoToMarker(t, marker) - f.verifyCompletionsWorker(t, expected) + list = f.verifyCompletionsWorker(t, expected) case *Marker: f.goToMarker(t, marker) - f.verifyCompletionsWorker(t, expected) + list = f.verifyCompletionsWorker(t, expected) case []string: for _, markerName := range marker { f.GoToMarker(t, markerName) @@ -526,29 +795,58 @@ func (f *FourslashTest) VerifyCompletions(t *testing.T, markerInput MarkerInput, f.verifyCompletionsWorker(t, expected) } case nil: - f.verifyCompletionsWorker(t, expected) + list = f.verifyCompletionsWorker(t, expected) default: t.Fatalf("Invalid marker input type: %T. Expected string, *Marker, []string, or []*Marker.", markerInput) } + + return VerifyCompletionsResult{ + AndApplyCodeAction: func(t *testing.T, expectedAction *CompletionsExpectedCodeAction) { + item := core.Find(list.Items, func(item *lsproto.CompletionItem) bool { + if item.Label != expectedAction.Name || item.Data == nil { + return false + } + data := item.Data + if data.AutoImport == nil { + return false + } + return data.AutoImport.ModuleSpecifier == expectedAction.Source + }) + if item == nil { + t.Fatalf("Code action '%s' from source '%s' not found in completions.", expectedAction.Name, expectedAction.Source) + } + assert.Check(t, strings.Contains(*item.Detail, expectedAction.Description), "Completion item detail does not contain expected description.") + f.applyTextEdits(t, *item.AdditionalTextEdits) + assert.Equal(t, f.getScriptInfo(f.activeFilename).content, expectedAction.NewFileContent, fmt.Sprintf("File content after applying code action '%s' did not match expected content.", expectedAction.Name)) + }, + } } -func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *CompletionsExpectedList) { +func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *CompletionsExpectedList) *lsproto.CompletionList { prefix := f.getCurrentPositionPrefix() + var userPreferences *lsutil.UserPreferences + if expected != nil { + userPreferences = expected.UserPreferences + } + list := f.getCompletions(t, userPreferences) + f.verifyCompletionsResult(t, list, expected, prefix) + return list +} + +func (f *FourslashTest) getCompletions(t *testing.T, userPreferences *lsutil.UserPreferences) *lsproto.CompletionList { params := &lsproto.CompletionParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, Context: &lsproto.CompletionContext{}, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentCompletionInfo, params) - if resMsg == nil { - t.Fatalf(prefix+"Nil response received for completion request", f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf(prefix+"Unexpected response type for completion request: %T", resMsg.AsResponse().Result) + if userPreferences != nil { + reset := f.ConfigureWithReset(t, userPreferences) + defer reset() } - f.verifyCompletionsResult(t, result.List, expected, prefix) + result := sendRequest(t, f, lsproto.TextDocumentCompletionInfo, params) + return result.List } func (f *FourslashTest) verifyCompletionsResult( @@ -632,9 +930,9 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu } return } - nameToActualItem := make(map[string]*lsproto.CompletionItem) + nameToActualItems := make(map[string][]*lsproto.CompletionItem) for _, item := range actual { - nameToActualItem[item.Label] = item + nameToActualItems[item.Label] = append(nameToActualItems[item.Label], item) } if expected.Unsorted != nil { if expected.Includes != nil { @@ -646,24 +944,30 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu for _, item := range expected.Unsorted { switch item := item.(type) { case string: - _, ok := nameToActualItem[item] + _, ok := nameToActualItems[item] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item, cmp.Diff(actual, nil)) } - delete(nameToActualItem, item) + delete(nameToActualItems, item) case *lsproto.CompletionItem: - actualItem, ok := nameToActualItem[item.Label] + actualItems, ok := nameToActualItems[item.Label] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item.Label, cmp.Diff(actual, nil)) } - delete(nameToActualItem, item.Label) + actualItem := actualItems[0] + actualItems = actualItems[1:] + if len(actualItems) == 0 { + delete(nameToActualItems, item.Label) + } else { + nameToActualItems[item.Label] = actualItems + } f.verifyCompletionItem(t, prefix+"Includes completion item mismatch for label "+item.Label+": ", actualItem, item) default: t.Fatalf("%sExpected completion item to be a string or *lsproto.CompletionItem, got %T", prefix, item) } } if len(expected.Unsorted) != len(actual) { - unmatched := slices.Collect(maps.Keys(nameToActualItem)) + unmatched := slices.Collect(maps.Keys(nameToActualItems)) t.Fatalf("%sAdditional completions found but not included in 'unsorted': %s", prefix, strings.Join(unmatched, "\n")) } return @@ -672,15 +976,22 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu for _, item := range expected.Includes { switch item := item.(type) { case string: - _, ok := nameToActualItem[item] + _, ok := nameToActualItems[item] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item, cmp.Diff(actual, nil)) } case *lsproto.CompletionItem: - actualItem, ok := nameToActualItem[item.Label] + actualItems, ok := nameToActualItems[item.Label] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item.Label, cmp.Diff(actual, nil)) } + actualItem := actualItems[0] + actualItems = actualItems[1:] + if len(actualItems) == 0 { + delete(nameToActualItems, item.Label) + } else { + nameToActualItems[item.Label] = actualItems + } f.verifyCompletionItem(t, prefix+"Includes completion item mismatch for label "+item.Label+": ", actualItem, item) default: t.Fatalf("%sExpected completion item to be a string or *lsproto.CompletionItem, got %T", prefix, item) @@ -688,7 +999,7 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu } } for _, exclude := range expected.Excludes { - if _, ok := nameToActualItem[exclude]; ok { + if _, ok := nameToActualItems[exclude]; ok { t.Fatalf("%sLabel '%s' should not be in actual items but was found. Actual items: %s", prefix, exclude, cmp.Diff(actual, nil)) } } @@ -711,36 +1022,65 @@ func (f *FourslashTest) verifyCompletionsAreExactly(t *testing.T, prefix string, } } -var completionIgnoreOpts = cmp.FilterPath( - func(p cmp.Path) bool { - switch p.Last().String() { - case ".Kind", ".SortText", ".Data": - return true - default: - return false - } - }, - cmp.Ignore(), +func ignorePaths(paths ...string) cmp.Option { + return cmp.FilterPath( + func(p cmp.Path) bool { + return slices.Contains(paths, p.Last().String()) + }, + cmp.Ignore(), + ) +} + +var ( + completionIgnoreOpts = ignorePaths(".Kind", ".SortText", ".FilterText", ".Data") + autoImportIgnoreOpts = ignorePaths(".Kind", ".SortText", ".FilterText", ".Data", ".LabelDetails", ".Detail", ".AdditionalTextEdits") + diagnosticsIgnoreOpts = ignorePaths(".Severity", ".Source", ".RelatedInformation") ) func (f *FourslashTest) verifyCompletionItem(t *testing.T, prefix string, actual *lsproto.CompletionItem, expected *lsproto.CompletionItem) { - if expected.Detail != nil || expected.Documentation != nil { - resMsg, result, resultOk := sendRequest(t, f, lsproto.CompletionItemResolveInfo, actual) - if resMsg == nil { - t.Fatal(prefix + "Expected non-nil response for completion item resolve, got nil") + var actualAutoImportData, expectedAutoImportData *lsproto.AutoImportData + if actual.Data != nil { + actualAutoImportData = actual.Data.AutoImport + } + if expected.Data != nil { + expectedAutoImportData = expected.Data.AutoImport + } + if (actualAutoImportData == nil) != (expectedAutoImportData == nil) { + t.Fatal(prefix + "Mismatch in auto-import data presence") + } + + if expected.Detail != nil || expected.Documentation != nil || actualAutoImportData != nil { + actual = f.resolveCompletionItem(t, actual) + } + + if actualAutoImportData != nil { + assertDeepEqual(t, actual, expected, prefix, autoImportIgnoreOpts) + if expected.AdditionalTextEdits == AnyTextEdits { + assert.Check(t, actual.AdditionalTextEdits != nil && len(*actual.AdditionalTextEdits) > 0, prefix+" Expected non-nil AdditionalTextEdits for auto-import completion item") } - if !resultOk { - t.Fatalf(prefix+"Unexpected response type for completion item resolve: %T", resMsg.AsResponse().Result) + if expected.LabelDetails != nil { + assertDeepEqual(t, actual.LabelDetails, expected.LabelDetails, prefix+" LabelDetails mismatch") } - actual = result + + assert.Equal(t, actualAutoImportData.ModuleSpecifier, expectedAutoImportData.ModuleSpecifier, prefix+" ModuleSpecifier mismatch") + } else { + assertDeepEqual(t, actual, expected, prefix, completionIgnoreOpts) + } + + if expected.FilterText != nil { + assertDeepEqual(t, actual.FilterText, expected.FilterText, prefix+" FilterText mismatch") } - assertDeepEqual(t, actual, expected, prefix, completionIgnoreOpts) if expected.Kind != nil { assertDeepEqual(t, actual.Kind, expected.Kind, prefix+" Kind mismatch") } assertDeepEqual(t, actual.SortText, core.OrElse(expected.SortText, ptrTo(string(ls.SortTextLocationPriority))), prefix+" SortText mismatch") } +func (f *FourslashTest) resolveCompletionItem(t *testing.T, item *lsproto.CompletionItem) *lsproto.CompletionItem { + result := sendRequest(t, f, lsproto.CompletionItemResolveInfo, item) + return result +} + func getExpectedLabel(t *testing.T, item CompletionsExpectedItem) string { switch item := item.(type) { case string: @@ -762,6 +1102,191 @@ func assertDeepEqual(t *testing.T, actual any, expected any, prefix string, opts } } +type ApplyCodeActionFromCompletionOptions struct { + Name string + Source string + AutoImportData *lsproto.AutoImportData + Description string + NewFileContent *string + NewRangeContent *string + UserPreferences *lsutil.UserPreferences +} + +func (f *FourslashTest) VerifyApplyCodeActionFromCompletion(t *testing.T, markerName *string, options *ApplyCodeActionFromCompletionOptions) { + f.GoToMarker(t, *markerName) + var userPreferences *lsutil.UserPreferences + if options != nil && options.UserPreferences != nil { + userPreferences = options.UserPreferences + } else { + // Default preferences: enables auto-imports + userPreferences = lsutil.NewDefaultUserPreferences() + } + + reset := f.ConfigureWithReset(t, userPreferences) + defer reset() + completionsList := f.getCompletions(t, nil) // Already configured, so we do not need to pass it in again + item := core.Find(completionsList.Items, func(item *lsproto.CompletionItem) bool { + if item.Label != options.Name || item.Data == nil { + return false + } + data := item.Data + if options.AutoImportData != nil { + return data.AutoImport != nil && ((data.AutoImport.FileName == options.AutoImportData.FileName) && + (options.AutoImportData.ModuleSpecifier == "" || data.AutoImport.ModuleSpecifier == options.AutoImportData.ModuleSpecifier) && + (options.AutoImportData.ExportName == "" || data.AutoImport.ExportName == options.AutoImportData.ExportName) && + (options.AutoImportData.AmbientModuleName == "" || data.AutoImport.AmbientModuleName == options.AutoImportData.AmbientModuleName) && + data.AutoImport.IsPackageJsonImport == options.AutoImportData.IsPackageJsonImport) + } + if data.AutoImport == nil && data.Source != "" && data.Source == options.Source { + return true + } + if data.AutoImport != nil && data.AutoImport.ModuleSpecifier == options.Source { + return true + } + return false + }) + if item == nil { + t.Fatalf("Code action '%s' from source '%s' not found in completions.", options.Name, options.Source) + } + item = f.resolveCompletionItem(t, item) + assert.Check(t, strings.Contains(*item.Detail, options.Description), "Completion item detail does not contain expected description.") + if item.AdditionalTextEdits == nil { + t.Fatalf("Expected non-nil AdditionalTextEdits for code action completion item.") + } + f.applyTextEdits(t, *item.AdditionalTextEdits) + if options.NewFileContent != nil { + assert.Equal(t, f.getScriptInfo(f.activeFilename).content, *options.NewFileContent, "File content after applying code action did not match expected content.") + } else if options.NewRangeContent != nil { + t.Fatal("!!! TODO") + } +} + +func (f *FourslashTest) VerifyImportFixAtPosition(t *testing.T, expectedTexts []string, preferences *lsutil.UserPreferences) { + fileName := f.activeFilename + ranges := f.Ranges() + var filteredRanges []*RangeMarker + for _, r := range ranges { + if r.FileName() == fileName { + filteredRanges = append(filteredRanges, r) + } + } + if len(filteredRanges) > 1 { + t.Fatalf("Exactly one range should be specified in the testfile.") + } + var rangeMarker *RangeMarker + if len(filteredRanges) == 1 { + rangeMarker = filteredRanges[0] + } + + if preferences != nil { + reset := f.ConfigureWithReset(t, preferences) + defer reset() + } + + // Get diagnostics at the current position to find errors that need import fixes + diagParams := &lsproto.DocumentDiagnosticParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + } + diagResult := sendRequest(t, f, lsproto.TextDocumentDiagnosticInfo, diagParams) + + var diagnostics []*lsproto.Diagnostic + if diagResult.FullDocumentDiagnosticReport != nil && diagResult.FullDocumentDiagnosticReport.Items != nil { + diagnostics = diagResult.FullDocumentDiagnosticReport.Items + } + + params := &lsproto.CodeActionParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Range: lsproto.Range{ + Start: f.currentCaretPosition, + End: f.currentCaretPosition, + }, + Context: &lsproto.CodeActionContext{ + Diagnostics: diagnostics, + }, + } + result := sendRequest(t, f, lsproto.TextDocumentCodeActionInfo, params) + + // Find all auto-import code actions (fixes with fixId/fixName related to imports) + var importActions []*lsproto.CodeAction + if result.CommandOrCodeActionArray != nil { + for _, item := range *result.CommandOrCodeActionArray { + if item.CodeAction != nil && item.CodeAction.Kind != nil && *item.CodeAction.Kind == lsproto.CodeActionKindQuickFix { + importActions = append(importActions, item.CodeAction) + } + } + } + + if len(importActions) == 0 { + if len(expectedTexts) != 0 { + t.Fatalf("No codefixes returned.") + } + return + } + + // Save the original content before any edits + script := f.getScriptInfo(f.activeFilename) + originalContent := script.content + + // For each import action, apply it and check the result + actualTextArray := make([]string, 0, len(importActions)) + for _, action := range importActions { + // Apply the code action + var edits []*lsproto.TextEdit + if action.Edit != nil && action.Edit.Changes != nil { + if len(*action.Edit.Changes) != 1 { + t.Fatalf("Expected exactly 1 change, got %d", len(*action.Edit.Changes)) + } + for uri, changeEdits := range *action.Edit.Changes { + if uri != lsconv.FileNameToDocumentURI(f.activeFilename) { + t.Fatalf("Expected change to file %s, got %s", f.activeFilename, uri) + } + edits = changeEdits + f.applyTextEdits(t, changeEdits) + } + } + + // Get the result text + var text string + if rangeMarker != nil { + text = f.getRangeText(rangeMarker) + } else { + text = f.getScriptInfo(f.activeFilename).content + } + actualTextArray = append(actualTextArray, text) + + // Undo changes to perform next fix + for _, textChange := range edits { + start := int(f.converters.LineAndCharacterToPosition(script, textChange.Range.Start)) + end := int(f.converters.LineAndCharacterToPosition(script, textChange.Range.End)) + deletedText := originalContent[start:end] + insertedText := textChange.NewText + f.editScriptAndUpdateMarkers(t, f.activeFilename, start, start+len(insertedText), deletedText) + } + } + + // Compare results + if len(expectedTexts) != len(actualTextArray) { + var actualJoined strings.Builder + for i, actual := range actualTextArray { + if i > 0 { + actualJoined.WriteString("\n\n" + strings.Repeat("-", 20) + "\n\n") + } + actualJoined.WriteString(actual) + } + t.Fatalf("Expected %d import fixes, got %d:\n\n%s", len(expectedTexts), len(actualTextArray), actualJoined.String()) + } + for i, expected := range expectedTexts { + actual := actualTextArray[i] + if expected != actual { + t.Fatalf("Import fix at index %d doesn't match.\nExpected:\n%s\n\nActual:\n%s", i, expected, actual) + } + } +} + func (f *FourslashTest) VerifyBaselineFindAllReferences( t *testing.T, markers ...string, @@ -774,28 +1299,13 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences( params := &lsproto.ReferenceParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, Context: &lsproto.ReferenceContext{}, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentReferencesInfo, params) - if resMsg == nil { - if f.lastKnownMarkerName == nil { - t.Fatalf("Nil response received for references request at pos %v", f.currentCaretPosition) - } else { - t.Fatalf("Nil response received for references request at marker '%s'", *f.lastKnownMarkerName) - } - } - if !resultOk { - if f.lastKnownMarkerName == nil { - t.Fatalf("Unexpected references response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) - } else { - t.Fatalf("Unexpected references response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) - } - } - - f.addResultToBaseline(t, "findAllReferences", f.getBaselineForLocationsWithFileContents(*result.Locations, baselineFourslashLocationsOptions{ + result := sendRequest(t, f, lsproto.TextDocumentReferencesInfo, params) + f.addResultToBaseline(t, findAllReferencesCmd, f.getBaselineForLocationsWithFileContents(*result.Locations, baselineFourslashLocationsOptions{ marker: markerOrRange, markerName: "/*FIND ALL REFS*/", })) @@ -803,8 +1313,40 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences( } } +func (f *FourslashTest) MarkTestAsStradaServer() { + f.isStradaServer = true +} + func (f *FourslashTest) VerifyBaselineGoToDefinition( t *testing.T, + includeOriginalSelectionRange bool, + markers ...string, +) { + f.verifyBaselineDefinitions( + t, + goToDefinitionCmd, + "/*GOTO DEF*/", /*definitionMarker*/ + func(t *testing.T, f *FourslashTest, fileName string, position lsproto.Position) lsproto.LocationOrLocationsOrDefinitionLinksOrNull { + params := &lsproto.DefinitionParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + + return sendRequest(t, f, lsproto.TextDocumentDefinitionInfo, params) + }, + includeOriginalSelectionRange, + markers..., + ) +} + +func (f *FourslashTest) verifyBaselineDefinitions( + t *testing.T, + definitionCommand baselineCommand, + definitionMarker string, + getDefinitions func(t *testing.T, f *FourslashTest, fileName string, position lsproto.Position) lsproto.LocationOrLocationsOrDefinitionLinksOrNull, + includeOriginalSelectionRange bool, markers ...string, ) { referenceLocations := f.lookupMarkersOrGetRanges(t, markers) @@ -813,45 +1355,95 @@ func (f *FourslashTest) VerifyBaselineGoToDefinition( // worker in `baselineEachMarkerOrRange` f.GoToMarkerOrRange(t, markerOrRange) - params := &lsproto.DefinitionParams{ - TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), - }, - Position: f.currentCaretPosition, - } - - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentDefinitionInfo, params) - if resMsg == nil { - if f.lastKnownMarkerName == nil { - t.Fatalf("Nil response received for definition request at pos %v", f.currentCaretPosition) - } else { - t.Fatalf("Nil response received for definition request at marker '%s'", *f.lastKnownMarkerName) - } - } - if !resultOk { - if f.lastKnownMarkerName == nil { - t.Fatalf("Unexpected definition response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) - } else { - t.Fatalf("Unexpected definition response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) - } - } + result := getDefinitions(t, f, f.activeFilename, f.currentCaretPosition) - var resultAsLocations []lsproto.Location + var resultAsSpans []documentSpan + var additionalSpan *documentSpan if result.Locations != nil { - resultAsLocations = *result.Locations + resultAsSpans = core.Map(*result.Locations, locationToSpan) } else if result.Location != nil { - resultAsLocations = []lsproto.Location{*result.Location} + resultAsSpans = []documentSpan{locationToSpan(*result.Location)} } else if result.DefinitionLinks != nil { - t.Fatalf("Unexpected definition response type at marker '%s': %T", *f.lastKnownMarkerName, result.DefinitionLinks) + var originRange *lsproto.Range + resultAsSpans = core.Map(*result.DefinitionLinks, func(link *lsproto.LocationLink) documentSpan { + if originRange != nil && originRange != link.OriginSelectionRange { + panic("multiple different origin ranges in definition links") + } + originRange = link.OriginSelectionRange + var contextSpan *lsproto.Range + if link.TargetRange != link.TargetSelectionRange && !f.isStradaServer { + contextSpan = &link.TargetRange + } + return documentSpan{ + uri: link.TargetUri, + textSpan: link.TargetSelectionRange, + contextSpan: contextSpan, + } + }) + if originRange != nil && includeOriginalSelectionRange { + additionalSpan = &documentSpan{ + uri: lsconv.FileNameToDocumentURI(f.activeFilename), + textSpan: *originRange, + } + } } - f.addResultToBaseline(t, "goToDefinition", f.getBaselineForLocationsWithFileContents(resultAsLocations, baselineFourslashLocationsOptions{ - marker: markerOrRange, - markerName: "/*GOTO DEF*/", + f.addResultToBaseline(t, definitionCommand, f.getBaselineForSpansWithFileContents(resultAsSpans, baselineFourslashLocationsOptions{ + marker: markerOrRange, + markerName: definitionMarker, + additionalSpan: additionalSpan, })) } } +func (f *FourslashTest) VerifyBaselineGoToTypeDefinition( + t *testing.T, + markers ...string, +) { + f.verifyBaselineDefinitions( + t, + goToTypeDefinitionCmd, + "/*GOTO TYPE*/", /*definitionMarker*/ + func(t *testing.T, f *FourslashTest, fileName string, position lsproto.Position) lsproto.LocationOrLocationsOrDefinitionLinksOrNull { + params := &lsproto.TypeDefinitionParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + + return sendRequest(t, f, lsproto.TextDocumentTypeDefinitionInfo, params) + }, + false, /*includeOriginalSelectionRange*/ + markers..., + ) +} + +func (f *FourslashTest) VerifyBaselineWorkspaceSymbol(t *testing.T, query string) { + t.Helper() + result := sendRequest(t, f, lsproto.WorkspaceSymbolInfo, &lsproto.WorkspaceSymbolParams{Query: query}) + + locationToText := map[documentSpan]*lsproto.SymbolInformation{} + groupedRanges := collections.MultiMap[lsproto.DocumentUri, documentSpan]{} + var symbolInformations []*lsproto.SymbolInformation + if result.SymbolInformations != nil { + symbolInformations = *result.SymbolInformations + } + for _, symbol := range symbolInformations { + uri := symbol.Location.Uri + span := locationToSpan(symbol.Location) + groupedRanges.Add(uri, span) + locationToText[span] = symbol + } + + f.addResultToBaseline(t, "workspaceSymbol", f.getBaselineForGroupedSpansWithFileContents( + &groupedRanges, + baselineFourslashLocationsOptions{ + getLocationData: func(span documentSpan) string { return symbolInformationToData(locationToText[span]) }, + }, + )) +} + func (f *FourslashTest) VerifyBaselineHover(t *testing.T) { markersAndItems := core.MapFiltered(f.Markers(), func(marker *Marker) (markerAndItem[*lsproto.Hover], bool) { if marker.Name == nil { @@ -860,19 +1452,12 @@ func (f *FourslashTest) VerifyBaselineHover(t *testing.T) { params := &lsproto.HoverParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: marker.LSPosition, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentHoverInfo, params) - if resMsg == nil { - t.Fatalf(f.getCurrentPositionPrefix()+"Nil response received for quick info request", f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf(f.getCurrentPositionPrefix()+"Unexpected response type for quick info request: %T", resMsg.AsResponse().Result) - } - + result := sendRequest(t, f, lsproto.TextDocumentHoverInfo, params) return markerAndItem[*lsproto.Hover]{Marker: marker, Item: result.Hover}, true }) @@ -908,9 +1493,9 @@ func (f *FourslashTest) VerifyBaselineHover(t *testing.T) { return result } - f.addResultToBaseline(t, "QuickInfo", annotateContentWithTooltips(t, f, markersAndItems, "quickinfo", getRange, getTooltipLines)) + f.addResultToBaseline(t, quickInfoCmd, annotateContentWithTooltips(t, f, markersAndItems, "quickinfo", getRange, getTooltipLines)) if jsonStr, err := core.StringifyJson(markersAndItems, "", " "); err == nil { - f.writeToBaseline("QuickInfo", jsonStr) + f.writeToBaseline(quickInfoCmd, jsonStr) } else { t.Fatalf("Failed to stringify markers and items for baseline: %v", err) } @@ -931,19 +1516,12 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { params := &lsproto.SignatureHelpParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: marker.LSPosition, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) - if resMsg == nil { - t.Fatalf(f.getCurrentPositionPrefix()+"Nil response received for signature help request", f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf(f.getCurrentPositionPrefix()+"Unexpected response type for signature help request: %T", resMsg.AsResponse().Result) - } - + result := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) return markerAndItem[*lsproto.SignatureHelp]{Marker: marker, Item: result.SignatureHelp}, true }) @@ -1023,17 +1601,150 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { return result } - f.addResultToBaseline(t, "SignatureHelp", annotateContentWithTooltips(t, f, markersAndItems, "signaturehelp", getRange, getTooltipLines)) + f.addResultToBaseline(t, signatureHelpCmd, annotateContentWithTooltips(t, f, markersAndItems, "signaturehelp", getRange, getTooltipLines)) if jsonStr, err := core.StringifyJson(markersAndItems, "", " "); err == nil { - f.writeToBaseline("SignatureHelp", jsonStr) + f.writeToBaseline(signatureHelpCmd, jsonStr) } else { t.Fatalf("Failed to stringify markers and items for baseline: %v", err) } } +func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { + markers := f.Markers() + var result strings.Builder + newLine := "\n" + + for i, marker := range markers { + if i > 0 { + result.WriteString(newLine + strings.Repeat("=", 80) + newLine + newLine) + } + + script := f.getScriptInfo(marker.FileName()) + fileContent := script.content + + // Add the marker position indicator + markerPos := marker.Position + baselineContent := fileContent[:markerPos] + "/**/" + fileContent[markerPos:] + newLine + result.WriteString(baselineContent) + + // Get selection ranges at this marker + params := &lsproto.SelectionRangeParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(marker.FileName()), + }, + Positions: []lsproto.Position{marker.LSPosition}, + } + + selectionRangeResult := sendRequest(t, f, lsproto.TextDocumentSelectionRangeInfo, params) + + if selectionRangeResult.SelectionRanges == nil || len(*selectionRangeResult.SelectionRanges) == 0 { + result.WriteString("No selection ranges available\n") + continue + } + + selectionRange := (*selectionRangeResult.SelectionRanges)[0] + + // Add blank line after source code section + result.WriteString(newLine) + + // Walk through the selection range chain + for selectionRange != nil { + start := int(f.converters.LineAndCharacterToPosition(script, selectionRange.Range.Start)) + end := int(f.converters.LineAndCharacterToPosition(script, selectionRange.Range.End)) + + // Create a masked version of the file showing only this range + runes := []rune(fileContent) + masked := make([]rune, len(runes)) + for i, ch := range runes { + if i >= start && i < end { + // Keep characters in the selection range + if ch == ' ' { + masked[i] = 'â€ĸ' + } else if ch == '\n' || ch == '\r' { + masked[i] = ch // Keep line breaks as-is, will add arrow later + } else { + masked[i] = ch + } + } else { + // Replace characters outside the range + if ch == '\n' || ch == '\r' { + masked[i] = ch + } else { + masked[i] = ' ' + } + } + } + + maskedStr := string(masked) + + // Add line break arrows + maskedStr = strings.ReplaceAll(maskedStr, "\n", "↲\n") + maskedStr = strings.ReplaceAll(maskedStr, "\r", "↲\r") + + // Remove blank lines + lines := strings.Split(maskedStr, "\n") + var nonBlankLines []string + for _, line := range lines { + trimmed := strings.TrimSpace(line) + if trimmed != "" && trimmed != "↲" { + nonBlankLines = append(nonBlankLines, line) + } + } + maskedStr = strings.Join(nonBlankLines, "\n") + + // Find leading and trailing width of non-whitespace characters + maskedRunes := []rune(maskedStr) + isRealCharacter := func(ch rune) bool { + return ch != 'â€ĸ' && ch != '↲' && !stringutil.IsWhiteSpaceLike(ch) + } + + leadingWidth := -1 + for i, ch := range maskedRunes { + if isRealCharacter(ch) { + leadingWidth = i + break + } + } + + trailingWidth := -1 + for j := len(maskedRunes) - 1; j >= 0; j-- { + if isRealCharacter(maskedRunes[j]) { + trailingWidth = j + break + } + } + + if leadingWidth != -1 && trailingWidth != -1 && leadingWidth <= trailingWidth { + // Clean up middle section + prefix := string(maskedRunes[:leadingWidth]) + middle := string(maskedRunes[leadingWidth : trailingWidth+1]) + suffix := string(maskedRunes[trailingWidth+1:]) + + middle = strings.ReplaceAll(middle, "â€ĸ", " ") + middle = strings.ReplaceAll(middle, "↲", "") + + maskedStr = prefix + middle + suffix + } + + // Add blank line before multi-line ranges + if strings.Contains(maskedStr, "\n") { + result.WriteString(newLine) + } + + result.WriteString(maskedStr) + if !strings.HasSuffix(maskedStr, "\n") { + result.WriteString(newLine) + } + + selectionRange = selectionRange.Parent + } + } + f.addResultToBaseline(t, smartSelectionCmd, strings.TrimSuffix(result.String(), "\n")) +} + func (f *FourslashTest) VerifyBaselineDocumentHighlights( t *testing.T, - preferences *ls.UserPreferences, + preferences *lsutil.UserPreferences, markerOrRangeOrNames ...MarkerOrRangeOrName, ) { var markerOrRanges []MarkerOrRange @@ -1059,7 +1770,7 @@ func (f *FourslashTest) VerifyBaselineDocumentHighlights( func (f *FourslashTest) verifyBaselineDocumentHighlights( t *testing.T, - preferences *ls.UserPreferences, + preferences *lsutil.UserPreferences, markerOrRanges []MarkerOrRange, ) { for _, markerOrRange := range markerOrRanges { @@ -1067,26 +1778,11 @@ func (f *FourslashTest) verifyBaselineDocumentHighlights( params := &lsproto.DocumentHighlightParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentDocumentHighlightInfo, params) - if resMsg == nil { - if f.lastKnownMarkerName == nil { - t.Fatalf("Nil response received for document highlights request at pos %v", f.currentCaretPosition) - } else { - t.Fatalf("Nil response received for document highlights request at marker '%s'", *f.lastKnownMarkerName) - } - } - if !resultOk { - if f.lastKnownMarkerName == nil { - t.Fatalf("Unexpected document highlights response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) - } else { - t.Fatalf("Unexpected document highlights response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) - } - } - + result := sendRequest(t, f, lsproto.TextDocumentDocumentHighlightInfo, params) highlights := result.DocumentHighlights if highlights == nil { highlights = &[]*lsproto.DocumentHighlight{} @@ -1095,13 +1791,13 @@ func (f *FourslashTest) verifyBaselineDocumentHighlights( var spans []lsproto.Location for _, h := range *highlights { spans = append(spans, lsproto.Location{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), Range: h.Range, }) } // Add result to baseline - f.addResultToBaseline(t, "documentHighlights", f.getBaselineForLocationsWithFileContents(spans, baselineFourslashLocationsOptions{ + f.addResultToBaseline(t, documentHighlightsCmd, f.getBaselineForLocationsWithFileContents(spans, baselineFourslashLocationsOptions{ marker: markerOrRange, markerName: "/*HIGHLIGHTS*/", })) @@ -1171,7 +1867,12 @@ func (f *FourslashTest) ReplaceLine(t *testing.T, lineIndex int, text string) { func (f *FourslashTest) selectLine(t *testing.T, lineIndex int) { script := f.getScriptInfo(f.activeFilename) start := script.lineMap.LineStarts[lineIndex] - end := script.lineMap.LineStarts[lineIndex+1] - 1 + var end core.TextPos + if lineIndex+1 >= len(script.lineMap.LineStarts) { + end = core.TextPos(len(script.content)) + } else { + end = script.lineMap.LineStarts[lineIndex+1] - 1 + } f.selectRange(t, core.NewTextRange(int(start), int(end))) } @@ -1197,6 +1898,22 @@ func (f *FourslashTest) getSelection() core.TextRange { ) } +func (f *FourslashTest) applyTextEdits(t *testing.T, edits []*lsproto.TextEdit) { + script := f.getScriptInfo(f.activeFilename) + slices.SortFunc(edits, func(a, b *lsproto.TextEdit) int { + aStart := f.converters.LineAndCharacterToPosition(script, a.Range.Start) + bStart := f.converters.LineAndCharacterToPosition(script, b.Range.Start) + return int(aStart) - int(bStart) + }) + // Apply edits in reverse order to avoid affecting the positions of earlier edits. + for i := len(edits) - 1; i >= 0; i-- { + edit := edits[i] + start := int(f.converters.LineAndCharacterToPosition(script, edit.Range.Start)) + end := int(f.converters.LineAndCharacterToPosition(script, edit.Range.End)) + f.editScriptAndUpdateMarkers(t, f.activeFilename, start, end, edit.NewText) + } +} + func (f *FourslashTest) Replace(t *testing.T, start int, length int, text string) { f.editScriptAndUpdateMarkers(t, f.activeFilename, start, start+length, text) // f.checkPostEditInvariants() // !!! do we need this? @@ -1272,13 +1989,9 @@ func (f *FourslashTest) editScript(t *testing.T, fileName string, start int, end } script.editContent(start, end, newText) - err := f.vfs.WriteFile(fileName, script.content, false) - if err != nil { - panic(fmt.Sprintf("Failed to write file %s: %v", fileName, err)) - } sendNotification(t, f, lsproto.TextDocumentDidChangeInfo, &lsproto.DidChangeTextDocumentParams{ TextDocument: lsproto.VersionedTextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(fileName), + Uri: lsconv.FileNameToDocumentURI(fileName), Version: script.version, }, ContentChanges: []lsproto.TextDocumentContentChangePartialOrWholeDocument{ @@ -1307,17 +2020,11 @@ func (f *FourslashTest) VerifyQuickInfoAt(t *testing.T, marker string, expectedT func (f *FourslashTest) getQuickInfoAtCurrentPosition(t *testing.T) *lsproto.Hover { params := &lsproto.HoverParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentHoverInfo, params) - if resMsg == nil { - t.Fatalf("Nil response received for hover request at marker '%s'", *f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf("Unexpected hover response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) - } + result := sendRequest(t, f, lsproto.TextDocumentHoverInfo, params) if result.Hover == nil { t.Fatalf("Expected hover result at marker '%s' but got nil", *f.lastKnownMarkerName) } @@ -1417,18 +2124,12 @@ func (f *FourslashTest) verifySignatureHelp( prefix := f.getCurrentPositionPrefix() params := &lsproto.SignatureHelpParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, Context: context, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) - if resMsg == nil { - t.Fatalf(prefix+"Nil response received for signature help request", f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf(prefix+"Unexpected response type for signature help request: %T", resMsg.AsResponse().Result) - } + result := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) f.verifySignatureHelpResult(t, result.SignatureHelp, expected, prefix) } @@ -1449,28 +2150,28 @@ func (f *FourslashTest) getCurrentPositionPrefix() string { } func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames []string) { + reset := f.ConfigureWithReset(t, &lsutil.UserPreferences{ + IncludeCompletionsForModuleExports: core.TSTrue, + IncludeCompletionsForImportStatements: core.TSTrue, + }) + defer reset() + for _, markerName := range markerNames { f.GoToMarker(t, markerName) params := &lsproto.CompletionParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, Context: &lsproto.CompletionContext{}, } - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentCompletionInfo, params) + result := sendRequest(t, f, lsproto.TextDocumentCompletionInfo, params) prefix := fmt.Sprintf("At marker '%s': ", markerName) - if resMsg == nil { - t.Fatalf(prefix+"Nil response received for completion request for autoimports", f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf(prefix+"Unexpected response type for completion request for autoimports: %T", resMsg.AsResponse().Result) - } - f.writeToBaseline("Auto Imports", "// === Auto Imports === \n") + f.writeToBaseline(autoImportsCmd, "// === Auto Imports === \n") - fileContent, ok := f.vfs.ReadFile(f.activeFilename) + fileContent, ok := f.textOfFile(f.activeFilename) if !ok { t.Fatalf(prefix+"Failed to read file %s for auto-import baseline", f.activeFilename) } @@ -1478,19 +2179,19 @@ func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames marker := f.testData.MarkerPositions[markerName] ext := strings.TrimPrefix(tspath.GetAnyExtensionFromPath(f.activeFilename, nil, true), ".") lang := core.IfElse(ext == "mts" || ext == "cts", "ts", ext) - f.writeToBaseline("Auto Imports", (codeFence( + f.writeToBaseline(autoImportsCmd, (codeFence( lang, "// @FileName: "+f.activeFilename+"\n"+fileContent[:marker.Position]+"/*"+markerName+"*/"+fileContent[marker.Position:], ))) currentFile := newScriptInfo(f.activeFilename, fileContent) - converters := ls.NewConverters(lsproto.PositionEncodingKindUTF8, func(_ string) *ls.LSPLineMap { + converters := lsconv.NewConverters(lsproto.PositionEncodingKindUTF8, func(_ string) *lsconv.LSPLineMap { return currentFile.lineMap }) var list []*lsproto.CompletionItem if result.Items == nil || len(*result.Items) == 0 { if result.List == nil || result.List.Items == nil || len(result.List.Items) == 0 { - f.writeToBaseline("Auto Imports", "no autoimport completions found"+"\n\n") + f.writeToBaseline(autoImportsCmd, "no autoimport completions found"+"\n\n") continue } @@ -1503,13 +2204,7 @@ func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames if item.Data == nil || *item.SortText != string(ls.SortTextAutoImportSuggestions) { continue } - resMsg, details, resultOk := sendRequest(t, f, lsproto.CompletionItemResolveInfo, item) - if resMsg == nil { - t.Fatalf(prefix+"Nil response received for resolve completion", f.lastKnownMarkerName) - } - if !resultOk { - t.Fatalf(prefix+"Unexpected response type for resolve completion: %T", resMsg.AsResponse().Result) - } + details := sendRequest(t, f, lsproto.CompletionItemResolveInfo, item) if details == nil || details.AdditionalTextEdits == nil || len(*details.AdditionalTextEdits) == 0 { t.Fatalf(prefix+"Entry %s from %s returned no code changes from completion details request", item.Label, item.Detail) } @@ -1531,12 +2226,12 @@ func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames // } // allChanges := append(allChanges, completionChange) // sorted from back-of-file-most to front-of-file-most - slices.SortFunc(allChanges, func(a, b *lsproto.TextEdit) int { return ls.ComparePositions(b.Range.Start, a.Range.Start) }) + slices.SortFunc(allChanges, func(a, b *lsproto.TextEdit) int { return lsproto.ComparePositions(b.Range.Start, a.Range.Start) }) newFileContent := fileContent for _, change := range allChanges { newFileContent = newFileContent[:converters.LineAndCharacterToPosition(currentFile, change.Range.Start)] + change.NewText + newFileContent[converters.LineAndCharacterToPosition(currentFile, change.Range.End):] } - f.writeToBaseline("Auto Imports", codeFence(lang, newFileContent)+"\n\n") + f.writeToBaseline(autoImportsCmd, codeFence(lang, newFileContent)+"\n\n") } } } @@ -1546,7 +2241,7 @@ type MarkerOrRangeOrName = any func (f *FourslashTest) VerifyBaselineRename( t *testing.T, - preferences *ls.UserPreferences, + preferences *lsutil.UserPreferences, markerOrNameOrRanges ...MarkerOrRangeOrName, ) { var markerOrRanges []MarkerOrRange @@ -1572,7 +2267,7 @@ func (f *FourslashTest) VerifyBaselineRename( func (f *FourslashTest) verifyBaselineRename( t *testing.T, - preferences *ls.UserPreferences, + preferences *lsutil.UserPreferences, markerOrRanges []MarkerOrRange, ) { for _, markerOrRange := range markerOrRanges { @@ -1581,31 +2276,25 @@ func (f *FourslashTest) verifyBaselineRename( // !!! set preferences params := &lsproto.RenameParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, NewName: "?", } - prefix := f.getCurrentPositionPrefix() - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentRenameInfo, params) - if resMsg == nil { - t.Fatal(prefix + "Nil response received for rename request") - } - if !resultOk { - t.Fatalf(prefix+"Unexpected rename response type: %T", resMsg.AsResponse().Result) - } + result := sendRequest(t, f, lsproto.TextDocumentRenameInfo, params) var changes map[lsproto.DocumentUri][]*lsproto.TextEdit if result.WorkspaceEdit != nil && result.WorkspaceEdit.Changes != nil { changes = *result.WorkspaceEdit.Changes } - locationToText := map[lsproto.Location]string{} - fileToRange := collections.MultiMap[lsproto.DocumentUri, lsproto.Range]{} + spanToText := map[documentSpan]string{} + fileToSpan := collections.MultiMap[lsproto.DocumentUri, documentSpan]{} for uri, edits := range changes { for _, edit := range edits { - fileToRange.Add(uri, edit.Range) - locationToText[lsproto.Location{Uri: uri, Range: edit.Range}] = edit.NewText + span := documentSpan{uri: uri, textSpan: edit.Range} + fileToSpan.Add(uri, span) + spanToText[span] = edit.NewText } } @@ -1614,27 +2303,27 @@ func (f *FourslashTest) verifyBaselineRename( if preferences.UseAliasesForRename != core.TSUnknown { fmt.Fprintf(&renameOptions, "// @useAliasesForRename: %v\n", preferences.UseAliasesForRename.IsTrue()) } - if preferences.QuotePreference != ls.QuotePreferenceUnknown { + if preferences.QuotePreference != lsutil.QuotePreferenceUnknown { fmt.Fprintf(&renameOptions, "// @quotePreference: %v\n", preferences.QuotePreference) } } - baselineFileContent := f.getBaselineForGroupedLocationsWithFileContents( - &fileToRange, + baselineFileContent := f.getBaselineForGroupedSpansWithFileContents( + &fileToSpan, baselineFourslashLocationsOptions{ marker: markerOrRange, markerName: "/*RENAME*/", endMarker: "RENAME|]", - startMarkerPrefix: func(span lsproto.Location) *string { - text := locationToText[span] + startMarkerPrefix: func(span documentSpan) *string { + text := spanToText[span] prefixAndSuffix := strings.Split(text, "?") if prefixAndSuffix[0] != "" { return ptrTo("/*START PREFIX*/" + prefixAndSuffix[0]) } return nil }, - endMarkerSuffix: func(span lsproto.Location) *string { - text := locationToText[span] + endMarkerSuffix: func(span documentSpan) *string { + text := spanToText[span] prefixAndSuffix := strings.Split(text, "?") if prefixAndSuffix[1] != "" { return ptrTo(prefixAndSuffix[1] + "/*END SUFFIX*/") @@ -1651,56 +2340,39 @@ func (f *FourslashTest) verifyBaselineRename( baselineResult = baselineFileContent } - f.addResultToBaseline(t, - "findRenameLocations", - baselineResult, - ) + f.addResultToBaseline(t, renameCmd, baselineResult) } } -func (f *FourslashTest) VerifyRenameSucceeded(t *testing.T, preferences *ls.UserPreferences) { +func (f *FourslashTest) VerifyRenameSucceeded(t *testing.T, preferences *lsutil.UserPreferences) { // !!! set preferences params := &lsproto.RenameParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, NewName: "?", } prefix := f.getCurrentPositionPrefix() - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentRenameInfo, params) - if resMsg == nil { - t.Fatal(prefix + "Nil response received for rename request") - } - if !resultOk { - t.Fatalf(prefix+"Unexpected rename response type: %T", resMsg.AsResponse().Result) - } - + result := sendRequest(t, f, lsproto.TextDocumentRenameInfo, params) if result.WorkspaceEdit == nil || result.WorkspaceEdit.Changes == nil || len(*result.WorkspaceEdit.Changes) == 0 { t.Fatal(prefix + "Expected rename to succeed, but got no changes") } } -func (f *FourslashTest) VerifyRenameFailed(t *testing.T, preferences *ls.UserPreferences) { +func (f *FourslashTest) VerifyRenameFailed(t *testing.T, preferences *lsutil.UserPreferences) { // !!! set preferences params := &lsproto.RenameParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: ls.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, NewName: "?", } prefix := f.getCurrentPositionPrefix() - resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentRenameInfo, params) - if resMsg == nil { - t.Fatal(prefix + "Nil response received for rename request") - } - if !resultOk { - t.Fatalf(prefix+"Unexpected rename response type: %T", resMsg.AsResponse().Result) - } - + result := sendRequest(t, f, lsproto.TextDocumentRenameInfo, params) if result.WorkspaceEdit != nil { t.Fatalf(prefix+"Expected rename to fail, but got changes: %s", cmp.Diff(result.WorkspaceEdit, nil)) } @@ -1708,7 +2380,7 @@ func (f *FourslashTest) VerifyRenameFailed(t *testing.T, preferences *ls.UserPre func (f *FourslashTest) VerifyBaselineRenameAtRangesWithText( t *testing.T, - preferences *ls.UserPreferences, + preferences *lsutil.UserPreferences, texts ...string, ) { var markerOrRanges []MarkerOrRange @@ -1737,8 +2409,416 @@ func (f *FourslashTest) getRangeText(r *RangeMarker) string { return script.content[r.Range.Pos():r.Range.End()] } -func (f *FourslashTest) verifyBaselines(t *testing.T) { - for command, content := range f.baselines { - baseline.Run(t, getBaselineFileName(t, command), content.String(), getBaselineOptions(command)) +func (f *FourslashTest) verifyBaselines(t *testing.T, testPath string) { + if !f.testData.isStateBaseliningEnabled() { + for command, content := range f.baselines { + baseline.Run(t, getBaselineFileName(t, command), content.String(), f.getBaselineOptions(command, testPath)) + } + } else { + baseline.Run(t, getBaseFileNameFromTest(t)+".baseline", f.stateBaseline.baseline.String(), baseline.Options{Subfolder: "fourslash/state"}) + } +} + +func (f *FourslashTest) VerifyBaselineInlayHints( + t *testing.T, + span *lsproto.Range, + testPreferences *lsutil.UserPreferences, +) { + fileName := f.activeFilename + var lspRange lsproto.Range + if span == nil { + lspRange = f.converters.ToLSPRange(f.getScriptInfo(fileName), core.NewTextRange(0, len(f.scriptInfos[fileName].content))) + } else { + lspRange = *span + } + + params := &lsproto.InlayHintParams{ + TextDocument: lsproto.TextDocumentIdentifier{Uri: lsconv.FileNameToDocumentURI(fileName)}, + Range: lspRange, + } + + preferences := testPreferences + if preferences == nil { + preferences = lsutil.NewDefaultUserPreferences() + } + reset := f.ConfigureWithReset(t, preferences) + defer reset() + + prefix := fmt.Sprintf("At position (Ln %d, Col %d): ", lspRange.Start.Line, lspRange.Start.Character) + result := sendRequest(t, f, lsproto.TextDocumentInlayHintInfo, params) + fileLines := strings.Split(f.getScriptInfo(fileName).content, "\n") + var annotations []string + if result.InlayHints != nil { + slices.SortFunc(*result.InlayHints, func(a, b *lsproto.InlayHint) int { + return lsproto.ComparePositions(a.Position, b.Position) + }) + annotations = core.Map(*result.InlayHints, func(hint *lsproto.InlayHint) string { + if hint.Label.InlayHintLabelParts != nil { + for _, part := range *hint.Label.InlayHintLabelParts { + if part.Location != nil && isLibFile(part.Location.Uri.FileName()) { + part.Location.Range.Start = lsproto.Position{Line: 0, Character: 0} + } + } + } + + underline := strings.Repeat(" ", int(hint.Position.Character)) + "^" + hintJson, err := core.StringifyJson(hint, "", " ") + if err != nil { + t.Fatalf(prefix+"Failed to stringify inlay hint for baseline: %v", err) + } + annotation := fileLines[hint.Position.Line] + annotation += "\n" + underline + "\n" + hintJson + return annotation + }) + } + + if len(annotations) == 0 { + annotations = append(annotations, "=== No inlay hints ===") + } + + f.addResultToBaseline(t, inlayHintsCmd, strings.Join(annotations, "\n\n")) +} + +func (f *FourslashTest) VerifyDiagnostics(t *testing.T, expected []*lsproto.Diagnostic) { + f.verifyDiagnostics(t, expected, func(d *lsproto.Diagnostic) bool { return true }) +} + +// Similar to `VerifyDiagnostics`, but excludes suggestion diagnostics returned from server. +func (f *FourslashTest) VerifyNonSuggestionDiagnostics(t *testing.T, expected []*lsproto.Diagnostic) { + f.verifyDiagnostics(t, expected, func(d *lsproto.Diagnostic) bool { return !isSuggestionDiagnostic(d) }) +} + +// Similar to `VerifyDiagnostics`, but includes only suggestion diagnostics returned from server. +func (f *FourslashTest) VerifySuggestionDiagnostics(t *testing.T, expected []*lsproto.Diagnostic) { + f.verifyDiagnostics(t, expected, isSuggestionDiagnostic) +} + +func (f *FourslashTest) verifyDiagnostics(t *testing.T, expected []*lsproto.Diagnostic, filterDiagnostics func(*lsproto.Diagnostic) bool) { + actualDiagnostics := f.getDiagnostics(t, f.activeFilename) + actualDiagnostics = core.Filter(actualDiagnostics, filterDiagnostics) + emptyRange := lsproto.Range{} + expectedWithRanges := make([]*lsproto.Diagnostic, len(expected)) + for i, diag := range expected { + if diag.Range == emptyRange { + rangesInFile := f.getRangesInFile(f.activeFilename) + if len(rangesInFile) == 0 { + t.Fatalf("No ranges found in file %s to assign to diagnostic with empty range", f.activeFilename) + } + diagWithRange := *diag + diagWithRange.Range = rangesInFile[0].LSRange + expectedWithRanges[i] = &diagWithRange + } else { + expectedWithRanges[i] = diag + } + } + if len(actualDiagnostics) == 0 && len(expectedWithRanges) == 0 { + return + } + assertDeepEqual(t, actualDiagnostics, expectedWithRanges, "Diagnostics do not match expected", diagnosticsIgnoreOpts) +} + +func (f *FourslashTest) getDiagnostics(t *testing.T, fileName string) []*lsproto.Diagnostic { + params := &lsproto.DocumentDiagnosticParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(fileName), + }, + } + result := sendRequest(t, f, lsproto.TextDocumentDiagnosticInfo, params) + if result.FullDocumentDiagnosticReport != nil { + return result.FullDocumentDiagnosticReport.Items + } + return nil +} + +func isSuggestionDiagnostic(diag *lsproto.Diagnostic) bool { + return diag.Severity != nil && *diag.Severity == lsproto.DiagnosticSeverityHint +} + +func (f *FourslashTest) VerifyBaselineNonSuggestionDiagnostics(t *testing.T) { + var diagnostics []*fourslashDiagnostic + var files []*harnessutil.TestFile + for fileName, scriptInfo := range f.scriptInfos { + if tspath.HasJSONFileExtension(fileName) { + continue + } + files = append(files, &harnessutil.TestFile{UnitName: fileName, Content: scriptInfo.content}) + lspDiagnostics := core.Filter( + f.getDiagnostics(t, fileName), + func(d *lsproto.Diagnostic) bool { return !isSuggestionDiagnostic(d) }, + ) + diagnostics = append(diagnostics, core.Map(lspDiagnostics, func(d *lsproto.Diagnostic) *fourslashDiagnostic { + return f.toDiagnostic(scriptInfo, d) + })...) + } + slices.SortFunc(files, func(a, b *harnessutil.TestFile) int { + return strings.Compare(a.UnitName, b.UnitName) + }) + result := tsbaseline.GetErrorBaseline(t, files, diagnostics, compareDiagnostics, false /*pretty*/) + f.addResultToBaseline(t, nonSuggestionDiagnosticsCmd, result) +} + +type fourslashDiagnostic struct { + file *fourslashDiagnosticFile + loc core.TextRange + code int32 + category diagnostics.Category + message string + relatedDiagnostics []*fourslashDiagnostic + reportsUnnecessary bool + reportsDeprecated bool +} + +type fourslashDiagnosticFile struct { + file *harnessutil.TestFile + ecmaLineMap []core.TextPos +} + +var _ diagnosticwriter.FileLike = (*fourslashDiagnosticFile)(nil) + +func (f *fourslashDiagnosticFile) FileName() string { + return f.file.UnitName +} + +func (f *fourslashDiagnosticFile) Text() string { + return f.file.Content +} + +func (f *fourslashDiagnosticFile) ECMALineMap() []core.TextPos { + if f.ecmaLineMap == nil { + f.ecmaLineMap = core.ComputeECMALineStarts(f.file.Content) + } + return f.ecmaLineMap +} + +var _ diagnosticwriter.Diagnostic = (*fourslashDiagnostic)(nil) + +func (d *fourslashDiagnostic) File() diagnosticwriter.FileLike { + return d.file +} + +func (d *fourslashDiagnostic) Pos() int { + return d.loc.Pos() +} + +func (d *fourslashDiagnostic) End() int { + return d.loc.End() +} + +func (d *fourslashDiagnostic) Len() int { + return d.loc.Len() +} + +func (d *fourslashDiagnostic) Code() int32 { + return d.code +} + +func (d *fourslashDiagnostic) Category() diagnostics.Category { + return d.category +} + +func (d *fourslashDiagnostic) Localize(locale locale.Locale) string { + return d.message +} + +func (d *fourslashDiagnostic) MessageChain() []diagnosticwriter.Diagnostic { + return nil +} + +func (d *fourslashDiagnostic) RelatedInformation() []diagnosticwriter.Diagnostic { + relatedInfo := make([]diagnosticwriter.Diagnostic, 0, len(d.relatedDiagnostics)) + for _, relDiag := range d.relatedDiagnostics { + relatedInfo = append(relatedInfo, relDiag) + } + return relatedInfo +} + +func (f *FourslashTest) toDiagnostic(scriptInfo *scriptInfo, lspDiagnostic *lsproto.Diagnostic) *fourslashDiagnostic { + var category diagnostics.Category + switch *lspDiagnostic.Severity { + case lsproto.DiagnosticSeverityError: + category = diagnostics.CategoryError + case lsproto.DiagnosticSeverityWarning: + category = diagnostics.CategoryWarning + case lsproto.DiagnosticSeverityInformation: + category = diagnostics.CategoryMessage + case lsproto.DiagnosticSeverityHint: + category = diagnostics.CategorySuggestion + default: + category = diagnostics.CategoryError + } + code := *lspDiagnostic.Code.Integer + + var relatedDiagnostics []*fourslashDiagnostic + if lspDiagnostic.RelatedInformation != nil { + for _, info := range *lspDiagnostic.RelatedInformation { + relatedScriptInfo := f.getScriptInfo(info.Location.Uri.FileName()) + if relatedScriptInfo == nil { + continue + } + relatedDiagnostic := &fourslashDiagnostic{ + file: &fourslashDiagnosticFile{file: &harnessutil.TestFile{UnitName: relatedScriptInfo.fileName, Content: relatedScriptInfo.content}}, + loc: f.converters.FromLSPRange(relatedScriptInfo, info.Location.Range), + code: code, + category: category, + message: info.Message, + } + relatedDiagnostics = append(relatedDiagnostics, relatedDiagnostic) + } + } + + diagnostic := &fourslashDiagnostic{ + file: &fourslashDiagnosticFile{ + file: &harnessutil.TestFile{ + UnitName: scriptInfo.fileName, + Content: scriptInfo.content, + }, + }, + loc: f.converters.FromLSPRange(scriptInfo, lspDiagnostic.Range), + code: code, + category: category, + message: lspDiagnostic.Message, + relatedDiagnostics: relatedDiagnostics, + } + return diagnostic +} + +func compareDiagnostics(d1, d2 *fourslashDiagnostic) int { + c := strings.Compare(d1.file.FileName(), d2.file.FileName()) + if c != 0 { + return c + } + c = d1.Pos() - d2.Pos() + if c != 0 { + return c + } + c = d1.End() - d2.End() + if c != 0 { + return c + } + c = int(d1.code) - int(d2.code) + if c != 0 { + return c + } + c = strings.Compare(d1.message, d2.message) + if c != 0 { + return c + } + return compareRelatedDiagnostics(d1.relatedDiagnostics, d2.relatedDiagnostics) +} + +func compareRelatedDiagnostics(d1, d2 []*fourslashDiagnostic) int { + c := len(d2) - len(d1) + if c != 0 { + return c + } + for i := range d1 { + c = compareDiagnostics(d1[i], d2[i]) + if c != 0 { + return c + } + } + return 0 +} + +func isLibFile(fileName string) bool { + baseName := tspath.GetBaseFileName(fileName) + if strings.HasPrefix(baseName, "lib.") && strings.HasSuffix(baseName, ".d.ts") { + return true + } + return false +} + +var AnyTextEdits *[]*lsproto.TextEdit + +func (f *FourslashTest) VerifyBaselineGoToImplementation(t *testing.T, markerNames ...string) { + f.verifyBaselineDefinitions( + t, + goToImplementationCmd, + "/*GOTO IMPL*/", /*definitionMarker*/ + func(t *testing.T, f *FourslashTest, fileName string, position lsproto.Position) lsproto.LocationOrLocationsOrDefinitionLinksOrNull { + params := &lsproto.ImplementationParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + + return sendRequest(t, f, lsproto.TextDocumentImplementationInfo, params) + }, + false, /*includeOriginalSelectionRange*/ + markerNames..., + ) +} + +type VerifyWorkspaceSymbolCase struct { + Pattern string + Includes *[]*lsproto.SymbolInformation + Exact *[]*lsproto.SymbolInformation + Preferences *lsutil.UserPreferences +} + +// `verify.navigateTo` in Strada. +func (f *FourslashTest) VerifyWorkspaceSymbol(t *testing.T, cases []*VerifyWorkspaceSymbolCase) { + originalPreferences := f.userPreferences.Copy() + for _, testCase := range cases { + preferences := testCase.Preferences + if preferences == nil { + preferences = lsutil.NewDefaultUserPreferences() + } + f.Configure(t, preferences) + result := sendRequest(t, f, lsproto.WorkspaceSymbolInfo, &lsproto.WorkspaceSymbolParams{Query: testCase.Pattern}) + if result.SymbolInformations == nil { + t.Fatalf("Expected non-nil symbol information array from workspace symbol request") + } + if testCase.Includes != nil { + if testCase.Exact != nil { + t.Fatalf("Test case cannot have both 'Includes' and 'Exact' fields set") + } + verifyIncludesSymbols(t, *result.SymbolInformations, *testCase.Includes, "Workspace symbols mismatch with pattern '"+testCase.Pattern+"'") + } else { + if testCase.Exact == nil { + t.Fatalf("Test case must have either 'Includes' or 'Exact' field set") + } + verifyExactSymbols(t, *result.SymbolInformations, *testCase.Exact, "Workspace symbols mismatch with pattern '"+testCase.Pattern+"'") + } + } + f.Configure(t, originalPreferences) +} + +func verifyExactSymbols( + t *testing.T, + actual []*lsproto.SymbolInformation, + expected []*lsproto.SymbolInformation, + prefix string, +) { + if len(actual) != len(expected) { + t.Fatalf("%s: Expected %d symbols, but got %d:\n%s", prefix, len(expected), len(actual), cmp.Diff(actual, expected)) + } + for i := range actual { + assertDeepEqual(t, actual[i], expected[i], prefix) + } +} + +func verifyIncludesSymbols( + t *testing.T, + actual []*lsproto.SymbolInformation, + includes []*lsproto.SymbolInformation, + prefix string, +) { + type key struct { + name string + loc lsproto.Location + } + nameAndLocToActualSymbol := make(map[key]*lsproto.SymbolInformation, len(actual)) + for _, sym := range actual { + nameAndLocToActualSymbol[key{name: sym.Name, loc: sym.Location}] = sym + } + + for _, sym := range includes { + actualSym, ok := nameAndLocToActualSymbol[key{name: sym.Name, loc: sym.Location}] + if !ok { + t.Fatalf("%s: Expected symbol '%s' at location '%v' not found", prefix, sym.Name, sym.Location) + } + assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' at location '%v' mismatch", prefix, sym.Name, sym.Location)) } } diff --git a/internal/fourslash/statebaseline.go b/internal/fourslash/statebaseline.go new file mode 100644 index 0000000000..df2ac9189b --- /dev/null +++ b/internal/fourslash/statebaseline.go @@ -0,0 +1,509 @@ +package fourslash + +import ( + "fmt" + "io" + "iter" + "maps" + "slices" + "strings" + "testing" + + "github.com/go-json-experiment/json" + "github.com/go-json-experiment/json/jsontext" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/project" + "github.com/microsoft/typescript-go/internal/testutil/fsbaselineutil" + "github.com/microsoft/typescript-go/internal/tspath" + "github.com/microsoft/typescript-go/internal/vfs/iovfs" + "gotest.tools/v3/assert" +) + +type stateBaseline struct { + baseline strings.Builder + fsDiffer *fsbaselineutil.FSDiffer + isInitialized bool + + serializedProjects map[string]projectInfo + serializedOpenFiles map[string]*openFileInfo + serializedConfigFileRegistry *project.ConfigFileRegistry +} + +func newStateBaseline(fsFromMap iovfs.FsWithSys) *stateBaseline { + stateBaseline := &stateBaseline{ + fsDiffer: &fsbaselineutil.FSDiffer{ + FS: fsFromMap, + WrittenFiles: &collections.SyncSet[string]{}, + }, + } + fmt.Fprintf(&stateBaseline.baseline, "UseCaseSensitiveFileNames: %v\n", fsFromMap.UseCaseSensitiveFileNames()) + stateBaseline.fsDiffer.BaselineFSwithDiff(&stateBaseline.baseline) + return stateBaseline +} + +type requestOrMessage struct { + Method lsproto.Method `json:"method"` + Params any `json:"params,omitzero"` +} + +func (f *FourslashTest) baselineRequestOrNotification(t *testing.T, method lsproto.Method, params any) { + t.Helper() + + if !f.testData.isStateBaseliningEnabled() { + return + } + + res, _ := json.Marshal(requestOrMessage{method, params}, jsontext.WithIndent(" ")) + f.stateBaseline.baseline.WriteString("\n" + string(res) + "\n") + f.stateBaseline.isInitialized = true +} + +func (f *FourslashTest) baselineProjectsAfterNotification(t *testing.T, fileName string) { + t.Helper() + if !f.testData.isStateBaseliningEnabled() { + return + } + // Do hover so we have snapshot to check things on!! + _, _, resultOk := sendRequestWorker(t, f, lsproto.TextDocumentHoverInfo, &lsproto.HoverParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(fileName), + }, + Position: lsproto.Position{ + Line: uint32(0), + Character: uint32(0), + }, + }) + assert.Assert(t, resultOk) + f.baselineState(t) +} + +func (f *FourslashTest) baselineState(t *testing.T) { + t.Helper() + + if !f.testData.isStateBaseliningEnabled() { + return + } + + serialized := f.serializedState(t) + if serialized != "" { + f.stateBaseline.baseline.WriteString("\n") + f.stateBaseline.baseline.WriteString(serialized) + } +} + +func (f *FourslashTest) serializedState(t *testing.T) string { + t.Helper() + + var builder strings.Builder + f.stateBaseline.fsDiffer.BaselineFSwithDiff(&builder) + if strings.TrimSpace(builder.String()) == "" { + builder.Reset() + } + + f.printStateDiff(t, &builder) + return builder.String() +} + +type projectInfo = *compiler.Program + +type openFileInfo struct { + defaultProjectName string + allProjects []string +} + +type diffTableOptions struct { + indent string + sortKeys bool +} + +type diffTable struct { + diff collections.OrderedMap[string, string] + options diffTableOptions +} + +func (d *diffTable) add(key, value string) { + d.diff.Set(key, value) +} + +func (d *diffTable) print(w io.Writer, header string) { + count := d.diff.Size() + if count == 0 { + return + } + if header != "" { + fmt.Fprintf(w, "%s%s\n", d.options.indent, header) + } + diffKeys := make([]string, 0, count) + keyWidth := 0 + indent := d.options.indent + " " + for key := range d.diff.Keys() { + keyWidth = max(keyWidth, len(key)) + diffKeys = append(diffKeys, key) + } + if d.options.sortKeys { + slices.Sort(diffKeys) + } + + for _, key := range diffKeys { + value := d.diff.GetOrZero(key) + fmt.Fprintf(w, "%s%-*s %s\n", indent, keyWidth+1, key, value) + } +} + +type diffTableWriter struct { + hasChange bool + header string + diffs map[string]func(io.Writer) +} + +func newDiffTableWriter(header string) *diffTableWriter { + return &diffTableWriter{header: header, diffs: make(map[string]func(io.Writer))} +} + +func (d *diffTableWriter) setHasChange() { + d.hasChange = true +} + +func (d *diffTableWriter) add(key string, fn func(io.Writer)) { + d.diffs[key] = fn +} + +func (d *diffTableWriter) print(w io.Writer) { + if d.hasChange { + fmt.Fprintf(w, "%s::\n", d.header) + keys := slices.Collect(maps.Keys(d.diffs)) + slices.Sort(keys) + for _, key := range keys { + d.diffs[key](w) + } + } +} + +func areIterSeqEqual(a, b iter.Seq[tspath.Path]) bool { + aSlice := slices.Collect(a) + bSlice := slices.Collect(b) + slices.Sort(aSlice) + slices.Sort(bSlice) + return slices.Equal(aSlice, bSlice) +} + +func printSlicesWithDiffTable(w io.Writer, header string, newSlice []string, getOldSlice func() []string, options diffTableOptions, topChange string, isDefault func(entry string) bool) { + var oldSlice []string + if topChange == "*modified*" { + oldSlice = getOldSlice() + } + table := diffTable{options: options} + for _, entry := range newSlice { + entryChange := "" + if isDefault != nil && isDefault(entry) { + entryChange = "(default) " + } + if topChange == "*modified*" && !slices.Contains(oldSlice, entry) { + entryChange = "*new*" + } + table.add(entry, entryChange) + } + if topChange == "*modified*" { + for _, entry := range oldSlice { + if !slices.Contains(newSlice, entry) { + table.add(entry, "*deleted*") + } + } + } + table.print(w, header) +} + +func sliceFromIterSeqPath(seq iter.Seq[tspath.Path]) []string { + var result []string + for path := range seq { + result = append(result, string(path)) + } + slices.Sort(result) + return result +} + +func printPathIterSeqWithDiffTable(w io.Writer, header string, newIterSeq iter.Seq[tspath.Path], getOldIterSeq func() iter.Seq[tspath.Path], options diffTableOptions, topChange string) { + printSlicesWithDiffTable( + w, + header, + sliceFromIterSeqPath(newIterSeq), + func() []string { return sliceFromIterSeqPath(getOldIterSeq()) }, + options, + topChange, + nil, + ) +} + +func (f *FourslashTest) printStateDiff(t *testing.T, w io.Writer) { + if !f.stateBaseline.isInitialized { + return + } + session := f.server.Session() + snapshot, release := session.Snapshot() + defer release() + + f.printProjectsDiff(t, snapshot, w) + f.printOpenFilesDiff(t, snapshot, w) + f.printConfigFileRegistryDiff(t, snapshot, w) +} + +func (f *FourslashTest) printProjectsDiff(t *testing.T, snapshot *project.Snapshot, w io.Writer) { + t.Helper() + + currentProjects := make(map[string]projectInfo) + options := diffTableOptions{indent: " "} + projectsDiffTable := newDiffTableWriter("Projects") + + for _, project := range snapshot.ProjectCollection.Projects() { + program := project.GetProgram() + var oldProgram *compiler.Program + currentProjects[project.Name()] = program + projectChange := "" + if existing, ok := f.stateBaseline.serializedProjects[project.Name()]; ok { + oldProgram = existing + if oldProgram != program { + projectChange = "*modified*" + projectsDiffTable.setHasChange() + } else { + projectChange = "" + } + } else { + projectChange = "*new*" + projectsDiffTable.setHasChange() + } + + projectsDiffTable.add(project.Name(), func(w io.Writer) { + fmt.Fprintf(w, " [%s] %s\n", project.Name(), projectChange) + subDiff := diffTable{options: options} + if program != nil { + for _, file := range program.GetSourceFiles() { + fileDiff := "" + // No need to write "*new*" for files as its obvious + fileName := file.FileName() + if projectChange == "*modified*" { + if oldProgram == nil { + if !isLibFile(fileName) { + fileDiff = "*new*" + } + } else if oldFile := oldProgram.GetSourceFileByPath(file.Path()); oldFile == nil { + fileDiff = "*new*" + } else if oldFile != file { + fileDiff = "*modified*" + } + } + if fileDiff != "" || !isLibFile(fileName) { + subDiff.add(fileName, fileDiff) + } + } + } + if oldProgram != program && oldProgram != nil { + for _, file := range oldProgram.GetSourceFiles() { + if program == nil || program.GetSourceFileByPath(file.Path()) == nil { + subDiff.add(file.FileName(), "*deleted*") + } + } + } + subDiff.print(w, "") + }) + } + + for projectName, info := range f.stateBaseline.serializedProjects { + if _, found := currentProjects[projectName]; !found { + projectsDiffTable.setHasChange() + projectsDiffTable.add(projectName, func(w io.Writer) { + fmt.Fprintf(w, " [%s] *deleted*\n", projectName) + subDiff := diffTable{options: options} + if info != nil { + for _, file := range info.GetSourceFiles() { + if fileName := file.FileName(); !isLibFile(fileName) { + subDiff.add(fileName, "") + } + } + } + subDiff.print(w, "") + }) + } + } + f.stateBaseline.serializedProjects = currentProjects + projectsDiffTable.print(w) +} + +func (f *FourslashTest) printOpenFilesDiff(t *testing.T, snapshot *project.Snapshot, w io.Writer) { + t.Helper() + + currentOpenFiles := make(map[string]*openFileInfo) + filesDiffTable := newDiffTableWriter("Open Files") + options := diffTableOptions{indent: " ", sortKeys: true} + for fileName := range f.openFiles { + path := tspath.ToPath(fileName, "/", f.vfs.UseCaseSensitiveFileNames()) + defaultProject := snapshot.ProjectCollection.GetDefaultProject(fileName, path) + newFileInfo := &openFileInfo{} + if defaultProject != nil { + newFileInfo.defaultProjectName = defaultProject.Name() + } + for _, project := range snapshot.ProjectCollection.Projects() { + if program := project.GetProgram(); program != nil && program.GetSourceFileByPath(path) != nil { + newFileInfo.allProjects = append(newFileInfo.allProjects, project.Name()) + } + } + slices.Sort(newFileInfo.allProjects) + currentOpenFiles[fileName] = newFileInfo + openFileChange := "" + var oldFileInfo *openFileInfo + if existing, ok := f.stateBaseline.serializedOpenFiles[fileName]; ok { + oldFileInfo = existing + if existing.defaultProjectName != newFileInfo.defaultProjectName || !slices.Equal(existing.allProjects, newFileInfo.allProjects) { + openFileChange = "*modified*" + filesDiffTable.setHasChange() + } else { + openFileChange = "" + } + } else { + openFileChange = "*new*" + filesDiffTable.setHasChange() + } + + filesDiffTable.add(fileName, func(w io.Writer) { + fmt.Fprintf(w, " [%s] %s\n", fileName, openFileChange) + printSlicesWithDiffTable( + w, + "", + newFileInfo.allProjects, + func() []string { return oldFileInfo.allProjects }, + options, + openFileChange, + func(projectName string) bool { return projectName == newFileInfo.defaultProjectName }, + ) + }) + } + for fileName := range f.stateBaseline.serializedOpenFiles { + if _, found := currentOpenFiles[fileName]; !found { + filesDiffTable.setHasChange() + filesDiffTable.add(fileName, func(w io.Writer) { + fmt.Fprintf(w, " [%s] *closed*\n", fileName) + }) + } + } + f.stateBaseline.serializedOpenFiles = currentOpenFiles + filesDiffTable.print(w) +} + +func (f *FourslashTest) printConfigFileRegistryDiff(t *testing.T, snapshot *project.Snapshot, w io.Writer) { + t.Helper() + configFileRegistry := snapshot.ProjectCollection.ConfigFileRegistry() + + configDiffsTable := newDiffTableWriter("Config") + configFileNamesDiffsTable := newDiffTableWriter("Config File Names") + + if f.stateBaseline.serializedConfigFileRegistry == configFileRegistry { + return + } + options := diffTableOptions{indent: " ", sortKeys: true} + configFileRegistry.ForEachTestConfigEntry(func(path tspath.Path, entry *project.TestConfigEntry) { + configChange := "" + oldEntry := f.stateBaseline.serializedConfigFileRegistry.GetTestConfigEntry(path) + if oldEntry == nil { + configChange = "*new*" + configDiffsTable.setHasChange() + } else if oldEntry != entry { + if !areIterSeqEqual(oldEntry.RetainingProjects, entry.RetainingProjects) || + !areIterSeqEqual(oldEntry.RetainingOpenFiles, entry.RetainingOpenFiles) || + !areIterSeqEqual(oldEntry.RetainingConfigs, entry.RetainingConfigs) { + configChange = "*modified*" + configDiffsTable.setHasChange() + } + } + configDiffsTable.add(string(path), func(w io.Writer) { + fmt.Fprintf(w, " [%s] %s\n", entry.FileName, configChange) + // Print the details of the config entry + var retainingProjectsModified string + var retainingOpenFilesModified string + var retainingConfigsModified string + if configChange == "*modified*" { + if !areIterSeqEqual(entry.RetainingProjects, oldEntry.RetainingProjects) { + retainingProjectsModified = " *modified*" + } + if !areIterSeqEqual(entry.RetainingOpenFiles, oldEntry.RetainingOpenFiles) { + retainingOpenFilesModified = " *modified*" + } + if !areIterSeqEqual(entry.RetainingConfigs, oldEntry.RetainingConfigs) { + retainingConfigsModified = " *modified*" + } + } + printPathIterSeqWithDiffTable(w, "RetainingProjects:"+retainingProjectsModified, entry.RetainingProjects, func() iter.Seq[tspath.Path] { return oldEntry.RetainingProjects }, options, configChange) + printPathIterSeqWithDiffTable(w, "RetainingOpenFiles:"+retainingOpenFilesModified, entry.RetainingOpenFiles, func() iter.Seq[tspath.Path] { return oldEntry.RetainingOpenFiles }, options, configChange) + printPathIterSeqWithDiffTable(w, "RetainingConfigs:"+retainingConfigsModified, entry.RetainingConfigs, func() iter.Seq[tspath.Path] { return oldEntry.RetainingConfigs }, options, configChange) + }) + }) + configFileRegistry.ForEachTestConfigFileNamesEntry(func(path tspath.Path, entry *project.TestConfigFileNamesEntry) { + configFileNamesChange := "" + oldEntry := f.stateBaseline.serializedConfigFileRegistry.GetTestConfigFileNamesEntry(path) + if oldEntry == nil { + configFileNamesChange = "*new*" + configFileNamesDiffsTable.setHasChange() + } else if oldEntry.NearestConfigFileName != entry.NearestConfigFileName || + !maps.Equal(oldEntry.Ancestors, entry.Ancestors) { + configFileNamesChange = "*modified*" + configFileNamesDiffsTable.setHasChange() + } + configFileNamesDiffsTable.add(string(path), func(w io.Writer) { + fmt.Fprintf(w, " [%s] %s\n", path, configFileNamesChange) + var nearestConfigFileNameModified string + var ancestorDiffModified string + if configFileNamesChange == "*modified*" { + if oldEntry.NearestConfigFileName != entry.NearestConfigFileName { + nearestConfigFileNameModified = " *modified*" + } + if !maps.Equal(oldEntry.Ancestors, entry.Ancestors) { + ancestorDiffModified = " *modified*" + } + } + fmt.Fprintf(w, " NearestConfigFileName: %s%s\n", entry.NearestConfigFileName, nearestConfigFileNameModified) + ancestorDiff := diffTable{options: options} + for config, ancestorOfConfig := range entry.Ancestors { + ancestorChange := "" + if configFileNamesChange == "*modified*" { + if oldConfigFileName, ok := oldEntry.Ancestors[config]; ok { + if oldConfigFileName != ancestorOfConfig { + ancestorChange = "*modified*" + } + } else { + ancestorChange = "*new*" + } + } + ancestorDiff.add(config, fmt.Sprintf("%s %s", ancestorOfConfig, ancestorChange)) + } + if configFileNamesChange == "*modified*" { + for ancestorPath, oldConfigFileName := range oldEntry.Ancestors { + if _, ok := entry.Ancestors[ancestorPath]; !ok { + ancestorDiff.add(ancestorPath, oldConfigFileName+" *deleted*") + } + } + } + ancestorDiff.print(w, "Ancestors:"+ancestorDiffModified) + }) + }) + + f.stateBaseline.serializedConfigFileRegistry.ForEachTestConfigEntry(func(path tspath.Path, entry *project.TestConfigEntry) { + if configFileRegistry.GetTestConfigEntry(path) == nil { + configDiffsTable.setHasChange() + configDiffsTable.add(string(path), func(w io.Writer) { + fmt.Fprintf(w, " [%s] *deleted*\n", entry.FileName) + }) + } + }) + f.stateBaseline.serializedConfigFileRegistry.ForEachTestConfigFileNamesEntry(func(path tspath.Path, entry *project.TestConfigFileNamesEntry) { + if configFileRegistry.GetTestConfigFileNamesEntry(path) == nil { + configFileNamesDiffsTable.setHasChange() + configFileNamesDiffsTable.add(string(path), func(w io.Writer) { + fmt.Fprintf(w, " [%s] *deleted*\n", path) + }) + } + }) + f.stateBaseline.serializedConfigFileRegistry = configFileRegistry + configDiffsTable.print(w) + configFileNamesDiffsTable.print(w) +} diff --git a/internal/fourslash/test_parser.go b/internal/fourslash/test_parser.go index da8de6fc79..4187d1c8ce 100644 --- a/internal/fourslash/test_parser.go +++ b/internal/fourslash/test_parser.go @@ -9,7 +9,7 @@ import ( "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/testrunner" @@ -44,6 +44,13 @@ func (r *RangeMarker) GetName() *string { return r.Marker.Name } +func (r *RangeMarker) LSLocation() lsproto.Location { + return lsproto.Location{ + Uri: lsconv.FileNameToDocumentURI(r.fileName), + Range: r.LSRange, + } +} + type Marker struct { fileName string Position int @@ -64,6 +71,16 @@ func (m *Marker) GetName() *string { return m.Name } +func (m *Marker) MakerWithSymlink(fileName string) *Marker { + return &Marker{ + fileName: fileName, + Position: m.Position, + LSPosition: m.LSPosition, + Name: m.Name, + Data: m.Data, + } +} + type MarkerOrRange interface { FileName() string LSPos() lsproto.Position @@ -79,12 +96,20 @@ type TestData struct { Ranges []*RangeMarker } +func (t *TestData) isStateBaseliningEnabled() bool { + return isStateBaseliningEnabled(t.GlobalOptions) +} + type testFileWithMarkers struct { file *TestFileInfo markers []*Marker ranges []*RangeMarker } +func isStateBaseliningEnabled(globalOptions map[string]string) bool { + return globalOptions["statebaseline"] == "true" +} + func ParseTestData(t *testing.T, contents string, fileName string) TestData { // List of all the subfiles we've parsed out var files []*TestFileInfo @@ -93,10 +118,13 @@ func ParseTestData(t *testing.T, contents string, fileName string) TestData { var markers []*Marker var ranges []*RangeMarker - filesWithMarker, symlinks, _, globalOptions, e := testrunner.ParseTestFilesAndSymlinks( + filesWithMarker, symlinks, _, globalOptions, e := testrunner.ParseTestFilesAndSymlinksWithOptions( contents, fileName, parseFileContent, + testrunner.ParseTestFilesOptions{ + AllowImplicitFirstFile: true, + }, ) if e != nil { t.Fatalf("Error parsing fourslash data: %s", e.Error()) @@ -125,7 +153,7 @@ func ParseTestData(t *testing.T, contents string, fileName string) TestData { } - if hasTSConfig && len(globalOptions) > 0 { + if hasTSConfig && len(globalOptions) > 0 && !isStateBaseliningEnabled(globalOptions) { t.Fatalf("It is not allowed to use global options along with config files.") } @@ -163,17 +191,17 @@ type TestFileInfo struct { emit bool } -// FileName implements ls.Script. +// FileName implements lsconv.Script. func (t *TestFileInfo) FileName() string { return t.fileName } -// Text implements ls.Script. +// Text implements lsconv.Script. func (t *TestFileInfo) Text() string { return t.Content } -var _ ls.Script = (*TestFileInfo)(nil) +var _ lsconv.Script = (*TestFileInfo)(nil) const emitThisFileOption = "emitthisfile" @@ -368,8 +396,8 @@ func parseFileContent(fileName string, content string, fileOptions map[string]st outputString := output.String() // Set LS positions for markers - lineMap := ls.ComputeLSPLineStarts(outputString) - converters := ls.NewConverters(lsproto.PositionEncodingKindUTF8, func(_ string) *ls.LSPLineMap { + lineMap := lsconv.ComputeLSPLineStarts(outputString) + converters := lsconv.NewConverters(lsproto.PositionEncodingKindUTF8, func(_ string) *lsconv.LSPLineMap { return lineMap }) @@ -407,13 +435,13 @@ func parseFileContent(fileName string, content string, fileOptions map[string]st func getObjectMarker(fileName string, location *locationInformation, text string) (*Marker, error) { // Attempt to parse the marker value as JSON - var v interface{} + var v any e := json.Unmarshal([]byte("{ "+text+" }"), &v) if e != nil { return nil, reportError(fileName, location.sourceLine, location.sourceColumn, "Unable to parse marker text "+text) } - markerValue, ok := v.(map[string]interface{}) + markerValue, ok := v.(map[string]any) if !ok || len(markerValue) == 0 { return nil, reportError(fileName, location.sourceLine, location.sourceColumn, "Object markers can not be empty") } diff --git a/internal/fourslash/tests/autoImportCompletion_test.go b/internal/fourslash/tests/autoImportCompletion_test.go index 7c5aeaf356..fb107e2d6a 100644 --- a/internal/fourslash/tests/autoImportCompletion_test.go +++ b/internal/fourslash/tests/autoImportCompletion_test.go @@ -6,7 +6,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -26,7 +26,7 @@ a/**/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ - UserPreferences: &ls.UserPreferences{ + UserPreferences: &lsutil.UserPreferences{ IncludeCompletionsForModuleExports: core.TSTrue, IncludeCompletionsForImportStatements: core.TSTrue, }, @@ -40,6 +40,21 @@ a/**/ }, }) f.BaselineAutoImportsCompletions(t, []string{""}) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + UserPreferences: &lsutil.UserPreferences{ + // completion autoimport preferences off; this tests if fourslash server communication correctly registers changes in user preferences + IncludeCompletionsForModuleExports: core.TSUnknown, + IncludeCompletionsForImportStatements: core.TSUnknown, + }, + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Excludes: []string{"anotherVar"}, + }, + }) } func TestAutoImportCompletion2(t *testing.T) { @@ -56,7 +71,7 @@ a/**/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ - UserPreferences: &ls.UserPreferences{ + UserPreferences: &lsutil.UserPreferences{ IncludeCompletionsForModuleExports: core.TSTrue, IncludeCompletionsForImportStatements: core.TSTrue, }, @@ -87,7 +102,7 @@ b/**/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ - UserPreferences: &ls.UserPreferences{ + UserPreferences: &lsutil.UserPreferences{ IncludeCompletionsForModuleExports: core.TSTrue, IncludeCompletionsForImportStatements: core.TSTrue, }, diff --git a/internal/fourslash/tests/autoImportQuoteDetection_test.go b/internal/fourslash/tests/autoImportQuoteDetection_test.go new file mode 100644 index 0000000000..a9a6ade067 --- /dev/null +++ b/internal/fourslash/tests/autoImportQuoteDetection_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportQuoteDetection(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.ts +import {} from 'node:path'; + +fo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import {} from 'node:path'; +import { foo } from './a'; + +fo`), + }) +} diff --git a/internal/fourslash/tests/basicQuickInfo_test.go b/internal/fourslash/tests/basicQuickInfo_test.go index 44e80c9a6f..f207771e24 100644 --- a/internal/fourslash/tests/basicQuickInfo_test.go +++ b/internal/fourslash/tests/basicQuickInfo_test.go @@ -28,5 +28,5 @@ class Foo/*3*/ { ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyQuickInfoAt(t, "1", "var someVar: number", "Some var") - f.VerifyQuickInfoAt(t, "2", "var otherVar: number", "Other var\nSee `someVar`") + f.VerifyQuickInfoAt(t, "2", "var otherVar: number", "Other var\nSee [someVar](file:///basicQuickInfo.ts#4,5-4,12)") } diff --git a/internal/fourslash/tests/documentHighlightReferenceDirective_test.go b/internal/fourslash/tests/documentHighlightReferenceDirective_test.go new file mode 100644 index 0000000000..c6ac898aa4 --- /dev/null +++ b/internal/fourslash/tests/documentHighlightReferenceDirective_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightReferenceDirective(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +/// + +const x = 1; + +// @filename: b.ts +export type Foo = number; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) +} diff --git a/internal/fourslash/tests/gen/ambientShorthandGotoDefinition_test.go b/internal/fourslash/tests/gen/ambientShorthandGotoDefinition_test.go index 7a10acdd9b..fc9cd5eb53 100644 --- a/internal/fourslash/tests/gen/ambientShorthandGotoDefinition_test.go +++ b/internal/fourslash/tests/gen/ambientShorthandGotoDefinition_test.go @@ -24,5 +24,5 @@ import [|/*importBang*/bang|] = require("jquery"); f.VerifyQuickInfoAt(t, "useBar", "(alias) module \"jquery\"\nimport bar", "") f.VerifyQuickInfoAt(t, "useBaz", "(alias) module \"jquery\"\nimport baz", "") f.VerifyQuickInfoAt(t, "useBang", "(alias) module \"jquery\"\nimport bang = require(\"jquery\")", "") - f.VerifyBaselineGoToDefinition(t, "useFoo", "importFoo", "useBar", "useBaz", "importBaz", "useBang", "importBang") + f.VerifyBaselineGoToDefinition(t, true, "useFoo", "importFoo", "useBar", "useBaz", "importBaz", "useBang", "importBang") } diff --git a/internal/fourslash/tests/gen/annotateWithTypeFromJSDoc2_test.go b/internal/fourslash/tests/gen/annotateWithTypeFromJSDoc2_test.go new file mode 100644 index 0000000000..b4be6d4cad --- /dev/null +++ b/internal/fourslash/tests/gen/annotateWithTypeFromJSDoc2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAnnotateWithTypeFromJSDoc2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: test123.ts +/** @type {number} */ +var [|x|]: string;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionAmbientMergedModule1_test.go b/internal/fourslash/tests/gen/autoImportCompletionAmbientMergedModule1_test.go new file mode 100644 index 0000000000..9599c87624 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionAmbientMergedModule1_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionAmbientMergedModule1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @module: commonjs +// @filename: /node_modules/@types/vscode/index.d.ts +declare module "vscode" { + export class Position { + readonly line: number; + readonly character: number; + } +} +// @filename: src/motion.ts +import { Position } from "vscode"; + +export abstract class MoveQuoteMatch { + public override async execActionWithCount( + position: Position, + ): Promise {} +} + +declare module "vscode" { + interface Position { + toString(): string; + } +} +// @filename: src/smartQuotes.ts +import { MoveQuoteMatch } from "./motion"; + +export class MoveInsideNextQuote extends MoveQuoteMatch {/*1*/ + keys = ["i", "n", "q"]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "execActionWithCount", + InsertText: PtrTo("public execActionWithCount(position: Position): Promise {\n}"), + FilterText: PtrTo("execActionWithCount"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + Source: "ClassMemberSnippet/", + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "execActionWithCount", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'execActionWithCount'", + NewFileContent: PtrTo(`import { Position } from "vscode"; +import { MoveQuoteMatch } from "./motion"; + +export class MoveInsideNextQuote extends MoveQuoteMatch { + keys = ["i", "n", "q"]; +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportEqualsWithDefault1_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportEqualsWithDefault1_test.go new file mode 100644 index 0000000000..d89cf56869 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportEqualsWithDefault1_test.go @@ -0,0 +1,103 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportEqualsWithDefault1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @filename: node.ts +import Container from "./container.js"; +import Document from "./document.js"; + +declare namespace Node { + class Node extends Node_ {} + + export { Node as default }; +} + +declare abstract class Node_ { + parent: Container | Document | undefined; +} + +declare class Node extends Node_ {} + +export = Node; +// @filename: document.ts +import Container from "./container.js"; + +declare namespace Document { + export { Document_ as default }; +} + +declare class Document_ extends Container {} + +declare class Document extends Document_ {} + +export = Document; +// @filename: container.ts +import Node from "./node.js"; + +declare namespace Container { + export { Container_ as default }; +} + +declare abstract class Container_ extends Node { + p/*1*/ +} + +declare class Container extends Container_ {} + +export = Container;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "parent", + InsertText: PtrTo("parent: Container_ | Document_ | undefined;"), + FilterText: PtrTo("parent"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + Source: "ClassMemberSnippet/", + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "parent", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'parent'", + NewFileContent: PtrTo(`import Document_ from "./document.js"; +import Node from "./node.js"; + +declare namespace Container { + export { Container_ as default }; +} + +declare abstract class Container_ extends Node { + p +} + +declare class Container extends Container_ {} + +export = Container;`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation1_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation1_test.go new file mode 100644 index 0000000000..56b7c820c4 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation1_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +interface Container { + stores: unknown; +} + +declare class Piece { + container: Container; +} + +export { Piece, type Container }; +// @FileName: /augmentation.ts +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } + export { Container }; +} +// @Filename: /index.ts +import { Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("container: Container;"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + Source: "ClassMemberSnippet/", + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import { Container, Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation2_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation2_test.go new file mode 100644 index 0000000000..3f1a7938a6 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation2_test.go @@ -0,0 +1,79 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +interface Container { + stores: unknown; +} + +declare class Piece { + get container(): Container; +} + +declare class AliasPiece extends Piece {} + +export { AliasPiece, type Container }; +// @Filename: /node_modules/@sapphire/framework/index.d.ts +import { AliasPiece } from "@sapphire/pieces"; + +declare class Command extends AliasPiece {} + +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } +} + +export { Command }; +// @Filename: /index.ts +import "@sapphire/pieces"; +import { Command } from "@sapphire/framework"; +class PingCommand extends Command { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("get container(): Container {\n}"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + Source: "ClassMemberSnippet/", + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import "@sapphire/pieces"; +import { Command } from "@sapphire/framework"; +import { Container } from "@sapphire/pieces"; +class PingCommand extends Command { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation3_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation3_test.go new file mode 100644 index 0000000000..ec0d324c52 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation3_test.go @@ -0,0 +1,68 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +export interface Container { + stores: unknown; +} + +declare class Piece { + container: Container; +} + +export { Piece }; +// @FileName: /augmentation.ts +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } +} +// @Filename: /index.ts +import { Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("container: Container;"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + Source: "ClassMemberSnippet/", + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import { Container, Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation4_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation4_test.go new file mode 100644 index 0000000000..38d77f6ddc --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation4_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +interface Container { + stores: unknown; +} + +declare class Piece { + get container(): Container; +} + +export { Piece as Alias, type Container }; +// @Filename: /node_modules/@sapphire/framework/index.d.ts +import { Alias } from "@sapphire/pieces"; + +declare class Command extends Alias {} + +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } +} + +export { Command as CommandAlias }; +// @Filename: /index.ts +import "@sapphire/pieces"; +import { CommandAlias } from "@sapphire/framework"; +class PingCommand extends CommandAlias { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("get container(): Container {\n}"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + Source: "ClassMemberSnippet/", + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import "@sapphire/pieces"; +import { CommandAlias } from "@sapphire/framework"; +import { Container } from "@sapphire/pieces"; +class PingCommand extends CommandAlias { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_paths_sharedOutDir_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_paths_sharedOutDir_test.go new file mode 100644 index 0000000000..93f837967e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_paths_sharedOutDir_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_paths_sharedOutDir(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.base.json +{ + "compilerOptions": { + "module": "commonjs", + "baseUrl": ".", + "paths": { + "packages/*": ["./packages/*"] + } + } +} +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "outDir": "../../dist/packages/app" }, + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/index.ts +dep/**/ +// @Filename: /home/src/workspaces/project/packages/app/utils.ts +import "packages/dep"; +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { "outDir": "../../dist/packages/dep" } +} +// @Filename: /home/src/workspaces/project/packages/dep/index.ts +import "./sub/folder"; +// @Filename: /home/src/workspaces/project/packages/dep/sub/folder/index.ts +export const dep = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep } from "packages/dep/sub/folder"; + +dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_paths_stripSrc_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_paths_stripSrc_test.go new file mode 100644 index 0000000000..9e4984348a --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_paths_stripSrc_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_paths_stripSrc(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/app/package.json +{ "name": "app", "dependencies": { "dep": "*" } } +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "baseUrl": ".", + "paths": { + "dep": ["../dep/src/main"], + "dep/*": ["../dep/src/*"] + } + } + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/src/index.ts +dep1/*1*/; +// @Filename: /home/src/workspaces/project/packages/app/src/utils.ts +dep2/*2*/; +// @Filename: /home/src/workspaces/project/packages/app/src/a.ts +import "dep"; +// @Filename: /home/src/workspaces/project/packages/dep/package.json +{ "name": "dep", "main": "dist/main.js", "types": "dist/main.d.ts" } +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" } +} +// @Filename: /home/src/workspaces/project/packages/dep/src/main.ts +import "./sub/folder"; +export const dep1 = 0; +// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts +export const dep2 = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep1 } from "dep"; + +dep1;`, + }, nil /*preferences*/) + f.GoToMarker(t, "2") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep2 } from "dep/sub/folder"; + +dep2;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_paths_toDist_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_paths_toDist_test.go new file mode 100644 index 0000000000..f635bb08ba --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_paths_toDist_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_paths_toDist(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/app/package.json +{ "name": "app", "dependencies": { "dep": "*" } } +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "baseUrl": ".", + "paths": { + "dep": ["../dep/src/main"], + "dep/dist/*": ["../dep/src/*"] + } + } + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/src/index.ts +dep1/*1*/; +// @Filename: /home/src/workspaces/project/packages/app/src/utils.ts +dep2/*2*/; +// @Filename: /home/src/workspaces/project/packages/app/src/a.ts +import "dep"; +// @Filename: /home/src/workspaces/project/packages/dep/package.json +{ "name": "dep", "main": "dist/main.js", "types": "dist/main.d.ts" } +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" } +} +// @Filename: /home/src/workspaces/project/packages/dep/src/main.ts +import "./sub/folder"; +export const dep1 = 0; +// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts +export const dep2 = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep1 } from "dep"; + +dep1;`, + }, nil /*preferences*/) + f.GoToMarker(t, "2") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep2 } from "dep/dist/sub/folder"; + +dep2;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_paths_toSrc_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_paths_toSrc_test.go new file mode 100644 index 0000000000..11a2b532a6 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_paths_toSrc_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_paths_toSrc(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/app/package.json +{ "name": "app", "dependencies": { "dep": "*" } } +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "baseUrl": ".", + "paths": { + "dep": ["../dep/src/main"], + "dep/*": ["../dep/*"] + } + } + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/src/index.ts +dep1/*1*/; +// @Filename: /home/src/workspaces/project/packages/app/src/utils.ts +dep2/*2*/; +// @Filename: /home/src/workspaces/project/packages/app/src/a.ts +import "dep"; +// @Filename: /home/src/workspaces/project/packages/dep/package.json +{ "name": "dep", "main": "dist/main.js", "types": "dist/main.d.ts" } +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" } +} +// @Filename: /home/src/workspaces/project/packages/dep/src/main.ts +import "./sub/folder"; +export const dep1 = 0; +// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts +export const dep2 = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep1 } from "dep"; + +dep1;`, + }, nil /*preferences*/) + f.GoToMarker(t, "2") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep2 } from "dep/src/sub/folder"; + +dep2;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_stripSrc_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_stripSrc_test.go new file mode 100644 index 0000000000..3627800a89 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_stripSrc_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_symlinks_stripSrc(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/app/package.json +{ "name": "app", "dependencies": { "dep": "*" } } +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "baseUrl": ".", + "paths": { + "dep/*": ["../dep/src/*"] + } + } + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/src/index.ts +dep/**/ +// @Filename: /home/src/workspaces/project/packages/dep/package.json +{ "name": "dep", "main": "dist/index.js", "types": "dist/index.d.ts" } +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" } +} +// @Filename: /home/src/workspaces/project/packages/dep/src/index.ts +import "./sub/folder"; +// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts +export const dep = 0; +// @link: /home/src/workspaces/project/packages/dep -> /home/src/workspaces/project/packages/app/node_modules/dep` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep } from "dep/sub/folder"; + +dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_toDist_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_toDist_test.go new file mode 100644 index 0000000000..9a8db8c438 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_toDist_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_symlinks_toDist(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/app/package.json +{ "name": "app", "dependencies": { "dep": "*" } } +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "baseUrl": ".", + "paths": { + "dep/dist/*": ["../dep/src/*"] + } + } + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/src/index.ts +dep/**/ +// @Filename: /home/src/workspaces/project/packages/dep/package.json +{ "name": "dep", "main": "dist/index.js", "types": "dist/index.d.ts" } +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" } +} +// @Filename: /home/src/workspaces/project/packages/dep/src/index.ts +import "./sub/folder"; +// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts +export const dep = 0; +// @link: /home/src/workspaces/project/packages/dep -> /home/src/workspaces/project/packages/app/node_modules/dep` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep } from "dep/dist/sub/folder"; + +dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_toSrc_test.go b/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_toSrc_test.go new file mode 100644 index 0000000000..b0e15cc961 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCrossProject_symlinks_toSrc_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCrossProject_symlinks_toSrc(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/app/package.json +{ "name": "app", "dependencies": { "dep": "*" } } +// @Filename: /home/src/workspaces/project/packages/app/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "baseUrl": "." + } + "references": [{ "path": "../dep" }] +} +// @Filename: /home/src/workspaces/project/packages/app/src/index.ts +dep/**/ +// @Filename: /home/src/workspaces/project/packages/dep/package.json +{ "name": "dep", "main": "dist/index.js", "types": "dist/index.d.ts" } +// @Filename: /home/src/workspaces/project/packages/dep/tsconfig.json +{ + "compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" } +} +// @Filename: /home/src/workspaces/project/packages/dep/src/index.ts +import "./sub/folder"; +// @Filename: /home/src/workspaces/project/packages/dep/src/sub/folder/index.ts +export const dep = 0; +// @link: /home/src/workspaces/project/packages/dep -> /home/src/workspaces/project/packages/app/node_modules/dep` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { dep } from "dep/src/sub/folder"; + +dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportFileExcludePatterns3_test.go b/internal/fourslash/tests/gen/autoImportFileExcludePatterns3_test.go new file mode 100644 index 0000000000..3c8140f48d --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportFileExcludePatterns3_test.go @@ -0,0 +1,71 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportFileExcludePatterns3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /ambient1.d.ts +declare module "foo" { + export const x = 1; +} +// @Filename: /ambient2.d.ts +declare module "foo" { + export const y = 2; +} +// @Filename: /index.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "foo", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "y", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "foo", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobals, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportJsDocImport1_test.go b/internal/fourslash/tests/gen/autoImportJsDocImport1_test.go new file mode 100644 index 0000000000..38b88edb01 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportJsDocImport1_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportJsDocImport1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @target: esnext +// @allowJs: true +// @checkJs: true +// @Filename: /foo.ts + export const A = 1; + export type B = { x: number }; + export type C = 1; + export class D { y: string } +// @Filename: /test.js +/** + * @import { A, D, C } from "./foo" + */ + +/** + * @param { typeof A } a + * @param { B/**/ | C } b + * @param { C } c + * @param { D } d + */ +export function f(a, b, c, d) { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `/** + * @import { A, D, C, B } from "./foo" + */ + +/** + * @param { typeof A } a + * @param { B | C } b + * @param { C } c + * @param { D } d + */ +export function f(a, b, c, d) { }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportModuleNone1_test.go b/internal/fourslash/tests/gen/autoImportModuleNone1_test.go new file mode 100644 index 0000000000..ccaa1dbf54 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportModuleNone1_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportModuleNone1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: none +// @moduleResolution: bundler +// @target: es5 +// @Filename: /node_modules/dep/index.d.ts +export const x: number; +// @Filename: /index.ts + x/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Excludes: []string{ + "x", + }, + }, + }) + f.ReplaceLine(t, 0, "import { x } from 'dep'; x;") + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/autoImportModuleNone2_test.go b/internal/fourslash/tests/gen/autoImportModuleNone2_test.go new file mode 100644 index 0000000000..9d4c927bd7 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportModuleNone2_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportModuleNone2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: none +// @moduleResolution: bundler +// @target: es2015 +// @Filename: /node_modules/dep/index.d.ts +export const x: number; +// @Filename: /index.ts + x/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dep", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.ReplaceLine(t, 0, "import { x } from 'dep'; x;") + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/autoImportNodeNextJSRequire_test.go b/internal/fourslash/tests/gen/autoImportNodeNextJSRequire_test.go new file mode 100644 index 0000000000..0afe25bc07 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportNodeNextJSRequire_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportNodeNextJSRequire(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @Filename: /matrix.js +exports.variants = []; +// @Filename: /main.js +exports.dedupeLines = data => { + variants/**/ +} +// @Filename: /totally-irrelevant-no-way-this-changes-things-right.js +export default 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/main.js") + f.VerifyImportFixAtPosition(t, []string{ + `const { variants } = require("./matrix") + +exports.dedupeLines = data => { + variants +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportPackageJsonFilterExistingImport2_test.go b/internal/fourslash/tests/gen/autoImportPackageJsonFilterExistingImport2_test.go new file mode 100644 index 0000000000..f07dfa1200 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportPackageJsonFilterExistingImport2_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportPackageJsonFilterExistingImport2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: preserve +// @Filename: /home/src/workspaces/project/node_modules/@types/react/index.d.ts +export declare function useMemo(): void; +export declare function useState(): void; +// @Filename: /home/src/workspaces/project/package.json +{} +// @Filename: /home/src/workspaces/project/index.ts +useMemo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{}, nil /*preferences*/) + f.GoToBOF(t) + f.InsertLine(t, "import { useState } from \"react\";") + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { useMemo, useState } from "react"; +useMemo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportPackageJsonFilterExistingImport3_test.go b/internal/fourslash/tests/gen/autoImportPackageJsonFilterExistingImport3_test.go new file mode 100644 index 0000000000..56ecdf8f47 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportPackageJsonFilterExistingImport3_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportPackageJsonFilterExistingImport3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: preserve +// @Filename: /home/src/workspaces/project/node_modules/@types/node/index.d.ts +declare module "node:fs" { + export function readFile(): void; + export function writeFile(): void; +} +// @Filename: /home/src/workspaces/project/package.json +{} +// @Filename: /home/src/workspaces/project/index.ts +readFile/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{}, nil /*preferences*/) + f.GoToBOF(t) + f.InsertLine(t, "import { writeFile } from \"node:fs\";") + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { readFile, writeFile } from "node:fs"; +readFile`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportPathsAliasesAndBarrels_test.go b/internal/fourslash/tests/gen/autoImportPathsAliasesAndBarrels_test.go new file mode 100644 index 0000000000..1347985775 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportPathsAliasesAndBarrels_test.go @@ -0,0 +1,83 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportPathsAliasesAndBarrels(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json + { + "compilerOptions": { + "module": "commonjs", + "paths": { + "~/*": ["src/*"] + } + } +} +// @Filename: /src/dirA/index.ts + export * from "./thing1A"; + export * from "./thing2A"; +// @Filename: /src/dirA/thing1A.ts + export class Thing1A {} + Thing/**/ +// @Filename: /src/dirA/thing2A.ts + export class Thing2A {} +// @Filename: /src/dirB/index.ts + export * from "./thing1B"; + export * from "./thing2B"; +// @Filename: /src/dirB/thing1B.ts + export class Thing1B {} +// @Filename: /src/dirB/thing2B.ts + export class Thing2B {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Thing2A", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./thing2A", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Thing1B", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "~/dirB", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Thing2B", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "~/dirB", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportPnpm_test.go b/internal/fourslash/tests/gen/autoImportPnpm_test.go new file mode 100644 index 0000000000..1f05b32afc --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportPnpm_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportPnpm(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx/package.json +{ "types": "dist/mobx.d.ts" } +// @Filename: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx/dist/mobx.d.ts +export declare function autorun(): void; +// @Filename: /index.ts +autorun/**/ +// @Filename: /utils.ts +import "mobx"; +// @link: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx -> /node_modules/mobx +// @link: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx -> /node_modules/.pnpm/cool-mobx-dependent@1.2.3/node_modules/mobx` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { autorun } from "mobx"; + +autorun`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider4_test.go b/internal/fourslash/tests/gen/autoImportProvider4_test.go new file mode 100644 index 0000000000..d548b38f1a --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider4_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/a/package.json +{ "dependencies": { "b": "*" } } +// @Filename: /home/src/workspaces/project/a/tsconfig.json +{ "compilerOptions": { "module": "commonjs", "target": "esnext" }, "references": [{ "path": "../b" }] } +// @Filename: /home/src/workspaces/project/a/index.ts +new Shape/**/ +// @Filename: /home/src/workspaces/project/b/package.json +{ "types": "out/index.d.ts" } +// @Filename: /home/src/workspaces/project/b/tsconfig.json +{ "compilerOptions": { "outDir": "out", "composite": true } } +// @Filename: /home/src/workspaces/project/b/index.ts +export class Shape {} +// @link: /home/src/workspaces/project/b -> /home/src/workspaces/project/a/node_modules/b` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { Shape } from "b"; + +new Shape`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider5_test.go b/internal/fourslash/tests/gen/autoImportProvider5_test.go new file mode 100644 index 0000000000..766167d218 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider5_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/package.json +{ "dependencies": { "react-hook-form": "*" } } +// @Filename: /home/src/workspaces/project/node_modules/react-hook-form/package.json +{ "types": "dist/index.d.ts" } +// @Filename: /home/src/workspaces/project/node_modules/react-hook-form/dist/index.d.ts +export * from "./useForm"; +// @Filename: /home/src/workspaces/project/node_modules/react-hook-form/dist/useForm.d.ts +export declare function useForm(): void; +// @Filename: /home/src/workspaces/project/index.ts +useForm/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { useForm } from "react-hook-form"; + +useForm`, + `import { useForm } from "react-hook-form/dist/useForm"; + +useForm`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider6_test.go b/internal/fourslash/tests/gen/autoImportProvider6_test.go new file mode 100644 index 0000000000..b523605594 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider6_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "commonjs", "lib": ["es2019"] } } +// @Filename: /home/src/workspaces/project/package.json +{ "dependencies": { "antd": "*", "react": "*" } } +// @Filename: /home/src/workspaces/project/node_modules/@types/react/index.d.ts +export declare function Component(): void; +// @Filename: /home/src/workspaces/project/node_modules/antd/index.d.ts +import "react"; +// @Filename: /home/src/workspaces/project/index.ts +Component/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Component", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap1_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap1_test.go new file mode 100644 index 0000000000..757031710f --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap1_test.go @@ -0,0 +1,84 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": { + "types": "./lib/index.d.ts" + }, + "./lol": { + "types": "./lib/lol.d.ts" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap2_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap2_test.go new file mode 100644 index 0000000000..615dcc1d0e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap2_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs" + "moduleResolution": "node10", + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "types": "./lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts" + }, + "./lol": { + "types": "./lib/lol.d.ts" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap3_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap3_test.go new file mode 100644 index 0000000000..55b3022f18 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap3_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "name": "dependency", + "version": "1.0.0", + "main": "./lib/index.js", + "exports": "./lib/lol.d.ts" +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromIndex", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap4_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap4_test.go new file mode 100644 index 0000000000..958bd9b242 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap4_test.go @@ -0,0 +1,73 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + "types": "./lib/index.d.ts", + "require": "./lib/lol.js" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromLol", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap5_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap5_test.go new file mode 100644 index 0000000000..6ef04daf4d --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap5_test.go @@ -0,0 +1,95 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap5(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @types package lookup +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.js", + "./lol": "./lib/lol.js" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.js +export function fooFromIndex() {} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.js +export function fooFromLol() {} +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/package.json +{ + "type": "module", + "name": "@types/dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.d.ts", + "./lol": "./lib/lol.d.ts" + } +} +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/index.d.ts +export declare function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/lol.d.ts +export declare function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap6_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap6_test.go new file mode 100644 index 0000000000..381a232b9e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap6_test.go @@ -0,0 +1,102 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap6(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @types package should be ignored because implementation package has types +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + }, + "devDependencies": { + "@types/dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.js", + "./lol": "./lib/lol.js" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.js +export function fooFromIndex() {} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export declare function fooFromIndex(): void +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.js +export function fooFromLol() {} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export declare function fooFromLol(): void +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/package.json +{ + "type": "module", + "name": "@types/dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.d.ts", + "./lol": "./lib/lol.d.ts" + } +} +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/index.d.ts +export declare function fooFromAtTypesIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/lol.d.ts +export declare function fooFromAtTypesLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap7_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap7_test.go new file mode 100644 index 0000000000..bb3b53e60e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap7_test.go @@ -0,0 +1,86 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap7(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": { + "types": "./lib/index.d.ts" + }, + "./lol": { + "types": "./lib/lol.d.ts" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/bar.ts +import { fooFromIndex } from "dependency"; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap8_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap8_test.go new file mode 100644 index 0000000000..613d833138 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap8_test.go @@ -0,0 +1,104 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap8(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + "./lol": { + "import": "./lib/index.js", + "require": "./lib/lol.js" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/bar.ts +import { fooFromIndex } from "dependency"; +// @Filename: /home/src/workspaces/project/src/foo.cts +fooFrom/*cts*/ +// @Filename: /home/src/workspaces/project/src/foo.mts +fooFrom/*mts*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "cts") + f.VerifyCompletions(t, "cts", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromIndex", + }, + }, + }) + f.GoToMarker(t, "mts") + f.VerifyCompletions(t, "mts", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromLol", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap9_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap9_test.go new file mode 100644 index 0000000000..c8b835f5a8 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap9_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap9(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + "./lol": ["./lib/index.js", "./lib/lol.js"] + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/bar.ts +import { fooFromIndex } from "dependency"; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromLol", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_globalTypingsCache_test.go b/internal/fourslash/tests/gen/autoImportProvider_globalTypingsCache_test.go new file mode 100644 index 0000000000..15bb9dce66 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_globalTypingsCache_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_globalTypingsCache(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/package.json + { "name": "@types/react-router-dom", "version": "16.8.4", "types": "index.d.ts" } +// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/index.d.ts + export class BrowserRouterFromDts {} +// @Filename: /home/src/workspaces/project/package.json + { "dependencies": { "react-router-dom": "*" } } +// @Filename: /home/src/workspaces/project/tsconfig.json + { "compilerOptions": { "module": "commonjs", "allowJs": true, "checkJs": true, "maxNodeModuleJsDepth": 2 }, "typeAcquisition": { "enable": true } } +// @Filename: /home/src/workspaces/project/node_modules/react-router-dom/package.json + { "name": "react-router-dom", "version": "16.8.4", "main": "index.js" } +// @Filename: /home/src/workspaces/project/node_modules/react-router-dom/index.js + import "./BrowserRouter"; + export {}; +// @Filename: /home/src/workspaces/project/node_modules/react-router-dom/BrowserRouter.js + export const BrowserRouterFromJs = () => null; +// @Filename: /home/src/workspaces/project/index.js +BrowserRouter/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsInJSPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "BrowserRouterFromDts", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react-router-dom", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_namespaceSameNameAsIntrinsic_test.go b/internal/fourslash/tests/gen/autoImportProvider_namespaceSameNameAsIntrinsic_test.go new file mode 100644 index 0000000000..835b7f33a2 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_namespaceSameNameAsIntrinsic_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_namespaceSameNameAsIntrinsic(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/node_modules/fp-ts/package.json +{ "name": "fp-ts", "version": "0.10.4" } +// @Filename: /home/src/workspaces/project/node_modules/fp-ts/index.d.ts +export * as string from "./lib/string"; +// @Filename: /home/src/workspaces/project/node_modules/fp-ts/lib/string.d.ts +export declare const fromString: (s: string) => string; +export type SafeString = string; +// @Filename: /home/src/workspaces/project/package.json +{ "dependencies": { "fp-ts": "^0.10.4" } } +// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: /home/src/workspaces/project/index.ts +type A = { name: string/**/ }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "string", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + &lsproto.CompletionItem{ + Label: "string", + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fp-ts", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_pnpm_test.go b/internal/fourslash/tests/gen/autoImportProvider_pnpm_test.go new file mode 100644 index 0000000000..eb05ee98d3 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_pnpm_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_pnpm(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: /home/src/workspaces/project/package.json +{ "dependencies": { "mobx": "*" } } +// @Filename: /home/src/workspaces/project/node_modules/.pnpm/mobx@6.0.4/node_modules/mobx/package.json +{ "types": "dist/mobx.d.ts" } +// @Filename: /home/src/workspaces/project/node_modules/.pnpm/mobx@6.0.4/node_modules/mobx/dist/mobx.d.ts +export declare function autorun(): void; +// @Filename: /home/src/workspaces/project/index.ts +autorun/**/ +// @link: /home/src/workspaces/project/node_modules/.pnpm/mobx@6.0.4/node_modules/mobx -> /home/src/workspaces/project/node_modules/mobx` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { autorun } from "mobx"; + +autorun`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_referencesCrash_test.go b/internal/fourslash/tests/gen/autoImportProvider_referencesCrash_test.go index 4189016e57..e5b211c395 100644 --- a/internal/fourslash/tests/gen/autoImportProvider_referencesCrash_test.go +++ b/internal/fourslash/tests/gen/autoImportProvider_referencesCrash_test.go @@ -39,6 +39,7 @@ new A/**/(); export {}; // @link: /home/src/workspaces/project/a -> /home/src/workspaces/project/c/node_modules/a` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToFile(t, "/home/src/workspaces/project/c/index.ts") f.VerifyBaselineFindAllReferences(t, "") } diff --git a/internal/fourslash/tests/gen/autoImportProvider_wildcardExports1_test.go b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports1_test.go new file mode 100644 index 0000000000..d82dc459d0 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports1_test.go @@ -0,0 +1,123 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_wildcardExports1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json +{ + "name": "pkg", + "version": "1.0.0", + "exports": { + "./*": "./a/*.js", + "./b/*.js": "./b/*.js", + "./c/*": "./c/*", + "./d/*": { + "import": "./d/*.mjs" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/pkg/a/a1.d.ts +export const a1: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/b/b1.d.ts +export const b1: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/b/b2.d.mts +export const NOT_REACHABLE: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/c/c1.d.ts +export const c1: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/c/subfolder/c2.d.mts +export const c2: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/d/d1.d.mts +export const d1: number; +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "pkg": "1.0.0" + } +} +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/main.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "a1", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "pkg/a1", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "b1", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "pkg/b/b1.js", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "c1", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "pkg/c/c1.js", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "c2", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "pkg/c/subfolder/c2.mjs", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "d1", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "pkg/d/d1", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "NOT_REACHABLE", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_wildcardExports2_test.go b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports2_test.go new file mode 100644 index 0000000000..1c8b937767 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports2_test.go @@ -0,0 +1,68 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_wildcardExports2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json +{ + "name": "pkg", + "version": "1.0.0", + "exports": { + "./core/*": { + "types": "./lib/core/*.d.ts", + "default": "./lib/core/*.js" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/pkg/lib/core/test.d.ts +export function test(): void; +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "pkg": "1.0.0" + } +} +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/main.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "test", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "pkg/core/test", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_wildcardExports3_test.go b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports3_test.go new file mode 100644 index 0000000000..1d16e505a9 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports3_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_wildcardExports3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/ui/package.json +{ + "name": "@repo/ui", + "version": "1.0.0", + "exports": { + "./*": "./src/*.tsx" + } +} +// @Filename: /home/src/workspaces/project/packages/ui/src/Card.tsx +export const Card = () => null; +// @Filename: /home/src/workspaces/project/apps/web/package.json +{ + "name": "web", + "version": "1.0.0", + "dependencies": { + "@repo/ui": "workspace:*" + } +} +// @Filename: /home/src/workspaces/project/apps/web/tsconfig.json +{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "noEmit": true, + "jsx": "preserve" + }, + "include": ["app"] +} +// @Filename: /home/src/workspaces/project/apps/web/app/index.tsx +(); +// @link: /home/src/workspaces/project/packages/ui -> /home/src/workspaces/project/apps/web/node_modules/@repo/ui` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Card", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@repo/ui/Card", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportReExportFromAmbientModule_test.go b/internal/fourslash/tests/gen/autoImportReExportFromAmbientModule_test.go new file mode 100644 index 0000000000..6d08ef00ce --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportReExportFromAmbientModule_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportReExportFromAmbientModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs" + } +} +// @Filename: /home/src/workspaces/project/node_modules/@types/node/index.d.ts +declare module "fs" { + export function accessSync(path: string): void; +} +// @Filename: /home/src/workspaces/project/node_modules/@types/fs-extra/index.d.ts +export * from "fs"; +// @Filename: /home/src/workspaces/project/index.ts +access/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "accessSync", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fs", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "accessSync", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fs-extra", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "accessSync", + Source: "fs-extra", + Description: "Add import from \"fs-extra\"", + NewFileContent: PtrTo(`import { accessSync } from "fs-extra"; + +access`), + AutoImportData: &lsproto.AutoImportData{ + ExportName: "accessSync", + FileName: "/home/src/workspaces/project/node_modules/@types/fs-extra/index.d.ts", + ModuleSpecifier: "fs-extra", + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportSameNameDefaultExported_test.go b/internal/fourslash/tests/gen/autoImportSameNameDefaultExported_test.go new file mode 100644 index 0000000000..c39937400b --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportSameNameDefaultExported_test.go @@ -0,0 +1,59 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportSameNameDefaultExported(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /node_modules/antd/index.d.ts +declare function Table(): void; +export default Table; +// @Filename: /node_modules/rc-table/index.d.ts +declare function Table(): void; +export default Table; +// @Filename: /index.ts +Table/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Table", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "antd", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "Table", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "rc-table", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportSortCaseSensitivity1_test.go b/internal/fourslash/tests/gen/autoImportSortCaseSensitivity1_test.go new file mode 100644 index 0000000000..020cfb9d4e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportSortCaseSensitivity1_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportSortCaseSensitivity1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /exports1.ts +export const a = 0; +export const A = 1; +export const b = 2; +export const B = 3; +export const c = 4; +export const C = 5; +// @Filename: /exports2.ts +export const d = 0; +export const D = 1; +export const e = 2; +export const E = 3; +// @Filename: /index0.ts +import { A, B, C } from "./exports1"; +a/*0*/ +// @Filename: /index1.ts +import { A, a, B, b } from "./exports1"; +import { E } from "./exports2"; +d/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C } from "./exports1"; +a`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C } from "./exports1"; +a`, + }, nil /*preferences*/) + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, a, B, b } from "./exports1"; +import { d, E } from "./exports2"; +d`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, a, B, b } from "./exports1"; +import { E, d } from "./exports2"; +d`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportSortCaseSensitivity2_test.go b/internal/fourslash/tests/gen/autoImportSortCaseSensitivity2_test.go new file mode 100644 index 0000000000..1a053fd54e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportSortCaseSensitivity2_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportSortCaseSensitivity2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export interface HasBar { bar: number } +export function hasBar(x: unknown): x is HasBar { return x && typeof x.bar === "number" } +export function foo() {} +export type __String = string; +// @Filename: /b.ts +import { __String, HasBar, hasBar } from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import { __String, foo, HasBar, hasBar } from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportSymlinkCaseSensitive_test.go b/internal/fourslash/tests/gen/autoImportSymlinkCaseSensitive_test.go new file mode 100644 index 0000000000..e8553396d2 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportSymlinkCaseSensitive_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportSymlinkCaseSensitive(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: /node_modules/.pnpm/mobx@6.0.4/node_modules/MobX/Foo.d.ts +export declare function autorun(): void; +// @Filename: /index.ts +autorun/**/ +// @Filename: /utils.ts +import "MobX/Foo"; +// @link: /node_modules/.pnpm/mobx@6.0.4/node_modules/MobX -> /node_modules/MobX +// @link: /node_modules/.pnpm/mobx@6.0.4/node_modules/MobX -> /node_modules/.pnpm/cool-mobx-dependent@1.2.3/node_modules/MobX` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { autorun } from "MobX/Foo"; + +autorun`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeImport1_test.go b/internal/fourslash/tests/gen/autoImportTypeImport1_test.go new file mode 100644 index 0000000000..7fc9f0a982 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeImport1_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeImport1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @target: esnext +// @Filename: /foo.ts +export const A = 1; +export type B = { x: number }; +export type C = 1; +export class D = { y: string }; +// @Filename: /test.ts +import { A, D, type C } from './foo'; +const b: B/**/ | C; +console.log(A, D);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, D, type C, type B } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, D, type B, type C } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, D, type C, type B } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeImport2_test.go b/internal/fourslash/tests/gen/autoImportTypeImport2_test.go new file mode 100644 index 0000000000..202dfc0dd1 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeImport2_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeImport2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @target: esnext +// @Filename: /foo.ts +export const A = 1; +export type B = { x: number }; +export type C = 1; +export class D = { y: string }; +// @Filename: /test.ts +import { A, type C, D } from './foo'; +const b: B/**/ | C; +console.log(A, D);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, type B, type C, D } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, type C, D, type B } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, type C, D, type B } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeImport3_test.go b/internal/fourslash/tests/gen/autoImportTypeImport3_test.go new file mode 100644 index 0000000000..20dd8d97fd --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeImport3_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeImport3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @target: esnext +// @Filename: /foo.ts +export const A = 1; +export type B = { x: number }; +export type C = 1; +export class D = { y: string }; +// @Filename: /test.ts +import { A, type B, type C } from './foo'; +const b: B | C; +console.log(A, D/**/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, D, type B, type C } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, type B, type C, D } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, type B, type C, D } from './foo'; +const b: B | C; +console.log(A, D);`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeImport4_test.go b/internal/fourslash/tests/gen/autoImportTypeImport4_test.go new file mode 100644 index 0000000000..ae19d60f17 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeImport4_test.go @@ -0,0 +1,123 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeImport4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @target: esnext +// @Filename: /exports1.ts +export const a = 0; +export const A = 1; +export const b = 2; +export const B = 3; +export const c = 4; +export const C = 5; +export type x = 6; +export const X = 7; +export const Y = 8; +export const Z = 9; +// @Filename: /exports2.ts +export const d = 0; +export const D = 1; +export const e = 2; +export const E = 3; +// @Filename: /index0.ts +import { A, B, C } from "./exports1"; +a/*0*//*0a*/; +b; +// @Filename: /index1.ts +import { A, B, C, type Y, type Z } from "./exports1"; +a/*1*//*1a*//*1b*//*1c*/; +b; +// @Filename: /index2.ts +import { A, a, B, b, type Y, type Z } from "./exports1"; +import { E } from "./exports2"; +d/*2*//*2a*//*2b*//*2c*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C } from "./exports1"; +a; +b;`, + `import { A, b, B, C } from "./exports1"; +a; +b;`, + }, nil /*preferences*/) + f.GoToMarker(t, "0a") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C } from "./exports1"; +a; +b;`, + `import { A, b, B, C } from "./exports1"; +a; +b;`, + }, nil /*preferences*/) + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + `import { A, b, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + }, nil /*preferences*/) + f.GoToMarker(t, "1a") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + `import { A, b, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + }, nil /*preferences*/) + f.GoToMarker(t, "1b") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + `import { A, b, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + }, nil /*preferences*/) + f.GoToMarker(t, "1c") + f.VerifyImportFixAtPosition(t, []string{ + `import { a, A, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + `import { A, b, B, C, type Y, type Z } from "./exports1"; +a; +b;`, + }, nil /*preferences*/) + f.GoToMarker(t, "2") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, a, B, b, type Y, type Z } from "./exports1"; +import { d, E } from "./exports2"; +d`, + }, nil /*preferences*/) + f.GoToMarker(t, "2a") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, a, B, b, type Y, type Z } from "./exports1"; +import { E, d } from "./exports2"; +d`, + }, nil /*preferences*/) + f.GoToMarker(t, "2b") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, a, B, b, type Y, type Z } from "./exports1"; +import { d, E } from "./exports2"; +d`, + }, nil /*preferences*/) + f.GoToMarker(t, "2c") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, a, B, b, type Y, type Z } from "./exports1"; +import { E, d } from "./exports2"; +d`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeImport5_test.go b/internal/fourslash/tests/gen/autoImportTypeImport5_test.go new file mode 100644 index 0000000000..85077ac85c --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeImport5_test.go @@ -0,0 +1,108 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeImport5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @target: esnext +// @Filename: /exports1.ts +export const a = 0; +export const A = 1; +export const b = 2; +export const B = 3; +export const c = 4; +export const C = 5; +export type x = 6; +export const X = 7; +export type y = 8 +export const Y = 9; +export const Z = 10; +// @Filename: /exports2.ts +export const d = 0; +export const D = 1; +export const e = 2; +export const E = 3; +// @Filename: /index0.ts +import { type X, type Y, type Z } from "./exports1"; +const foo: x/*0*/; +const bar: y; +// @Filename: /index1.ts +import { A, B, type X, type Y, type Z } from "./exports1"; +const foo: x/*1*/; +const bar: y;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyImportFixAtPosition(t, []string{ + `import { type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import { A, B, type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { A, B, type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { A, B, type x, type X, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + `import { A, B, type X, type y, type Y, type Z } from "./exports1"; +const foo: x; +const bar: y;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred1_test.go b/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred1_test.go new file mode 100644 index 0000000000..72bc3617b7 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred1_test.go @@ -0,0 +1,63 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeOnlyPreferred1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @module: esnext +// @moduleResolution: bundler +// @Filename: /ts.d.ts +declare namespace ts { + interface SourceFile { + text: string; + } + function createSourceFile(): SourceFile; +} +export = ts; +// @Filename: /types.ts +export interface VFS { + getSourceFile(path: string): ts/**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "ts", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./ts", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }).AndApplyCodeAction(t, &fourslash.CompletionsExpectedCodeAction{ + Name: "ts", + Source: "./ts", + Description: "Add import from \"./ts\"", + NewFileContent: `import type ts from "./ts"; + +export interface VFS { + getSourceFile(path: string): ts +}`, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred2_test.go b/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred2_test.go new file mode 100644 index 0000000000..c79ec30ad6 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred2_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeOnlyPreferred2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/react/index.d.ts +export interface ComponentType {} +export interface ComponentProps {} +export declare function useState(initialState: T): [T, (newState: T) => void]; +export declare function useEffect(callback: () => void, deps: any[]): void; +// @Filename: /main.ts +import type { ComponentType } from "react"; +import { useState } from "react"; + +export function Component({ prop } : { prop: ComponentType }) { + const codeIsUnimportant = useState(1); + useEffect/*1*/(() => {}, []); +} +// @Filename: /main2.ts +import { useState } from "react"; +import type { ComponentType } from "react"; + +type _ = ComponentProps/*2*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyImportFixAtPosition(t, []string{ + `import type { ComponentType } from "react"; +import { useEffect, useState } from "react"; + +export function Component({ prop } : { prop: ComponentType }) { + const codeIsUnimportant = useState(1); + useEffect(() => {}, []); +}`, + }, nil /*preferences*/) + f.GoToMarker(t, "2") + f.VerifyImportFixAtPosition(t, []string{ + `import { useState } from "react"; +import type { ComponentProps, ComponentType } from "react"; + +type _ = ComponentProps;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/autoImportVerbatimTypeOnly1_test.go b/internal/fourslash/tests/gen/autoImportVerbatimTypeOnly1_test.go new file mode 100644 index 0000000000..e3e8815481 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportVerbatimTypeOnly1_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportVerbatimTypeOnly1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @verbatimModuleSyntax: true +// @Filename: /mod.ts +export const value = 0; +export class C { constructor(v: any) {} } +export interface I {} +// @Filename: /a.mts +const x: /**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "I", + Source: "./mod", + Description: "Add import from \"./mod.js\"", + AutoImportData: &lsproto.AutoImportData{ + ExportName: "I", + FileName: "/mod.ts", + ModuleSpecifier: "./mod.js", + }, + NewFileContent: PtrTo(`import type { I } from "./mod.js"; + +const x: `), + }) + f.Insert(t, "I = new C") + f.VerifyApplyCodeActionFromCompletion(t, nil, &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "C", + Source: "./mod", + Description: "Update import from \"./mod.js\"", + AutoImportData: &lsproto.AutoImportData{ + ExportName: "C", + FileName: "/mod.ts", + ModuleSpecifier: "./mod.js", + }, + NewFileContent: PtrTo(`import { C, type I } from "./mod.js"; + +const x: I = new C`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportsNodeNext1_test.go b/internal/fourslash/tests/gen/autoImportsNodeNext1_test.go new file mode 100644 index 0000000000..a174ed157c --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportsNodeNext1_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportsNodeNext1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/pack/package.json +{ + "name": "pack", + "version": "1.0.0", + "exports": { + ".": "./main.mjs" + } +} +// @Filename: /node_modules/pack/main.d.mts +import {} from "./unreachable.mjs"; +export const fromMain = 0; +// @Filename: /node_modules/pack/unreachable.d.mts +export const fromUnreachable = 0; +// @Filename: /index.mts +import { fromMain } from "pack"; +fromUnreachable/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{}, nil /*preferences*/) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Excludes: []string{ + "fromUnreachable", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/codeFixInferFromUsageBindingElement_test.go b/internal/fourslash/tests/gen/codeFixInferFromUsageBindingElement_test.go new file mode 100644 index 0000000000..b186df0321 --- /dev/null +++ b/internal/fourslash/tests/gen/codeFixInferFromUsageBindingElement_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCodeFixInferFromUsageBindingElement(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f([car, cdr]) { + return car + cdr + 1 +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/codeFixRemoveUnnecessaryAwait_mixedUnion_test.go b/internal/fourslash/tests/gen/codeFixRemoveUnnecessaryAwait_mixedUnion_test.go new file mode 100644 index 0000000000..40bcd52600 --- /dev/null +++ b/internal/fourslash/tests/gen/codeFixRemoveUnnecessaryAwait_mixedUnion_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCodeFixRemoveUnnecessaryAwait_mixedUnion(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +async function fn1(a: Promise | void) { + await a; +} + +async function fn2 | void>(a: T) { + await a; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/codeFixRemoveUnnecessaryAwait_notAvailableOnReturn_test.go b/internal/fourslash/tests/gen/codeFixRemoveUnnecessaryAwait_notAvailableOnReturn_test.go new file mode 100644 index 0000000000..b795b91523 --- /dev/null +++ b/internal/fourslash/tests/gen/codeFixRemoveUnnecessaryAwait_notAvailableOnReturn_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCodeFixRemoveUnnecessaryAwait_notAvailableOnReturn(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +async function fn(): Promise { + return 0; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/codeFixUnreachableCode_noSuggestionIfDisabled_test.go b/internal/fourslash/tests/gen/codeFixUnreachableCode_noSuggestionIfDisabled_test.go new file mode 100644 index 0000000000..63f9f0d954 --- /dev/null +++ b/internal/fourslash/tests/gen/codeFixUnreachableCode_noSuggestionIfDisabled_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCodeFixUnreachableCode_noSuggestionIfDisabled(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowUnreachableCode: true +if (false) 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/codeFixUnusedLabel_noSuggestionIfDisabled_test.go b/internal/fourslash/tests/gen/codeFixUnusedLabel_noSuggestionIfDisabled_test.go new file mode 100644 index 0000000000..1f238e081f --- /dev/null +++ b/internal/fourslash/tests/gen/codeFixUnusedLabel_noSuggestionIfDisabled_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCodeFixUnusedLabel_noSuggestionIfDisabled(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowUnusedLabels: true +foo: while (true) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go b/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go index 3f67b274df..3f78988212 100644 --- a/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go +++ b/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go @@ -10,25 +10,9 @@ import ( func TestCompletionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @Filename: /node_modules/@types/react/index.d.ts -export = React; -export as namespace React; -declare namespace React { - function createElement(): any; - interface Component

{ } - class Component { - static contextType?: any; - context: any; - constructor(props: Readonly

); - setState( - state: ((prevState: Readonly, props: Readonly

) => (Pick | S | null)) | (Pick | S | null), - callback?: () => void - ): void; - } -} -// @Filename: /a.ts + const content = `// @Filename: /a.ts import React from 'react' class Slider extends React.Component { static defau/**/ltProps = { diff --git a/internal/fourslash/tests/gen/completionForObjectProperty_test.go b/internal/fourslash/tests/gen/completionForObjectProperty_test.go new file mode 100644 index 0000000000..d1fd378f99 --- /dev/null +++ b/internal/fourslash/tests/gen/completionForObjectProperty_test.go @@ -0,0 +1,189 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionForObjectProperty(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = { bar: 'baz' }; +// @Filename: /b.ts +const test = foo/*1*/ +// @Filename: /c.ts +const test2 = {...foo/*2*/} +// @Filename: /d.ts +const test3 = [{...foo/*3*/}] +// @Filename: /e.ts +const test4 = { foo/*4*/ } +// @Filename: /f.ts +const test5 = { foo: /*5*/ } +// @Filename: /g.ts +const test6 = { unrelated: foo/*6*/ } +// @Filename: /i.ts +const test7: { foo/*7*/: "unrelated" } +// @Filename: /h.ts +const test8: { foo: string } = { foo/*8*/ }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "7", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Excludes: []string{ + "foo", + }, + }, + }) + f.VerifyCompletions(t, "8", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go b/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go index be55991de2..a269f1a909 100644 --- a/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go +++ b/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go @@ -16,6 +16,7 @@ func TestCompletionForStringLiteralNonrelativeImport16(t *testing.T) { const content = `// @Filename: tsconfig.json { "compilerOptions": { + "resolveJsonModule": false, "baseUrl": "./", "paths": { "module1/path1": ["some/path/whatever.ts"], diff --git a/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport7_test.go b/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport7_test.go index 59b0088b59..5c6740e18f 100644 --- a/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport7_test.go +++ b/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport7_test.go @@ -10,7 +10,7 @@ import ( func TestCompletionForStringLiteralNonrelativeImport7(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @baseUrl: tests/cases/fourslash/modules // @Filename: tests/test0.ts diff --git a/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go b/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go index 70e23f84fa..dd636cca8b 100644 --- a/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go +++ b/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go @@ -12,7 +12,7 @@ import ( func TestCompletionInNamedImportLocation(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: file.ts export var x = 10; diff --git a/internal/fourslash/tests/gen/completionListForTransitivelyExportedMembers04_test.go b/internal/fourslash/tests/gen/completionListForTransitivelyExportedMembers04_test.go index 0061cd86a6..695a4b7f53 100644 --- a/internal/fourslash/tests/gen/completionListForTransitivelyExportedMembers04_test.go +++ b/internal/fourslash/tests/gen/completionListForTransitivelyExportedMembers04_test.go @@ -10,10 +10,9 @@ import ( func TestCompletionListForTransitivelyExportedMembers04(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @ModuleResolution: classic -// @Filename: A.ts + const content = `// @Filename: A.ts export interface I1 { one: number } export interface I2 { two: string } export type I1_OR_I2 = I1 | I2; @@ -35,10 +34,10 @@ export module Inner { export var bVar = "bee!"; // @Filename: C.ts export var cVar = "see!"; -export * from "A"; -export * from "B" +export * from "./A"; +export * from "./B" // @Filename: D.ts -import * as c from "C"; +import * as c from "./C"; var x: c.Inner./**/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ diff --git a/internal/fourslash/tests/gen/completionListInImportClause01_test.go b/internal/fourslash/tests/gen/completionListInImportClause01_test.go index baf14e33e1..a991772673 100644 --- a/internal/fourslash/tests/gen/completionListInImportClause01_test.go +++ b/internal/fourslash/tests/gen/completionListInImportClause01_test.go @@ -10,21 +10,20 @@ import ( func TestCompletionListInImportClause01(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @ModuleResolution: classic -// @Filename: m1.ts + const content = `// @Filename: m1.ts export var foo: number = 1; export function bar() { return 10; } export function baz() { return 10; } // @Filename: m2.ts -import {/*1*/, /*2*/ from "m1" -import {/*3*/} from "m1" -import {foo,/*4*/ from "m1" -import {bar as /*5*/, /*6*/ from "m1" -import {foo, bar, baz as b,/*7*/} from "m1" -import { type /*8*/ } from "m1"; -import { type b/*9*/ } from "m1";` +import {/*1*/, /*2*/ from "./m1" +import {/*3*/} from "./m1" +import {foo,/*4*/ from "./m1" +import {bar as /*5*/, /*6*/ from "./m1" +import {foo, bar, baz as b,/*7*/} from "./m1" +import { type /*8*/ } from "./m1"; +import { type b/*9*/ } from "./m1";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyCompletions(t, []string{"8", "9"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, diff --git a/internal/fourslash/tests/gen/completionListObjectMembersInTypeLocationWithTypeof_test.go b/internal/fourslash/tests/gen/completionListObjectMembersInTypeLocationWithTypeof_test.go index 18576a0bff..7c1baea148 100644 --- a/internal/fourslash/tests/gen/completionListObjectMembersInTypeLocationWithTypeof_test.go +++ b/internal/fourslash/tests/gen/completionListObjectMembersInTypeLocationWithTypeof_test.go @@ -11,7 +11,7 @@ import ( func TestCompletionListObjectMembersInTypeLocationWithTypeof(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @strict: true const languageService = { getCompletions() {} } diff --git a/internal/fourslash/tests/gen/completionListStaticProtectedMembers2_test.go b/internal/fourslash/tests/gen/completionListStaticProtectedMembers2_test.go index 274cd4dc14..7b5cb87dae 100644 --- a/internal/fourslash/tests/gen/completionListStaticProtectedMembers2_test.go +++ b/internal/fourslash/tests/gen/completionListStaticProtectedMembers2_test.go @@ -140,14 +140,30 @@ class C2 extends Base { Label: "protectedOverriddenMethod", SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), }, + &lsproto.CompletionItem{ + Label: "protectedOverriddenProperty", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, + &lsproto.CompletionItem{ + Label: "protectedProperty", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, &lsproto.CompletionItem{ Label: "publicMethod", SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), }, + &lsproto.CompletionItem{ + Label: "publicProperty", + SortText: PtrTo(string(ls.SortTextLocalDeclarationPriority)), + }, &lsproto.CompletionItem{ Label: "apply", SortText: PtrTo(string(ls.SortTextLocationPriority)), }, + &lsproto.CompletionItem{ + Label: "arguments", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, &lsproto.CompletionItem{ Label: "bind", SortText: PtrTo(string(ls.SortTextLocationPriority)), @@ -156,6 +172,18 @@ class C2 extends Base { Label: "call", SortText: PtrTo(string(ls.SortTextLocationPriority)), }, + &lsproto.CompletionItem{ + Label: "caller", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "length", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + &lsproto.CompletionItem{ + Label: "prototype", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, &lsproto.CompletionItem{ Label: "toString", SortText: PtrTo(string(ls.SortTextLocationPriority)), diff --git a/internal/fourslash/tests/gen/completionPropertyShorthandForObjectLiteral5_test.go b/internal/fourslash/tests/gen/completionPropertyShorthandForObjectLiteral5_test.go new file mode 100644 index 0000000000..45c4549522 --- /dev/null +++ b/internal/fourslash/tests/gen/completionPropertyShorthandForObjectLiteral5_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionPropertyShorthandForObjectLiteral5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +export const exportedConstant = 0; +// @Filename: /b.ts +const foo = 'foo' +const obj = { exp/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "exportedConstant", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completions01_test.go b/internal/fourslash/tests/gen/completions01_test.go index c45a912378..1318192ba9 100644 --- a/internal/fourslash/tests/gen/completions01_test.go +++ b/internal/fourslash/tests/gen/completions01_test.go @@ -16,6 +16,7 @@ func TestCompletions01(t *testing.T) { x.forEach(function (y) { y/*1*/ x.forEach(y => y/*2*/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "1") f.Insert(t, ".") f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ diff --git a/internal/fourslash/tests/gen/completions03_test.go b/internal/fourslash/tests/gen/completions03_test.go index e2a1f5b622..b05b9407f0 100644 --- a/internal/fourslash/tests/gen/completions03_test.go +++ b/internal/fourslash/tests/gen/completions03_test.go @@ -24,6 +24,7 @@ let x: Foo = { /**/ }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter1_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter1_test.go new file mode 100644 index 0000000000..1a537ea7ce --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter1_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /generation.d.ts +export type GenerationConfigType = { max_length?: number }; +// @FileName: /index.d.ts +export declare class PreTrainedModel { + _get_generation_config( + param: import("./generation.js").GenerationConfigType, + ): import("./generation.js").GenerationConfigType; +} + +export declare class BlenderbotSmallPreTrainedModel extends PreTrainedModel { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "_get_generation_config", + InsertText: PtrTo("_get_generation_config(param: import(\"./generation.js\").GenerationConfigType): import(\"./generation.js\").GenerationConfigType;"), + FilterText: PtrTo("_get_generation_config"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter2_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter2_test.go new file mode 100644 index 0000000000..291c5f4023 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter2_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @FileName: /index.d.ts +export declare class Cls { + method( + param: import("./doesntexist.js").Foo, + ): import("./doesntexist.js").Foo; +} + +export declare class Derived extends Cls { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "method", + InsertText: PtrTo("method(param: import(\"./doesntexist.js\").Foo);"), + FilterText: PtrTo("method"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter3_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter3_test.go new file mode 100644 index 0000000000..d3a0eb7fc7 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter3_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @FileName: /other/foo.d.ts +export declare type Bar = { baz: string }; +// @FileName: /other/cls.d.ts +export declare class Cls { + method( + param: import("./foo.js").Bar, + ): import("./foo.js").Bar; +} +// @FileName: /index.d.ts +import { Cls } from "./other/cls.js"; + +export declare class Derived extends Cls { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "method", + InsertText: PtrTo("method(param: import(\"./other/foo.js\").Bar): import(\"./other/foo.js\").Bar;"), + FilterText: PtrTo("method"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter4_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter4_test.go new file mode 100644 index 0000000000..52343b3055 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter4_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @FileName: /other/cls.d.ts +export declare class Cls { + method( + param: import("./doesntexist.js").Foo, + ): import("./doesntexist.js").Foo; +} +// @FileName: /index.d.ts +import { Cls } from "./other/cls.js"; + +export declare class Derived extends Cls { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "method", + InsertText: PtrTo("method(param: import(\"./doesntexist.js\").Foo);"), + FilterText: PtrTo("method"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsDotInArrayLiteralInObjectLiteral_test.go b/internal/fourslash/tests/gen/completionsDotInArrayLiteralInObjectLiteral_test.go new file mode 100644 index 0000000000..690efe9698 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsDotInArrayLiteralInObjectLiteral_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsDotInArrayLiteralInObjectLiteral(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const o = { x: [[|.|][||]/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNonSuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](1109)}, + Message: "Expression expected.", + Range: f.Ranges()[0].LSRange, + }, + { + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](1003)}, + Message: "Identifier expected.", + Range: f.Ranges()[1].LSRange, + }, + }) + f.VerifyCompletions(t, "", nil) +} diff --git a/internal/fourslash/tests/gen/completionsImportBaseUrl_test.go b/internal/fourslash/tests/gen/completionsImportBaseUrl_test.go new file mode 100644 index 0000000000..971082cf39 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportBaseUrl_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportBaseUrl(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "module": "esnext" + } +} +// @Filename: /src/a.ts +export const foo = 0; +// @Filename: /src/b.ts +fo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("const foo: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportDefaultExportCrash2_test.go b/internal/fourslash/tests/gen/completionsImportDefaultExportCrash2_test.go new file mode 100644 index 0000000000..10c5ee50a6 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportDefaultExportCrash2_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportDefaultExportCrash2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @allowJs: true +// @Filename: /node_modules/dom7/index.d.ts +export interface Dom7Array { + length: number; + prop(propName: string): any; +} + +export interface Dom7 { + (): Dom7Array; + fn: any; +} + +declare const Dom7: Dom7; + +export { + Dom7 as $, +}; +// @Filename: /dom7.js +import * as methods from 'dom7'; +Object.keys(methods).forEach((methodName) => { + if (methodName === '$') return; + methods.$.fn[methodName] = methods[methodName]; +}); + +export default methods.$; +// @Filename: /swipe-back.js +/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "$", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dom7", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Dom7", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./dom7", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportFromJSXTag_test.go b/internal/fourslash/tests/gen/completionsImportFromJSXTag_test.go new file mode 100644 index 0000000000..c0488b300a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportFromJSXTag_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportFromJSXTag(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: react +// @Filename: /types.d.ts +declare namespace JSX { + interface IntrinsicElements { a } +} +// @Filename: /Box.tsx +export function Box(props: any) { return null; } +// @Filename: /App.tsx +export function App() { + return ( +

+ + ) +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Box", + Source: "./Box", + Description: "Add import from \"./Box\"", + NewFileContent: PtrTo(`import { Box } from "./Box"; + +export function App() { + return ( +
+ + ) +}`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportModuleAugmentationWithJS_test.go b/internal/fourslash/tests/gen/completionsImportModuleAugmentationWithJS_test.go new file mode 100644 index 0000000000..39ec087d07 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportModuleAugmentationWithJS_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportModuleAugmentationWithJS(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @noEmit: true +// @Filename: /test.js +class Abcde { + x +} + +module.exports = { + Abcde +}; +// @Filename: /index.ts +export {}; +declare module "./test" { + interface Abcde { b: string } +} + +Abcde/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Abcde", + Source: "./test", + Description: "Add import from \"./test\"", + NewFileContent: PtrTo(`import { Abcde } from "./test"; + +export {}; +declare module "./test" { + interface Abcde { b: string } +} + +Abcde`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportPathsConflict_test.go b/internal/fourslash/tests/gen/completionsImportPathsConflict_test.go new file mode 100644 index 0000000000..5fb7a8f139 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportPathsConflict_test.go @@ -0,0 +1,68 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportPathsConflict(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "module": "esnext", + "paths": { + "@reduxjs/toolkit": ["src/index.ts"], + "@internal/*": ["src/*"] + } + } +} +// @Filename: /src/index.ts +export { configureStore } from "./configureStore"; +// @Filename: /src/configureStore.ts +export function configureStore() {} +// @Filename: /src/tests/createAsyncThunk.typetest.ts +import {} from "@reduxjs/toolkit"; +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "configureStore", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@reduxjs/toolkit", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "configureStore", + Source: "@reduxjs/toolkit", + AutoImportData: &lsproto.AutoImportData{ + ExportName: "configureStore", + FileName: "/src/configureStore.ts", + ModuleSpecifier: "@reduxjs/toolkit", + }, + Description: "Update import from \"@reduxjs/toolkit\"", + NewFileContent: PtrTo(`import { configureStore } from "@reduxjs/toolkit"; +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportTypeKeyword_test.go b/internal/fourslash/tests/gen/completionsImportTypeKeyword_test.go new file mode 100644 index 0000000000..c6d307912d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportTypeKeyword_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportTypeKeyword(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /os.d.ts +declare module "os" { + export function type(): string; +} +// @Filename: /index.ts +type/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "type", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + &lsproto.CompletionItem{ + Label: "type", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "os", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportYieldExpression_test.go b/internal/fourslash/tests/gen/completionsImportYieldExpression_test.go new file mode 100644 index 0000000000..f0c76cee39 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportYieldExpression_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportYieldExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export function a() {} +// @Filename: /b.ts +function *f() { + yield a/**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "a", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { a } from "./a"; + +function *f() { + yield a +}`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_46332_test.go b/internal/fourslash/tests/gen/completionsImport_46332_test.go new file mode 100644 index 0000000000..1676ac368d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_46332_test.go @@ -0,0 +1,101 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_46332(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @moduleResolution: bundler +// @Filename: /node_modules/vue/package.json +{ + "name": "vue", + "types": "dist/vue.d.ts" +} +// @Filename: /node_modules/vue/dist/vue.d.ts +export * from "@vue/runtime-dom" +// @Filename: /node_modules/@vue/runtime-dom/package.json +{ + "name": "@vue/runtime-dom", + "types": "dist/runtime-dom.d.ts" +} +// @Filename: /node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +export * from "@vue/runtime-core"; +export {} +declare module '@vue/reactivity' { + export interface RefUnwrapBailTypes { + runtimeDOMBailTypes: any + } +} +// @Filename: /node_modules/@vue/runtime-core/package.json +{ + "name": "@vue/runtime-core", + "types": "dist/runtime-core.d.ts" +} +// @Filename: /node_modules/@vue/runtime-core/dist/runtime-core.d.ts +import { ref } from '@vue/reactivity'; +export { ref }; +declare module '@vue/reactivity' { + export interface RefUnwrapBailTypes { + runtimeCoreBailTypes: any + } +} +// @Filename: /node_modules/@vue/reactivity/package.json +{ + "name": "@vue/reactivity", + "types": "dist/reactivity.d.ts" +} +// @Filename: /node_modules/@vue/reactivity/dist/reactivity.d.ts +export declare function ref(): T; +// @Filename: /package.json +{ + "dependencies": { + "vue": "*" + } +} +// @Filename: /index.ts +import {} from "vue"; +ref/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "ref", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "vue", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "ref", + Source: "vue", + Description: "Update import from \"vue\"", + AutoImportData: &lsproto.AutoImportData{ + ExportName: "ref", + FileName: "/node_modules/vue/dist/vue.d.ts", + }, + NewFileContent: PtrTo(`import { ref } from "vue"; +ref`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_ambient_test.go b/internal/fourslash/tests/gen/completionsImport_ambient_test.go new file mode 100644 index 0000000000..041c2d61cf --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_ambient_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_ambient(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: a.d.ts +declare namespace foo { class Bar {} } +declare module 'path1' { + import Bar = foo.Bar; + export default Bar; +} +declare module 'path2longer' { + import Bar = foo.Bar; + export {Bar}; +} + +// @Filename: b.ts +Ba/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + &lsproto.CompletionItem{ + Label: "Bar", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "path1", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Bar", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "path2longer", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Bar", + Source: "path2longer", + Description: "Add import from \"path2longer\"", + NewFileContent: PtrTo(`import { Bar } from "path2longer"; + +Ba`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_augmentation_test.go b/internal/fourslash/tests/gen/completionsImport_augmentation_test.go new file mode 100644 index 0000000000..324ebf3f95 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_augmentation_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_augmentation(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /bar.ts +export {}; +declare module "./a" { + export const bar = 0; +} +// @Filename: /user.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("const foo: 0"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "bar", + Detail: PtrTo("const bar: 0"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_compilerOptionsModule_test.go b/internal/fourslash/tests/gen/completionsImport_compilerOptionsModule_test.go new file mode 100644 index 0000000000..f35fe5bd55 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_compilerOptionsModule_test.go @@ -0,0 +1,65 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_compilerOptionsModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @module: commonjs +// @Filename: /node_modules/a/index.d.ts +export const foo = 0; +// @Filename: /b.js +const a = require("./a"); +fo/*b*/ +// @Filename: /c.js +const x = 0;/*c*/ +// @Filename: /c1.js +// @ts-check +const x = 0;/*ccheck*/ +// @Filename: /c2.ts +const x = 0;/*cts*/ +// @Filename: /d.js +const a = import("./a"); // Does not make this an external module +fo/*d*/ +// @Filename: /d1.js +// @ts-check +const a = import("./a"); // Does not make this an external module +fo/*dcheck*/ +// @Filename: /d2.ts +const a = import("./a"); // Does not make this an external module +fo/*dts*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"b", "c", "ccheck", "cts", "d", "dcheck", "dts"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "a", + }, + }, + Detail: PtrTo("const foo: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_computedSymbolName_test.go b/internal/fourslash/tests/gen/completionsImport_computedSymbolName_test.go index 6c98e8fbac..3b793cc756 100644 --- a/internal/fourslash/tests/gen/completionsImport_computedSymbolName_test.go +++ b/internal/fourslash/tests/gen/completionsImport_computedSymbolName_test.go @@ -39,6 +39,7 @@ declare module "process" { // @Filename: /home/src/workspaces/project/index.ts I/**/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/completionsImport_defaultAndNamedConflict_test.go b/internal/fourslash/tests/gen/completionsImport_defaultAndNamedConflict_test.go new file mode 100644 index 0000000000..7f48814987 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_defaultAndNamedConflict_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_defaultAndNamedConflict(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /someModule.ts +export const someModule = 0; +export default 1; +// @Filename: /index.ts +someMo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "someModule", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./someModule", + }, + }, + Detail: PtrTo("(property) default: 1"), + Kind: PtrTo(lsproto.CompletionItemKindField), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "someModule", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./someModule", + }, + }, + Detail: PtrTo("const someModule: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, true), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "someModule", + Source: "./someModule", + AutoImportData: &lsproto.AutoImportData{ + ExportName: "default", + FileName: "/someModule.ts", + }, + Description: "Add import from \"./someModule\"", + NewFileContent: PtrTo(`import someModule from "./someModule"; + +someMo`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_defaultFalsePositive_test.go b/internal/fourslash/tests/gen/completionsImport_defaultFalsePositive_test.go new file mode 100644 index 0000000000..50c9e1f9b6 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_defaultFalsePositive_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_defaultFalsePositive(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/foo/index.ts +export default function f(): void; +// @Filename: /node_modules/bar/concat.d.ts +export const concat = 0; +// @Filename: /a.ts +export {}; +conca/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "concat", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "bar/concat", + }, + }, + Detail: PtrTo("const concat: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "concat", + Source: "bar/concat", + Description: "Add import from \"bar/concat\"", + NewFileContent: PtrTo(`import { concat } from "bar/concat"; + +export {}; +conca`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_addToNamedImports_test.go b/internal/fourslash/tests/gen/completionsImport_default_addToNamedImports_test.go new file mode 100644 index 0000000000..2a55384787 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_addToNamedImports_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_addToNamedImports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo() {} +export const x = 0; +// @Filename: /b.ts +import { x } from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import foo, { x } from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_addToNamespaceImport_test.go b/internal/fourslash/tests/gen/completionsImport_default_addToNamespaceImport_test.go new file mode 100644 index 0000000000..d94b59d904 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_addToNamespaceImport_test.go @@ -0,0 +1,53 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_addToNamespaceImport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo() {} +// @Filename: /b.ts +import * as a from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import foo, * as a from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_alreadyExistedWithRename_test.go b/internal/fourslash/tests/gen/completionsImport_default_alreadyExistedWithRename_test.go new file mode 100644 index 0000000000..533d34449f --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_alreadyExistedWithRename_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_alreadyExistedWithRename(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo() {} +// @Filename: /b.ts +import f_o_o from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import foo from "./a"; +import f_o_o from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_anonymous_test.go b/internal/fourslash/tests/gen/completionsImport_default_anonymous_test.go new file mode 100644 index 0000000000..c439845b41 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_anonymous_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_anonymous(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @noLib: true +// @Filename: /src/foo-bar.ts +export default 0; +// @Filename: /src/b.ts +def/*0*/ +fooB/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{}, true), + }, + }) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooBar", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo-bar", + }, + }, + Detail: PtrTo("(property) default: 0"), + Kind: PtrTo(lsproto.CompletionItemKindField), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "fooBar", + Source: "./foo-bar", + Description: "Add import from \"./foo-bar\"", + NewFileContent: PtrTo(`import fooBar from "./foo-bar" + +def +fooB`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_didNotExistBefore_test.go b/internal/fourslash/tests/gen/completionsImport_default_didNotExistBefore_test.go new file mode 100644 index 0000000000..25bc6bb562 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_didNotExistBefore_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_didNotExistBefore(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +export default function foo() {} +// @Filename: /b.ts +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import foo from "./a"; + +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_exportDefaultIdentifier_test.go b/internal/fourslash/tests/gen/completionsImport_default_exportDefaultIdentifier_test.go new file mode 100644 index 0000000000..ce3fe46687 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_exportDefaultIdentifier_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_exportDefaultIdentifier(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +const foo = 0; +export default foo; +// @Filename: /b.ts +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("(alias) const foo: 0\nexport default foo"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import foo from "./a"; + +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_fromMergedDeclarations_test.go b/internal/fourslash/tests/gen/completionsImport_default_fromMergedDeclarations_test.go new file mode 100644 index 0000000000..9f710f509d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_fromMergedDeclarations_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_fromMergedDeclarations(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +declare module "m" { + export default class M {} +} +// @Filename: /b.ts +declare module "m" { + export default interface M {} +} +// @Filename: /c.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "M", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "m", + }, + }, + Detail: PtrTo("class M"), + Kind: PtrTo(lsproto.CompletionItemKindClass), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "M", + Source: "m", + Description: "Add import from \"m\"", + NewFileContent: PtrTo(`import M from "m"; + +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_reExport_test.go b/internal/fourslash/tests/gen/completionsImport_default_reExport_test.go new file mode 100644 index 0000000000..106dd7850d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_reExport_test.go @@ -0,0 +1,64 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_reExport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @allowJs: true +// @Filename: /file1.js +const a = 1; +export { + a as b +}; +export default a; +// @Filename: /file2.js +import * as foo from './file1'; +/**/ +export default foo.b;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsInJSPlus( + []fourslash.CompletionsExpectedItem{ + "foo", + &lsproto.CompletionItem{ + Label: "a", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./file1", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "b", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./file1", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_symbolName_test.go b/internal/fourslash/tests/gen/completionsImport_default_symbolName_test.go new file mode 100644 index 0000000000..5f4ca45510 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_symbolName_test.go @@ -0,0 +1,62 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_symbolName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /node_modules/@types/range-parser/index.d.ts +declare function RangeParser(): string; +declare namespace RangeParser { + interface Options { + combine?: boolean; + } +} +export = RangeParser; +// @Filename: /b.ts +R/*0*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "RangeParser", + Kind: PtrTo(lsproto.CompletionItemKindFunction), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "range-parser", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Detail: PtrTo("namespace RangeParser\nfunction RangeParser(): string"), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "RangeParser", + Source: "range-parser", + Description: "Add import from \"range-parser\"", + NewFileContent: PtrTo(`import RangeParser = require("range-parser"); + +R`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_details_withMisspelledName_test.go b/internal/fourslash/tests/gen/completionsImport_details_withMisspelledName_test.go new file mode 100644 index 0000000000..a1d9650f99 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_details_withMisspelledName_test.go @@ -0,0 +1,46 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_details_withMisspelledName(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const abc = 0; +// @Filename: /b.ts +acb/*1*/; +// @Filename: /c.ts +acb/*2*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "abc", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { abc } from "./a"; + +acb;`), + }) + f.GoToMarker(t, "2") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("2"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "abc", + Source: "./a", + AutoImportData: &lsproto.AutoImportData{ + ExportName: "abc", + FileName: "/a.ts", + ModuleSpecifier: "./a", + }, + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { abc } from "./a"; + +acb;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypesAndNotTypes_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypesAndNotTypes_test.go new file mode 100644 index 0000000000..4130e9a3c8 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypesAndNotTypes_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_scopedTypesAndNotTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/scope__react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/scope__react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/scope__react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@scope/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@scope/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "react-dom"; +import "react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@scope/react-dom", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@scope/react", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypes_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypes_test.go new file mode 100644 index 0000000000..e33a97c857 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypes_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_scopedTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/scope__react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/scope__react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/scope__react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@types/scope__react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@types/scope__react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "@scope/react-dom"; +import "@scope/react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@scope/react-dom", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@scope/react", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scoped_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scoped_test.go new file mode 100644 index 0000000000..92020a9638 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scoped_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_scoped(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@scope/react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@scope/react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@scope/react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@scope/react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@scope/react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@scope/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@scope/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "@scope/react-dom"; +import "@scope/react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@scope/react-dom", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "@scope/react", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_typesAndNotTypes_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_typesAndNotTypes_test.go new file mode 100644 index 0000000000..9d68899199 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_typesAndNotTypes_test.go @@ -0,0 +1,64 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_typesAndNotTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "react-dom"; +import "react"; +// @Filename: /packages/a/foo.ts +useState/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "useState", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_types_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_types_test.go new file mode 100644 index 0000000000..9f6f5b5b2a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_types_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_types(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@types/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@types/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "react-dom"; +import "react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react-dom", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEqualsNamespace_noDuplicate_test.go b/internal/fourslash/tests/gen/completionsImport_exportEqualsNamespace_noDuplicate_test.go new file mode 100644 index 0000000000..a4e9766d0a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEqualsNamespace_noDuplicate_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEqualsNamespace_noDuplicate(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/a/index.d.ts +declare namespace core { + const foo: number; +} +declare module "a" { + export = core; +} +declare module "a/alias" { + export = core; +} +// @Filename: /user.ts +import * as a from "a"; +/**/foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEquals_anonymous_test.go b/internal/fourslash/tests/gen/completionsImport_exportEquals_anonymous_test.go new file mode 100644 index 0000000000..50e8885186 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEquals_anonymous_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEquals_anonymous(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /src/foo-bar.ts +export = 0; +// @Filename: /src/b.ts +exp/*0*/ +fooB/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{}, true), + }, + }) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooBar", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo-bar", + }, + }, + Detail: PtrTo("(property) export=: 0"), + Kind: PtrTo(lsproto.CompletionItemKindField), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, true), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "fooBar", + Source: "./foo-bar", + Description: "Add import from \"./foo-bar\"", + NewFileContent: PtrTo(`import fooBar = require("./foo-bar") + +exp +fooB`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEquals_global_test.go b/internal/fourslash/tests/gen/completionsImport_exportEquals_global_test.go new file mode 100644 index 0000000000..9f4f618159 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEquals_global_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEquals_global(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: es6 +// @Filename: /console.d.ts + interface Console {} + declare var console: Console; + declare module "console" { + export = console; + } +// @Filename: /react-native.d.ts + import 'console'; + declare global { + interface Console {} + var console: Console; + } +// @Filename: /a.ts +conso/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "console", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEquals_test.go b/internal/fourslash/tests/gen/completionsImport_exportEquals_test.go new file mode 100644 index 0000000000..e1a9b2dc9d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEquals_test.go @@ -0,0 +1,91 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEquals(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /a.d.ts +declare function a(): void; +declare namespace a { + export interface b {} +} +export = a; +// @Filename: /b.ts +a/*0*/; +let x: b/*1*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "a", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "b", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "b", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { b } from "./a"; + +a; +let x: b;`), + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "a", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { b } from "./a"; +import a = require("./a"); + +a; +let x: b;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByInvalidPackageJson_direct_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByInvalidPackageJson_direct_test.go new file mode 100644 index 0000000000..3f3207d769 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByInvalidPackageJson_direct_test.go @@ -0,0 +1,73 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByInvalidPackageJson_direct(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "mod" + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /node_modules/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/fake-react/package.json +{ + "name": "fake-react", + "types": "./index.d.ts" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "ReactFake", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fake-react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesImplicit_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesImplicit_test.go new file mode 100644 index 0000000000..f4889d38e8 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesImplicit_test.go @@ -0,0 +1,63 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_typesImplicit(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/@types/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/@types/react/package.json +{ + "name": "@types/react" +} +//@Filename: /node_modules/@types/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/@types/fake-react/package.json +{ + "name": "@types/fake-react" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesOnly_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesOnly_test.go new file mode 100644 index 0000000000..72f2c11ca2 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesOnly_test.go @@ -0,0 +1,63 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_typesOnly(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "devDependencies": { + "@types/react": "*" + } +} +//@Filename: /node_modules/@types/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/@types/react/package.json +{ + "name": "@types/react" +} +//@Filename: /node_modules/@types/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/@types/fake-react/package.json +{ + "name": "@types/fake-react" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_ambient_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_ambient_test.go new file mode 100644 index 0000000000..e62e7ed0dc --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_ambient_test.go @@ -0,0 +1,153 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_ambient(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react-syntax-highlighter": "*", + "declared-by-foo": "*" + } +} +//@Filename: /node_modules/@types/foo/index.d.ts +declare module "foo" { + export const foo: any; +} +declare module "declared-by-foo" { + export const declaredBySomethingNotInPackageJson: any; +} +//@Filename: /node_modules/@types/foo/package.json +{ + "name": "@types/node" +} +//@Filename: /node_modules/@types/react-syntax-highlighter/index.d.ts +declare module "react-syntax-highlighter/sub" { + const agate: any; + export default agate; +} +declare module "something-else" { + export const somethingElse: any; +} +//@Filename: /node_modules/@types/react-syntax-highlighter/package.json +{ + "name": "@types/react-syntax-highlighter" +} +//@Filename: /src/ambient.ts +declare module "local" { + export const local: any'; +} +//@Filename: /src/index.ts +fo/*1*/ +aga/*2*/ +somethi/*3*/ +declaredBy/*4*/ +loca/*5*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobals, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "agate", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react-syntax-highlighter/sub", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "somethingElse", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "something-else", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "declaredBySomethingNotInPackageJson", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "declared-by-foo", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "local", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "local", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_direct_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_direct_test.go new file mode 100644 index 0000000000..11a62d6f14 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_direct_test.go @@ -0,0 +1,65 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_direct(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /node_modules/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/fake-react/package.json +{ + "name": "fake-react", + "types": "./index.d.ts" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_nested_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_nested_test.go new file mode 100644 index 0000000000..973447640e --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_nested_test.go @@ -0,0 +1,89 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_nested(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /dir/package.json +{ + "dependencies": { + "redux": "*" + } +} +//@Filename: /dir/node_modules/redux/package.json +{ + "name": "redux", + "types": "./index.d.ts" +} +//@Filename: /dir/node_modules/redux/index.d.ts +export declare var Redux: any; +//@Filename: /dir/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Redux", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "redux", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_peerDependencies_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_peerDependencies_test.go new file mode 100644 index 0000000000..48669d36da --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_peerDependencies_test.go @@ -0,0 +1,65 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_peerDependencies(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "peerDependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /node_modules/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/fake-react/package.json +{ + "name": "fake-react", + "types": "./index.d.ts" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "react", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_fromAmbientModule_test.go b/internal/fourslash/tests/gen/completionsImport_fromAmbientModule_test.go new file mode 100644 index 0000000000..e070b3e47f --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_fromAmbientModule_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_fromAmbientModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +declare module "m" { + export const x: number; +} +// @Filename: /b.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "m", + Description: "Add import from \"m\"", + NewFileContent: PtrTo(`import { x } from "m"; + +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_importType_test.go b/internal/fourslash/tests/gen/completionsImport_importType_test.go new file mode 100644 index 0000000000..b74932bcfa --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_importType_test.go @@ -0,0 +1,83 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_importType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +export const x = 0; +export class C {} +/** @typedef {number} T */ +// @Filename: /b.js +export const m = 0; +/** @type {/*0*/} */ +/** @type {/*1*/} */` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"0", "1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "C", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("class C"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "T", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("type T = number"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "x", + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "C", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { C } from "./a"; + +export const m = 0; +/** @type {} */ +/** @type {} */`), + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "T", + Source: "./a", + Description: "Change 'T' to 'import(\"./a\").T'", + NewFileContent: PtrTo(`import { C } from "./a"; + +export const m = 0; +/** @type {} */ +/** @type {import("./a").} */`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_jsxOpeningTagImportDefault_test.go b/internal/fourslash/tests/gen/completionsImport_jsxOpeningTagImportDefault_test.go new file mode 100644 index 0000000000..9a29a81114 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_jsxOpeningTagImportDefault_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_jsxOpeningTagImportDefault(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @jsx: react +// @Filename: /component.tsx +export default function (props: any) {} +// @Filename: /index.tsx +export function Index() { + return void; +declare const namedExport: () => void; + +export default defaultExport; +export { namedExport }; +// @Filename: /node_modules/example/dist/index.d.ts +export { default, namedExport } from "./nested/module"; +// @Filename: /index.mjs +import { namedExport } from "example"; +defaultExp/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsInJSPlus( + []fourslash.CompletionsExpectedItem{ + "namedExport", + &lsproto.CompletionItem{ + Label: "defaultExport", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "example", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_reExportDefault_test.go b/internal/fourslash/tests/gen/completionsImport_reExportDefault_test.go new file mode 100644 index 0000000000..e1a22cb24a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_reExportDefault_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_reExportDefault(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a/b/impl.ts +export default function foo() {} +// @Filename: /a/index.ts +export { default as foo } from "./b/impl"; +// @Filename: /use.ts +fo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("(alias) function foo(): void\nexport foo"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { foo } from "./a"; + +fo`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_reExport_wrongName_test.go b/internal/fourslash/tests/gen/completionsImport_reExport_wrongName_test.go new file mode 100644 index 0000000000..852fa9809b --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_reExport_wrongName_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_reExport_wrongName(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @Filename: /a.ts +export const x = 0; +// @Filename: /index.ts +export { x as y } from "./a"; +// @Filename: /c.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("const x: 0"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "y", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: ".", + }, + }, + Detail: PtrTo("(alias) const y: 0\nexport y"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { x } from "./a"; + +`), + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "y", + Source: ".", + Description: "Add import from \".\"", + NewFileContent: PtrTo(`import { y } from "."; +import { x } from "./a"; + +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_reexportTransient_test.go b/internal/fourslash/tests/gen/completionsImport_reexportTransient_test.go new file mode 100644 index 0000000000..c98d13c8c7 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_reexportTransient_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_reexportTransient(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @esModuleInterop: true +// @Filename: /transient.d.ts +declare const map: { [K in "one"]: number }; +export = map; +// @Filename: /r1.ts +export { one } from "./transient"; +// @Filename: /r2.ts +export { one } from "./r1"; +// @Filename: /index.ts +one/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "one", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./transient", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_require_addNew_test.go b/internal/fourslash/tests/gen/completionsImport_require_addNew_test.go new file mode 100644 index 0000000000..322627ab42 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_require_addNew_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_require_addNew(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +const x = 0; +module.exports = { x }; +// @Filename: /b.js +x/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("(alias) const x: 0\nimport x"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`const { x } = require("./a"); + +x`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_require_addToExisting_test.go b/internal/fourslash/tests/gen/completionsImport_require_addToExisting_test.go new file mode 100644 index 0000000000..d05a627f8d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_require_addToExisting_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_require_addToExisting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +const x = 0; +function f() {} +module.exports = { x, f }; +// @Filename: /b.js +const { f } = require("./a"); + +x/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("(alias) const x: 0\nimport x"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`const { f, x } = require("./a"); + +x`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_require_test.go b/internal/fourslash/tests/gen/completionsImport_require_test.go new file mode 100644 index 0000000000..00aab91f5b --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_require_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_require(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.js +import * as s from "something"; +fo/*b*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "b", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("const foo: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("b"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import * as s from "something"; +import { foo } from "./a"; +fo`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_sortingModuleSpecifiers_test.go b/internal/fourslash/tests/gen/completionsImport_sortingModuleSpecifiers_test.go new file mode 100644 index 0000000000..ce364ba799 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_sortingModuleSpecifiers_test.go @@ -0,0 +1,75 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_sortingModuleSpecifiers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: path.d.ts +declare module "path/posix" { + export function normalize(p: string): string; +} +declare module "path/win32" { + export function normalize(p: string): string; +} +declare module "path" { + export function normalize(p: string): string; +} +// @Filename: main.ts +normalize/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "normalize", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "path", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "normalize", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "path/posix", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "normalize", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "path/win32", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_tsx_test.go b/internal/fourslash/tests/gen/completionsImport_tsx_test.go new file mode 100644 index 0000000000..6e394a5bf3 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_tsx_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_tsx(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @jsx: preserve +// @Filename: /a.tsx +export type Bar = 0; +export default function Foo() {}; +// @Filename: /b.tsx +;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "Bar", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_typeOnly_test.go b/internal/fourslash/tests/gen/completionsImport_typeOnly_test.go new file mode 100644 index 0000000000..27d374d54e --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_typeOnly_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_typeOnly(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @moduleResolution: bundler +// @Filename: /a.ts +export class A {} +export class B {} +// @Filename: /b.ts +import type { A } from './a'; +const b: B/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "B", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import type { A, B } from './a'; +const b: B`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash1_test.go b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash1_test.go new file mode 100644 index 0000000000..6bc47c034c --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdDefaultNoCrash1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @allowJs: true +// @checkJs: true +// @Filename: /node_modules/dottie/package.json +{ + "name": "dottie", + "main": "dottie.js" +} +// @Filename: /node_modules/dottie/dottie.js +(function (undefined) { + var root = this; + + var Dottie = function () {}; + + Dottie["default"] = function (object, path, value) {}; + + if (typeof module !== "undefined" && module.exports) { + exports = module.exports = Dottie; + } else { + root["Dottie"] = Dottie; + root["Dot"] = Dottie; + + if (typeof define === "function") { + define([], function () { + return Dottie; + }); + } + } +})(); +// @Filename: /src/index.js +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Dottie", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "dottie", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go index 57ecd5cb67..64dc8a4459 100644 --- a/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go +++ b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go @@ -13,7 +13,7 @@ func TestCompletionsImport_umdDefaultNoCrash2(t *testing.T) { t.Parallel() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @allowJs: true // @checkJs: true // @Filename: /node_modules/dottie/package.json diff --git a/internal/fourslash/tests/gen/completionsImport_umdModules1_globalAccess_test.go b/internal/fourslash/tests/gen/completionsImport_umdModules1_globalAccess_test.go new file mode 100644 index 0000000000..331af0b944 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdModules1_globalAccess_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdModules1_globalAccess(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /package.json +{ "dependencies": { "@types/classnames": "*" } } +// @filename: /tsconfig.json +{ "compilerOptions": { "allowUmdGlobalAccess": true } } +// @filename: /node_modules/@types/classnames/package.json +{ "name": "@types/classnames", "types": "index.d.ts" } +// @filename: /node_modules/@types/classnames/index.d.ts +declare const classNames: () => string; +export = classNames; +export as namespace classNames; +// @filename: /SomeReactComponent.tsx +import * as React from 'react'; + +const el1 =
foo
;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "classNames", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdModules2_moduleExports_test.go b/internal/fourslash/tests/gen/completionsImport_umdModules2_moduleExports_test.go new file mode 100644 index 0000000000..78e7991f2d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdModules2_moduleExports_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdModules2_moduleExports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /package.json +{ "dependencies": { "@types/classnames": "*" } } +// @filename: /tsconfig.json +{} +// @filename: /node_modules/@types/classnames/package.json +{ "name": "@types/classnames", "types": "index.d.ts" } +// @filename: /node_modules/@types/classnames/index.d.ts +declare const classNames: () => string; +export = classNames; +export as namespace classNames; +// @filename: /SomeReactComponent.tsx +import * as React from 'react'; + +const el1 =
foo
;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "classNames", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "classnames", + }, + }, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdModules3_script_test.go b/internal/fourslash/tests/gen/completionsImport_umdModules3_script_test.go new file mode 100644 index 0000000000..f3781b3757 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdModules3_script_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdModules3_script(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /package.json +{ "dependencies": { "@types/classnames": "*" } } +// @filename: /tsconfig.json +{ "compilerOptions": { "module": "es2015" }} +// @filename: /node_modules/@types/classnames/package.json +{ "name": "@types/classnames", "types": "index.d.ts" } +// @filename: /node_modules/@types/classnames/index.d.ts +declare const classNames: () => string; +export = classNames; +export as namespace classNames; +// @filename: /SomeReactComponent.tsx + +const el1 =
foo
` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "classNames", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules1_test.go b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules1_test.go new file mode 100644 index 0000000000..7293d6799b --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules1_test.go @@ -0,0 +1,78 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_uriStyleNodeCoreModules1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /node_modules/@types/node/index.d.ts +declare module "fs" { function writeFile(): void } +declare module "fs/promises" { function writeFile(): Promise } +declare module "node:fs" { export * from "fs"; } +declare module "node:fs/promises" { export * from "fs/promises"; } +// @Filename: /index.ts +write/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "writeFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fs", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "node:fs", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fs/promises", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "node:fs/promises", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules2_test.go b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules2_test.go new file mode 100644 index 0000000000..cc1ebfc7d6 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules2_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_uriStyleNodeCoreModules2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /node_modules/@types/node/index.d.ts +declare module "fs" { function writeFile(): void } +declare module "fs/promises" { function writeFile(): Promise } +declare module "node:fs" { export * from "fs"; } +declare module "node:fs/promises" { export * from "fs/promises"; } +// @Filename: /other.ts +import "node:fs/promises"; +// @Filename: /index.ts +write/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "writeFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "node:fs", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "node:fs/promises", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_weirdDefaultSynthesis_test.go b/internal/fourslash/tests/gen/completionsImport_weirdDefaultSynthesis_test.go new file mode 100644 index 0000000000..5514308ba0 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_weirdDefaultSynthesis_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_weirdDefaultSynthesis(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /collection.ts +class Collection { + public static readonly default: typeof Collection = Collection; +} +export = Collection as typeof Collection & { default: typeof Collection }; +// @Filename: /index.ts +Colle/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Collection", + Source: "./collection", + Description: "Add import from \"./collection\"", + NewFileContent: PtrTo(`import Collection = require("./collection"); + +Colle`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_windowsPathsProjectRelative_test.go b/internal/fourslash/tests/gen/completionsImport_windowsPathsProjectRelative_test.go new file mode 100644 index 0000000000..c0acb25aa4 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_windowsPathsProjectRelative_test.go @@ -0,0 +1,131 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_windowsPathsProjectRelative(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: c:/project/tsconfig.json +{ + "compilerOptions": { + "paths": { + "~/noIndex/*": ["./src/noIndex/*"], + "~/withIndex": ["./src/withIndex/index.ts"] + } + } +} +// @Filename: c:/project/package.json +{} +// @Filename: c:/project/src/noIndex/a.ts +export const myFunctionA = () => {}; +// @Filename: c:/project/src/withIndex/b.ts +export const myFunctionB = () => {}; +// @Filename: c:/project/src/withIndex/index.ts +export * from './b'; +// @Filename: c:/project/src/reproduction/1.ts +myFunction/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myFunctionA", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "~/noIndex/a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "myFunctionB", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "~/withIndex", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myFunctionA", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "../noIndex/a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "myFunctionB", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "../withIndex", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myFunctionA", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "../noIndex/a", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "myFunctionB", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "../withIndex", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go b/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go index a66a4523b6..0da18ee5e1 100644 --- a/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go +++ b/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go @@ -12,7 +12,7 @@ func TestCompletionsPathsJsonModuleWithoutResolveJsonModule(t *testing.T) { t.Parallel() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @resolveJsonModule: false // @Filename: /project/test.json not read // @Filename: /project/index.ts diff --git a/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go b/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go index b713e79f35..bf86ca473b 100644 --- a/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go +++ b/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go @@ -13,7 +13,7 @@ func TestCompletionsPathsJsonModule(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @resolveJsonModule: true // @Filename: /project/node_modules/test.json not read diff --git a/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go b/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go index 98803f175d..48d174cad0 100644 --- a/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go +++ b/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go @@ -13,7 +13,7 @@ func TestCompletionsPathsRelativeJsonModule(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @resolveJsonModule: true // @Filename: /project/test.json not read diff --git a/internal/fourslash/tests/gen/completionsPaths_importType_test.go b/internal/fourslash/tests/gen/completionsPaths_importType_test.go index 3caae8585e..a0b677054e 100644 --- a/internal/fourslash/tests/gen/completionsPaths_importType_test.go +++ b/internal/fourslash/tests/gen/completionsPaths_importType_test.go @@ -14,7 +14,7 @@ func TestCompletionsPaths_importType(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true -// @moduleResolution: node +// @moduleResolution: bundler // @Filename: /ns.ts file content not read // @Filename: /node_modules/package/index.ts diff --git a/internal/fourslash/tests/gen/completionsRecommended_namespace_test.go b/internal/fourslash/tests/gen/completionsRecommended_namespace_test.go new file mode 100644 index 0000000000..2640c1b108 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsRecommended_namespace_test.go @@ -0,0 +1,92 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsRecommended_namespace(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /a.ts +export namespace Name { + export class C {} +} +export function f(c: Name.C) {} +f(new N/*a0*/); +f(new /*a1*/); +// @Filename: /b.ts +import { f } from "./a"; +f(new N/*b0*/); +f(new /*b1*/); +// @Filename: /c.ts +import * as alpha from "./a"; +alpha.f(new a/*c0*/); +alpha.f(new /*c1*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"a0", "a1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Name", + Detail: PtrTo("namespace Name"), + Kind: PtrTo(lsproto.CompletionItemKindModule), + Preselect: PtrTo(true), + }, + }, + }, + }) + f.VerifyCompletions(t, []string{"b0", "b1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Name", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + Detail: PtrTo("namespace Name"), + Kind: PtrTo(lsproto.CompletionItemKindModule), + AdditionalTextEdits: fourslash.AnyTextEdits, + Preselect: PtrTo(true), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, []string{"c0", "c1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "alpha", + Detail: PtrTo("import alpha"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + Preselect: PtrTo(true), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsUniqueSymbol_import_test.go b/internal/fourslash/tests/gen/completionsUniqueSymbol_import_test.go new file mode 100644 index 0000000000..66bb27cb0a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsUniqueSymbol_import_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsUniqueSymbol_import(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /globals.d.ts +declare const Symbol: () => symbol; +// @Filename: /a.ts +const privateSym = Symbol(); +export const publicSym = Symbol(); +export interface I { + [privateSym]: number; + [publicSym]: number; + [defaultPublicSym]: number; + n: number; +} +export const i: I; +// @Filename: /user.ts +import { i } from "./a"; +i[|./**/|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "n", + &lsproto.CompletionItem{ + Label: "publicSym", + InsertText: PtrTo("[publicSym]"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./a", + }, + }, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + AdditionalTextEdits: fourslash.AnyTextEdits, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "publicSym", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "publicSym", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import { i, publicSym } from "./a"; +i.;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsWithDeprecatedTag10_test.go b/internal/fourslash/tests/gen/completionsWithDeprecatedTag10_test.go new file mode 100644 index 0000000000..788d453490 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsWithDeprecatedTag10_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsWithDeprecatedTag10(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo.ts +/** @deprecated foo */ +export const foo = 0; +// @Filename: /index.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + Kind: PtrTo(lsproto.CompletionItemKindVariable), + SortText: PtrTo(string(ls.DeprecateSortText(ls.SortTextAutoImportSuggestions))), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go b/internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go deleted file mode 100644 index 3f86d91582..0000000000 --- a/internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package fourslash_test - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" - "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/testutil" -) - -func TestCompletionsWithDeprecatedTag9(t *testing.T) { - t.Parallel() - - defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @lib: dom -// @allowJs: true -// @Filename: globals.d.ts -/** @deprecated foo */ -declare var foo: string; -// @Filename: index.ts -class Foo { - foo: number; - m() { - foo/**/ - } -}` - f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ - IsIncomplete: false, - ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ - CommitCharacters: &DefaultCommitCharacters, - EditRange: Ignored, - }, - Items: &fourslash.CompletionsExpectedItems{ - Includes: []fourslash.CompletionsExpectedItem{ - &lsproto.CompletionItem{ - Label: "foo", - Kind: PtrTo(lsproto.CompletionItemKindVariable), - SortText: PtrTo(string(ls.DeprecateSortText(ls.SortTextGlobalsOrKeywords))), - }, - }, - }, - }) - f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ - IsIncomplete: false, - ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ - CommitCharacters: &DefaultCommitCharacters, - EditRange: Ignored, - }, - Items: &fourslash.CompletionsExpectedItems{}, - }) -} diff --git a/internal/fourslash/tests/gen/declarationMapGoToDefinition_test.go b/internal/fourslash/tests/gen/declarationMapGoToDefinition_test.go index 6778b87390..f60b2538e2 100644 --- a/internal/fourslash/tests/gen/declarationMapGoToDefinition_test.go +++ b/internal/fourslash/tests/gen/declarationMapGoToDefinition_test.go @@ -49,5 +49,6 @@ import * as mod from "./indexdef"; const instance = new mod.Foo(); instance.[|/*1*/methodName|]({member: 12});` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/declarationMapsGoToDefinitionRelativeSourceRoot_test.go b/internal/fourslash/tests/gen/declarationMapsGoToDefinitionRelativeSourceRoot_test.go index 83e31fd848..52a1d8b01b 100644 --- a/internal/fourslash/tests/gen/declarationMapsGoToDefinitionRelativeSourceRoot_test.go +++ b/internal/fourslash/tests/gen/declarationMapsGoToDefinitionRelativeSourceRoot_test.go @@ -49,5 +49,6 @@ import * as mod from "./out/indexdef"; const instance = new mod.Foo(); instance.[|/*1*/methodName|]({member: 12});` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/declarationMapsGoToDefinitionSameNameDifferentDirectory_test.go b/internal/fourslash/tests/gen/declarationMapsGoToDefinitionSameNameDifferentDirectory_test.go index f3272269c6..b990faf552 100644 --- a/internal/fourslash/tests/gen/declarationMapsGoToDefinitionSameNameDifferentDirectory_test.go +++ b/internal/fourslash/tests/gen/declarationMapsGoToDefinitionSameNameDifferentDirectory_test.go @@ -66,5 +66,6 @@ class Button extends [|/*1*/Control|] { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "3") + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToDefinition(t, true, "1", "3") } diff --git a/internal/fourslash/tests/gen/declarationMapsOutOfDateMapping_test.go b/internal/fourslash/tests/gen/declarationMapsOutOfDateMapping_test.go index 9f9069abc7..6949f56815 100644 --- a/internal/fourslash/tests/gen/declarationMapsOutOfDateMapping_test.go +++ b/internal/fourslash/tests/gen/declarationMapsOutOfDateMapping_test.go @@ -33,6 +33,7 @@ export class /*2*/Foo { // @Filename: /home/src/workspaces/project/index.ts import { Foo/*1*/ } from "a";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToFile(t, "/home/src/workspaces/project/index.ts") - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/declareFunction_test.go b/internal/fourslash/tests/gen/declareFunction_test.go new file mode 100644 index 0000000000..84d8b17e64 --- /dev/null +++ b/internal/fourslash/tests/gen/declareFunction_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDeclareFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: index.ts +declare function` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{}), + }, + }) +} diff --git a/internal/fourslash/tests/gen/definition01_test.go b/internal/fourslash/tests/gen/definition01_test.go index e10e638c24..028a8aa391 100644 --- a/internal/fourslash/tests/gen/definition01_test.go +++ b/internal/fourslash/tests/gen/definition01_test.go @@ -17,5 +17,6 @@ var x = new n.Foo(); // @Filename: a.ts /*2*/export class Foo {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/definitionNameOnEnumMember_test.go b/internal/fourslash/tests/gen/definitionNameOnEnumMember_test.go index 2d65c70c52..99bd19b1f1 100644 --- a/internal/fourslash/tests/gen/definitionNameOnEnumMember_test.go +++ b/internal/fourslash/tests/gen/definitionNameOnEnumMember_test.go @@ -18,5 +18,5 @@ func TestDefinitionNameOnEnumMember(t *testing.T) { } var enumMember = e.[|/*1*/thirdMember|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/definition_test.go b/internal/fourslash/tests/gen/definition_test.go index da810012be..4c0d633dbf 100644 --- a/internal/fourslash/tests/gen/definition_test.go +++ b/internal/fourslash/tests/gen/definition_test.go @@ -17,5 +17,5 @@ var x = new n.Foo(); // @Filename: a.ts /*2*/export class Foo {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/documentHighlights01_test.go b/internal/fourslash/tests/gen/documentHighlights01_test.go index 27c28183c0..6e3c9c188a 100644 --- a/internal/fourslash/tests/gen/documentHighlights01_test.go +++ b/internal/fourslash/tests/gen/documentHighlights01_test.go @@ -17,5 +17,6 @@ function [|f|](x: typeof [|f|]) { [|f|]([|f|]); }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) } diff --git a/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go b/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go index 8eee5defce..ec6bef6214 100644 --- a/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go +++ b/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go @@ -15,5 +15,6 @@ func TestDocumentHighlightsTypeParameterInHeritageClause01(t *testing.T) { const content = `interface I<[|T|]> extends I<[|T|]>, [|T|] { }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) } diff --git a/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go b/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go index 32f1db0ff0..b610460f44 100644 --- a/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go +++ b/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go @@ -13,7 +13,7 @@ func TestExportEqualNamespaceClassESModuleInterop(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @esModuleInterop: true -// @moduleResolution: node +// @moduleResolution: bundler // @target: es2015 // @module: esnext // @Filename: /node_modules/@bar/foo/index.d.ts diff --git a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go index f41ebfe43a..85578f9b73 100644 --- a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go +++ b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsForDefaultExport03(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `/*1*/function /*2*/f() { return 100; diff --git a/internal/fourslash/tests/gen/findAllRefsForDefaultExport_test.go b/internal/fourslash/tests/gen/findAllRefsForDefaultExport_test.go index 5354788ffc..7f4520786e 100644 --- a/internal/fourslash/tests/gen/findAllRefsForDefaultExport_test.go +++ b/internal/fourslash/tests/gen/findAllRefsForDefaultExport_test.go @@ -20,5 +20,5 @@ import /*deg*/g from "./a"; import { f } from "./a";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyBaselineFindAllReferences(t, "def", "deg") - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/findAllRefsForModule_test.go b/internal/fourslash/tests/gen/findAllRefsForModule_test.go index f0f4d2f456..fef3dab43e 100644 --- a/internal/fourslash/tests/gen/findAllRefsForModule_test.go +++ b/internal/fourslash/tests/gen/findAllRefsForModule_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsForModule(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true // @Filename: /a.ts diff --git a/internal/fourslash/tests/gen/findAllRefsModuleDotExports_test.go b/internal/fourslash/tests/gen/findAllRefsModuleDotExports_test.go index e2fa622891..97fa6533ec 100644 --- a/internal/fourslash/tests/gen/findAllRefsModuleDotExports_test.go +++ b/internal/fourslash/tests/gen/findAllRefsModuleDotExports_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsModuleDotExports(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true // @Filename: /a.js diff --git a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go index b219b100e5..d12c4f724b 100644 --- a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go +++ b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go @@ -11,7 +11,7 @@ func TestFindReferencesBindingPatternInJsdocNoCrash1(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @Filename: node_modules/use-query/package.json { "name": "use-query", diff --git a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go index 1fcafea499..94b4584713 100644 --- a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go +++ b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go @@ -11,7 +11,7 @@ func TestFindReferencesBindingPatternInJsdocNoCrash2(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @Filename: node_modules/use-query/package.json { "name": "use-query", diff --git a/internal/fourslash/tests/gen/getJavaScriptCompletions18_test.go b/internal/fourslash/tests/gen/getJavaScriptCompletions18_test.go index c03b46a66e..030b5a5442 100644 --- a/internal/fourslash/tests/gen/getJavaScriptCompletions18_test.go +++ b/internal/fourslash/tests/gen/getJavaScriptCompletions18_test.go @@ -11,7 +11,7 @@ import ( func TestGetJavaScriptCompletions18(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowNonTsExtensions: true // @Filename: file.js diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics01_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics01_test.go new file mode 100644 index 0000000000..989e0903c2 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics01_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +var ===;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics02_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics02_test.go new file mode 100644 index 0000000000..2a52729b9b --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics02_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: b.js +var a = "a"; +var b: boolean = true; +function foo(): string { } +var var = "c";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics10_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics10_test.go new file mode 100644 index 0000000000..c1ac23aa81 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics10_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics10(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function F() { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics11_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics11_test.go new file mode 100644 index 0000000000..875e0aac31 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics11_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics11(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function F(): number { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics12_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics12_test.go new file mode 100644 index 0000000000..cba5db238b --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics12_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics12(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +declare var v;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics13_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics13_test.go new file mode 100644 index 0000000000..bd51a808fc --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics13_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics13(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +var v: () => number;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics14_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics14_test.go new file mode 100644 index 0000000000..932818ae6e --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics14_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics14(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +Foo();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics15_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics15_test.go new file mode 100644 index 0000000000..c9c1f4f91d --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics15_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics15(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function F(public p) { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics16_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics16_test.go new file mode 100644 index 0000000000..826fac6510 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics16_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics16(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function F(p?) { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics17_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics17_test.go new file mode 100644 index 0000000000..b5ec3bcea3 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics17_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics17(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function F(a: number) { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics18_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics18_test.go new file mode 100644 index 0000000000..f8c1dbd261 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics18_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics18(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +class C { + x; // Regular property declaration allowed + static y; // static allowed + public z; // public not allowed +} +// @Filename: b.js +class C { + x: number; // Types not allowed +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics19_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics19_test.go new file mode 100644 index 0000000000..5df7a2c35e --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics19_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics19(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +enum E { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics1_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics1_test.go new file mode 100644 index 0000000000..e0ea67f04b --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +import a = b;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics21_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics21_test.go new file mode 100644 index 0000000000..639cb7e585 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics21_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics21(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @experimentalDecorators: true +// @Filename: a.js +@internal class C {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics22_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics22_test.go new file mode 100644 index 0000000000..59b854c310 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics22_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics22(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function foo(...a) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics23_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics23_test.go new file mode 100644 index 0000000000..9d77d39070 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics23_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics23(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +function Person(age) { + if (age >= 18) { + this.canVote = true; + } else { + this.canVote = false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNonSuggestionDiagnostics(t, nil) + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics2_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics2_test.go new file mode 100644 index 0000000000..9597a92036 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +export = b;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics3_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics3_test.go new file mode 100644 index 0000000000..8551aec682 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics3_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +class C { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics4_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics4_test.go new file mode 100644 index 0000000000..b1179f5639 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics4_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +public class C { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics5_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics5_test.go new file mode 100644 index 0000000000..b19508d1fe --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics5_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +class C implements D { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics6_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics6_test.go new file mode 100644 index 0000000000..57aeba6777 --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics6_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +interface I { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics7_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics7_test.go new file mode 100644 index 0000000000..6b1228203d --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics7_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +module M { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics8_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics8_test.go new file mode 100644 index 0000000000..103fd7542e --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics8_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +type a = b;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics9_test.go b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics9_test.go new file mode 100644 index 0000000000..4ac13df47f --- /dev/null +++ b/internal/fourslash/tests/gen/getJavaScriptSyntacticDiagnostics9_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetJavaScriptSyntacticDiagnostics9(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +public function F() { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/getQuickInfoForIntersectionTypes_test.go b/internal/fourslash/tests/gen/getQuickInfoForIntersectionTypes_test.go index d3d68ddc6b..fb71b8925f 100644 --- a/internal/fourslash/tests/gen/getQuickInfoForIntersectionTypes_test.go +++ b/internal/fourslash/tests/gen/getQuickInfoForIntersectionTypes_test.go @@ -9,7 +9,7 @@ import ( func TestGetQuickInfoForIntersectionTypes(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `function f(): string & {(): any} { return {}; diff --git a/internal/fourslash/tests/gen/goToDefinitionAcrossMultipleProjects_test.go b/internal/fourslash/tests/gen/goToDefinitionAcrossMultipleProjects_test.go index 7671b9344a..bd055de68b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAcrossMultipleProjects_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAcrossMultipleProjects_test.go @@ -26,5 +26,5 @@ var /*def4*/x: number; /// [|/*use*/x|]++;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, true, "use") } diff --git a/internal/fourslash/tests/gen/goToDefinitionAlias_test.go b/internal/fourslash/tests/gen/goToDefinitionAlias_test.go index 56d94b0b7d..87f03b311f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAlias_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAlias_test.go @@ -32,5 +32,5 @@ export interface IFoo { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "alias1Type", "alias1Value", "alias2Type", "alias2Value") + f.VerifyBaselineGoToDefinition(t, true, "alias1Type", "alias1Value", "alias2Type", "alias2Value") } diff --git a/internal/fourslash/tests/gen/goToDefinitionAmbiants_test.go b/internal/fourslash/tests/gen/goToDefinitionAmbiants_test.go index bacf157695..2b86e09ccc 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAmbiants_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAmbiants_test.go @@ -25,5 +25,5 @@ var ambientClassVariable = new /*constructorReference*/ambientClass(); ambientClass./*staticMethodReference*/method(); ambientClassVariable./*instanceMethodReference*/method();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "ambientVariableReference", "ambientFunctionReference", "constructorReference", "staticMethodReference", "instanceMethodReference") + f.VerifyBaselineGoToDefinition(t, false, "ambientVariableReference", "ambientFunctionReference", "constructorReference", "staticMethodReference", "instanceMethodReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionApparentTypeProperties_test.go b/internal/fourslash/tests/gen/goToDefinitionApparentTypeProperties_test.go index 857642a5f0..91d37e6a55 100644 --- a/internal/fourslash/tests/gen/goToDefinitionApparentTypeProperties_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionApparentTypeProperties_test.go @@ -19,5 +19,5 @@ var o = 0; o.[|/*reference1*/myObjectMethod|](); o[[|"/*reference2*/myObjectMethod"|]]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "reference1", "reference2") + f.VerifyBaselineGoToDefinition(t, true, "reference1", "reference2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionAwait1_test.go b/internal/fourslash/tests/gen/goToDefinitionAwait1_test.go index 3ae2f4cc4f..b3a3aa3a56 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAwait1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAwait1_test.go @@ -18,5 +18,5 @@ function notAsync() { [|/*start2*/await|] Promise.resolve(0); }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start1", "start2") + f.VerifyBaselineGoToDefinition(t, true, "start1", "start2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionAwait2_test.go b/internal/fourslash/tests/gen/goToDefinitionAwait2_test.go index ad1366db62..e379aaea9d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAwait2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAwait2_test.go @@ -13,5 +13,5 @@ func TestGoToDefinitionAwait2(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `[|/*start*/await|] Promise.resolve(0);` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionAwait3_test.go b/internal/fourslash/tests/gen/goToDefinitionAwait3_test.go index c6e4aa643d..9add48227b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAwait3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAwait3_test.go @@ -21,5 +21,5 @@ func TestGoToDefinitionAwait3(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start1", "start2") + f.VerifyBaselineGoToDefinition(t, true, "start1", "start2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionAwait4_test.go b/internal/fourslash/tests/gen/goToDefinitionAwait4_test.go index c7223d838f..279ad03ad4 100644 --- a/internal/fourslash/tests/gen/goToDefinitionAwait4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionAwait4_test.go @@ -17,5 +17,5 @@ func TestGoToDefinitionAwait4(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionBuiltInTypes_test.go b/internal/fourslash/tests/gen/goToDefinitionBuiltInTypes_test.go index 946765d934..5d393d3ad1 100644 --- a/internal/fourslash/tests/gen/goToDefinitionBuiltInTypes_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionBuiltInTypes_test.go @@ -16,5 +16,5 @@ var s: /*string*/string; var b: /*boolean*/boolean; var v: /*void*/void;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, f.MarkerNames()...) + f.VerifyBaselineGoToDefinition(t, true, f.MarkerNames()...) } diff --git a/internal/fourslash/tests/gen/goToDefinitionBuiltInValues_test.go b/internal/fourslash/tests/gen/goToDefinitionBuiltInValues_test.go index b2ab6600fe..a148d6f854 100644 --- a/internal/fourslash/tests/gen/goToDefinitionBuiltInValues_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionBuiltInValues_test.go @@ -17,5 +17,5 @@ var a = function() { return /*arguments*/arguments; }; var t = /*true*/true; var f = /*false*/false;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, f.MarkerNames()...) + f.VerifyBaselineGoToDefinition(t, true, f.MarkerNames()...) } diff --git a/internal/fourslash/tests/gen/goToDefinitionCSSPatternAmbientModule_test.go b/internal/fourslash/tests/gen/goToDefinitionCSSPatternAmbientModule_test.go index df138a37ce..55ce3265cb 100644 --- a/internal/fourslash/tests/gen/goToDefinitionCSSPatternAmbientModule_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionCSSPatternAmbientModule_test.go @@ -22,5 +22,5 @@ declare module /*2b*/"*.css" { // @Filename: index.ts import styles from [|/*1*/"./index.css"|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionClassConstructors_test.go b/internal/fourslash/tests/gen/goToDefinitionClassConstructors_test.go index 62149ecf3e..a5d127909e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionClassConstructors_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionClassConstructors_test.go @@ -38,5 +38,5 @@ class HasConstructor extends Base { } const hasConstructor = new [|/*HasConstructor*/HasConstructor|](cArg)` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "Derived", "SameFile", "HasConstructor", "Base") + f.VerifyBaselineGoToDefinition(t, true, "Derived", "SameFile", "HasConstructor", "Base") } diff --git a/internal/fourslash/tests/gen/goToDefinitionClassStaticBlocks_test.go b/internal/fourslash/tests/gen/goToDefinitionClassStaticBlocks_test.go index ec829346ca..42a7db9bfe 100644 --- a/internal/fourslash/tests/gen/goToDefinitionClassStaticBlocks_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionClassStaticBlocks_test.go @@ -20,5 +20,5 @@ func TestGoToDefinitionClassStaticBlocks(t *testing.T) { [|/*classStaticBocks3*/static|] {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classStaticBocks1", "classStaticBocks2", "classStaticBocks3") + f.VerifyBaselineGoToDefinition(t, true, "classStaticBocks1", "classStaticBocks2", "classStaticBocks3") } diff --git a/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassExpression01_test.go b/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassExpression01_test.go index 7715ab45fd..88657cd398 100644 --- a/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassExpression01_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassExpression01_test.go @@ -34,5 +34,5 @@ var x2 = new [|/*xref*/x|](); var y1 = new [|/*yref*/y|](); var z1 = new [|/*zref*/z|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "xusage", "yusage", "zusage", "cref", "xref", "yref", "zref") + f.VerifyBaselineGoToDefinition(t, true, "xusage", "yusage", "zusage", "cref", "xref", "yref", "zref") } diff --git a/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01_test.go b/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01_test.go index 588532109d..88538f729d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01_test.go @@ -22,5 +22,5 @@ class Foo { var x = new [|/*usage*/Foo|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "usage") + f.VerifyBaselineGoToDefinition(t, true, "usage") } diff --git a/internal/fourslash/tests/gen/goToDefinitionConstructorOverloads_test.go b/internal/fourslash/tests/gen/goToDefinitionConstructorOverloads_test.go index 12d54e2570..57ef6ad7e4 100644 --- a/internal/fourslash/tests/gen/goToDefinitionConstructorOverloads_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionConstructorOverloads_test.go @@ -26,5 +26,5 @@ class Extended extends ConstructorOverload { var extended1 = new [|/*extendedRef1*/Extended|](); var extended2 = new [|/*extendedRef2*/Extended|]("foo");` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "constructorOverloadReference1", "constructorOverloadReference2", "constructorOverload1", "extendedRef1", "extendedRef2") + f.VerifyBaselineGoToDefinition(t, true, "constructorOverloadReference1", "constructorOverloadReference2", "constructorOverload1", "extendedRef1", "extendedRef2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDecoratorOverloads_test.go b/internal/fourslash/tests/gen/goToDefinitionDecoratorOverloads_test.go index 7e28fa62db..2acc7737ef 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDecoratorOverloads_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDecoratorOverloads_test.go @@ -25,5 +25,5 @@ class C { @[|/*useDecSymbol*/dec|] [s]() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "useDecString", "useDecSymbol") + f.VerifyBaselineGoToDefinition(t, true, "useDecString", "useDecSymbol") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDecorator_test.go b/internal/fourslash/tests/gen/goToDefinitionDecorator_test.go index b780378149..05eaf7abfd 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDecorator_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDecorator_test.go @@ -25,5 +25,5 @@ function /*decoratorFactoryDefinition*/decoratorFactory(...args) { return target => target; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "decoratorUse", "decoratorFactoryUse") + f.VerifyBaselineGoToDefinition(t, true, "decoratorUse", "decoratorFactoryUse") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire1_test.go b/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire1_test.go index dba2ca82ba..7b12756c0b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire1_test.go @@ -19,5 +19,5 @@ module.exports = { Util }; const { Util } = require('./util'); new [|Util/*1*/|]()` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire2_test.go b/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire2_test.go index faac04960c..8b5eb51d0a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDestructuredRequire2_test.go @@ -22,5 +22,5 @@ module.exports = { Util }; const { Util } = require('./reexport'); new [|Util/*1*/|]()` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDifferentFileIndirectly_test.go b/internal/fourslash/tests/gen/goToDefinitionDifferentFileIndirectly_test.go index 625731a5f7..8998b76a20 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDifferentFileIndirectly_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDifferentFileIndirectly_test.go @@ -30,5 +30,5 @@ var rem2foo = new /*remoteClassReference*/rem2Cls(); class rem2fooCls implements /*remoteInterfaceReference*/rem2Int { } var rem2fooVar = /*remoteModuleReference*/rem2Mod.foo;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "remoteVariableReference", "remoteFunctionReference", "remoteClassReference", "remoteInterfaceReference", "remoteModuleReference") + f.VerifyBaselineGoToDefinition(t, false, "remoteVariableReference", "remoteFunctionReference", "remoteClassReference", "remoteInterfaceReference", "remoteModuleReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDifferentFile_test.go b/internal/fourslash/tests/gen/goToDefinitionDifferentFile_test.go index 51332093e5..566569628f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDifferentFile_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDifferentFile_test.go @@ -24,5 +24,5 @@ var foo = new /*remoteClassReference*/remoteClass(); class fooCls implements /*remoteInterfaceReference*/remoteInterface { } var fooVar = /*remoteModuleReference*/remoteModule.foo;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "remoteVariableReference", "remoteFunctionReference", "remoteClassReference", "remoteInterfaceReference", "remoteModuleReference") + f.VerifyBaselineGoToDefinition(t, false, "remoteVariableReference", "remoteFunctionReference", "remoteClassReference", "remoteInterfaceReference", "remoteModuleReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDynamicImport1_test.go b/internal/fourslash/tests/gen/goToDefinitionDynamicImport1_test.go index 6a7d91b094..4db84ced2f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDynamicImport1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDynamicImport1_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionDynamicImport1(t *testing.T) { import([|"./f/*1*/oo"|]) var x = import([|"./fo/*2*/o"|])` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2") + f.VerifyBaselineGoToDefinition(t, true, "1", "2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDynamicImport2_test.go b/internal/fourslash/tests/gen/goToDefinitionDynamicImport2_test.go index 9806c5971c..431778c2a0 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDynamicImport2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDynamicImport2_test.go @@ -18,5 +18,5 @@ x.then(foo => { foo.[|b/*1*/ar|](); })` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDynamicImport3_test.go b/internal/fourslash/tests/gen/goToDefinitionDynamicImport3_test.go index f9fa8665d9..745450597a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDynamicImport3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDynamicImport3_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionDynamicImport3(t *testing.T) { export function /*Destination*/bar() { return "bar"; } import('./foo').then(({ [|ba/*1*/r|] }) => undefined);` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionDynamicImport4_test.go b/internal/fourslash/tests/gen/goToDefinitionDynamicImport4_test.go index 3413aec057..7a5fc69e4a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionDynamicImport4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionDynamicImport4_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionDynamicImport4(t *testing.T) { export function /*Destination*/bar() { return "bar"; } import('./foo').then(({ [|ba/*1*/r|] }) => undefined);` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExpandoClass1_test.go b/internal/fourslash/tests/gen/goToDefinitionExpandoClass1_test.go index c97ebc43d2..c93d1e7791 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExpandoClass1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExpandoClass1_test.go @@ -23,5 +23,5 @@ Core.Test.prototype.foo = 10 new Core.Tes/*1*/t()` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExpandoClass2_test.go b/internal/fourslash/tests/gen/goToDefinitionExpandoClass2_test.go index 58dcfd634f..b317a621fb 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExpandoClass2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExpandoClass2_test.go @@ -25,5 +25,5 @@ Core.Test.prototype.foo = 10 new Core.Tes/*1*/t()` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExpandoElementAccess_test.go b/internal/fourslash/tests/gen/goToDefinitionExpandoElementAccess_test.go index 1986ceaf57..2206f94f7e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExpandoElementAccess_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExpandoElementAccess_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionExpandoElementAccess(t *testing.T) { f[/*0*/"x"] = 0; f[[|/*1*/"x"|]] = 1;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName2_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName2_test.go index 5cc4923261..90cb5b0927 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName2_test.go @@ -18,5 +18,5 @@ var x = new n.Foo(); /*2*/class Foo {} export var x = 0;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName3_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName3_test.go index 0957b2764f..29beb808bb 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName3_test.go @@ -19,5 +19,5 @@ declare module /*2*/"e" { class Foo { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName4_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName4_test.go index a812039c94..0e8a6ea29c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName4_test.go @@ -14,5 +14,5 @@ func TestGoToDefinitionExternalModuleName4(t *testing.T) { const content = `// @Filename: b.ts import n = require('unknown/*1*/');` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName5_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName5_test.go index 8ecbe769c8..8df98a9bda 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName5_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName5_test.go @@ -16,5 +16,5 @@ declare module /*2*/[|"external/*1*/"|] { class Foo { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName6_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName6_test.go index 608c8a9dd3..2944a40028 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName6_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName6_test.go @@ -18,5 +18,5 @@ declare module /*2*/"e" { class Foo { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName7_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName7_test.go index 7d6cd491c0..ae6f4ba0ba 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName7_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName7_test.go @@ -18,5 +18,5 @@ declare module /*2*/"e" { class Foo { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName8_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName8_test.go index bcc2d5e23a..61e7a1c269 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName8_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName8_test.go @@ -18,5 +18,5 @@ declare module /*2*/"e" { class Foo { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName9_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName9_test.go index 2c6e7cb655..56947b3d6e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName9_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName9_test.go @@ -18,5 +18,5 @@ declare module /*2*/"e" { class Foo { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName_test.go b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName_test.go index c8e0124f9c..816c83a2b2 100644 --- a/internal/fourslash/tests/gen/goToDefinitionExternalModuleName_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionExternalModuleName_test.go @@ -17,5 +17,5 @@ var x = new n.Foo(); // @Filename: a.ts /*2*/export class Foo {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionFunctionOverloadsInClass_test.go b/internal/fourslash/tests/gen/goToDefinitionFunctionOverloadsInClass_test.go index 044908790c..0855e7cb77 100644 --- a/internal/fourslash/tests/gen/goToDefinitionFunctionOverloadsInClass_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionFunctionOverloadsInClass_test.go @@ -22,5 +22,5 @@ func TestGoToDefinitionFunctionOverloadsInClass(t *testing.T) { constructor() { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "staticFunctionOverload", "functionOverload") + f.VerifyBaselineGoToDefinition(t, true, "staticFunctionOverload", "functionOverload") } diff --git a/internal/fourslash/tests/gen/goToDefinitionFunctionOverloads_test.go b/internal/fourslash/tests/gen/goToDefinitionFunctionOverloads_test.go index ac12c5fcbc..0b5b5863ba 100644 --- a/internal/fourslash/tests/gen/goToDefinitionFunctionOverloads_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionFunctionOverloads_test.go @@ -19,5 +19,5 @@ function /*functionOverloadDefinition*/functionOverload() {} [|/*functionOverloadReference2*/functionOverload|]("123"); [|/*brokenOverload*/functionOverload|]({});` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "functionOverloadReference1", "functionOverloadReference2", "brokenOverload", "functionOverload1") + f.VerifyBaselineGoToDefinition(t, true, "functionOverloadReference1", "functionOverloadReference2", "brokenOverload", "functionOverload1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionFunctionType_test.go b/internal/fourslash/tests/gen/goToDefinitionFunctionType_test.go index 51e1cdd877..6ba869bdfa 100644 --- a/internal/fourslash/tests/gen/goToDefinitionFunctionType_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionFunctionType_test.go @@ -23,5 +23,5 @@ class C { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "constReference", "cbReference", "propReference") + f.VerifyBaselineGoToDefinition(t, false, "constReference", "cbReference", "propReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImplicitConstructor_test.go b/internal/fourslash/tests/gen/goToDefinitionImplicitConstructor_test.go index b2b03257ce..9590dabe9a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImplicitConstructor_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImplicitConstructor_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionImplicitConstructor(t *testing.T) { } var implicitConstructor = new /*constructorReference*/ImplicitConstructor();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "constructorReference") + f.VerifyBaselineGoToDefinition(t, false, "constructorReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImport1_test.go b/internal/fourslash/tests/gen/goToDefinitionImport1_test.go index a824e8a200..dc9eafb975 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImport1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImport1_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionImport1(t *testing.T) { // @Filename: /a.ts import { foo } from [|"./b/*1*/"|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImport2_test.go b/internal/fourslash/tests/gen/goToDefinitionImport2_test.go index b3ea5fc5b4..ecb593aba7 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImport2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImport2_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionImport2(t *testing.T) { // @Filename: /a.ts import { foo } [|from/*1*/|] "./b";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImport3_test.go b/internal/fourslash/tests/gen/goToDefinitionImport3_test.go index 55461f1e4a..9b01e696a2 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImport3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImport3_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionImport3(t *testing.T) { // @Filename: /a.ts import { foo } [|from /*1*/|] "./b";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames10_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames10_test.go index 075938ada7..fd749c8a60 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames10_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames10_test.go @@ -21,5 +21,5 @@ func TestGoToDefinitionImportedNames10(t *testing.T) { const { Class } = require("./a"); [|/*classAliasDefinition*/Class|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames11_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames11_test.go index 37fb3acd9f..b6c0764d7d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames11_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames11_test.go @@ -21,5 +21,5 @@ func TestGoToDefinitionImportedNames11(t *testing.T) { const { Class } = require("./a"); [|/*classAliasDefinition*/Class|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames2_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames2_test.go index 1a7ef5318c..fbdb46692d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames2_test.go @@ -23,5 +23,5 @@ export interface Interface { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames3_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames3_test.go index 78c83de203..4b93f3320d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames3_test.go @@ -30,5 +30,5 @@ export interface Interface { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classReference", "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classReference", "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames4_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames4_test.go index 06e1b0f791..55dc5400de 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames4_test.go @@ -23,5 +23,5 @@ export interface Interface { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames5_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames5_test.go index 37f88b26a2..411b5656ed 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames5_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames5_test.go @@ -23,5 +23,5 @@ export interface Interface { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames6_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames6_test.go index 29446fac49..5442d4e15c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames6_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames6_test.go @@ -23,5 +23,5 @@ export interface Interface { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "moduleAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "moduleAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames7_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames7_test.go index 9da2326429..b6b09e8b56 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames7_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames7_test.go @@ -19,5 +19,5 @@ class /*classDefinition*/Class { } export default Class;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames8_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames8_test.go index f07ea9ac00..8920b3f599 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames8_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames8_test.go @@ -20,5 +20,5 @@ class /*classDefinition*/Class { } export { Class };` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames9_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames9_test.go index 80b3ab7df8..b359cb5984 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames9_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames9_test.go @@ -21,5 +21,5 @@ class /*classDefinition*/Class { const { Class } = require("./a"); [|/*classAliasDefinition*/Class|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImportedNames_test.go b/internal/fourslash/tests/gen/goToDefinitionImportedNames_test.go index 27977d1dda..bd149489aa 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImportedNames_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImportedNames_test.go @@ -23,5 +23,5 @@ export interface Interface { x; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "classAliasDefinition") + f.VerifyBaselineGoToDefinition(t, true, "classAliasDefinition") } diff --git a/internal/fourslash/tests/gen/goToDefinitionImports_test.go b/internal/fourslash/tests/gen/goToDefinitionImports_test.go index 694524fe0b..4e25cab13d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionImports_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionImports_test.go @@ -26,5 +26,5 @@ import b = require("./b"); [|/*aUse*/a|]; [|/*bUse*/b|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "aUse", "fUse", "xUse", "bUse") + f.VerifyBaselineGoToDefinition(t, true, "aUse", "fUse", "xUse", "bUse") } diff --git a/internal/fourslash/tests/gen/goToDefinitionInMemberDeclaration_test.go b/internal/fourslash/tests/gen/goToDefinitionInMemberDeclaration_test.go index d5d42c1853..f80f956c89 100644 --- a/internal/fourslash/tests/gen/goToDefinitionInMemberDeclaration_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionInMemberDeclaration_test.go @@ -30,5 +30,5 @@ class /*selfDefinition*/Bar { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "interfaceReference", "interfaceReferenceInList", "interfaceReferenceInConstructor", "classReference", "classReferenceInInitializer", "enumReference", "enumReferenceInInitializer", "selfReference") + f.VerifyBaselineGoToDefinition(t, true, "interfaceReference", "interfaceReferenceInList", "interfaceReferenceInConstructor", "classReference", "classReferenceInInitializer", "enumReference", "enumReferenceInInitializer", "selfReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionInTypeArgument_test.go b/internal/fourslash/tests/gen/goToDefinitionInTypeArgument_test.go index 6457ad27fc..e5b8f3b6fd 100644 --- a/internal/fourslash/tests/gen/goToDefinitionInTypeArgument_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionInTypeArgument_test.go @@ -17,5 +17,5 @@ class /*barDefinition*/Bar { } var x = new Fo/*fooReference*/o();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "barReference", "fooReference") + f.VerifyBaselineGoToDefinition(t, false, "barReference", "fooReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionIndexSignature2_test.go b/internal/fourslash/tests/gen/goToDefinitionIndexSignature2_test.go index e851516382..5403b58416 100644 --- a/internal/fourslash/tests/gen/goToDefinitionIndexSignature2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionIndexSignature2_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionIndexSignature2(t *testing.T) { const o = {}; o.[|/*use*/foo|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, true, "use") } diff --git a/internal/fourslash/tests/gen/goToDefinitionIndexSignature_test.go b/internal/fourslash/tests/gen/goToDefinitionIndexSignature_test.go index 1cf112a5dd..d56a427de3 100644 --- a/internal/fourslash/tests/gen/goToDefinitionIndexSignature_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionIndexSignature_test.go @@ -30,5 +30,5 @@ k.[|/*usea*/a|]; k.[|/*useb*/b|]; k.[|/*useab*/ab|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "useI", "useIJ", "usea", "useb", "useab") + f.VerifyBaselineGoToDefinition(t, true, "useI", "useIJ", "usea", "useb", "useab") } diff --git a/internal/fourslash/tests/gen/goToDefinitionInstanceof1_test.go b/internal/fourslash/tests/gen/goToDefinitionInstanceof1_test.go index 6f8a5f90ef..0bf6c1d723 100644 --- a/internal/fourslash/tests/gen/goToDefinitionInstanceof1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionInstanceof1_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionInstanceof1(t *testing.T) { declare var obj: any; obj [|/*start*/instanceof|] C;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionInstanceof2_test.go b/internal/fourslash/tests/gen/goToDefinitionInstanceof2_test.go index caa38a204e..1d66b01a1c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionInstanceof2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionInstanceof2_test.go @@ -19,5 +19,5 @@ class C { declare var obj: any; obj [|/*start*/instanceof|] C;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionInterfaceAfterImplement_test.go b/internal/fourslash/tests/gen/goToDefinitionInterfaceAfterImplement_test.go index b7603fbfaa..7b94e788c3 100644 --- a/internal/fourslash/tests/gen/goToDefinitionInterfaceAfterImplement_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionInterfaceAfterImplement_test.go @@ -22,5 +22,5 @@ class iClass implements /*interfaceReference*/sInt { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "interfaceReference") + f.VerifyBaselineGoToDefinition(t, false, "interfaceReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag1_test.go b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag1_test.go index 44ba7f81a3..d2411d9b58 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag1_test.go @@ -20,5 +20,5 @@ func TestGoToDefinitionJsDocImportTag1(t *testing.T) { * @import { A } from [|"./b/*1*/"|] */` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag2_test.go b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag2_test.go index 75cd42c9e3..3dddb6a70b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag2_test.go @@ -20,5 +20,5 @@ func TestGoToDefinitionJsDocImportTag2(t *testing.T) { * @import { A } [|from/*1*/|] "./b" */` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag3_test.go b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag3_test.go index 64d6d8fccd..3cdf25492b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag3_test.go @@ -20,5 +20,5 @@ func TestGoToDefinitionJsDocImportTag3(t *testing.T) { * @import { A } [|from /*1*/|] "./b"; */` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag4_test.go b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag4_test.go index 4cfae13302..a75af4f618 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag4_test.go @@ -20,5 +20,5 @@ export interface /*2*/A { } * @import { [|A/*1*/|] } from "./b"; */` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag5_test.go b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag5_test.go index ef517aa177..00e3a27585 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag5_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsDocImportTag5_test.go @@ -25,5 +25,5 @@ export interface /*2*/A { } */ function f(a) {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsModuleExports_test.go b/internal/fourslash/tests/gen/goToDefinitionJsModuleExports_test.go index 5fba869159..40d7f77acb 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsModuleExports_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsModuleExports_test.go @@ -18,5 +18,5 @@ x.[|/*ref*/test|](); x./*defFn*/test3 = function () { } x.[|/*refFn*/test3|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "ref", "refFn") + f.VerifyBaselineGoToDefinition(t, true, "ref", "refFn") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsModuleNameAtImportName_test.go b/internal/fourslash/tests/gen/goToDefinitionJsModuleNameAtImportName_test.go index c3088ea9da..6cbe3c5f5b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsModuleNameAtImportName_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsModuleNameAtImportName_test.go @@ -25,5 +25,5 @@ new [|/*importUsage*/BlahModule|].Blah() import [|/*importDefTs*/BlahModule|] = require("./foo.js"); new [|/*importUsageTs*/BlahModule|].Blah()` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "importDef", "importUsage", "importDefTs", "importUsageTs") + f.VerifyBaselineGoToDefinition(t, true, "importDef", "importUsage", "importDefTs", "importUsageTs") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsModuleName_test.go b/internal/fourslash/tests/gen/goToDefinitionJsModuleName_test.go index 5feb7b54c1..7c75b15658 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsModuleName_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsModuleName_test.go @@ -17,5 +17,5 @@ func TestGoToDefinitionJsModuleName(t *testing.T) { // @Filename: bar.js var x = require([|/*1*/"./foo"|]);` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsxCall_test.go b/internal/fourslash/tests/gen/goToDefinitionJsxCall_test.go index 1d15fca89d..d589b832e5 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsxCall_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsxCall_test.go @@ -19,5 +19,5 @@ interface FC

{ const Thing: FC = (props) =>

; const HelloWorld = () => <[|/**/Thing|] />;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "") + f.VerifyBaselineGoToDefinition(t, true, "") } diff --git a/internal/fourslash/tests/gen/goToDefinitionJsxNotSet_test.go b/internal/fourslash/tests/gen/goToDefinitionJsxNotSet_test.go index d23e885139..2b63d9381c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionJsxNotSet_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionJsxNotSet_test.go @@ -21,5 +21,5 @@ export default Foo; import Foo from './foo'; const a = <[|/*use*/Foo|] />` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, true, "use") } diff --git a/internal/fourslash/tests/gen/goToDefinitionLabels_test.go b/internal/fourslash/tests/gen/goToDefinitionLabels_test.go index fea6f06531..44858d4dbf 100644 --- a/internal/fourslash/tests/gen/goToDefinitionLabels_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionLabels_test.go @@ -20,5 +20,5 @@ func TestGoToDefinitionLabels(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2", "3", "4") + f.VerifyBaselineGoToDefinition(t, true, "1", "2", "3", "4") } diff --git a/internal/fourslash/tests/gen/goToDefinitionMember_test.go b/internal/fourslash/tests/gen/goToDefinitionMember_test.go index 87eb40c675..9b73418938 100644 --- a/internal/fourslash/tests/gen/goToDefinitionMember_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionMember_test.go @@ -16,5 +16,5 @@ class A { private z/*z*/: string; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "z") + f.VerifyBaselineGoToDefinition(t, true, "z") } diff --git a/internal/fourslash/tests/gen/goToDefinitionMetaProperty_test.go b/internal/fourslash/tests/gen/goToDefinitionMetaProperty_test.go index 84bbece66a..76b83ffeff 100644 --- a/internal/fourslash/tests/gen/goToDefinitionMetaProperty_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionMetaProperty_test.go @@ -18,5 +18,5 @@ function /*functionDefinition*/f() { n/*3*/ew.[|t/*4*/arget|]; } im/*5*/port.m; class /*classDefinition*/c { constructor() { n/*6*/ew.[|t/*7*/arget|]; } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2", "3", "4", "5", "6", "7") + f.VerifyBaselineGoToDefinition(t, true, "1", "2", "3", "4", "5", "6", "7") } diff --git a/internal/fourslash/tests/gen/goToDefinitionMethodOverloads_test.go b/internal/fourslash/tests/gen/goToDefinitionMethodOverloads_test.go index 2ced5f4df4..712c45d0d7 100644 --- a/internal/fourslash/tests/gen/goToDefinitionMethodOverloads_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionMethodOverloads_test.go @@ -27,5 +27,5 @@ var methodOverload = new MethodOverload(); methodOverload.[|/*instanceMethodReference1*/method|](); methodOverload.[|/*instanceMethodReference2*/method|]("456");` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "staticMethodReference1", "staticMethodReference2", "instanceMethodReference1", "instanceMethodReference2", "staticMethodOverload1", "instanceMethodOverload1") + f.VerifyBaselineGoToDefinition(t, true, "staticMethodReference1", "staticMethodReference2", "instanceMethodReference1", "instanceMethodReference2", "staticMethodOverload1", "instanceMethodOverload1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionModifiers_test.go b/internal/fourslash/tests/gen/goToDefinitionModifiers_test.go index 8c8a7b6493..a87b85890e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionModifiers_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionModifiers_test.go @@ -27,5 +27,5 @@ func TestGoToDefinitionModifiers(t *testing.T) { exp/*exportFunction*/ort function foo/*foo*/() { }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "export", "A", "private", "z", "readonly", "x", "async", "a", "override", "b", "public1", "public2", "multipleModifiers", "c", "exportFunction", "foo") + f.VerifyBaselineGoToDefinition(t, true, "export", "A", "private", "z", "readonly", "x", "async", "a", "override", "b", "public1", "public2", "multipleModifiers", "c", "exportFunction", "foo") } diff --git a/internal/fourslash/tests/gen/goToDefinitionMultipleDefinitions_test.go b/internal/fourslash/tests/gen/goToDefinitionMultipleDefinitions_test.go index 27bb5cf689..911e1bda0b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionMultipleDefinitions_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionMultipleDefinitions_test.go @@ -36,5 +36,5 @@ module /*moduleDefinition2*/Module { // @Filename: e.ts [|Modul/*moduleReference*/e|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "interfaceReference", "moduleReference") + f.VerifyBaselineGoToDefinition(t, true, "interfaceReference", "moduleReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionNewExpressionTargetNotClass_test.go b/internal/fourslash/tests/gen/goToDefinitionNewExpressionTargetNotClass_test.go index d556c60486..f88abdc9b4 100644 --- a/internal/fourslash/tests/gen/goToDefinitionNewExpressionTargetNotClass_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionNewExpressionTargetNotClass_test.go @@ -21,5 +21,5 @@ let /*symbolDeclaration*/I2: { }; new [|/*invokeExpression2*/I2|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "invokeExpression1", "invokeExpression2") + f.VerifyBaselineGoToDefinition(t, true, "invokeExpression1", "invokeExpression2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionObjectBindingElementPropertyName01_test.go b/internal/fourslash/tests/gen/goToDefinitionObjectBindingElementPropertyName01_test.go index dc0cea0530..30e797635f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionObjectBindingElementPropertyName01_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionObjectBindingElementPropertyName01_test.go @@ -19,5 +19,5 @@ func TestGoToDefinitionObjectBindingElementPropertyName01(t *testing.T) { var foo: I; var { [|/*use*/property1|]: prop1 } = foo;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, true, "use") } diff --git a/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties1_test.go b/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties1_test.go index 8bba3b2fc9..1e8028e69e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties1_test.go @@ -23,5 +23,5 @@ bar(true, { [|pr/*p2*/opx|]: 10 })` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "p1", "p2") + f.VerifyBaselineGoToDefinition(t, true, "p1", "p2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties_test.go b/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties_test.go index 823cbaf910..c8b9d9a69c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionObjectLiteralProperties_test.go @@ -25,5 +25,5 @@ o./*setterReference*/setter; o./*methodReference*/method; o./*es6StyleMethodReference*/es6StyleMethod;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "valueReference", "getterReference", "setterReference", "methodReference", "es6StyleMethodReference") + f.VerifyBaselineGoToDefinition(t, false, "valueReference", "getterReference", "setterReference", "methodReference", "es6StyleMethodReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionObjectSpread_test.go b/internal/fourslash/tests/gen/goToDefinitionObjectSpread_test.go index 8c16508f5e..e1ae75e52f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionObjectSpread_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionObjectSpread_test.go @@ -18,5 +18,5 @@ let a2: A2; let a12 = { ...a1, ...a2 }; a12.[|a/*3*/|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "3") + f.VerifyBaselineGoToDefinition(t, true, "3") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverloadsInMultiplePropertyAccesses_test.go b/internal/fourslash/tests/gen/goToDefinitionOverloadsInMultiplePropertyAccesses_test.go index fc7921af7d..5933239870 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverloadsInMultiplePropertyAccesses_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverloadsInMultiplePropertyAccesses_test.go @@ -20,5 +20,5 @@ func TestGoToDefinitionOverloadsInMultiplePropertyAccesses(t *testing.T) { } A.B.[|/*2*/f|]("");` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "2") + f.VerifyBaselineGoToDefinition(t, true, "2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember10_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember10_test.go index 51292ec5b2..edd63ac123 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember10_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember10_test.go @@ -22,5 +22,5 @@ class Bar extends Foo { m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember11_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember11_test.go index eabda19f48..a8cfcc749b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember11_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember11_test.go @@ -24,5 +24,5 @@ class Bar extends Foo { m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2", "3", "4", "5") + f.VerifyBaselineGoToDefinition(t, true, "1", "2", "3", "4", "5") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember12_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember12_test.go index af0a92b515..409224e4cb 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember12_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember12_test.go @@ -19,5 +19,5 @@ class Bar extends Foo { static [|/*1*/override|] p = ''; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember13_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember13_test.go index a74ebda1b0..f872dcc8bd 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember13_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember13_test.go @@ -19,5 +19,5 @@ class Bar extends Foo { static [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember14_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember14_test.go index d3266b4dd8..59caed4987 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember14_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember14_test.go @@ -20,5 +20,5 @@ class C extends B { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember15_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember15_test.go index f9ab7abeab..f4aaece592 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember15_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember15_test.go @@ -20,5 +20,5 @@ class C extends B { static [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember16_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember16_test.go index b4b1fc4dea..ce7833786e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember16_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember16_test.go @@ -24,5 +24,5 @@ export class C extends CompletelyUndefined { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember17_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember17_test.go index 937ea783ba..9ebb8cb528 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember17_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember17_test.go @@ -24,5 +24,5 @@ export class MySqlVarBinary extends MySqlColumn { static [|/*1*/override|] readonly [entityKind]: string = "MySqlVarBinary"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember18_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember18_test.go index fc12bc75ab..5d85a2fc1f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember18_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember18_test.go @@ -24,5 +24,5 @@ export class MySqlVarBinary extends MySqlColumn { [|/*1*/override|] readonly [entityKind]: string = "MySqlVarBinary"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember19_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember19_test.go index dbbb89c6f1..5824b6ac49 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember19_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember19_test.go @@ -24,5 +24,5 @@ export class B extends A { static [|/*1*/override|] readonly [prop] = "B"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember1_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember1_test.go index 345846e1dd..6dde000fb2 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember1_test.go @@ -19,5 +19,5 @@ class Bar extends Foo { [|/*1*/override|] p = ''; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember20_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember20_test.go index 37e7b825db..3773ba0f50 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember20_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember20_test.go @@ -24,5 +24,5 @@ export class B extends A { [|/*1*/override|] readonly [prop] = "B"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember21_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember21_test.go index ae959061de..4d22577a3e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember21_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember21_test.go @@ -22,5 +22,5 @@ export class B extends A { static [|/*1*/override|] readonly [prop] = "B"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember22_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember22_test.go index 5f339b2c6c..a2eea9b495 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember22_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember22_test.go @@ -22,5 +22,5 @@ export class B extends A { [|/*1*/override|] readonly [prop] = "B"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember23_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember23_test.go index c10e72245d..5c885a6546 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember23_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember23_test.go @@ -24,5 +24,5 @@ export class B extends A { static [|/*1*/override|] [prop]() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember24_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember24_test.go index 59a3748668..156083f466 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember24_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember24_test.go @@ -24,5 +24,5 @@ export class B extends A { [|/*1*/override|] [prop]() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember25_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember25_test.go index 9870325c4f..e15bb35a14 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember25_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember25_test.go @@ -22,5 +22,5 @@ export class B extends A { static [|/*1*/override|] [prop]() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember26_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember26_test.go index b727ec1ffd..5ac7569293 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember26_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember26_test.go @@ -22,5 +22,5 @@ export class B extends A { [|/*1*/override|] [prop]() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember2_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember2_test.go index e267cb2330..394b3268ec 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember2_test.go @@ -20,5 +20,5 @@ class Bar extends Foo { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember3_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember3_test.go index e72d30c5fb..82bdbc993b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember3_test.go @@ -20,5 +20,5 @@ export class Bar extends Foo { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember4_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember4_test.go index 0145cc7d35..0e6c5fcf2a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember4_test.go @@ -21,5 +21,5 @@ function f () { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember5_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember5_test.go index bd10ca3fdf..6adb2ecd79 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember5_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember5_test.go @@ -18,5 +18,5 @@ class Foo extends (class { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember6_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember6_test.go index 1d577cbda1..9fc6fad97a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember6_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember6_test.go @@ -19,5 +19,5 @@ class Bar extends Foo { [|/*1*/override|] m1() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember7_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember7_test.go index 559443153e..0dde609939 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember7_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember7_test.go @@ -16,5 +16,5 @@ class Foo { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember8_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember8_test.go index 819bc32c6e..94dae65c6a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember8_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember8_test.go @@ -22,5 +22,5 @@ class B extends A { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember9_test.go b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember9_test.go index f23f27682d..e73959daa8 100644 --- a/internal/fourslash/tests/gen/goToDefinitionOverriddenMember9_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionOverriddenMember9_test.go @@ -22,5 +22,5 @@ class B extends A implements I { [|/*1*/override|] m() {} }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionPartialImplementation_test.go b/internal/fourslash/tests/gen/goToDefinitionPartialImplementation_test.go index 3b648feff3..83b547c684 100644 --- a/internal/fourslash/tests/gen/goToDefinitionPartialImplementation_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionPartialImplementation_test.go @@ -26,5 +26,5 @@ module A { var x: [|/*Part2Use*/IA|]; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "Part2Use") + f.VerifyBaselineGoToDefinition(t, true, "Part2Use") } diff --git a/internal/fourslash/tests/gen/goToDefinitionPrimitives_test.go b/internal/fourslash/tests/gen/goToDefinitionPrimitives_test.go index 5fa9cec76e..99e447bc17 100644 --- a/internal/fourslash/tests/gen/goToDefinitionPrimitives_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionPrimitives_test.go @@ -13,5 +13,5 @@ func TestGoToDefinitionPrimitives(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `var x: st/*primitive*/ring;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "primitive") + f.VerifyBaselineGoToDefinition(t, true, "primitive") } diff --git a/internal/fourslash/tests/gen/goToDefinitionPrivateName_test.go b/internal/fourslash/tests/gen/goToDefinitionPrivateName_test.go index 0f19340464..b8dfdc68b3 100644 --- a/internal/fourslash/tests/gen/goToDefinitionPrivateName_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionPrivateName_test.go @@ -23,5 +23,5 @@ func TestGoToDefinitionPrivateName(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "pnFieldUse", "pnMethodUse", "pnPropUse") + f.VerifyBaselineGoToDefinition(t, true, "pnFieldUse", "pnMethodUse", "pnPropUse") } diff --git a/internal/fourslash/tests/gen/goToDefinitionPropertyAssignment_test.go b/internal/fourslash/tests/gen/goToDefinitionPropertyAssignment_test.go index 9efc4ab81d..e7d4c5229a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionPropertyAssignment_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionPropertyAssignment_test.go @@ -18,5 +18,5 @@ Component./*PropertyResult*/displayName = 'Component' Component.[|/*PropertyClick*/displayName|]` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "FunctionClick", "PropertyClick") + f.VerifyBaselineGoToDefinition(t, true, "FunctionClick", "PropertyClick") } diff --git a/internal/fourslash/tests/gen/goToDefinitionRest_test.go b/internal/fourslash/tests/gen/goToDefinitionRest_test.go index ad50a2796a..39935e4c76 100644 --- a/internal/fourslash/tests/gen/goToDefinitionRest_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionRest_test.go @@ -20,5 +20,5 @@ let t: Gen; var { x, ...rest } = t; rest.[|/*2*/parent|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "2") + f.VerifyBaselineGoToDefinition(t, true, "2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn1_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn1_test.go index 64645fa259..89f85fb8ad 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn1_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionReturn1(t *testing.T) { [|/*start*/return|] 10; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn2_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn2_test.go index 61f4225dd1..3da50d570d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn2_test.go @@ -17,5 +17,5 @@ func TestGoToDefinitionReturn2(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn3_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn3_test.go index 85dc2a488c..0041119f7c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn3_test.go @@ -17,5 +17,5 @@ func TestGoToDefinitionReturn3(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn4_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn4_test.go index d0b5fd61cd..5a3a3de015 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn4_test.go @@ -13,5 +13,5 @@ func TestGoToDefinitionReturn4(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `[|/*start*/return|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn5_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn5_test.go index fd32825e00..1f0f5dffb5 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn5_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn5_test.go @@ -17,5 +17,5 @@ func TestGoToDefinitionReturn5(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn6_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn6_test.go index 14598db819..006e475acb 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn6_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn6_test.go @@ -17,5 +17,5 @@ func TestGoToDefinitionReturn6(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionReturn7_test.go b/internal/fourslash/tests/gen/goToDefinitionReturn7_test.go index 8c1e4d7183..a32367f60b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionReturn7_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionReturn7_test.go @@ -17,5 +17,5 @@ function /*end*/foo(a: any, b: any): any { [|/*start*/return|] a + b; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSameFile_test.go b/internal/fourslash/tests/gen/goToDefinitionSameFile_test.go index f9775bcb59..a3aeeb3607 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSameFile_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSameFile_test.go @@ -24,5 +24,5 @@ var foo = new /*localClassReference*/localClass(); class fooCls implements /*localInterfaceReference*/localInterface { } var fooVar = /*localModuleReference*/localModule.foo;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "localVariableReference", "localFunctionReference", "localClassReference", "localInterfaceReference", "localModuleReference") + f.VerifyBaselineGoToDefinition(t, false, "localVariableReference", "localFunctionReference", "localClassReference", "localInterfaceReference", "localModuleReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSatisfiesExpression1_test.go b/internal/fourslash/tests/gen/goToDefinitionSatisfiesExpression1_test.go index 41c1cdefde..186145938b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSatisfiesExpression1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSatisfiesExpression1_test.go @@ -18,5 +18,5 @@ func TestGoToDefinitionSatisfiesExpression1(t *testing.T) { //somewhere in app STRINGS.[|/*usage*/title|]` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "definition", "usage") + f.VerifyBaselineGoToDefinition(t, true, "definition", "usage") } diff --git a/internal/fourslash/tests/gen/goToDefinitionScriptImportServer_test.go b/internal/fourslash/tests/gen/goToDefinitionScriptImportServer_test.go index 3a105914d1..875ca1c75a 100644 --- a/internal/fourslash/tests/gen/goToDefinitionScriptImportServer_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionScriptImportServer_test.go @@ -22,5 +22,6 @@ import [|/*1*/"./scriptThing"|]; import [|/*2*/"./stylez.css"|]; import [|/*3*/"./foo.txt"|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2", "3") + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToDefinition(t, true, "1", "2", "3") } diff --git a/internal/fourslash/tests/gen/goToDefinitionScriptImport_test.go b/internal/fourslash/tests/gen/goToDefinitionScriptImport_test.go index f839bccfba..88c41d1452 100644 --- a/internal/fourslash/tests/gen/goToDefinitionScriptImport_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionScriptImport_test.go @@ -21,5 +21,5 @@ func TestGoToDefinitionScriptImport(t *testing.T) { import [|/*1*/"./scriptThing"|]; import [|/*2*/"./stylez.css"|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2") + f.VerifyBaselineGoToDefinition(t, true, "1", "2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShadowVariableInsideModule_test.go b/internal/fourslash/tests/gen/goToDefinitionShadowVariableInsideModule_test.go index d37813e33a..83be434bad 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShadowVariableInsideModule_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShadowVariableInsideModule_test.go @@ -16,5 +16,5 @@ func TestGoToDefinitionShadowVariableInsideModule(t *testing.T) { /*shadowVariableReference*/shdVar = 1; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "shadowVariableReference") + f.VerifyBaselineGoToDefinition(t, false, "shadowVariableReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShadowVariable_test.go b/internal/fourslash/tests/gen/goToDefinitionShadowVariable_test.go index 527f25b922..ea858e3603 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShadowVariable_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShadowVariable_test.go @@ -17,5 +17,5 @@ function shadowVariableTestModule() { /*shadowVariableReference*/shadowVariable = 1; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "shadowVariableReference") + f.VerifyBaselineGoToDefinition(t, false, "shadowVariableReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty01_test.go b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty01_test.go index 96c48b7bd2..cadf47b50d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty01_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty01_test.go @@ -18,5 +18,5 @@ var obj = {[|/*valueDefinition1*/name|], [|/*valueDefinition2*/id|]}; obj.[|/*valueReference1*/name|]; obj.[|/*valueReference2*/id|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "valueDefinition1", "valueDefinition2", "valueReference1", "valueReference2") + f.VerifyBaselineGoToDefinition(t, true, "valueDefinition1", "valueDefinition2", "valueReference1", "valueReference2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty02_test.go b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty02_test.go index 7cad04ef38..b51a6366f4 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty02_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty02_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionShorthandProperty02(t *testing.T) { [|f/*1*/oo|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty03_test.go b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty03_test.go index efecfd8244..61b5e9b67e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty03_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty03_test.go @@ -18,5 +18,5 @@ let /*letDef*/y = { [|/*letProp*/y|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "varProp", "letProp") + f.VerifyBaselineGoToDefinition(t, true, "varProp", "letProp") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty04_test.go b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty04_test.go index 955d260227..508fe65b21 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty04_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty04_test.go @@ -19,5 +19,5 @@ let x: Foo = { [|f/*1*/oo|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty05_test.go b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty05_test.go index 8b3698520a..849e76c98b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty05_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty05_test.go @@ -19,5 +19,5 @@ let x: Foo = { [|f/*1*/oo|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty06_test.go b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty06_test.go index 5639fb4aa5..45ba5a6a3b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionShorthandProperty06_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionShorthandProperty06_test.go @@ -19,5 +19,5 @@ let x: Foo = { [|f/*1*/oo|]() }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSignatureAlias_require_test.go b/internal/fourslash/tests/gen/goToDefinitionSignatureAlias_require_test.go index 77085588cf..5d6a172faa 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSignatureAlias_require_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSignatureAlias_require_test.go @@ -21,5 +21,5 @@ const f = require("./a"); import f = require("./a"); [|/*useTs*/f|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use", "useTs") + f.VerifyBaselineGoToDefinition(t, true, "use", "useTs") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSimple_test.go b/internal/fourslash/tests/gen/goToDefinitionSimple_test.go index 2d07fafb0d..7a6771ffcc 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSimple_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSimple_test.go @@ -17,5 +17,5 @@ class /*2*/c { } var n = new [|/*1*/c|](); var n = new [|c/*3*/|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "3") + f.VerifyBaselineGoToDefinition(t, true, "1", "3") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSourceUnit_test.go b/internal/fourslash/tests/gen/goToDefinitionSourceUnit_test.go index 9d2aec096c..32870316e4 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSourceUnit_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSourceUnit_test.go @@ -26,5 +26,5 @@ func TestGoToDefinitionSourceUnit(t *testing.T) { // @Filename: b.ts /*fileB*/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "unknownFile", "knownFile") + f.VerifyBaselineGoToDefinition(t, true, "unknownFile", "knownFile") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase1_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase1_test.go index a029e85918..a918973bab 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase1_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionSwitchCase1(t *testing.T) { [|/*start*/case|] null: break; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase2_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase2_test.go index ff50f02a3f..afbe858a11 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase2_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionSwitchCase2(t *testing.T) { [|/*start*/default|]: break; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase3_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase3_test.go index 4ee9736a7a..ffd06bced8 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase3_test.go @@ -19,5 +19,5 @@ func TestGoToDefinitionSwitchCase3(t *testing.T) { }; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start1", "start2") + f.VerifyBaselineGoToDefinition(t, true, "start1", "start2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase4_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase4_test.go index 0367913533..7bf999aeb1 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase4_test.go @@ -19,5 +19,5 @@ func TestGoToDefinitionSwitchCase4(t *testing.T) { [|/*start*/case|] null: break; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase5_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase5_test.go index 2e5a9b483f..645086836b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase5_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase5_test.go @@ -13,5 +13,5 @@ func TestGoToDefinitionSwitchCase5(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `export [|/*start*/default|] {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase6_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase6_test.go index 40462d5db5..90f82f006c 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase6_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase6_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionSwitchCase6(t *testing.T) { [|/*b*/default|]; [|/*c*/case|] 42;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "a", "b", "c") + f.VerifyBaselineGoToDefinition(t, true, "a", "b", "c") } diff --git a/internal/fourslash/tests/gen/goToDefinitionSwitchCase7_test.go b/internal/fourslash/tests/gen/goToDefinitionSwitchCase7_test.go index 18b242dbda..3e103e4062 100644 --- a/internal/fourslash/tests/gen/goToDefinitionSwitchCase7_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionSwitchCase7_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionSwitchCase7(t *testing.T) { case null: export [|/*start*/default|] 123;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionTaggedTemplateOverloads_test.go b/internal/fourslash/tests/gen/goToDefinitionTaggedTemplateOverloads_test.go index 1251dc5eaa..8a870f5de2 100644 --- a/internal/fourslash/tests/gen/goToDefinitionTaggedTemplateOverloads_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionTaggedTemplateOverloads_test.go @@ -18,5 +18,5 @@ function f(strs: TemplateStringsArray, x: number | boolean) {} [|/*useFNumber*/f|]` + "`" + `${0}` + "`" + `; [|/*useFBool*/f|]` + "`" + `${false}` + "`" + `;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "useFNumber", "useFBool") + f.VerifyBaselineGoToDefinition(t, true, "useFNumber", "useFBool") } diff --git a/internal/fourslash/tests/gen/goToDefinitionThis_test.go b/internal/fourslash/tests/gen/goToDefinitionThis_test.go index 71ec274705..be4f95f231 100644 --- a/internal/fourslash/tests/gen/goToDefinitionThis_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionThis_test.go @@ -19,5 +19,5 @@ class /*cls*/C { get self(/*getterDecl*/this: number) { return [|/*getterUse*/this|]; } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "fnUse", "clsUse", "getterUse") + f.VerifyBaselineGoToDefinition(t, true, "fnUse", "clsUse", "getterUse") } diff --git a/internal/fourslash/tests/gen/goToDefinitionTypeOnlyImport_test.go b/internal/fourslash/tests/gen/goToDefinitionTypeOnlyImport_test.go index 9be637addb..bf5627b2fe 100644 --- a/internal/fourslash/tests/gen/goToDefinitionTypeOnlyImport_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionTypeOnlyImport_test.go @@ -20,5 +20,5 @@ export type { SyntaxKind } import type { SyntaxKind } from './b'; let kind: [|/*2*/SyntaxKind|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "2") + f.VerifyBaselineGoToDefinition(t, true, "2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionTypePredicate_test.go b/internal/fourslash/tests/gen/goToDefinitionTypePredicate_test.go index 867ac5f157..9df49b4aae 100644 --- a/internal/fourslash/tests/gen/goToDefinitionTypePredicate_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionTypePredicate_test.go @@ -16,5 +16,5 @@ function f(/*parameterDeclaration*/parameter: any): [|/*parameterName*/parameter return typeof parameter === "string"; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "parameterName", "typeReference") + f.VerifyBaselineGoToDefinition(t, true, "parameterName", "typeReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionTypeReferenceDirective_test.go b/internal/fourslash/tests/gen/goToDefinitionTypeReferenceDirective_test.go index e0af7da678..db6e28ec73 100644 --- a/internal/fourslash/tests/gen/goToDefinitionTypeReferenceDirective_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionTypeReferenceDirective_test.go @@ -18,5 +18,5 @@ func TestGoToDefinitionTypeReferenceDirective(t *testing.T) { /// $.x;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToDefinitionTypeofThis_test.go b/internal/fourslash/tests/gen/goToDefinitionTypeofThis_test.go index 41c31e07ff..f364ffad2f 100644 --- a/internal/fourslash/tests/gen/goToDefinitionTypeofThis_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionTypeofThis_test.go @@ -19,5 +19,5 @@ class /*cls*/C { get self(/*getterDecl*/this: number) { type X = typeof [|/*getterUse*/this|]; } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "fnUse", "clsUse", "getterUse") + f.VerifyBaselineGoToDefinition(t, true, "fnUse", "clsUse", "getterUse") } diff --git a/internal/fourslash/tests/gen/goToDefinitionUndefinedSymbols_test.go b/internal/fourslash/tests/gen/goToDefinitionUndefinedSymbols_test.go index 05a97e927a..adbc442729 100644 --- a/internal/fourslash/tests/gen/goToDefinitionUndefinedSymbols_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionUndefinedSymbols_test.go @@ -16,5 +16,5 @@ var a: some/*undefinedType*/Type; var x = {}; x.some/*undefinedProperty*/Property; var a: any; a.some/*unkownProperty*/Property;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, f.MarkerNames()...) + f.VerifyBaselineGoToDefinition(t, true, f.MarkerNames()...) } diff --git a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty1_test.go b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty1_test.go index ca3270b848..61bc54e6a7 100644 --- a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty1_test.go @@ -26,5 +26,5 @@ var x : One | Two; x.[|/*propertyReference*/commonProperty|]; x./*3*/commonFunction;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "propertyReference") + f.VerifyBaselineGoToDefinition(t, true, "propertyReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty2_test.go b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty2_test.go index a5fb8ece19..c52c7e4bcd 100644 --- a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty2_test.go @@ -28,5 +28,5 @@ var x : One | Two; x.common.[|/*propertyReference*/a|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "propertyReference") + f.VerifyBaselineGoToDefinition(t, true, "propertyReference") } diff --git a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty3_test.go b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty3_test.go index a8311f6309..ad0732c1f8 100644 --- a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty3_test.go @@ -20,5 +20,5 @@ var numbers: number[]; var x = (strings || numbers).[|/*usage*/specialPop|]()` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "usage") + f.VerifyBaselineGoToDefinition(t, true, "usage") } diff --git a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty4_test.go b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty4_test.go index 7c784045dd..6e87070854 100644 --- a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty4_test.go @@ -29,5 +29,5 @@ var snapcrackle: SnapCrackle; var x = (snapcrackle || magnitude || art).[|/*usage*/pop|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "usage") + f.VerifyBaselineGoToDefinition(t, true, "usage") } diff --git a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty_discriminated_test.go b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty_discriminated_test.go index f0328248c7..a75bf9d38b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty_discriminated_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionUnionTypeProperty_discriminated_test.go @@ -32,5 +32,5 @@ const u2: U = { [|/*propBogus*/prop|]: 0, };` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "kind", "prop", "kindBogus", "propBogus") + f.VerifyBaselineGoToDefinition(t, true, "kind", "prop", "kindBogus", "propBogus") } diff --git a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment1_test.go b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment1_test.go index 10c7c6b3b9..333e7aa9b1 100644 --- a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment1_test.go @@ -19,5 +19,5 @@ Foo.prototype.bar = function() {} new [|Foo/*ref*/|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.GoToFile(t, "foo.js") - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment2_test.go b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment2_test.go index 3267978c7b..73234adbc5 100644 --- a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment2_test.go @@ -18,5 +18,5 @@ Foo.prototype.bar = function() {} new [|Foo/*ref*/|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.GoToFile(t, "foo.ts") - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment3_test.go b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment3_test.go index 2a74d4edbc..ba6149203b 100644 --- a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment3_test.go @@ -17,5 +17,5 @@ Foo.prototype.bar = function() {} new [|Foo/*ref*/|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.GoToFile(t, "foo.ts") - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment_test.go b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment_test.go index fa00c4a06d..e3df39abbf 100644 --- a/internal/fourslash/tests/gen/goToDefinitionVariableAssignment_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionVariableAssignment_test.go @@ -20,5 +20,5 @@ Foo.prototype.bar = function() {} new [|Foo/*ref*/|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.GoToFile(t, "foo.js") - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinitionYield1_test.go b/internal/fourslash/tests/gen/goToDefinitionYield1_test.go index 0320866b4a..3b081b1a22 100644 --- a/internal/fourslash/tests/gen/goToDefinitionYield1_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionYield1_test.go @@ -19,5 +19,5 @@ const /*end2*/genFunction = function*() { [|/*start2*/yield|] 0; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start1", "start2") + f.VerifyBaselineGoToDefinition(t, true, "start1", "start2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionYield2_test.go b/internal/fourslash/tests/gen/goToDefinitionYield2_test.go index 853de203d2..5f1ea73102 100644 --- a/internal/fourslash/tests/gen/goToDefinitionYield2_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionYield2_test.go @@ -18,5 +18,5 @@ func TestGoToDefinitionYield2(t *testing.T) { return gen }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinitionYield3_test.go b/internal/fourslash/tests/gen/goToDefinitionYield3_test.go index 80bc5dd8bb..1e2c7f9d6d 100644 --- a/internal/fourslash/tests/gen/goToDefinitionYield3_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionYield3_test.go @@ -21,5 +21,5 @@ func TestGoToDefinitionYield3(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start1", "start2") + f.VerifyBaselineGoToDefinition(t, true, "start1", "start2") } diff --git a/internal/fourslash/tests/gen/goToDefinitionYield4_test.go b/internal/fourslash/tests/gen/goToDefinitionYield4_test.go index d7b9f70aac..03712a181e 100644 --- a/internal/fourslash/tests/gen/goToDefinitionYield4_test.go +++ b/internal/fourslash/tests/gen/goToDefinitionYield4_test.go @@ -15,5 +15,5 @@ func TestGoToDefinitionYield4(t *testing.T) { class C { [/*start*/yield 10]() {} } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/goToDefinition_filteringGenericMappedType_test.go b/internal/fourslash/tests/gen/goToDefinition_filteringGenericMappedType_test.go index a7e85bd471..a9091fe108 100644 --- a/internal/fourslash/tests/gen/goToDefinition_filteringGenericMappedType_test.go +++ b/internal/fourslash/tests/gen/goToDefinition_filteringGenericMappedType_test.go @@ -33,5 +33,5 @@ const obj2 = omit2(obj, { obj2.[|/*ref*/id|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinition_filteringMappedType_test.go b/internal/fourslash/tests/gen/goToDefinition_filteringMappedType_test.go index f2e01ba04f..9f50301cb0 100644 --- a/internal/fourslash/tests/gen/goToDefinition_filteringMappedType_test.go +++ b/internal/fourslash/tests/gen/goToDefinition_filteringMappedType_test.go @@ -15,5 +15,5 @@ func TestGoToDefinition_filteringMappedType(t *testing.T) { const filtered: { [P in keyof typeof obj as P extends 'b' ? never : P]: 0; } = { a: 0 }; filtered.[|/*ref*/a|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinition_mappedType_test.go b/internal/fourslash/tests/gen/goToDefinition_mappedType_test.go index f3216b0b5b..07ac8e43fe 100644 --- a/internal/fourslash/tests/gen/goToDefinition_mappedType_test.go +++ b/internal/fourslash/tests/gen/goToDefinition_mappedType_test.go @@ -15,5 +15,5 @@ func TestGoToDefinition_mappedType(t *testing.T) { declare const i: { [K in "m"]: I[K] }; i.[|/*ref*/m|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "ref") + f.VerifyBaselineGoToDefinition(t, true, "ref") } diff --git a/internal/fourslash/tests/gen/goToDefinition_super_test.go b/internal/fourslash/tests/gen/goToDefinition_super_test.go index a9aae6ff2d..5cece137b6 100644 --- a/internal/fourslash/tests/gen/goToDefinition_super_test.go +++ b/internal/fourslash/tests/gen/goToDefinition_super_test.go @@ -30,5 +30,5 @@ class D { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "super", "superExpression", "superBroken") + f.VerifyBaselineGoToDefinition(t, true, "super", "superExpression", "superBroken") } diff --git a/internal/fourslash/tests/gen/goToDefinition_untypedModule_test.go b/internal/fourslash/tests/gen/goToDefinition_untypedModule_test.go index 8e4d1e3195..ecd5ab89a4 100644 --- a/internal/fourslash/tests/gen/goToDefinition_untypedModule_test.go +++ b/internal/fourslash/tests/gen/goToDefinition_untypedModule_test.go @@ -17,5 +17,5 @@ not read import { /*def*/f } from "foo"; [|/*use*/f|]();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, true, "use") } diff --git a/internal/fourslash/tests/gen/goToImplementationClassMethod_00_test.go b/internal/fourslash/tests/gen/goToImplementationClassMethod_00_test.go new file mode 100644 index 0000000000..d02e7c6aaf --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationClassMethod_00_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationClassMethod_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Bar { + [|{|"parts": ["(","method",")"," ","Bar",".","hello","(",")",":"," ","void"], "kind": "method"|}hello|]() {} +} + +new Bar().hel/*reference*/lo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationClassMethod_01_test.go b/internal/fourslash/tests/gen/goToImplementationClassMethod_01_test.go new file mode 100644 index 0000000000..e7c05e2591 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationClassMethod_01_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationClassMethod_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `abstract class AbstractBar { + abstract he/*declaration*/llo(): void; +} + +class Bar extends AbstractBar{ + [|hello|]() {} +} + +function whatever(x: AbstractBar) { + x.he/*reference*/llo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference", "declaration") +} diff --git a/internal/fourslash/tests/gen/goToImplementationEnum_00_test.go b/internal/fourslash/tests/gen/goToImplementationEnum_00_test.go new file mode 100644 index 0000000000..abc6e7f129 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationEnum_00_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationEnum_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum Foo { + [|Foo1|] = function initializer() { return 5 } (), + Foo2 = 6 +} + +Foo.Fo/*reference*/o1;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationEnum_01_test.go b/internal/fourslash/tests/gen/goToImplementationEnum_01_test.go new file mode 100644 index 0000000000..aae6605377 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationEnum_01_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationEnum_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum [|Foo|] { + Foo1 = function initializer() { return 5 } (), + Foo2 = 6 +} + +Fo/*reference*/o;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_00_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_00_test.go new file mode 100644 index 0000000000..34d7f11605 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_00_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + he/*declaration*/llo: () => void +} + +var bar: Foo = { [|hello|]: helloImpl }; +var baz: Foo = { "[|hello|]": helloImpl }; + +function helloImpl () {} + +function whatever(x: Foo = { [|hello|]() {/**1*/} }) { + x.he/*function_call*/llo() +} + +class Bar { + x: Foo = { [|hello|]() {/*2*/} } + + constructor(public f: Foo = { [|hello|]() {/**3*/} } ) {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call", "declaration") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_01_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_01_test.go new file mode 100644 index 0000000000..963a8a7dbc --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_01_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hel/*declaration*/lo(): void; + okay?: number; +} + +class Bar implements Foo { + [|hello|]() {} + public sure() {} +} + +function whatever(a: Foo) { + a.he/*function_call*/llo(); +} + +whatever(new Bar());` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call", "declaration") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_02_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_02_test.go new file mode 100644 index 0000000000..839a37a72b --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_02_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + he/*declaration*/llo(): void +} + +abstract class AbstractBar implements Foo { + abstract hello(): void; +} + +class Bar extends AbstractBar { + [|hello|]() {} +} + +function whatever(a: AbstractBar) { + a.he/*function_call*/llo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call", "declaration") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_03_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_03_test.go new file mode 100644 index 0000000000..ff8dd77d57 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_03_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_03(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello (): void; +} + +class Bar extends SuperBar { + [|hello|]() {} +} + +class SuperBar implements Foo { + hello() {} // should not show up +} + +class OtherBar implements Foo { + hello() {} // should not show up +} + +new Bar().hel/*function_call*/lo(); +new Bar()["hello"]();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_04_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_04_test.go new file mode 100644 index 0000000000..3da4db562d --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_04_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_04(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello (): void; +} + +class Bar extends SuperBar { + [|hello|]() {} +} + +class SuperBar implements Foo { + [|hello|]() {} +} + +class OtherBar implements Foo { + hello() {} // should not show up +} + +function (x: SuperBar) { + x.he/*function_call*/llo() +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_05_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_05_test.go new file mode 100644 index 0000000000..8173bbb024 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_05_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_05(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello (): void; +} + +class SuperBar implements Foo { + [|hello|]() {} +} + +class Bar extends SuperBar { + hello2() {} +} + +class OtherBar extends SuperBar { + hello() {} + hello2() {} + hello3() {} +} + +class NotRelatedToBar { + hello() {} // Equivalent to last case, but shares no common ancestors with Bar and so is not returned + hello2() {} + hello3() {} +} + +class NotBar extends SuperBar { + hello() {} // Should not be returned because it is not structurally equivalent to Bar +} + +function whatever(x: Bar) { + x.he/*function_call*/llo() +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_06_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_06_test.go new file mode 100644 index 0000000000..032803fd35 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_06_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_06(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface SuperFoo { + hello (): void; +} + +interface Foo extends SuperFoo { + someOtherFunction(): void; +} + +class Bar implements Foo { + [|hello|]() {} + someOtherFunction() {} +} + +function createFoo(): Foo { + return { + [|hello|]() {}, + someOtherFunction() {} + }; +} + +var y: Foo = { + [|hello|]() {}, + someOtherFunction() {} +}; + +class FooLike implements SuperFoo { + hello() {} + someOtherFunction() {} +} + +class NotRelatedToFoo { + hello() {} // This case is equivalent to the last case, but is not returned because it does not share a common ancestor with Foo + someOtherFunction() {} +} + +class NotFoo implements SuperFoo { + hello() {} // We only want implementations of Foo, even though the function is declared in SuperFoo +} + +function (x: Foo) { + x.he/*function_call*/llo() +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_08_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_08_test.go new file mode 100644 index 0000000000..42bc11d378 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_08_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_08(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello (): void; +} + +class SuperBar implements Foo { + [|hello|]() {} +} + +class Bar extends SuperBar { + whatever() { this.he/*function_call*/llo(); } +} + +class SubBar extends Bar { + [|hello|]() {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_09_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_09_test.go new file mode 100644 index 0000000000..2f4304e95d --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_09_test.go @@ -0,0 +1,40 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_09(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello (): void; +} + +class SubBar extends Bar { + hello() {} +} + +class Bar extends SuperBar { + hello() {} + + whatever() { + super.he/*function_call*/llo(); + super["hel/*element_access*/lo"](); + } +} + +class SuperBar extends MegaBar { + [|hello|]() {} +} + +class MegaBar implements Foo { + hello() {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call", "element_access") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_10_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_10_test.go new file mode 100644 index 0000000000..10a713a1f5 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_10_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_10(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface BaseFoo { + hello(): void; +} + +interface Foo extends BaseFoo { + aloha(): void; +} + +interface Bar { + hello(): void; + goodbye(): void; +} + +class FooImpl implements Foo { + [|hello|]() {/**FooImpl*/} + aloha() {} +} + +class BaseFooImpl implements BaseFoo { + hello() {/**BaseFooImpl*/} // Should not show up +} + +class BarImpl implements Bar { + [|hello|]() {/**BarImpl*/} + goodbye() {} +} + +class FooAndBarImpl implements Foo, Bar { + [|hello|]() {/**FooAndBarImpl*/} + aloha() {} + goodbye() {} +} + +function someFunction(x: Foo | Bar) { + x.he/*function_call0*/llo(); +} + +function anotherFunction(x: Foo & Bar) { + x.he/*function_call1*/llo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call0", "function_call1") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_11_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_11_test.go new file mode 100644 index 0000000000..881446244f --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceMethod_11_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceMethod_11(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hel/*reference*/lo(): void; +} + +var x = { [|hello|]: () => {} }; +var y = (((({ [|hello|]: () => {} }))));` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceProperty_00_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceProperty_00_test.go new file mode 100644 index 0000000000..e1f0a87e26 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceProperty_00_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceProperty_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello: number +} + +var bar: Foo = { [|hello|]: 5 }; + + +function whatever(x: Foo = { [|hello|]: 5 * 9 }) { + x.he/*reference*/llo +} + +class Bar { + x: Foo = { [|hello|]: 6 } + + constructor(public f: Foo = { [|hello|]: 7 } ) {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterfaceProperty_01_test.go b/internal/fourslash/tests/gen/goToImplementationInterfaceProperty_01_test.go new file mode 100644 index 0000000000..f7d65062f1 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterfaceProperty_01_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterfaceProperty_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { hello: number } + +class Bar implements Foo { + [|hello|] = 5 * 9; +} + +function whatever(foo: Foo) { + foo.he/*reference*/llo; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_00_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_00_test.go new file mode 100644 index 0000000000..61ac5304fb --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_00_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { + hello: () => void +} + +interface Baz extends Foo {} + +var bar: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello: helloImpl /**0*/ }|]; +var baz: Foo[] = [|[{ hello: helloImpl /**4*/ }]|]; + +function helloImpl () {} + +function whatever(x: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello() {/**1*/} }|] ) { +} + +class Bar { + x: Foo = [|{ hello() {/*2*/} }|] + + constructor(public f: Foo = [|{ hello() {/**3*/} }|] ) {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_01_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_01_test.go new file mode 100644 index 0000000000..34a2f5845d --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_01_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { hello(): void } + +class [|SuperBar|] implements Foo { + hello () {} +} + +abstract class [|AbstractBar|] implements Foo { + abstract hello (): void; +} + +class [|Bar|] extends SuperBar { +} + +class [|NotAbstractBar|] extends AbstractBar { + hello () {} +} + +var x = new SuperBar(); +var y: SuperBar = new SuperBar(); +var z: AbstractBar = new NotAbstractBar();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_02_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_02_test.go new file mode 100644 index 0000000000..5fc61d7b96 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_02_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { hello: () => void } + +let x: number = 9; + +function createFoo(): Foo { + if (x === 2) { + return [|{ + hello() {} + }|]; + } + return [|{ + hello() {} + }|]; +} + +let createFoo2 = (): Foo => [|({hello() {}})|]; + +function createFooLike() { + return { + hello() {} + }; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_03_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_03_test.go new file mode 100644 index 0000000000..d65535edab --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_03_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_03(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { hello: () => void } + +var x = [|{ hello: () => {} }|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_04_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_04_test.go new file mode 100644 index 0000000000..e6b134284d --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_04_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_04(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { + (a: number): void +} + +var bar: Foo = [|(a) => {/**0*/}|]; + +function whatever(x: Foo = [|(a) => {/**1*/}|] ) { +} + +class Bar { + x: Foo = [|(a) => {/**2*/}|] + + constructor(public f: Foo = [|function(a) {}|] ) {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_05_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_05_test.go new file mode 100644 index 0000000000..114836e474 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_05_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_05(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { + (a: number): void +} + +let bar2 = [|function(a) {}|]; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_06_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_06_test.go new file mode 100644 index 0000000000..f2351c8317 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_06_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_06(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { + new (a: number): SomeOtherType; +} + +interface SomeOtherType {} + +let x: Foo = [|class { constructor (a: number) {} }|]; +let y = [|class { constructor (a: number) {} }|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_07_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_07_test.go new file mode 100644 index 0000000000..92bc2a63b1 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_07_test.go @@ -0,0 +1,40 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_07(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*interface_definition*/o { + hello (): void; +} + +interface Bar { + hello (): void; +} + +let x1: Foo = [|{ hello () { /**typeReference*/ } }|]; +let x2: () => Foo = [|(() => { hello () { /**functionType*/} })|]; +let x3: Foo | Bar = [|{ hello () { /**unionType*/} }|]; +let x4: Foo & (Foo & Bar) = [|{ hello () { /**intersectionType*/} }|]; +let x5: [Foo] = [|[{ hello () { /**tupleType*/} }]|]; +let x6: (Foo) = [|{ hello () { /**parenthesizedType*/} }|]; +let x7: (new() => Foo) = [|class { hello () { /**constructorType*/} }|]; +let x8: Foo[] = [|[{ hello () { /**arrayType*/} }]|]; +let x9: { y: Foo } = [|{ y: { hello () { /**typeLiteral*/} } }|]; +let x10 = [|{|"parts": ["(","anonymous local class",")"], "kind": "local class"|}class implements Foo { hello() {} }|] +let x11 = class [|{|"parts": ["(","local class",")"," ","C"], "kind": "local class"|}C|] implements Foo { hello() {} } + +// Should not do anything for type predicates +function isFoo(a: any): a is Foo { + return true; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "interface_definition") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_08_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_08_test.go new file mode 100644 index 0000000000..bbd6760eec --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_08_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_08(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Base { + hello (): void; +} + +interface A extends Base {} +interface B extends C, A {} +interface C extends B, A {} + +class X implements B { + [|hello|]() {} +} + +function someFunction(d : A) { + d.he/*function_call*/llo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_09_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_09_test.go new file mode 100644 index 0000000000..f3f826a333 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_09_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_09(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: def.d.ts +export interface Interface { P: number } +// @Filename: ref.ts +import { Interface } from "./def"; +const c: I/*ref*/nterface = [|{ P: 2 }|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "ref") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInterface_10_test.go b/internal/fourslash/tests/gen/goToImplementationInterface_10_test.go new file mode 100644 index 0000000000..d48e7fc862 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInterface_10_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInterface_10(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +interface /*def*/A { + foo: boolean; +} +interface [|B|] extends A { + bar: boolean; +} +export class [|C|] implements B { + foo = true; + bar = true; +} +export class [|D|] extends C { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "def") +} diff --git a/internal/fourslash/tests/gen/goToImplementationInvalid_test.go b/internal/fourslash/tests/gen/goToImplementationInvalid_test.go new file mode 100644 index 0000000000..69b49f0fd4 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationInvalid_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationInvalid(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x1 = 50/*0*/0; +var x2 = "hel/*1*/lo"; +/*2*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "0", "1", "2") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_00_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_00_test.go new file mode 100644 index 0000000000..125626b1db --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_00_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `he/*function_call*/llo(); +function [|hello|]() {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_01_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_01_test.go new file mode 100644 index 0000000000..96e14a25cf --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_01_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const [|hello|] = function() {}; +he/*function_call*/llo();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_02_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_02_test.go new file mode 100644 index 0000000000..ebb077701b --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_02_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const x = { [|hello|]: () => {} }; + +x.he/*function_call*/llo(); +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_03_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_03_test.go new file mode 100644 index 0000000000..ed43e627ca --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_03_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_03(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let [|he/*local_var*/llo|] = {}; + +x.hello(); + +hello = {}; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "local_var") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_04_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_04_test.go new file mode 100644 index 0000000000..ea91053dea --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_04_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_04(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function [|he/*local_var*/llo|]() {} + +hello(); +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "local_var") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_05_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_05_test.go new file mode 100644 index 0000000000..ec96c39051 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_05_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_05(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Bar { + public hello() {} +} + +var [|someVar|] = new Bar(); +someVa/*reference*/r.hello();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_06_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_06_test.go new file mode 100644 index 0000000000..b00ee92098 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_06_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_06(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare var [|someVar|]: string; +someVa/*reference*/r` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_07_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_07_test.go new file mode 100644 index 0000000000..737acf11bf --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_07_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_07(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function [|someFunction|](): () => void; +someFun/*reference*/ction();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationLocal_08_test.go b/internal/fourslash/tests/gen/goToImplementationLocal_08_test.go new file mode 100644 index 0000000000..dcede3ae1e --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationLocal_08_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationLocal_08(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function [|someFunction|](): () => void; +someFun/*reference*/ction();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_00_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_00_test.go new file mode 100644 index 0000000000..9bdd97d9f2 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_00_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace /*implementation0*/Foo { + export function hello() {} +} + +module /*implementation1*/Bar { + export function sure() {} +} + +let x = Fo/*reference0*/o; +let y = Ba/*reference1*/r;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference0", "reference1") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_01_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_01_test.go new file mode 100644 index 0000000000..414b997363 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_01_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace Foo { + export function [|hello|]() {} +} + +Foo.hell/*reference*/o();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_02_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_02_test.go new file mode 100644 index 0000000000..0eb0f76eba --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_02_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Foo { + export function [|hello|]() {} +} + +Foo.hell/*reference*/o();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_03_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_03_test.go new file mode 100644 index 0000000000..f10f737c76 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_03_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_03(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace Foo { + export interface Bar { + hello(): void; + } + + class [|BarImpl|] implements Bar { + hello() {} + } +} + +class [|Baz|] implements Foo.Bar { + hello() {} +} + +var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; + +var someVar2 = [|{ hello: () => {/**2*/} }|]; + +function whatever(x: Foo.Ba/*reference*/r) { + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_04_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_04_test.go new file mode 100644 index 0000000000..24bdd2c2e9 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_04_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_04(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Foo { + export interface Bar { + hello(): void; + } + + class [|BarImpl|] implements Bar { + hello() {} + } +} + +class [|Baz|] implements Foo.Bar { + hello() {} +} + +var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; + +var someVar2 = [|{ hello: () => {/**2*/} }|]; + +function whatever(x: Foo.Ba/*reference*/r) { + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_05_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_05_test.go new file mode 100644 index 0000000000..7fe5580ef5 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_05_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_05(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace /*implementation0*/Foo./*implementation2*/Baz { + export function hello() {} +} + +module /*implementation1*/Bar./*implementation3*/Baz { + export function sure() {} +} + +let x = Fo/*reference0*/o; +let y = Ba/*reference1*/r; +let x1 = Foo.B/*reference2*/az; +let y1 = Bar.B/*reference3*/az;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference0", "reference1", "reference2", "reference3") +} diff --git a/internal/fourslash/tests/gen/goToImplementationNamespace_06_test.go b/internal/fourslash/tests/gen/goToImplementationNamespace_06_test.go new file mode 100644 index 0000000000..e878b1bc54 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationNamespace_06_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationNamespace_06(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace [|F/*declaration*/oo|] { + declare function hello(): void; +} + + +let x: typeof Foo = [|{ hello() {} }|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "declaration") +} diff --git a/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_00_test.go b/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_00_test.go new file mode 100644 index 0000000000..04a33c4828 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_00_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationShorthandPropertyAssignment_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + someFunction(): void; +} + +interface FooConstructor { + new (): Foo +} + +interface Bar { + Foo: FooConstructor; +} + +var x = class /*classExpression*/Foo { + createBarInClassExpression(): Bar { + return { + Fo/*classExpressionRef*/o + }; + } + + someFunction() {} +} + +class /*declaredClass*/Foo { + +} + +function createBarUsingClassDeclaration(): Bar { + return { + Fo/*declaredClassRef*/o + }; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "classExpressionRef", "declaredClassRef") +} diff --git a/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_01_test.go b/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_01_test.go new file mode 100644 index 0000000000..df0fbba559 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_01_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationShorthandPropertyAssignment_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + someFunction(): void; +} + +interface FooConstructor { + new (): Foo +} + +interface Bar { + Foo: FooConstructor; +} + +// Class expression that gets used in a bar implementation +var x = class [|Foo|] { + createBarInClassExpression(): Bar { + return { + Foo + }; + } + + someFunction() {} +}; + +// Class declaration that gets used in a bar implementation. This class has multiple definitions +// (the class declaration and the interface above), but we only want the class returned +class [|Foo|] { + +} + +function createBarUsingClassDeclaration(): Bar { + return { + Foo + }; +} + +// Class expression that does not get used in a bar implementation +var y = class Foo { + someFunction() {} +}; + +createBarUsingClassDeclaration().Fo/*reference*/o;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_02_test.go b/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_02_test.go new file mode 100644 index 0000000000..dc118f3744 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationShorthandPropertyAssignment_02_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationShorthandPropertyAssignment_02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Foo { + hello(): void; +} + +function createFoo(): Foo { + return { + hello + }; + + function [|hello|]() {} +} + +function whatever(x: Foo) { + x.h/*function_call*/ello(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "function_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationSuper_00_test.go b/internal/fourslash/tests/gen/goToImplementationSuper_00_test.go new file mode 100644 index 0000000000..61c7bd6dfe --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationSuper_00_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationSuper_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class [|Foo|] { + constructor() {} +} + +class Bar extends Foo { + constructor() { + su/*super_call*/per(); + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "super_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationSuper_01_test.go b/internal/fourslash/tests/gen/goToImplementationSuper_01_test.go new file mode 100644 index 0000000000..128287e4cb --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationSuper_01_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationSuper_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class [|Foo|] { + hello() {} +} + +class Bar extends Foo { + hello() { + sup/*super_call*/er.hello(); + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "super_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationThis_00_test.go b/internal/fourslash/tests/gen/goToImplementationThis_00_test.go new file mode 100644 index 0000000000..df43e906a3 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationThis_00_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationThis_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class [|Bar|] extends Foo { + hello() { + thi/*this_call*/s.whatever(); + } + + whatever() {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "this_call") +} diff --git a/internal/fourslash/tests/gen/goToImplementationThis_01_test.go b/internal/fourslash/tests/gen/goToImplementationThis_01_test.go new file mode 100644 index 0000000000..37ac056763 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationThis_01_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationThis_01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class [|Bar|] extends Foo { + hello(): th/*this_type*/is { + return this; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "this_type") +} diff --git a/internal/fourslash/tests/gen/goToImplementationTypeAlias_00_test.go b/internal/fourslash/tests/gen/goToImplementationTypeAlias_00_test.go new file mode 100644 index 0000000000..914878ce98 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementationTypeAlias_00_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementationTypeAlias_00(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: def.d.ts +export type TypeAlias = { P: number } +// @Filename: ref.ts +import { TypeAlias } from "./def"; +const c: T/*ref*/ypeAlias = [|{ P: 2 }|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "ref") +} diff --git a/internal/fourslash/tests/gen/goToImplementation_inDifferentFiles_test.go b/internal/fourslash/tests/gen/goToImplementation_inDifferentFiles_test.go new file mode 100644 index 0000000000..23ac008447 --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementation_inDifferentFiles_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementation_inDifferentFiles(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/bar.ts +import {Foo} from './foo' + +class [|A|] implements Foo { + func() {} +} + +class [|B|] implements Foo { + func() {} +} +// @Filename: /home/src/workspaces/project/foo.ts +export interface /**/Foo { + func(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToImplementation(t, "") +} diff --git a/internal/fourslash/tests/gen/goToImplementation_satisfies_test.go b/internal/fourslash/tests/gen/goToImplementation_satisfies_test.go new file mode 100644 index 0000000000..fae6a4f70d --- /dev/null +++ b/internal/fourslash/tests/gen/goToImplementation_satisfies_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToImplementation_satisfies(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /a.ts +interface /*def*/I { + foo: string; +} + +function f() { + const foo = { foo: '' } satisfies [|I|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToImplementation(t, "def") +} diff --git a/internal/fourslash/tests/gen/goToModuleAliasDefinition_test.go b/internal/fourslash/tests/gen/goToModuleAliasDefinition_test.go index 4f795fae0a..e068cabd6f 100644 --- a/internal/fourslash/tests/gen/goToModuleAliasDefinition_test.go +++ b/internal/fourslash/tests/gen/goToModuleAliasDefinition_test.go @@ -17,5 +17,5 @@ export class /*2*/Foo {} import /*3*/n = require('a'); var x = new [|/*1*/n|].Foo();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, true, "1") } diff --git a/internal/fourslash/tests/gen/goToTypeDefinition2_test.go b/internal/fourslash/tests/gen/goToTypeDefinition2_test.go new file mode 100644 index 0000000000..ebcbd8ab16 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: goToTypeDefinition2_Definition.ts +interface /*definition*/I1 { + p; +} +type propertyType = I1; +interface I2 { + property: propertyType; +} +// @Filename: goToTypeDefinition2_Consumption.ts +var i2: I2; +i2.prop/*reference*/erty;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition3_test.go b/internal/fourslash/tests/gen/goToTypeDefinition3_test.go new file mode 100644 index 0000000000..959731d36c --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition3_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type /*definition*/T = string; +const x: /*reference*/T;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition4_test.go b/internal/fourslash/tests/gen/goToTypeDefinition4_test.go new file mode 100644 index 0000000000..a1d87d9b40 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition4_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: foo.ts +export type /*def0*/T = string; +export const /*def1*/T = ""; +// @Filename: bar.ts +import { T } from "./foo"; +let x: [|/*reference*/T|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") + f.VerifyBaselineGoToDefinition(t, true, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition5_test.go b/internal/fourslash/tests/gen/goToTypeDefinition5_test.go new file mode 100644 index 0000000000..a6e495eddd --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition5_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: foo.ts +let Foo: /*definition*/unresolved; +type Foo = { x: string }; +/*reference*/Foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionAliases_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionAliases_test.go new file mode 100644 index 0000000000..cf70f8b7e6 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionAliases_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionAliases(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: goToTypeDefinitioAliases_module1.ts +interface /*definition*/I { + p; +} +export {I as I2}; +// @Filename: goToTypeDefinitioAliases_module2.ts +import {I2 as I3} from "./goToTypeDefinitioAliases_module1"; +var v1: I3; +export {v1 as v2}; +// @Filename: goToTypeDefinitioAliases_module3.ts +import {/*reference1*/v2 as v3} from "./goToTypeDefinitioAliases_module2"; +/*reference2*/v3;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference1", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionEnumMembers_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionEnumMembers_test.go new file mode 100644 index 0000000000..6a248e3e46 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionEnumMembers_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionEnumMembers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum E { + value1, + /*definition*/value2 +} +var x = E.value2; + +/*reference*/x;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionImportMeta_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionImportMeta_test.go new file mode 100644 index 0000000000..9cda20577e --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionImportMeta_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionImportMeta(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: foo.ts +/// +/// +import.me/*reference*/ta; +//@Filename: bar.d.ts +interface /*definition*/ImportMeta { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionModifiers_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionModifiers_test.go new file mode 100644 index 0000000000..957d3ff39e --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionModifiers_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionModifiers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +/*export*/export class A/*A*/ { + + /*private*/private z/*z*/: string; + + /*private2*/private y/*y*/: A; + + /*readonly*/readonly x/*x*/: string; + + /*async*/async a/*a*/() { } + + /*override*/override b/*b*/() {} + + /*public1*/public/*public2*/ as/*multipleModifiers*/ync c/*c*/() { } +} + +exp/*exportFunction*/ort function foo/*foo*/() { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "export", "A", "private", "z", "private2", "y", "readonly", "x", "async", "a", "override", "b", "public1", "public2", "multipleModifiers", "c", "exportFunction", "foo") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionModule_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionModule_test.go new file mode 100644 index 0000000000..988f92ddd2 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionModule_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: module1.ts +module /*definition*/M { + export var p; +} +var m: typeof M; +// @Filename: module3.ts +/*reference1*/M; +/*reference2*/m;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference1", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionPrimitives_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionPrimitives_test.go new file mode 100644 index 0000000000..18e9fe06ef --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionPrimitives_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionPrimitives(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: module1.ts +var w: {a: number}; +var x = "string"; +var y: number | string; +var z; // any +// @Filename: module2.ts +w./*reference1*/a; +/*reference2*/x; +/*reference3*/y; +/*reference4*/y;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference1", "reference2", "reference3", "reference4") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionUnionType_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionUnionType_test.go new file mode 100644 index 0000000000..76e52a123e --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionUnionType_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionUnionType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class /*definition0*/C { + p; +} + +interface /*definition1*/I { + x; +} + +module M { + export interface /*definition2*/I { + y; + } +} + +var x: C | I | M.I; + +/*reference*/x;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_Pick_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_Pick_test.go new file mode 100644 index 0000000000..ed7dae6496 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_Pick_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_Pick(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { id: number; name: string; }; +declare const user: Pick +/*reference*/user + +type PickedUser = Pick +declare const user2: PickedUser +/*reference2*/user2` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_arrayType_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_arrayType_test.go new file mode 100644 index 0000000000..8d3803c3bb --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_arrayType_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_arrayType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { name: string }; +declare const users: User[] +/*reference*/users + +type UsersArr = Array +declare const users2: UsersArr +/*reference2*/users2 + +class CustomArray extends Array { immutableReverse() { return [...this].reverse() } } +declare const users3: CustomArray +/*reference3*/users3` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference", "reference2", "reference3") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_promiseType_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_promiseType_test.go new file mode 100644 index 0000000000..c13cbf198d --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_promiseType_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_promiseType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { name: string }; +async function /*reference*/getUser() { return { name: "Bob" } satisfies User as User } + +const /*reference2*/promisedBob = getUser() + +export {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_returnType_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_returnType_test.go new file mode 100644 index 0000000000..930b658c60 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_returnType_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_returnType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface /*I*/I { x: number; } +interface /*J*/J { y: number; } + +function f0(): I { return { x: 0 }; } + +type T = /*T*/(i: I) => I; +const f1: T = i => ({ x: i.x + 1 }); + +const f2 = (i: I): I => ({ x: i.x + 1 }); + +const f3 = (i: I) => (/*f3Def*/{ x: i.x + 1 }); + +const f4 = (i: I) => i; + +const f5 = /*f5Def*/(i: I): I | J => ({ x: i.x + 1 }); + +const f6 = (i: I, j: J, b: boolean) => b ? i : j; + +const /*f7Def*/f7 = (i: I) => {}; + +function f8(i: I): I; +function f8(j: J): J; +function /*f8Def*/f8(ij: any): any { return ij; } + +/*f0*/f0(); +/*f1*/f1(); +/*f2*/f2(); +/*f3*/f3(); +/*f4*/f4(); +/*f5*/f5(); +/*f6*/f6(); +/*f7*/f7(); +/*f8*/f8();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_test.go new file mode 100644 index 0000000000..2b9a7ca2a1 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: goToTypeDefinition_Definition.ts +class /*definition*/C { + p; +} +var c: C; +// @Filename: goToTypeDefinition_Consumption.ts +/*reference*/c = undefined;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_typeReference_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_typeReference_test.go new file mode 100644 index 0000000000..e7e8ae6ee9 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_typeReference_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_typeReference(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { name: string }; +type Box = { value: T }; +declare const boxedUser: Box +/*reference*/boxedUser` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_typedef_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_typedef_test.go new file mode 100644 index 0000000000..8f8c1868cb --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_typedef_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_typedef(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +/** + * /*def*/@typedef {object} I + * @property {number} x + */ + +/** @type {I} */ +const /*ref*/i = { x: 0 };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "ref") +} diff --git a/internal/fourslash/tests/gen/gotoDefinitionConstructorFunction_test.go b/internal/fourslash/tests/gen/gotoDefinitionConstructorFunction_test.go index c50e0c3da9..1f4bdfc482 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionConstructorFunction_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionConstructorFunction_test.go @@ -24,5 +24,5 @@ function runMode () { new [|/*start*/StringStreamm|]() };` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "start") + f.VerifyBaselineGoToDefinition(t, true, "start") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern1_test.go b/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern1_test.go index 065f1e429d..898005e744 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern1_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern1_test.go @@ -19,5 +19,5 @@ interface Test { } bar(({[|pr/*goto*/op2|]})=>{});` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "goto") + f.VerifyBaselineGoToDefinition(t, true, "goto") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern2_test.go b/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern2_test.go index 1c21fbf704..b86506f5e0 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern2_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionInObjectBindingPattern2_test.go @@ -14,5 +14,5 @@ func TestGotoDefinitionInObjectBindingPattern2(t *testing.T) { const content = `var p0 = ({a/*1*/a}) => {console.log(aa)}; function f2({ [|a/*a1*/1|], [|b/*b1*/1|] }: { /*a1_dest*/a1: number, /*b1_dest*/b1: number } = { a1: 0, b1: 0 }) {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "a1", "b1") + f.VerifyBaselineGoToDefinition(t, true, "1", "a1", "b1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionLinkTag1_test.go b/internal/fourslash/tests/gen/gotoDefinitionLinkTag1_test.go index 78f94a66b0..89e5171464 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionLinkTag1_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionLinkTag1_test.go @@ -36,5 +36,5 @@ function foo(x) { } /** {@link /*use7*/[|Foo|] }dd*/ const f = ""` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use1", "use2", "use3", "use4", "use5", "use6", "use7") + f.VerifyBaselineGoToDefinition(t, false, "use1", "use2", "use3", "use4", "use5", "use6", "use7") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionLinkTag2_test.go b/internal/fourslash/tests/gen/gotoDefinitionLinkTag2_test.go index 1a71fdebf9..a146bd1d09 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionLinkTag2_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionLinkTag2_test.go @@ -16,5 +16,5 @@ func TestGotoDefinitionLinkTag2(t *testing.T) { [|/*2*/A|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionLinkTag3_test.go b/internal/fourslash/tests/gen/gotoDefinitionLinkTag3_test.go index bffc3f3939..31c7af31ec 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionLinkTag3_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionLinkTag3_test.go @@ -20,5 +20,5 @@ interface [|/*2*/Foo|] { foo: E.Foo; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionLinkTag4_test.go b/internal/fourslash/tests/gen/gotoDefinitionLinkTag4_test.go index 4ce0bb3688..da2fc4a5bc 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionLinkTag4_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionLinkTag4_test.go @@ -21,5 +21,5 @@ enum E { Foo }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionLinkTag5_test.go b/internal/fourslash/tests/gen/gotoDefinitionLinkTag5_test.go index 8c13319dd1..a8be0065f8 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionLinkTag5_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionLinkTag5_test.go @@ -17,5 +17,5 @@ func TestGotoDefinitionLinkTag5(t *testing.T) { [|/*2*/B|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionLinkTag6_test.go b/internal/fourslash/tests/gen/gotoDefinitionLinkTag6_test.go index 129ce4cb00..7dcbdc64cd 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionLinkTag6_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionLinkTag6_test.go @@ -16,5 +16,5 @@ func TestGotoDefinitionLinkTag6(t *testing.T) { [|/*2*/A|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionPropertyAccessExpressionHeritageClause_test.go b/internal/fourslash/tests/gen/gotoDefinitionPropertyAccessExpressionHeritageClause_test.go index 33da44d58e..f172cbb95b 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionPropertyAccessExpressionHeritageClause_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionPropertyAccessExpressionHeritageClause_test.go @@ -18,5 +18,5 @@ function foo() { class C extends (foo()).[|/*B*/B|] {} class C1 extends foo().[|/*B1*/B|] {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "B", "B1") + f.VerifyBaselineGoToDefinition(t, true, "B", "B1") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionSatisfiesTag_test.go b/internal/fourslash/tests/gen/gotoDefinitionSatisfiesTag_test.go index 433911b622..3320e7dfbc 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionSatisfiesTag_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionSatisfiesTag_test.go @@ -23,5 +23,5 @@ func TestGotoDefinitionSatisfiesTag(t *testing.T) { /** @satisfies {/*use*/[|T|]} comment */ const foo = { a: 1 };` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, false, "use") } diff --git a/internal/fourslash/tests/gen/gotoDefinitionThrowsTag_test.go b/internal/fourslash/tests/gen/gotoDefinitionThrowsTag_test.go index 406c93d8c0..5029bfe1da 100644 --- a/internal/fourslash/tests/gen/gotoDefinitionThrowsTag_test.go +++ b/internal/fourslash/tests/gen/gotoDefinitionThrowsTag_test.go @@ -18,5 +18,5 @@ func TestGotoDefinitionThrowsTag(t *testing.T) { */ function f() {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, false, "use") } diff --git a/internal/fourslash/tests/gen/hoverOverComment_test.go b/internal/fourslash/tests/gen/hoverOverComment_test.go index 971e578dc1..c6cbac301f 100644 --- a/internal/fourslash/tests/gen/hoverOverComment_test.go +++ b/internal/fourslash/tests/gen/hoverOverComment_test.go @@ -18,5 +18,5 @@ func TestHoverOverComment(t *testing.T) { f.GoToMarker(t, "") f.VerifyQuickInfoIs(t, "", "") f.VerifyBaselineFindAllReferences(t, "") - f.VerifyBaselineGoToDefinition(t, "") + f.VerifyBaselineGoToDefinition(t, false, "") } diff --git a/internal/fourslash/tests/gen/implementation01_test.go b/internal/fourslash/tests/gen/implementation01_test.go new file mode 100644 index 0000000000..2e3b57c619 --- /dev/null +++ b/internal/fourslash/tests/gen/implementation01_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImplementation01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Fo/*1*/o {} +class /*2*/Bar implements Foo {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToImplementation(t, "1") +} diff --git a/internal/fourslash/tests/gen/importCompletions_importsMap1_test.go b/internal/fourslash/tests/gen/importCompletions_importsMap1_test.go index 4b173fb093..8a15ddefce 100644 --- a/internal/fourslash/tests/gen/importCompletions_importsMap1_test.go +++ b/internal/fourslash/tests/gen/importCompletions_importsMap1_test.go @@ -37,6 +37,7 @@ export const isBrowser = false; // @Filename: /home/src/workspaces/project/src/a.ts import {} from "/*1*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, []string{"1"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/importCompletions_importsMap2_test.go b/internal/fourslash/tests/gen/importCompletions_importsMap2_test.go index 8a602bf253..8c025e19e0 100644 --- a/internal/fourslash/tests/gen/importCompletions_importsMap2_test.go +++ b/internal/fourslash/tests/gen/importCompletions_importsMap2_test.go @@ -33,6 +33,7 @@ export function something(name: string) {} import {} from "/*1*/"; import {} from "#internal//*2*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, []string{"1"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/importCompletions_importsMap3_test.go b/internal/fourslash/tests/gen/importCompletions_importsMap3_test.go index 8b7ddfd85d..13ddd8f868 100644 --- a/internal/fourslash/tests/gen/importCompletions_importsMap3_test.go +++ b/internal/fourslash/tests/gen/importCompletions_importsMap3_test.go @@ -33,6 +33,7 @@ export function something(name: string) {} import {} from "/*1*/"; import {} from "#internal//*2*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, []string{"1"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/importCompletions_importsMap4_test.go b/internal/fourslash/tests/gen/importCompletions_importsMap4_test.go index d1ed920327..041a06d42e 100644 --- a/internal/fourslash/tests/gen/importCompletions_importsMap4_test.go +++ b/internal/fourslash/tests/gen/importCompletions_importsMap4_test.go @@ -35,6 +35,7 @@ export const isBrowser = true; // @Filename: /home/src/workspaces/project/src/a.ts import {} from "/*1*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, []string{"1"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/importCompletions_importsMap5_test.go b/internal/fourslash/tests/gen/importCompletions_importsMap5_test.go index 18b3397015..0b610c6ab1 100644 --- a/internal/fourslash/tests/gen/importCompletions_importsMap5_test.go +++ b/internal/fourslash/tests/gen/importCompletions_importsMap5_test.go @@ -36,6 +36,7 @@ export const isBrowser = true; // @Filename: /home/src/workspaces/project/src/a.ts import {} from "/*1*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, []string{"1"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/importFixWithMultipleModuleExportAssignment_test.go b/internal/fourslash/tests/gen/importFixWithMultipleModuleExportAssignment_test.go new file mode 100644 index 0000000000..e0f9edde84 --- /dev/null +++ b/internal/fourslash/tests/gen/importFixWithMultipleModuleExportAssignment_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportFixWithMultipleModuleExportAssignment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @allowJs: true +// @checkJs: true +// @Filename: /a.js +function f() {} +module.exports = f; +module.exports = 42; +// @Filename: /b.js +export const foo = 0; +// @Filename: /c.js +foo` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/c.js") + f.VerifyImportFixAtPosition(t, []string{ + `const { foo } = require("./b"); + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importFixesGlobalTypingsCache_test.go b/internal/fourslash/tests/gen/importFixesGlobalTypingsCache_test.go new file mode 100644 index 0000000000..b0393b485a --- /dev/null +++ b/internal/fourslash/tests/gen/importFixesGlobalTypingsCache_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportFixesGlobalTypingsCache(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /project/tsconfig.json + { "compilerOptions": { "allowJs": true, "checkJs": true } } +// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/package.json + { "name": "@types/react-router-dom", "version": "16.8.4", "types": "index.d.ts" } +// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/index.d.ts +export class BrowserRouter {} +// @Filename: /project/node_modules/react-router-dom/package.json + { "name": "react-router-dom", "version": "16.8.4", "main": "index.js" } +// @Filename: /project/node_modules/react-router-dom/index.js + export const BrowserRouter = () => null; +// @Filename: /project/index.js +BrowserRouter/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/project/index.js") + f.VerifyImportFixAtPosition(t, []string{ + `const { BrowserRouter } = require("react-router-dom"); + +BrowserRouter`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importFixes_quotePreferenceDouble_importHelpers_test.go b/internal/fourslash/tests/gen/importFixes_quotePreferenceDouble_importHelpers_test.go new file mode 100644 index 0000000000..06b9436e0a --- /dev/null +++ b/internal/fourslash/tests/gen/importFixes_quotePreferenceDouble_importHelpers_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportFixes_quotePreferenceDouble_importHelpers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @importHelpers: true +// @filename: /a.ts +export default () => {}; +// @filename: /b.ts +export default () => {}; +// @filename: /test.ts +import a from "./a"; +[|b|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import b from "./b"; +b`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importFixes_quotePreferenceSingle_importHelpers_test.go b/internal/fourslash/tests/gen/importFixes_quotePreferenceSingle_importHelpers_test.go new file mode 100644 index 0000000000..228e3087e2 --- /dev/null +++ b/internal/fourslash/tests/gen/importFixes_quotePreferenceSingle_importHelpers_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportFixes_quotePreferenceSingle_importHelpers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @importHelpers: true +// @filename: /a.ts +export default () => {}; +// @filename: /b.ts +export default () => {}; +// @filename: /test.ts +import a from './a'; +[|b|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import b from './b'; +b`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixConvertTypeOnly1_test.go b/internal/fourslash/tests/gen/importNameCodeFixConvertTypeOnly1_test.go new file mode 100644 index 0000000000..fdf289e16a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixConvertTypeOnly1_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixConvertTypeOnly1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export class A {} +export class B {} +// @Filename: /b.ts +import type { A } from './a'; +new B` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { B, type A } from './a'; +new B`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport1_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport1_test.go new file mode 100644 index 0000000000..52cea508c2 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport1_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo-bar.ts +export default function fooBar(); +// @Filename: /b.ts +[|import * as fb from "./foo-bar"; +foo/**/Bar|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import fooBar, * as fb from "./foo-bar"; +fooBar`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport2_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport2_test.go new file mode 100644 index 0000000000..de4fe9d2f6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport2_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /lib.ts +class Base { } +export default Base; +// @Filename: /test.ts +[|class Derived extends Base { }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import Base from "./lib"; + +class Derived extends Base { }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport3_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport3_test.go new file mode 100644 index 0000000000..51fb3c50a6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport3_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo-bar/index.ts +export default 0; +// @Filename: /b.ts +[|foo/**/Bar|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import fooBar from "./foo-bar"; + +fooBar`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport4_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport4_test.go new file mode 100644 index 0000000000..7b911543b5 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport4_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo.ts +const a = () => {}; +export default a; +// @Filename: /test.ts +[|foo|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "./foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport5_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport5_test.go new file mode 100644 index 0000000000..c06e07ba0e --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport5_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @Filename: /node_modules/hooks/useFoo.ts +declare const _default: () => void; +export default _default; +// @Filename: /test.ts +[|useFoo|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import useFoo from "hooks/useFoo"; + +useFoo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport6_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport6_test.go new file mode 100644 index 0000000000..43b6d1076a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport6_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default Math.foo; +// @Filename: /index.ts +a/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "a", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import a from "./a"; + +a`), + }) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport7_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport7_test.go new file mode 100644 index 0000000000..1ca3fbf64a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport7_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @lib: dom +// @Filename: foo.ts +export default globalThis.localStorage; +// @Filename: index.ts +foo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "./foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport_test.go new file mode 100644 index 0000000000..32c7ac6873 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo-bar.ts +export default 0; +// @Filename: /b.ts +[|foo/**/Bar|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import fooBar from "./foo-bar"; + +fooBar`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport0_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport0_test.go new file mode 100644 index 0000000000..4553d948be --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport0_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ v1 }|] from "./module"; +f1/*0*/(); +// @Filename: module.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ f1, v1 }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport10_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport10_test.go new file mode 100644 index 0000000000..836756a4f6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport10_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport10(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ + v1, + v2 +}|] from "./module"; +f1/*0*/(); +// @Filename: module.ts +export function f1() {} +export var v1 = 5; +export var v2 = 5; +export var v3 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ + f1, + v1, + v2 +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport11_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport11_test.go new file mode 100644 index 0000000000..da6b393b5b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport11_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport11(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ + v1, v2, + v3 +}|] from "./module"; +f1/*0*/(); +// @Filename: module.ts + export function f1() {} + export var v1 = 5; + export var v2 = 5; + export var v3 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ + f1, + v1, v2, + v3 +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport12_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport12_test.go new file mode 100644 index 0000000000..9b5c7e8d75 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport12_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport12(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{}|] from "./module"; +f1/*0*/(); +// @Filename: module.ts +export function f1() {} +export var v1 = 5; +export var v2 = 5; +export var v3 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ f1 }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport1_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport1_test.go new file mode 100644 index 0000000000..31c9f9ea01 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import d, [|{ v1 }|] from "./module"; +f1/*0*/(); +// @Filename: module.ts +export function f1() {} +export var v1 = 5; +export default var d1 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ f1, v1 }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport2_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport2_test.go new file mode 100644 index 0000000000..0602242203 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import * as ns from "./module"; +// Comment +f1/*0*/(); +// @Filename: module.ts + export function f1() {} + export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as ns from "./module"; +// Comment +ns.f1();`, + `import * as ns from "./module"; +import { f1 } from "./module"; +// Comment +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport3_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport3_test.go new file mode 100644 index 0000000000..041f86f0e2 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport3_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import d, * as ns from "./module" ; +f1/*0*/();|] +// @Filename: module.ts +export function f1() {} +export var v1 = 5; +export default var d1 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import d, * as ns from "./module" ; +ns.f1();`, + `import d, * as ns from "./module" ; +import { f1 } from "./module"; +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport4_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport4_test.go new file mode 100644 index 0000000000..19e959db2d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport4_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import d from "./module"; +f1/*0*/();|] +// @Filename: module.ts +export function f1() {} +export var v1 = 5; +export default var d1 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import d, { f1 } from "./module"; +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport5_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport5_test.go new file mode 100644 index 0000000000..31610760a8 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport5_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import "./module"; +f1/*0*/();|] +// @Filename: module.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import "./module"; +import { f1 } from "./module"; +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport6_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport6_test.go new file mode 100644 index 0000000000..bc15f5e573 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport6_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ v1 }|] from "fake-module"; +f1/*0*/(); +// @Filename: ../package.json +{ "dependencies": { "fake-module": "latest" } } +// @Filename: ../node_modules/fake-module/index.ts +export var v1 = 5; +export function f1();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ f1, v1 }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport7_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport7_test.go new file mode 100644 index 0000000000..e82d0ed3fd --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport7_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ v1 }|] from "../other_dir/module"; +f1/*0*/(); +// @Filename: ../other_dir/module.ts +export var v1 = 5; +export function f1();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ f1, v1 }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport8_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport8_test.go new file mode 100644 index 0000000000..0ae3edc2e4 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport8_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport8(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{v1, v2, v3,}|] from "./module"; +v4/*0*/(); +// @Filename: module.ts +export function v4() {} +export var v1 = 5; +export var v2 = 5; +export var v3 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{v1, v2, v3, v4,}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImport9_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImport9_test.go new file mode 100644 index 0000000000..71964dca5f --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImport9_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImport9(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ + v1 +}|] from "./module"; +f1/*0*/(); +// @Filename: module.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `{ + f1, + v1 +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExistingImportEquals0_test.go b/internal/fourslash/tests/gen/importNameCodeFixExistingImportEquals0_test.go new file mode 100644 index 0000000000..0cf8875bb5 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExistingImportEquals0_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExistingImportEquals0(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import ns = require("ambient-module"); +var x = v1/*0*/ + 5;|] +// @Filename: ambientModule.ts +declare module "ambient-module" { + export function f1(); + export var v1; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import ns = require("ambient-module"); +var x = ns.v1 + 5;`, + `import { v1 } from "ambient-module"; +import ns = require("ambient-module"); +var x = v1 + 5;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExportAsDefaultExistingImport_test.go b/internal/fourslash/tests/gen/importNameCodeFixExportAsDefaultExistingImport_test.go new file mode 100644 index 0000000000..97df987bbe --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExportAsDefaultExistingImport_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExportAsDefaultExistingImport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import [|{ v1, v2, v3 }|] from "./module"; +v4/*0*/(); +// @Filename: module.ts +const v4 = 5; +export { v4 as default }; +export const v1 = 5; +export const v2 = 5; +export const v3 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `v4, { v1, v2, v3 }`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExportAsDefault_test.go b/internal/fourslash/tests/gen/importNameCodeFixExportAsDefault_test.go new file mode 100644 index 0000000000..d5b712b078 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExportAsDefault_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExportAsDefault(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo.ts +const foo = 'foo' +export { foo as default } +// @Filename: /index.ts + foo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./foo", + Description: "Add import from \"./foo\"", + NewFileContent: PtrTo(`import foo from "./foo"; + +foo`), + }) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixIndentedIdentifier_test.go b/internal/fourslash/tests/gen/importNameCodeFixIndentedIdentifier_test.go new file mode 100644 index 0000000000..b5c0e91aec --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixIndentedIdentifier_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixIndentedIdentifier(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +[|import * as b from "./b"; +{ + x/**/ +}|] +// @Filename: /b.ts +export const x = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as b from "./b"; +{ + b.x +}`, + `import * as b from "./b"; +import { x } from "./b"; +{ + x +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports0_test.go new file mode 100644 index 0000000000..4c8fc42141 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports0_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAllowSyntheticDefaultImports0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: true +// @Filename: a/f1.ts +[|export var x = 0; +bar/*0*/();|] +// @Filename: a/foo.d.ts +declare function bar(): number; +export = bar; +export as namespace bar;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import bar from "./foo"; + +export var x = 0; +bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports1_test.go new file mode 100644 index 0000000000..4e197d35c8 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAllowSyntheticDefaultImports1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Module: system +// @Filename: a/f1.ts +[|export var x = 0; +bar/*0*/();|] +// @Filename: a/foo.d.ts +declare function bar(): number; +export = bar; +export as namespace bar;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import bar from "./foo"; + +export var x = 0; +bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports2_test.go new file mode 100644 index 0000000000..3b3daf56b3 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAllowSyntheticDefaultImports2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: system +// @Filename: a/f1.ts +[|export var x = 0; +bar/*0*/();|] +// @Filename: a/foo.d.ts +declare function bar(): number; +export = bar; +export as namespace bar;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as bar from "./foo"; + +export var x = 0; +bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports3_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports3_test.go new file mode 100644 index 0000000000..4da5bbf181 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports3_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAllowSyntheticDefaultImports3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: commonjs +// @Filename: a/f1.ts +[|export var x = 0; +bar/*0*/();|] +// @Filename: a/foo.d.ts +declare function bar(): number; +export = bar; +export as namespace bar;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import bar = require("./foo"); + +export var x = 0; +bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports4_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports4_test.go new file mode 100644 index 0000000000..8611d94c55 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports4_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAllowSyntheticDefaultImports4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: amd +// @Filename: a/f1.ts +[|export var x = 0; +bar/*0*/();|] +// @Filename: a/foo.d.ts +declare function bar(): number; +export = bar; +export as namespace bar;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import bar = require("./foo"); + +export var x = 0; +bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports5_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports5_test.go new file mode 100644 index 0000000000..97912e6a85 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAllowSyntheticDefaultImports5_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAllowSyntheticDefaultImports5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: umd +// @Filename: a/f1.ts +[|export var x = 0; +bar/*0*/();|] +// @Filename: a/foo.d.ts +declare function bar(): number; +export = bar; +export as namespace bar;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import bar = require("./foo"); + +export var x = 0; +bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient0_test.go new file mode 100644 index 0000000000..3b2776f970 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient0_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAmbient0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: ambientModule.ts +declare module "ambient-module" { + export function f1(); + export var v1; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "ambient-module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient1_test.go new file mode 100644 index 0000000000..22892b732c --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient1_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAmbient1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import d from "other-ambient-module"; +import * as ns from "yet-another-ambient-module"; +var x = v1/*0*/ + 5; +// @Filename: ambientModule.ts +declare module "ambient-module" { + export function f1(); + export var v1; +} +// @Filename: otherAmbientModule.ts +declare module "other-ambient-module" { + export default function f2(); +} +// @Filename: yetAnotherAmbientModule.ts +declare module "yet-another-ambient-module" { + export function f3(); + export var v3; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { v1 } from "ambient-module"; +import d from "other-ambient-module"; +import * as ns from "yet-another-ambient-module"; +var x = v1 + 5;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient2_test.go new file mode 100644 index 0000000000..592328caa5 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient2_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAmbient2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|/*! + * I'm a license or something + */ +f1/*0*/();|] +// @Filename: ambientModule.ts + declare module "ambient-module" { + export function f1(); + export var v1; + }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `/*! + * I'm a license or something + */ + +import { f1 } from "ambient-module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient3_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient3_test.go new file mode 100644 index 0000000000..d20e88242d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportAmbient3_test.go @@ -0,0 +1,40 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportAmbient3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let a = "I am a non-trivial statement that appears before imports"; +import d from "other-ambient-module" +import * as ns from "yet-another-ambient-module" +var x = v1/*0*/ + 5; +// @Filename: ambientModule.ts +declare module "ambient-module" { + export function f1(); + export var v1; +} +// @Filename: otherAmbientModule.ts +declare module "other-ambient-module" { + export default function f2(); +} +// @Filename: yetAnotherAmbientModule.ts +declare module "yet-another-ambient-module" { + export function f3(); + export var v3; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `let a = "I am a non-trivial statement that appears before imports"; +import { v1 } from "ambient-module"; +import d from "other-ambient-module" +import * as ns from "yet-another-ambient-module" +var x = v1 + 5;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl0_test.go new file mode 100644 index 0000000000..dd4b002813 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl0_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportBaseUrl0(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: tsconfig.json +{ + "compilerOptions": { + "baseUrl": "./a" + } +} +// @Filename: a/b.ts +export function f1() { };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "b"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl1_test.go new file mode 100644 index 0000000000..a3ce15ee9c --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl1_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportBaseUrl1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": "./a" + } +} +// @Filename: /a/b/x.ts +export function f1() { }; +// @Filename: /a/b/y.ts +[|f1/*0*/();|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a/b/y.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "./x"; + +f1();`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "b/x"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl2_test.go new file mode 100644 index 0000000000..0796d349b6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportBaseUrl2_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportBaseUrl2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": "./a" + } +} +// @Filename: /a/b/x.ts +export function f1() { }; +// @Filename: /a/c/y.ts +[|f1/*0*/();|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a/c/y.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "b/x"; + +f1();`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "../b/x"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportDefault0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportDefault0_test.go new file mode 100644 index 0000000000..f74774cf90 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportDefault0_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportDefault0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: module.ts +export default function f1() { };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import f1 from "./module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsCommonJSInteropOn_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsCommonJSInteropOn_test.go new file mode 100644 index 0000000000..b058fb5b34 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsCommonJSInteropOn_test.go @@ -0,0 +1,62 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportExportEqualsCommonJSInteropOn(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Module: commonjs +// @EsModuleInterop: true +// @Filename: /foo.d.ts +declare module "bar" { + const bar: number; + export = bar; +} +declare module "foo" { + const foo: number; + export = foo; +} +declare module "es" { + const es = 0; + export default es; +} +// @Filename: /a.ts +import bar = require("bar"); + +foo +// @Filename: /b.ts +foo +// @Filename: /c.ts +import es from "es"; +import bar = require("bar"); + +foo` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import bar = require("bar"); +import foo = require("foo"); + +foo`, + }, nil /*preferences*/) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "foo"; + +foo`, + }, nil /*preferences*/) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import es from "es"; +import bar = require("bar"); +import foo = require("foo"); + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsESNextInteropOff_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsESNextInteropOff_test.go new file mode 100644 index 0000000000..b8b70b3191 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsESNextInteropOff_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportExportEqualsESNextInteropOff(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Module: esnext +// @Filename: /foo.d.ts +declare module "foo" { + const foo: number; + export = foo; +} +// @Filename: /index.ts +foo` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/index.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsESNextInteropOn_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsESNextInteropOn_test.go new file mode 100644 index 0000000000..acb8eaf0d3 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportExportEqualsESNextInteropOn_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportExportEqualsESNextInteropOn(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @EsModuleInterop: true +// @Module: es2015 +// @Filename: /foo.d.ts +declare module "foo" { + const foo: number; + export = foo; +} +// @Filename: /index.ts +[|foo|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/index.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFile0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile0_test.go new file mode 100644 index 0000000000..b72c4f7f00 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile0_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFile0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: jalapeÃąo.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "./jalapeÃąo"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFile1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile1_test.go new file mode 100644 index 0000000000..a4babb34d7 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFile1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|/// +f1/*0*/();|] +// @Filename: Module.ts +export function f1() {} +export var v1 = 5; +// @Filename: tripleSlashReference.ts +var x = 5;/*dummy*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `/// + +import { f1 } from "./Module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFile2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile2_test.go new file mode 100644 index 0000000000..a1e91b616c --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile2_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFile2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: ../../other_dir/module.ts +export var v1 = 5; +export function f1();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "../../other_dir/module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFile3_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile3_test.go new file mode 100644 index 0000000000..056d7c4900 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile3_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFile3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|let t: XXX/*0*/.I;|] +// @Filename: ./module.ts +export module XXX { + export interface I { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { XXX } from "./module"; + +let t: XXX.I;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFile4_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile4_test.go new file mode 100644 index 0000000000..d1adddbd81 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFile4_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFile4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|let t: A/*0*/.B.I;|] +// @Filename: ./module.ts +export namespace A { + export namespace B { + export interface I { } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { A } from "./module"; + +let t: A.B.I;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileAllComments_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileAllComments_test.go new file mode 100644 index 0000000000..f80f1c7ec9 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileAllComments_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileAllComments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|/*! + * This is a license or something + */ +/// +/// +/// +/** + * This is a comment intended to be attached to this interface + */ +export interface SomeInterface { +} +f1/*0*/();|] +// @Filename: module.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `/*! + * This is a license or something + */ +/// +/// +/// + +import { f1 } from "./module"; + +/** + * This is a comment intended to be attached to this interface + */ +export interface SomeInterface { +} +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileDetachedComments_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileDetachedComments_test.go new file mode 100644 index 0000000000..9cb3620715 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileDetachedComments_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileDetachedComments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|/** + * This is a comment intended to be attached to this interface + */ +export interface SomeInterface { +} +f1/*0*/();|] +// @Filename: module.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "./module"; + +/** + * This is a comment intended to be attached to this interface + */ +export interface SomeInterface { +} +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle0_test.go new file mode 100644 index 0000000000..40922da0e1 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle0_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileQuoteStyle0(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import { v2 } from './module2'; + +f1/*0*/();|] +// @Filename: module1.ts +export function f1() {} +// @Filename: module2.ts +export var v2 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from './module1'; +import { v2 } from './module2'; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle1_test.go new file mode 100644 index 0000000000..04cdc80d4b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle1_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileQuoteStyle1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import { v2 } from "./module2"; + +f1/*0*/();|] +// @Filename: module1.ts +export function f1() {} +// @Filename: module2.ts +export var v2 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "./module1"; +import { v2 } from "./module2"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle2_test.go new file mode 100644 index 0000000000..464fae8baa --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle2_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileQuoteStyle2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import m2 = require('./module2'); + +f1/*0*/();|] +// @Filename: module1.ts +export function f1() {} +// @Filename: module2.ts +export var v2 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from './module1'; +import m2 = require('./module2'); + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle3_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle3_test.go new file mode 100644 index 0000000000..f7799d0470 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyle3_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileQuoteStyle3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|export { v2 } from './module2'; + +f1/*0*/();|] +// @Filename: module1.ts +export function f1() {} +// @Filename: module2.ts +export var v2 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from './module1'; + +export { v2 } from './module2'; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyleMixed0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyleMixed0_test.go new file mode 100644 index 0000000000..5be114b185 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyleMixed0_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileQuoteStyleMixed0(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import { v2 } from "./module2"; +import { v3 } from './module3'; + +f1/*0*/();|] +// @Filename: module1.ts +export function f1() {} +// @Filename: module2.ts +export var v2 = 6; +// @Filename: module3.ts +export var v3 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "./module1"; +import { v2 } from "./module2"; +import { v3 } from './module3'; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyleMixed1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyleMixed1_test.go new file mode 100644 index 0000000000..ea402be77d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFileQuoteStyleMixed1_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFileQuoteStyleMixed1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|import { v2 } from './module2'; +import { v3 } from "./module3"; + +f1/*0*/();|] +// @Filename: module1.ts +export function f1() {} +// @Filename: module2.ts +export var v2 = 6; +// @Filename: module3.ts +export var v3 = 6;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from './module1'; +import { v2 } from './module2'; +import { v3 } from "./module3"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFromAtTypesScopedPackage_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFromAtTypesScopedPackage_test.go new file mode 100644 index 0000000000..1bddf142ab --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFromAtTypesScopedPackage_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFromAtTypesScopedPackage(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: node_modules/@types/myLib__scoped/index.d.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "@myLib/scoped"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportFromAtTypes_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportFromAtTypes_test.go new file mode 100644 index 0000000000..9999dd1b94 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportFromAtTypes_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportFromAtTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: node_modules/@types/myLib/index.d.ts +export function f1() {} +export var v1 = 5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "myLib"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportIndex_notForClassicResolution_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportIndex_notForClassicResolution_test.go new file mode 100644 index 0000000000..28987429d2 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportIndex_notForClassicResolution_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportIndex_notForClassicResolution(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: classic +// @Filename: /a/index.ts +export const foo = 0; +// @Filename: /node_modules/x/index.d.ts +export const bar = 0; +// @Filename: /b.ts +[|foo;|] +// @Filename: /c.ts +[|bar;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a/index.ts") + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "./a/index"; + +foo;`, + }, nil /*preferences*/) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { bar } from "./node_modules/x/index"; + +bar;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportIndex_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportIndex_test.go new file mode 100644 index 0000000000..997183b8bb --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportIndex_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportIndex(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a/index.ts +export const foo = 0; +// @Filename: /b.ts +[|/**/foo;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a/index.ts") + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "./a"; + +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules0_test.go new file mode 100644 index 0000000000..37276238c6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules0_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: ../package.json +{ "dependencies": { "fake-module": "latest" } } +// @Filename: ../node_modules/fake-module/index.ts +export var v1 = 5; +export function f1(); +// @Filename: ../node_modules/fake-module/package.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "fake-module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules1_test.go new file mode 100644 index 0000000000..36d5ac9762 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules1_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: ../package.json +{ "dependencies": { "fake-module": "latest" } } +// @Filename: ../node_modules/fake-module/nested.ts +export var v1 = 5; +export function f1();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "fake-module/nested"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules2_test.go new file mode 100644 index 0000000000..1c3c9f578b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules2_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/();|] +// @Filename: ../package.json +{ "dependencies": { "fake-module": "latest" } } +// @Filename: ../node_modules/fake-module/notindex.d.ts +export var v1 = 5; +export function f1(); +// @Filename: ../node_modules/fake-module/notindex.js +module.exports = { + v1: 5, + f1: function () {} +}; +// @Filename: ../node_modules/fake-module/package.json +{ "main":"./notindex.js", "typings":"./notindex.d.ts" }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "fake-module"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules3_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules3_test.go new file mode 100644 index 0000000000..93e39ffc5b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules3_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +[|f1/*0*/();|] +// @Filename: /node_modules/@types/random/index.d.ts +export var v1 = 5; +export function f1();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "random"; + +f1();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules4_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules4_test.go new file mode 100644 index 0000000000..db140c6eaf --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules4_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/('');|] +// @Filename: package.json +{ "dependencies": { "package-name": "latest" } } +// @Filename: node_modules/package-name/bin/lib/libfile.d.ts +export function f1(text: string): string; +// @Filename: node_modules/package-name/bin/lib/libfile.js +function f1(text) { } +exports.f1 = f1; +// @Filename: node_modules/package-name/package.json +{ + "main": "bin/lib/libfile.js", + "types": "bin/lib/libfile.d.ts" +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "package-name"; + +f1('');`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules6_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules6_test.go new file mode 100644 index 0000000000..93c9eb9174 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules6_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/('');|] +// @Filename: package.json +{ "dependencies": { "package-name": "latest" } } +// @Filename: node_modules/package-name/bin/lib/index.d.ts +export function f1(text: string): string; +// @Filename: node_modules/package-name/bin/lib/index.js +function f1(text) { } +exports.f1 = f1; +// @Filename: node_modules/package-name/package.json +{ + "main": "bin/lib/index.js", + "types": "bin/lib/index.d.ts" +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "package-name"; + +f1('');`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules7_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules7_test.go new file mode 100644 index 0000000000..3b0216ab89 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules7_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/('');|] +// @Filename: package.json +{ "dependencies": { "package-name": "0.0.1" } } +// @Filename: node_modules/package-name/bin/lib/libfile.d.ts +export declare function f1(text: string): string; +// @Filename: node_modules/package-name/bin/lib/libfile.js +function f1(text) {} +exports.f1 = f1; +// @Filename: node_modules/package-name/package.json +{ "main": "bin/lib/libfile.js" }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "package-name"; + +f1('');`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules8_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules8_test.go new file mode 100644 index 0000000000..3be79505b8 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportNodeModules8_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportNodeModules8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|f1/*0*/('');|] +// @Filename: package.json +{ "dependencies": { "@scope/package-name": "latest" } } +// @Filename: node_modules/@scope/package-name/bin/lib/index.d.ts +export function f1(text: string): string; +// @Filename: node_modules/@scope/package-name/bin/lib/index.js +function f1(text) { } +exports.f1 = f1; +// @Filename: node_modules/@scope/package-name/package.json +{ + "main": "bin/lib/index.js", + "types": "bin/lib/index.d.ts" +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { f1 } from "@scope/package-name"; + +f1('');`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths0_test.go new file mode 100644 index 0000000000..508996c694 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths0_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportPaths0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|foo/*0*/();|] +// @Filename: folder_a/f2.ts +export function foo() {}; +// @Filename: tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "a": [ "folder_a/f2" ] + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "a"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths1_test.go new file mode 100644 index 0000000000..96f8460d4f --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths1_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportPaths1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|foo/*0*/();|] +// @Filename: folder_b/f2.ts +export function foo() {}; +// @Filename: tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "b/*": [ "folder_b/*" ] + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "b/f2"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths2_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths2_test.go new file mode 100644 index 0000000000..b291f27f7b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths2_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportPaths2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|foo/*0*/();|] +// @Filename: folder_b/index.ts +export function foo() {}; +// @Filename: tsconfig.path.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "b": [ "folder_b/index" ] + } + } +} +// @Filename: tsconfig.json +{ + "extends": "./tsconfig.path", + "compilerOptions": { } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "b"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withExtension_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withExtension_test.go new file mode 100644 index 0000000000..8c137c06c9 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withExtension_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportPaths_withExtension(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /src/a.ts +[|foo|] +// @Filename: /src/thisHasPathMapping.ts +export function foo() {}; +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "foo": ["src/thisHasPathMapping.ts"] + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withLeadingDotSlash_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withLeadingDotSlash_test.go new file mode 100644 index 0000000000..35d33b1f8d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withLeadingDotSlash_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportPaths_withLeadingDotSlash(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +[|foo|] +// @Filename: /thisHasPathMapping.ts +export function foo() {}; +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "foo": ["././thisHasPathMapping"] + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withParentRelativePath_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withParentRelativePath_test.go new file mode 100644 index 0000000000..f52909c872 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportPaths_withParentRelativePath_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportPaths_withParentRelativePath(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /src/a.ts +[|foo|] +// @Filename: /thisHasPathMapping.ts +export function foo() {}; +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": "src", + "paths": { + "foo": ["..\\thisHasPathMapping"] + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "foo"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportRootDirs0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportRootDirs0_test.go new file mode 100644 index 0000000000..c192ad7931 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportRootDirs0_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportRootDirs0(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a/f1.ts +[|foo/*0*/();|] +// @Filename: b/c/f2.ts +export function foo() {}; +// @Filename: tsconfig.json +{ + "compilerOptions": { + "rootDirs": [ + "a", + "b/c" + ] + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "./f2"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportRootDirs1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportRootDirs1_test.go new file mode 100644 index 0000000000..b122ccd697 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportRootDirs1_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportRootDirs1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a/f1.ts +[|foo/*0*/();|] +// @Filename: a/b/index.ts +export function foo() {}; +// @Filename: tsconfig.json +{ + "compilerOptions": { + "rootDirs": [ + "a" + ] + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "./b"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportTypeRoots0_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportTypeRoots0_test.go new file mode 100644 index 0000000000..aad50b5007 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportTypeRoots0_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportTypeRoots0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a/f1.ts +[|foo/*0*/();|] +// @Filename: types/random/index.ts +export function foo() {}; +// @Filename: tsconfig.json +{ + "compilerOptions": { + "typeRoots": [ + "./types" + ] + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "../types/random"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixNewImportTypeRoots1_test.go b/internal/fourslash/tests/gen/importNameCodeFixNewImportTypeRoots1_test.go new file mode 100644 index 0000000000..c92b250137 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixNewImportTypeRoots1_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixNewImportTypeRoots1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a/f1.ts +[|foo/*0*/();|] +// @Filename: types/random/index.ts +export function foo() {}; +// @Filename: tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "typeRoots": [ + "./types" + ] + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "types/random"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixOptionalImport0_test.go b/internal/fourslash/tests/gen/importNameCodeFixOptionalImport0_test.go new file mode 100644 index 0000000000..38ad76631d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixOptionalImport0_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixOptionalImport0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a/f1.ts +[|import * as ns from "./foo"; +foo/*0*/();|] +// @Filename: a/foo/bar.ts +export function foo() {}; +// @Filename: a/foo.ts +export { foo } from "./foo/bar";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as ns from "./foo"; +ns.foo();`, + `import * as ns from "./foo"; +import { foo } from "./foo"; +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixOptionalImport1_test.go b/internal/fourslash/tests/gen/importNameCodeFixOptionalImport1_test.go new file mode 100644 index 0000000000..a086546674 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixOptionalImport1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixOptionalImport1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a/f1.ts +[|foo/*0*/();|] +// @Filename: a/node_modules/bar/index.ts +export function foo() {}; +// @Filename: a/foo.ts +export { foo } from "bar";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "bar"; + +foo();`, + `import { foo } from "./foo"; + +foo();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixShebang_test.go b/internal/fourslash/tests/gen/importNameCodeFixShebang_test.go new file mode 100644 index 0000000000..d5f6f4d062 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixShebang_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixShebang(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.ts +[|#!/usr/bin/env node +foo/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.ts") + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `#!/usr/bin/env node + +import { foo } from "./a"; + +foo`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixUMDGlobal0_test.go b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobal0_test.go new file mode 100644 index 0000000000..117fb890cb --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobal0_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixUMDGlobal0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: es2015 +// @Filename: a/f1.ts +[|export function test() { }; +bar1/*0*/.bar;|] +// @Filename: a/foo.d.ts +export declare function bar(): number; +export as namespace bar1; ` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as bar1 from "./foo"; + +export function test() { }; +bar1.bar;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixUMDGlobal1_test.go b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobal1_test.go new file mode 100644 index 0000000000..b52bd9657b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobal1_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixUMDGlobal1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: esnext +// @Filename: a/f1.ts +[|import { bar } from "./foo"; + +export function test() { }; +bar1/*0*/.bar();|] +// @Filename: a/foo.d.ts +export declare function bar(): number; +export as namespace bar1; ` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as bar1 from "./foo"; +import { bar } from "./foo"; + +export function test() { }; +bar1.bar();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalJavaScript_test.go b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalJavaScript_test.go new file mode 100644 index 0000000000..7fadc60437 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalJavaScript_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixUMDGlobalJavaScript(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @AllowSyntheticDefaultImports: false +// @Module: commonjs +// @CheckJs: true +// @AllowJs: true +// @Filename: a/f1.js +[|export function test() { }; +bar1/*0*/.bar;|] +// @Filename: a/foo.d.ts +export declare function bar(): number; +export as namespace bar1; ` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import * as bar1 from "./foo"; + +export function test() { }; +bar1.bar;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact0_test.go b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact0_test.go new file mode 100644 index 0000000000..97a304325c --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact0_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixUMDGlobalReact0(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: react +// @allowSyntheticDefaultImports: false +// @module: es2015 +// @moduleResolution: bundler +// @Filename: /node_modules/@types/react/index.d.ts +export = React; +export as namespace React; +declare namespace React { + export class Component { render(): JSX.Element | null; } +} +declare global { + namespace JSX { + interface Element {} + } +} +// @Filename: /a.tsx +[|import { Component } from "react"; +export class MyMap extends Component { } +;|] +// @Filename: /b.tsx +[|import { Component } from "react"; +<>;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.tsx") + f.VerifyImportFixAtPosition(t, []string{ + `import * as React from "react"; +import { Component } from "react"; +export class MyMap extends Component { } +;`, + }, nil /*preferences*/) + f.GoToFile(t, "/b.tsx") + f.VerifyImportFixAtPosition(t, []string{ + `import * as React from "react"; +import { Component } from "react"; +<>;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact1_test.go b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact1_test.go new file mode 100644 index 0000000000..a4772340ee --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact1_test.go @@ -0,0 +1,41 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixUMDGlobalReact1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: react +// @allowSyntheticDefaultImports: false +// @module: es2015 +// @moduleResolution: bundler +// @Filename: /node_modules/@types/react/index.d.ts +export = React; +export as namespace React; +declare namespace React { + export class Component { render(): JSX.Element | null; } +} +declare global { + namespace JSX { + interface Element {} + } +} +// @Filename: /a.tsx +[|import { Component } from "react"; +export class MyMap extends Component { } +;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.tsx") + f.VerifyImportFixAtPosition(t, []string{ + `import * as React from "react"; +import { Component } from "react"; +export class MyMap extends Component { } +;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact2_test.go b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact2_test.go new file mode 100644 index 0000000000..4302412c8d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixUMDGlobalReact2_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixUMDGlobalReact2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: react +// @jsxFactory: factory +// @Filename: /factory.ts +export function factory() { return {}; } +declare global { + namespace JSX { + interface Element {} + } +} +// @Filename: /a.tsx +[|
|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.tsx") + f.VerifyImportFixAtPosition(t, []string{ + `import { factory } from "./factory"; + +
`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_HeaderComment1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_HeaderComment1_test.go new file mode 100644 index 0000000000..7bc55cb9ae --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_HeaderComment1_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_HeaderComment1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.ts +export const bar = 0; +// @Filename: /c.ts +/*-------------------- + * Copyright Header + *--------------------*/ + +import { bar } from "./b"; +foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `/*-------------------- + * Copyright Header + *--------------------*/ + +import { foo } from "./a"; +import { bar } from "./b"; +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_HeaderComment2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_HeaderComment2_test.go new file mode 100644 index 0000000000..36b33f05fe --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_HeaderComment2_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_HeaderComment2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.ts +export const bar = 0; +// @Filename: /c.ts +/*-------------------- + * Copyright Header + *--------------------*/ + +const afterHeader = 1; + +// non-header comment +import { bar } from "./b"; +foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `/*-------------------- + * Copyright Header + *--------------------*/ + +const afterHeader = 1; + +import { foo } from "./a"; +// non-header comment +import { bar } from "./b"; +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_avoidRelativeNodeModules_test.go b/internal/fourslash/tests/gen/importNameCodeFix_avoidRelativeNodeModules_test.go new file mode 100644 index 0000000000..4b0885f69d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_avoidRelativeNodeModules_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_avoidRelativeNodeModules(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a/index.d.ts +// @Symlink: /b/node_modules/a/index.d.ts +// @Symlink: /c/node_modules/a/index.d.ts +export const a: number; +// @Filename: /b/index.ts +// @Symlink: /c/node_modules/b/index.d.ts +import { a } from 'a' +export const b: number; +// @Filename: /c/a_user.ts +import { a } from "a"; +// @Filename: /c/foo.ts +[|import { b } from "b"; +a;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/c/foo.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { a } from "a"; +import { b } from "b"; +a;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_commonjs_allowSynthetic_test.go b/internal/fourslash/tests/gen/importNameCodeFix_commonjs_allowSynthetic_test.go new file mode 100644 index 0000000000..bf093cc95d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_commonjs_allowSynthetic_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_commonjs_allowSynthetic(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @moduleResolution: bundler +// @allowJs: true +// @checkJs: true +// @allowSyntheticDefaultImports: true +// @Filename: /test_module.js +const MY_EXPORTS = {} +module.exports = MY_EXPORTS; +// @Filename: /index.js +const newVar = { + any: MY_EXPORTS/**/, +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `const MY_EXPORTS = require("./test_module"); + +const newVar = { + any: MY_EXPORTS, +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_defaultExport_test.go b/internal/fourslash/tests/gen/importNameCodeFix_defaultExport_test.go new file mode 100644 index 0000000000..5c1f1252e3 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_defaultExport_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_defaultExport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @allowJs: true +// @checkJs: true +// @Filename: /a.js +class C {} +export default C; +// @Filename: /b.js +[|C;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.js") + f.VerifyImportFixAtPosition(t, []string{ + `import C from "./a"; + +C;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_dollar_test.go b/internal/fourslash/tests/gen/importNameCodeFix_dollar_test.go new file mode 100644 index 0000000000..0b52076265 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_dollar_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_dollar(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @moduleResolution: bundler +// @Filename: /node_modules/qwik/index.d.ts +export declare const $: any; +// @Filename: /index.ts +import {} from "qwik"; +$/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { $ } from "qwik"; +$`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_fileWithNoTrailingNewline_test.go b/internal/fourslash/tests/gen/importNameCodeFix_fileWithNoTrailingNewline_test.go new file mode 100644 index 0000000000..819c94f71c --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_fileWithNoTrailingNewline_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_fileWithNoTrailingNewline(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.ts +export const bar = 0; +// @Filename: /c.ts +foo; +import { bar } from "./b";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `foo; +import { foo } from "./a"; +import { bar } from "./b";`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_fromPathMapping_test.go b/internal/fourslash/tests/gen/importNameCodeFix_fromPathMapping_test.go new file mode 100644 index 0000000000..dc71d0e7eb --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_fromPathMapping_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_fromPathMapping(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /x/y.ts +foo; +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@root/*": ["*"], + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/x/y.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "@root/a"; + +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_getCanonicalFileName_test.go b/internal/fourslash/tests/gen/importNameCodeFix_getCanonicalFileName_test.go new file mode 100644 index 0000000000..22ec6d259f --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_getCanonicalFileName_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_getCanonicalFileName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /howNow/node_modules/brownCow/index.d.ts +export const foo: number; +// @Filename: /howNow/a.ts +foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/howNow/a.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "brownCow"; + +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType1_test.go new file mode 100644 index 0000000000..058e1a75f8 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType1_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @module: es2015 +// @Filename: /exports.ts +export default someValue = 0; +export function Component() {} +export interface ComponentProps {} +// @Filename: /a.ts +import { Component } from "./exports.js"; +interface MoreProps extends /*a*/ComponentProps {} +// @Filename: /b.ts +import someValue from "./exports.js"; +interface MoreProps extends /*b*/ComponentProps {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "a") + f.VerifyImportFixAtPosition(t, []string{ + `import { Component, type ComponentProps } from "./exports.js"; +interface MoreProps extends ComponentProps {}`, + }, nil /*preferences*/) + f.GoToMarker(t, "b") + f.VerifyImportFixAtPosition(t, []string{ + `import someValue, { type ComponentProps } from "./exports.js"; +interface MoreProps extends ComponentProps {}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType2_test.go new file mode 100644 index 0000000000..1a09b188c4 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType2_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @module: es2015 +// @Filename: /exports1.ts +export default interface SomeType {} +export interface OtherType {} +export interface OtherOtherType {} +export const someValue = 0; +// @Filename: /a.ts +import type SomeType from "./exports1.js"; +someValue/*a*/ +// @Filename: /b.ts +import { someValue } from "./exports1.js"; +const b: SomeType/*b*/ = someValue; +// @Filename: /c.ts +import type SomeType from "./exports1.js"; +const x: OtherType/*c*/ +// @Filename: /d.ts +import type { OtherType } from "./exports1.js"; +const x: OtherOtherType/*d*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "a") + f.VerifyImportFixAtPosition(t, []string{ + `import type SomeType from "./exports1.js"; +import { someValue } from "./exports1.js"; +someValue`, + }, nil /*preferences*/) + f.GoToMarker(t, "b") + f.VerifyImportFixAtPosition(t, []string{ + `import type SomeType from "./exports1.js"; +import { someValue } from "./exports1.js"; +const b: SomeType = someValue;`, + }, nil /*preferences*/) + f.GoToMarker(t, "c") + f.VerifyImportFixAtPosition(t, []string{ + `import type { OtherType } from "./exports1.js"; +import type SomeType from "./exports1.js"; +const x: OtherType`, + }, nil /*preferences*/) + f.GoToMarker(t, "d") + f.VerifyImportFixAtPosition(t, []string{ + `import type { OtherOtherType, OtherType } from "./exports1.js"; +const x: OtherOtherType`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType3_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType3_test.go new file mode 100644 index 0000000000..abb40aa078 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType3_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @module: es2015 +// @Filename: /exports.ts +class SomeClass {} +export type { SomeClass }; +// @Filename: /a.ts +import {} from "./exports.js"; +function takeSomeClass(c: SomeClass/**/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { type SomeClass } from "./exports.js"; +function takeSomeClass(c: SomeClass)`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType4_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType4_test.go new file mode 100644 index 0000000000..3fadc0f617 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType4_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @preserveValueImports: true +// @isolatedModules: true +// @module: es2015 +// @Filename: /exports.ts +export interface SomeInterface {} +export class SomePig {} +// @Filename: /a.ts +import type { SomeInterface } from "./exports.js"; +new SomePig/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { SomePig, type SomeInterface } from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType5_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType5_test.go new file mode 100644 index 0000000000..e35bdb4cb7 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType5_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: es2015 +// @Filename: /exports.ts +export interface SomeInterface {} +export class SomePig {} +// @Filename: /a.ts +import type { SomeInterface, SomePig } from "./exports.js"; +new SomePig/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { SomeInterface, SomePig } from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType6_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType6_test.go new file mode 100644 index 0000000000..775fc58e70 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType6_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: es2015 +// @esModuleInterop: true +// @jsx: react +// @Filename: /types.d.ts +declare module "react" { var React: any; export = React; export as namespace React; } +// @Filename: /a.tsx +import type React from "react"; +function Component() {} +()` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import React from "react"; +function Component() {} +()`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType7_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType7_test.go new file mode 100644 index 0000000000..3f5d77e92a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType7_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType7(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: es2015 +// @Filename: /exports.ts +export interface SomeInterface {} +export class SomePig {} +// @Filename: /a.ts +import { + type SomeInterface, + type SomePig, +} from "./exports.js"; +new SomePig/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { + SomePig, + type SomeInterface, +} from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { + SomePig, + type SomeInterface, +} from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { + type SomeInterface, + SomePig, +} from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) + f.VerifyImportFixAtPosition(t, []string{ + `import { + type SomeInterface, + SomePig, +} from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType8_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType8_test.go new file mode 100644 index 0000000000..f239ddfd14 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType8_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType8(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: es2015 +// @verbatimModuleSyntax: true +// @Filename: /exports.ts +export interface SomeInterface {} +export class SomePig {} +// @Filename: /a.ts +import type { SomeInterface, SomePig } from "./exports.js"; +new SomePig/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { SomePig, type SomeInterface } from "./exports.js"; +new SomePig`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_importType_test.go b/internal/fourslash/tests/gen/importNameCodeFix_importType_test.go new file mode 100644 index 0000000000..a0db33f11e --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_importType_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_importType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +export {}; +/** @typedef {number} T */ +// @Filename: /b.js +/** @type {T} */ +const x = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.js") + f.VerifyImportFixAtPosition(t, []string{ + `/** @type {import("./a").T} */ +const x = 0;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM1_test.go new file mode 100644 index 0000000000..3d5735dd2a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_jsCJSvsESM1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: types/dep.d.ts +export declare class Dep {} +// @Filename: index.js +Dep/**/ +// @Filename: util.js +import fs from 'fs';` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { Dep } from "./types/dep"; + +Dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM2_test.go new file mode 100644 index 0000000000..be73839c63 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM2_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_jsCJSvsESM2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: types/dep.d.ts +export declare class Dep {} +// @Filename: index.js +Dep/**/ +// @Filename: util1.ts +import fs from 'fs'; +// @Filename: util2.js +const fs = require('fs');` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `const { Dep } = require("./types/dep"); + +Dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM3_test.go b/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM3_test.go new file mode 100644 index 0000000000..7006d6b90a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_jsCJSvsESM3_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_jsCJSvsESM3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: types/dep.d.ts +export declare class Dep {} +// @Filename: index.js +import fs from 'fs'; +const path = require('path'); + +Dep/**/ +// @Filename: util2.js +export {};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import fs from 'fs'; +import { Dep } from './types/dep'; +const path = require('path'); + +Dep`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_jsx1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_jsx1_test.go new file mode 100644 index 0000000000..655a57f416 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_jsx1_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_jsx1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: react +// @Filename: /node_modules/react/index.d.ts +export const React: any; +// @Filename: /a.tsx +[||] +// @Filename: /Foo.tsx +export const Foo = 0; +// @Filename: /c.tsx +import { React } from "react"; +; +// @Filename: /d.tsx +import { Foo } from "./Foo"; +;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.tsx") + f.VerifyImportFixAtPosition(t, []string{}, nil /*preferences*/) + f.GoToFile(t, "/c.tsx") + f.VerifyImportFixAtPosition(t, []string{ + `import { React } from "react"; +import { Foo } from "./Foo"; +;`, + }, nil /*preferences*/) + f.GoToFile(t, "/d.tsx") + f.VerifyImportFixAtPosition(t, []string{ + `import { React } from "react"; +import { Foo } from "./Foo"; +;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_jsxOpeningTagImportDefault_test.go b/internal/fourslash/tests/gen/importNameCodeFix_jsxOpeningTagImportDefault_test.go new file mode 100644 index 0000000000..91aeb29425 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_jsxOpeningTagImportDefault_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_jsxOpeningTagImportDefault(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @jsx: react-jsx +// @Filename: /component.tsx +export default function (props: any) {} +// @Filename: /index.tsx +export function Index() { + return ; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import Component from "./component"; + +export function Index() { + return ; +}`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_jsxReact17_test.go b/internal/fourslash/tests/gen/importNameCodeFix_jsxReact17_test.go new file mode 100644 index 0000000000..6dbc973a45 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_jsxReact17_test.go @@ -0,0 +1,41 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_jsxReact17(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: preserve +// @module: commonjs +// @Filename: /node_modules/@types/react/index.d.ts +declare namespace React { + function createElement(): any; +} +export = React; +export as namespace React; + +declare global { + namespace JSX { + interface IntrinsicElements {} + interface IntrinsicAttributes {} + } +} +// @Filename: /component.tsx +import "react"; +export declare function Component(): any; +// @Filename: /index.tsx +();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { Component } from "./component"; + +();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_order2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_order2_test.go new file mode 100644 index 0000000000..ff7d259f51 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_order2_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_order2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const _aB: number; +export const _Ab: number; +export const aB: number; +export const Ab: number; +// @Filename: /b.ts +[|import { + _aB, + _Ab, + Ab, +} from "./a"; +aB;|] +// @Filename: /c.ts +[|import { + _aB, + _Ab, + Ab, +} from "./a"; +aB;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { + _aB, + _Ab, + Ab, + aB, +} from "./a"; +aB;`, + }, nil /*preferences*/) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { + _aB, + _Ab, + aB, + Ab, +} from "./a"; +aB;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_order_test.go b/internal/fourslash/tests/gen/importNameCodeFix_order_test.go new file mode 100644 index 0000000000..e24829a31b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_order_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_order(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo: number; +// @Filename: /b.ts +export const foo: number; +export const bar: number; +// @Filename: /c.ts +[|import { bar } from "./b"; +foo;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { bar, foo } from "./b"; +foo;`, + `import { foo } from "./a"; +import { bar } from "./b"; +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_pathsWithoutBaseUrl1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_pathsWithoutBaseUrl1_test.go new file mode 100644 index 0000000000..85aa10e76b --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_pathsWithoutBaseUrl1_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_pathsWithoutBaseUrl1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "paths": { + "@app/*": ["./lib/*"] + } + } +} +// @Filename: index.ts +utils/**/ +// @Filename: lib/utils.ts +export const utils = {};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { utils } from "@app/utils"; + +utils`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_pathsWithoutBaseUrl2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_pathsWithoutBaseUrl2_test.go new file mode 100644 index 0000000000..ccda7d8e28 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_pathsWithoutBaseUrl2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_pathsWithoutBaseUrl2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /packages/test-package-1/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + "paths": { + "test-package-2/*": ["../test-package-2/src/*"] + } + } +} +// @Filename: /packages/test-package-1/src/common/logging.ts +export class Logger {}; +// @Filename: /packages/test-package-1/src/something/index.ts +Logger/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { Logger } from "../common/logging"; + +Logger`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_pnpm1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_pnpm1_test.go new file mode 100644 index 0000000000..3cfca3130e --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_pnpm1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_pnpm1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: /home/src/workspaces/project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react/index.d.ts +export declare function Component(): void; +// @Filename: /home/src/workspaces/project/index.ts +Component/**/ +// @link: /home/src/workspaces/project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react -> /home/src/workspaces/project/node_modules/@types/react` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { Component } from "react"; + +Component`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_preferBaseUrl_test.go b/internal/fourslash/tests/gen/importNameCodeFix_preferBaseUrl_test.go new file mode 100644 index 0000000000..06168a5bfc --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_preferBaseUrl_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_preferBaseUrl(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "baseUrl": "./src" } } +// @Filename: /src/d0/d1/d2/file.ts +foo/**/; +// @Filename: /src/d0/a.ts +export const foo = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/src/d0/d1/d2/file.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "d0/a"; + +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_quoteStyle_test.go b/internal/fourslash/tests/gen/importNameCodeFix_quoteStyle_test.go new file mode 100644 index 0000000000..ee57b2659d --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_quoteStyle_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_quoteStyle(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo: number; +// @Filename: /b.ts +[|foo;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from './a'; + +foo;`, + }, &lsutil.UserPreferences{QuotePreference: lsutil.QuotePreference("single")}) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_reExportDefault_test.go b/internal/fourslash/tests/gen/importNameCodeFix_reExportDefault_test.go new file mode 100644 index 0000000000..8a99b77559 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_reExportDefault_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_reExportDefault(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /user.ts +foo; +// @Filename: /user2.ts +unnamed; +// @Filename: /user3.ts +reExportUnnamed; +// @Filename: /reExportNamed.ts +export { default } from "./named"; +// @Filename: /reExportUnnamed.ts +export { default } from "./unnamed"; +// @Filename: /named.ts +function foo() {} +export default foo; +// @Filename: /unnamed.ts +export default 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/user.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "./named"; + +foo;`, + `import foo from "./reExportNamed"; + +foo;`, + }, nil /*preferences*/) + f.GoToFile(t, "/user2.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import unnamed from "./unnamed"; + +unnamed;`, + `import unnamed from "./reExportUnnamed"; + +unnamed;`, + }, nil /*preferences*/) + f.GoToFile(t, "/user3.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import reExportUnnamed from "./reExportUnnamed"; + +reExportUnnamed;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_reExport_test.go b/internal/fourslash/tests/gen/importNameCodeFix_reExport_test.go new file mode 100644 index 0000000000..f895975f15 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_reExport_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_reExport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo(): void {} +// @Filename: /b.ts +export { default } from "./a"; +// @Filename: /user.ts +[|foo;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/user.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import foo from "./a"; + +foo;`, + `import foo from "./b"; + +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_shorthandPropertyAssignment1_test.go b/internal/fourslash/tests/gen/importNameCodeFix_shorthandPropertyAssignment1_test.go new file mode 100644 index 0000000000..e828e39af6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_shorthandPropertyAssignment1_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_shorthandPropertyAssignment1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const a = 1; +// @Filename: /b.ts +const b = { /**/a };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { a } from "./a"; + +const b = { a };`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_shorthandPropertyAssignment2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_shorthandPropertyAssignment2_test.go new file mode 100644 index 0000000000..0020bc1031 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_shorthandPropertyAssignment2_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_shorthandPropertyAssignment2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +const a = 1; +export default a; +// @Filename: /b.ts +const b = { /**/a };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import a from "./a"; + +const b = { a };`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_sortByDistance_test.go b/internal/fourslash/tests/gen/importNameCodeFix_sortByDistance_test.go new file mode 100644 index 0000000000..f03212e595 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_sortByDistance_test.go @@ -0,0 +1,41 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_sortByDistance(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /src/admin/utils/db/db.ts +export const db = {}; +// @Filename: /src/admin/utils/db/index.ts +export * from "./db"; +// @Filename: /src/client/helpers/db.ts +export const db = {}; +// @Filename: /src/client/db.ts +export const db = {}; +// @Filename: /src/client/foo.ts +db/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { db } from "./db"; + +db`, + `import { db } from "./helpers/db"; + +db`, + `import { db } from "../admin/utils/db"; + +db`, + `import { db } from "../admin/utils/db/db"; + +db`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_symlink_own_package_2_test.go b/internal/fourslash/tests/gen/importNameCodeFix_symlink_own_package_2_test.go new file mode 100644 index 0000000000..0381a6302c --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_symlink_own_package_2_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_symlink_own_package_2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /packages/a/test.ts +// @Symlink: /node_modules/a/test.ts +x; +// @Filename: /packages/a/utils.ts +// @Symlink: /node_modules/a/utils.ts +import {} from "a/utils"; +export const x = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/packages/a/test.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { x } from "./utils"; + +x;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_symlink_own_package_test.go b/internal/fourslash/tests/gen/importNameCodeFix_symlink_own_package_test.go new file mode 100644 index 0000000000..1e4a28c2da --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_symlink_own_package_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_symlink_own_package(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /packages/b/b0.ts +// @Symlink: /node_modules/b/b0.ts +x; +// @Filename: /packages/b/b1.ts +// @Symlink: /node_modules/b/b1.ts +import { a } from "a"; +export const x = 0; +// @Filename: /packages/a/index.d.ts +// @Symlink: /node_modules/a/index.d.ts +export const a: number;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/packages/b/b0.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { x } from "./b1"; + +x;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_symlink_test.go b/internal/fourslash/tests/gen/importNameCodeFix_symlink_test.go new file mode 100644 index 0000000000..ca04ad52c6 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_symlink_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_symlink(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @noLib: true +// @Filename: /node_modules/real/index.d.ts +// @Symlink: /node_modules/link/index.d.ts +export const foo: number; +// @Filename: /a.ts +import { foo } from "link"; +// @Filename: /b.ts +[|foo;|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { foo } from "link"; + +foo;`, + `import { foo } from "real"; + +foo;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_trailingComma_test.go b/internal/fourslash/tests/gen/importNameCodeFix_trailingComma_test.go new file mode 100644 index 0000000000..07f720b6e5 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_trailingComma_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_trailingComma(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: index.ts +import { + T2, + T1, +} from "./types"; + +const x: T3/**/ +// @Filename: types.ts +export type T1 = 0; +export type T2 = 0; +export type T3 = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyImportFixAtPosition(t, []string{ + `import { + T2, + T1, + T3, +} from "./types"; + +const x: T3`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_tripleSlashOrdering_test.go b/internal/fourslash/tests/gen/importNameCodeFix_tripleSlashOrdering_test.go new file mode 100644 index 0000000000..d03ba3b561 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_tripleSlashOrdering_test.go @@ -0,0 +1,119 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_tripleSlashOrdering(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "skipDefaultLibCheck": false + } +} +// @Filename: /a.ts +export const x = 0; +// @Filename: /b.ts +// some comment + +/// + +const y = x + 1; +// @Filename: /c.ts +// some comment + +/// + +const y = x + 1; +// @Filename: /d.ts +// some comment + +/// + +const y = x + 1; +// @Filename: /e.ts +// some comment + +/// + +const y = x + 1; +// @Filename: /f.ts +// some comment + +/// + +const y = x + 1; +// @Filename: /g.ts +// some comment + +/// + +const y = x + 1;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `// some comment + +/// + +import { x } from "./a"; + +const y = x + 1;`, + }, nil /*preferences*/) + f.GoToFile(t, "/c.ts") + f.VerifyImportFixAtPosition(t, []string{ + `// some comment + +/// + +import { x } from "./a"; + +const y = x + 1;`, + }, nil /*preferences*/) + f.GoToFile(t, "/d.ts") + f.VerifyImportFixAtPosition(t, []string{ + `// some comment + +/// + +import { x } from "./a"; + +const y = x + 1;`, + }, nil /*preferences*/) + f.GoToFile(t, "/e.ts") + f.VerifyImportFixAtPosition(t, []string{ + `// some comment + +/// + +import { x } from "./a"; + +const y = x + 1;`, + }, nil /*preferences*/) + f.GoToFile(t, "/f.ts") + f.VerifyImportFixAtPosition(t, []string{ + `// some comment + +/// + +import { x } from "./a"; + +const y = x + 1;`, + }, nil /*preferences*/) + f.GoToFile(t, "/g.ts") + f.VerifyImportFixAtPosition(t, []string{ + `// some comment + +/// + +import { x } from "./a"; + +const y = x + 1;`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_typeOnly_test.go b/internal/fourslash/tests/gen/importNameCodeFix_typeOnly_test.go new file mode 100644 index 0000000000..c81ef37ec3 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_typeOnly_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_typeOnly(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @verbatimModuleSyntax: true +// @Filename: types.ts +export class A {} +// @Filename: index.ts +const a: /**/A` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import type { A } from "./types"; + +const a: A`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_typeUsedAsValue_test.go b/internal/fourslash/tests/gen/importNameCodeFix_typeUsedAsValue_test.go new file mode 100644 index 0000000000..c44a172826 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_typeUsedAsValue_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_typeUsedAsValue(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export class ReadonlyArray {} +// @Filename: /b.ts +[|new ReadonlyArray();|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { ReadonlyArray } from "./a"; + +new ReadonlyArray();`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFix_withJson_test.go b/internal/fourslash/tests/gen/importNameCodeFix_withJson_test.go new file mode 100644 index 0000000000..3af50482e0 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFix_withJson_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFix_withJson(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const a = 'a'; +// @Filename: /b.ts +import "./anything.json"; + +a/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyImportFixAtPosition(t, []string{ + `import { a } from "./a"; +import "./anything.json"; + +a`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/importStatementCompletions_pnpmTransitive_test.go b/internal/fourslash/tests/gen/importStatementCompletions_pnpmTransitive_test.go index 297213158f..e8345d759f 100644 --- a/internal/fourslash/tests/gen/importStatementCompletions_pnpmTransitive_test.go +++ b/internal/fourslash/tests/gen/importStatementCompletions_pnpmTransitive_test.go @@ -26,6 +26,7 @@ export interface SvgProperties {} // @link: /home/src/workspaces/project/node_modules/.pnpm/@types+react@17.0.7/node_modules/@types/react -> /home/src/workspaces/project/node_modules/@types/react // @link: /home/src/workspaces/project/node_modules/.pnpm/csstype@3.0.8/node_modules/csstype -> /home/src/workspaces/project/node_modules/.pnpm/@types+react@17.0.7/node_modules/csstype` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "") f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, diff --git a/internal/fourslash/tests/gen/importSuggestionsCache_exportUndefined_test.go b/internal/fourslash/tests/gen/importSuggestionsCache_exportUndefined_test.go new file mode 100644 index 0000000000..64e8f7ea11 --- /dev/null +++ b/internal/fourslash/tests/gen/importSuggestionsCache_exportUndefined_test.go @@ -0,0 +1,71 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportSuggestionsCache_exportUndefined(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "esnext" } } +// @Filename: /home/src/workspaces/project/undefined.ts +export = undefined; +// @Filename: /home/src/workspaces/project/undefinedAlias.ts +const x = undefined; +export = x; +// @Filename: /home/src/workspaces/project/index.ts + /**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./undefinedAlias", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./undefinedAlias", + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importSuggestionsCache_invalidPackageJson_test.go b/internal/fourslash/tests/gen/importSuggestionsCache_invalidPackageJson_test.go new file mode 100644 index 0000000000..38ebadef27 --- /dev/null +++ b/internal/fourslash/tests/gen/importSuggestionsCache_invalidPackageJson_test.go @@ -0,0 +1,59 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportSuggestionsCache_invalidPackageJson(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/jsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + }, +} +// @Filename: /home/src/workspaces/project/node_modules/@types/node/index.d.ts +declare module 'fs' { + export function readFile(): void; +} +declare module 'util' { + export function promisify(): void; +} +// @Filename: /home/src/workspaces/project/package.json +{ "mod" } +// @Filename: /home/src/workspaces/project/a.js + +readF/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "readFile", + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "fs", + }, + }, + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions1_test.go b/internal/fourslash/tests/gen/importTypeCompletions1_test.go new file mode 100644 index 0000000000..155e925d79 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions1_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import type F/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type { Foo } from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions3_test.go b/internal/fourslash/tests/gen/importTypeCompletions3_test.go new file mode 100644 index 0000000000..dbce0bda89 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions3_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import type { F/**/ }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type { Foo } from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions4_test.go b/internal/fourslash/tests/gen/importTypeCompletions4_test.go new file mode 100644 index 0000000000..14cae4b8dc --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions4_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @esModuleInterop: true +// @Filename: /foo.ts +interface Foo { }; +export = Foo; +// @Filename: /bar.ts + [|import type f/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type Foo from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions5_test.go b/internal/fourslash/tests/gen/importTypeCompletions5_test.go new file mode 100644 index 0000000000..725b844260 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions5_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowSyntheticDefaultImports: false +// @esModuleInterop: false +// @Filename: /foo.ts +interface Foo { }; +export = Foo; +// @Filename: /bar.ts + [|import type f/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type Foo = require(\"./foo\");"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions6_test.go b/internal/fourslash/tests/gen/importTypeCompletions6_test.go new file mode 100644 index 0000000000..ec387c2ac4 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions6_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions6(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /foo.ts +export const foo = { }; +export interface Foo { }; +// @Filename: /bar.ts + [|import type * as f/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type { Foo } from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions7_test.go b/internal/fourslash/tests/gen/importTypeCompletions7_test.go new file mode 100644 index 0000000000..82c46afe0f --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions7_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions7(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: es2020 +// @module: esnext +// @Filename: /foo.d.ts +declare namespace Foo {} +export = Foo; +// @Filename: /test.ts +[|import F/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import Foo from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + &lsproto.CompletionItem{ + Label: "type", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions8_test.go b/internal/fourslash/tests/gen/importTypeCompletions8_test.go new file mode 100644 index 0000000000..221d24cf1a --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions8_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions8(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import { type F/**/ }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import { type Foo } from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions9_test.go b/internal/fourslash/tests/gen/importTypeCompletions9_test.go new file mode 100644 index 0000000000..8820440158 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions9_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions9(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import { type /**/ }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import { type Foo } from \"./foo\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./foo", + }, + }, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeNodeGoToDefinition_test.go b/internal/fourslash/tests/gen/importTypeNodeGoToDefinition_test.go index ab2f1fe217..f148d932d4 100644 --- a/internal/fourslash/tests/gen/importTypeNodeGoToDefinition_test.go +++ b/internal/fourslash/tests/gen/importTypeNodeGoToDefinition_test.go @@ -21,5 +21,5 @@ func TestImportTypeNodeGoToDefinition(t *testing.T) { type A = typeof import([|/*1*/"./ns"|]).[|/*2*/Foo|].[|/*3*/Bar|]; type B = import([|/*4*/"./ns"|]).[|/*5*/Foo|].[|/*6*/Bar|].[|/*7*/Baz|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1", "2", "3", "4", "5", "6", "7") + f.VerifyBaselineGoToDefinition(t, true, "1", "2", "3", "4", "5", "6", "7") } diff --git a/internal/fourslash/tests/gen/importTypesDeclarationDiagnosticsNoServerError_test.go b/internal/fourslash/tests/gen/importTypesDeclarationDiagnosticsNoServerError_test.go new file mode 100644 index 0000000000..52acdbbea4 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypesDeclarationDiagnosticsNoServerError_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypesDeclarationDiagnosticsNoServerError(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @declaration: true +// @Filename: node_modules/foo/index.d.ts +export function f(): I; +export interface I { + x: number; +} +// @Filename: a.ts +import { f } from "foo"; +export const x = f();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFileNumber(t, 1) + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/inlayHintsCrash1_test.go b/internal/fourslash/tests/gen/inlayHintsCrash1_test.go new file mode 100644 index 0000000000..4539986ea0 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsCrash1_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsCrash1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: foo.js +/** + * @param {function(string): boolean} f + */ +function doThing(f) { + f(100) +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsEnumMemberValue_test.go b/internal/fourslash/tests/gen/inlayHintsEnumMemberValue_test.go new file mode 100644 index 0000000000..56f297f84a --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsEnumMemberValue_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsEnumMemberValue(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum E { + A, + AA, + B = 10, + BB, + C = 'C', +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayEnumMemberValueHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes1_test.go b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes1_test.go new file mode 100644 index 0000000000..e6ad86f45e --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes1_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsFunctionParameterTypes1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type F1 = (a: string, b: number) => void +const f1: F1 = (a, b) => { } +const f2: F1 = (a, b: number) => { } +function foo1 (cb: (a: string) => void) {} +foo1((a) => { }) +function foo2 (cb: (a: Exclude<1 | 2 | 3, 1>) => void) {} +foo2((a) => { }) +function foo3 (a: (b: (c: (d: Exclude<1 | 2 | 3, 1>) => void) => void) => void) {} +foo3(a => { + a(d => {}) +}) +function foo4(v: T, a: (v: T) => void) {} +foo4(1, a => { }) +type F2 = (a: { + a: number + b: string +}) => void +const foo5: F2 = (a) => { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes2_test.go b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes2_test.go new file mode 100644 index 0000000000..9470f6a255 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes2_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsFunctionParameterTypes2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +namespace N { export class Foo {} } +interface Foo {} +function f1(a = 1) {} +function f2(a = "a") {} +function f3(a = true) {} +function f4(a = { } as Foo) {} +function f5(a = {}) {} +function f6(a = {} as const) {} +function f7(a = (({} as const))) {} +function f8(a = new C()) {} +function f9(a = new N.C()) {} +function f10(a = ((((new C()))))) {} +function f11(a = { a: 1, b: 1 }) {} +function f12(a = ((({ a: 1, b: 1 })))) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes3_test.go b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes3_test.go new file mode 100644 index 0000000000..20925b00f0 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes3_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsFunctionParameterTypes3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IFoo { + bar(x?: boolean): void; +} + +const a: IFoo = { + bar: function (x?): void { + throw new Error("Function not implemented."); + } +} +class Foo { + #value = 0; + get foo(): number { return this.#value; } + set foo(value) { this.#value = value; } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes4_test.go b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes4_test.go new file mode 100644 index 0000000000..785aed0b31 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes4_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsFunctionParameterTypes4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +class Foo { + #value = 0; + get foo() { return this.#value; } + /** + * @param {number} value + */ + set foo(value) { this.#value = value; } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes5_test.go b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes5_test.go new file mode 100644 index 0000000000..a04873dd05 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsFunctionParameterTypes5_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsFunctionParameterTypes5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare const STATE_SIGNAL: unique symbol; + +declare function test( + cb: (state: { [STATE_SIGNAL]: unknown }) => void, +): unknown; + +test((state) => {});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsImportType1_test.go b/internal/fourslash/tests/gen/inlayHintsImportType1_test.go new file mode 100644 index 0000000000..4fd1af5a85 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsImportType1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsImportType1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports.a = 1 +// @Filename: /b.js +const a = require('./a');` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.js") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsImportType2_test.go b/internal/fourslash/tests/gen/inlayHintsImportType2_test.go new file mode 100644 index 0000000000..c11a2af3de --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsImportType2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsImportType2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports.a = 1 +// @Filename: /b.js +function foo () { return require('./a'); } +function bar () { return require('./a').a; } +const c = foo() +const d = bar()` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.js") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInferredTypePredicate1_test.go b/internal/fourslash/tests/gen/inlayHintsInferredTypePredicate1_test.go new file mode 100644 index 0000000000..cd7c9209ef --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInferredTypePredicate1_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInferredTypePredicate1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +function test(x: unknown) { + return typeof x === 'number'; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveAnyParameter1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveAnyParameter1_test.go new file mode 100644 index 0000000000..b2e6ca94e2 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveAnyParameter1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveAnyParameter1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo (v: any) {} +foo(1); +foo(''); +foo(true); +foo(foo); +foo((1)); +foo(foo(1));` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveAnyParameter2_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveAnyParameter2_test.go new file mode 100644 index 0000000000..4a639146a6 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveAnyParameter2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveAnyParameter2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo (v: any) {} +foo(1); +foo(''); +foo(true); +foo(() => 1); +foo(function () { return 1 }); +foo({}); +foo({ a: 1 }); +foo([]); +foo([1]); +foo(foo); +foo((1)); +foo(foo(1));` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes1_test.go new file mode 100644 index 0000000000..2d9d3d24ee --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes1_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveFunctionParameterTypes1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` type F1 = (a: string, b: number) => void + const f1: F1 = (a, b) => { } + const f2: F1 = (a, b: number) => { } + function foo1 (cb: (a: string) => void) {} + foo1((a) => { }) + function foo2 (cb: (a: Exclude<1 | 2 | 3, 1>) => void) {} + foo2((a) => { }) + function foo3 (a: (b: (c: (d: Exclude<1 | 2 | 3, 1>) => void) => void) => void) {} + foo3(a => { + a(d => {}) + }) + function foo4(v: T, a: (v: T) => void) {} + foo4(1, a => { }) + type F2 = (a: { + a: number + b: string + readonly c: boolean + d?: number + e(): string + f?(): boolean + g(): T + h?(x: X): Y + (x: X): Y + [i: string]: number + }) => void + const foo5: F2 = (a) => { } + type F3 = (a: { + (): 42 + }) => void + const foo6: F3 = (a) => { } +interface Thing {} +function foo4(callback: (thing: Thing) => void) {} +foo4(p => {}) + type F4 = (a: { + [i in string]: number + }) => void + const foo5: F4 = (a) => { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes2_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes2_test.go new file mode 100644 index 0000000000..0ae5484a04 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes2_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveFunctionParameterTypes2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +namespace N { export class Foo {} } +interface Foo {} +function f1(a = 1) {} +function f2(a = "a") {} +function f3(a = true) {} +function f4(a = { } as Foo) {} +function f5(a = {}) {} +function f6(a = {} as const) {} +function f7(a = (({} as const))) {} +function f8(a = new C()) {} +function f9(a = new N.C()) {} +function f10(a = ((((new C()))))) {} +function f11(a = { a: 1, b: 1 }) {} +function f12(a = ((({ a: 1, b: 1 })))) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes3_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes3_test.go new file mode 100644 index 0000000000..d0fe2a46bf --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes3_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveFunctionParameterTypes3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IFoo { + bar(x?: boolean): void; +} + +const a: IFoo = { + bar: function (x?): void { + throw new Error("Function not implemented."); + } +} +class Foo { + #value = 0; + get foo(): number { return this.#value; } + set foo(value) { this.#value = value; } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes4_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes4_test.go new file mode 100644 index 0000000000..72325aa707 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes4_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveFunctionParameterTypes4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +class Foo { + #value = 0; + get foo() { return this.#value; } + /** + * @param {number} value + */ + set foo(value) { this.#value = value; } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes5_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes5_test.go new file mode 100644 index 0000000000..ec542d8918 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveFunctionParameterTypes5_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveFunctionParameterTypes5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const foo: 1n = 1n; +export function fn(b = foo) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveImportType1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveImportType1_test.go new file mode 100644 index 0000000000..bfdcec6dbc --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveImportType1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveImportType1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports.a = 1 +// @Filename: /b.js +const a = require('./a');` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.js") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveImportType2_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveImportType2_test.go new file mode 100644 index 0000000000..70ec8d1911 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveImportType2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveImportType2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +module.exports.a = 1 +// @Filename: /b.js +function foo () { return require('./a'); } +function bar () { return require('./a').a; } +const c = foo() +const d = bar()` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.js") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveInferredTypePredicate1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveInferredTypePredicate1_test.go new file mode 100644 index 0000000000..34623d1070 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveInferredTypePredicate1_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveInferredTypePredicate1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +function test(x: unknown) { + return typeof x === 'number'; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveJsDocParameterNames_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveJsDocParameterNames_test.go new file mode 100644 index 0000000000..09dba6947c --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveJsDocParameterNames_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveJsDocParameterNames(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +var x +x.foo(1, 2); +/** + * @type {{foo: (a: number, b: number) => void}} + */ +var y +y.foo(1, 2) +/** + * @type {string} + */ +var z = ""` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.js") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveMultifile1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveMultifile1_test.go new file mode 100644 index 0000000000..80bef58e2e --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveMultifile1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveMultifile1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export interface Foo { a: string } +// @Filename: /b.ts +async function foo () { + return {} as any as import('./a').Foo +} +function bar () { return import('./a') } +async function main () { + const a = await foo() + const b = await bar() +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveMultifileFunctionCalls_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveMultifileFunctionCalls_test.go new file mode 100644 index 0000000000..0d3bd01c0f --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveMultifileFunctionCalls_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveMultifileFunctionCalls(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Target: esnext +// @module: node18 +// @Filename: aaa.mts +import { helperB } from "./bbb.mjs"; +helperB("hello, world!"); +// @Filename: bbb.mts +import { helperC } from "./ccc.mjs"; +export function helperB(bParam: string) { + helperC(bParam); +} +// @Filename: ccc.mts +export function helperC(cParam: string) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "./aaa.mts") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveOverloadCall_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveOverloadCall_test.go new file mode 100644 index 0000000000..9fcb7cf42f --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveOverloadCall_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveOverloadCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Call { + (a: number): void + (b: number, c: number): void + new (d: number): Call +} +declare const call: Call; +call(1); +call(1, 2); +new call(1); +declare function foo(w: number): void +declare function foo(a: number, b: number): void; +declare function foo(a: number | undefined, b: number | undefined): void; +foo(1) +foo(1, 2) +class Class { + constructor(a: number); + constructor(b: number, c: number); + constructor(b: number, c?: number) { } +} +new Class(1) +new Class(1, 2)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveParameterNamesWithComments_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveParameterNamesWithComments_test.go new file mode 100644 index 0000000000..3d66eda391 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveParameterNamesWithComments_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveParameterNamesWithComments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const fn = (x: any) => { } +fn(/* nobody knows exactly what this param is */ 42); +function foo (aParameter: number, bParameter: number, cParameter: number) { } +foo( + /** aParameter */ + 1, + // bParameter + 2, + /* cParameter */ + 3 +) +foo( + /** multiple comments */ + /** aParameter */ + 1, + /** bParameter */ + /** multiple comments */ + 2, + // cParameter + /** multiple comments */ + 3 +) +foo( + /** wrong name */ + 1, + 2, + /** multiple */ + /** wrong */ + /** name */ + 3 +)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveParameterNames_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveParameterNames_test.go new file mode 100644 index 0000000000..37dd18ab80 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveParameterNames_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveParameterNames(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` function foo1 (a: number, b: number) {} + foo1(1, 2); + function foo2 (a: number, { c }: any) {} + foo2(1, { c: 1 }); +const foo3 = (a = 1) => class { } +const C1 = class extends foo3(1) { } +class C2 extends foo3(1) { } +function foo4(a: number, b: number, c: number, d: number) {} +foo4(1, +1, -1, +"1"); +function foo5( + a: string, + b: undefined, + c: null, + d: boolean, + e: boolean, + f: number, + g: number, + h: number, + i: RegExp, + j: bigint, +) { +} +foo5( + "hello", + undefined, + null, + true, + false, + Infinity, + -Infinity, + NaN, + /hello/g, + 123n, +); + declare const unknownCall: any; + unknownCall(); +function trace(message: string) {} +trace(` + "`" + `${1}` + "`" + `); +trace(` + "`" + `` + "`" + `);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters1_test.go new file mode 100644 index 0000000000..ee1b93b715 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters1_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveRestParameters1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1(a: number, ...b: number[]) {} +foo1(1, 1, 1, 1); +type Args2 = [a: number, b: number] +declare function foo2(c: number, ...args: Args2); +foo2(1, 2, 3) +type Args3 = [number, number] +declare function foo3(c: number, ...args: Args3); +foo3(1, 2, 3)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters2_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters2_test.go new file mode 100644 index 0000000000..7f5fa36d05 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters2_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveRestParameters2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(a: unknown, b: unknown, c: unknown) { } +function foo1(...x: [number, number | undefined]) { + foo(...x, 3); +} +function foo2(...x: []) { + foo(...x, 1, 2, 3); +} +function foo3(...x: [number, number?]) { + foo(1, ...x); +} +function foo4(...x: [number, number?]) { + foo(...x, 3); +} +function foo5(...x: [number, number]) { + foo(...x, 3); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters3_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters3_test.go new file mode 100644 index 0000000000..66c1fad9d5 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveRestParameters3_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveRestParameters3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function fn(x: number, y: number, a: number, b: number) { + return x + y + a + b; +} +const foo: [x: number, y: number] = [1, 2]; +fn(...foo, 3, 4);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveReturnType_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveReturnType_test.go new file mode 100644 index 0000000000..e7888fdf63 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveReturnType_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveReturnType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1 () { + return 1 +} +function foo2 (): number { + return 1 +} +class C { + foo() { + return 1 + } + bar() { + return this + } +} +const a = () => 1 +const b = function () { return 1 } +const c = (b) => 1 +const d = b => 1` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveTemplateLiteralTypes_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveTemplateLiteralTypes_test.go new file mode 100644 index 0000000000..5c0876565d --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveTemplateLiteralTypes_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveTemplateLiteralTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function getTemplateLiteral1(): ` + "`" + `${string},${string}` + "`" + `; +const lit1 = getTemplateLiteral1(); +declare function getTemplateLiteral2(): ` + "`" + `\${${string},${string}` + "`" + `; +const lit2 = getTemplateLiteral2(); +declare function getTemplateLiteral3(): ` + "`" + `start${string}\${,$${string}end` + "`" + `; +const lit3 = getTemplateLiteral3(); +declare function getTemplateLiteral4(): ` + "`" + `${string}\` + "`" + `,${string}` + "`" + `; +const lit4 = getTemplateLiteral4();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveVariableTypes1_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveVariableTypes1_test.go new file mode 100644 index 0000000000..82d4c72f45 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveVariableTypes1_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveVariableTypes1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +namespace N { export class Foo {} } +interface Foo {} +const a = "a"; +const b = 1; +const c = true; +const d = {} as Foo; +const e = {}; +const f = {} as const; +const g = (({} as const)); +const h = new C(); +const i = new N.C(); +const j = ((((new C())))); +const k = { a: 1, b: 1 }; +const l = ((({ a: 1, b: 1 }))); + const m = () => 123; + const n; + const o = () => -1 as const; + const p = ([a]: Foo[]) => a; + const q = ({ a }: { a: Foo }) => a;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveVariableTypes2_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveVariableTypes2_test.go new file mode 100644 index 0000000000..f6c2ad29fa --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveVariableTypes2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveVariableTypes2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const object = { foo: 1, bar: 2 } +const array = [1, 2] +const a = object; +const { foo, bar } = object; +const {} = object; +const b = array; +const [ first, second ] = array; +const [] = array; +declare function foo(t: T): T +const x = foo(1)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsInteractiveWithClosures_test.go b/internal/fourslash/tests/gen/inlayHintsInteractiveWithClosures_test.go new file mode 100644 index 0000000000..4c30b7ece0 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsInteractiveWithClosures_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveWithClosures(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1(a: number) { + return (b: number) => { + return a + b + } +} +foo1(1)(2); +function foo2(a: (b: number) => number) { + return a(1) + 2 +} +foo2((c: number) => c + 1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsJsDocParameterNames_test.go b/internal/fourslash/tests/gen/inlayHintsJsDocParameterNames_test.go new file mode 100644 index 0000000000..99b090429b --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsJsDocParameterNames_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsJsDocParameterNames(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: /a.js +var x +x.foo(1, 2); +/** + * @type {{foo: (a: number, b: number) => void}} + */ +var y +y.foo(1, 2) +/** + * @type {string} + */ +var z = ""` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.js") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsMultifile1_test.go b/internal/fourslash/tests/gen/inlayHintsMultifile1_test.go new file mode 100644 index 0000000000..20572e2fe0 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsMultifile1_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsMultifile1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export interface Foo { a: string } +// @Filename: /b.ts +async function foo () { + return {} as any as import('./a').Foo +} +function bar () { return import('./a') } +async function main () { + const a = await foo() + const b = await bar() +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsNoHintWhenArgumentMatchesName_test.go b/internal/fourslash/tests/gen/inlayHintsNoHintWhenArgumentMatchesName_test.go new file mode 100644 index 0000000000..4e27a0ff68 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsNoHintWhenArgumentMatchesName_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsNoHintWhenArgumentMatchesName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo (a: number, b: number) {} +declare const a: 1; +foo(a, 2); +declare const v: any; +foo(v.a, v.a); +foo(v.b, v.b); +foo(v.c, v.c);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll, IncludeInlayParameterNameHintsWhenArgumentMatchesName: false}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsNoParameterHints_test.go b/internal/fourslash/tests/gen/inlayHintsNoParameterHints_test.go new file mode 100644 index 0000000000..1386c3f367 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsNoParameterHints_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsNoParameterHints(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo (a: number, b: number) {} +foo(1, 2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsNone}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsNoVariableTypeHints_test.go b/internal/fourslash/tests/gen/inlayHintsNoVariableTypeHints_test.go new file mode 100644 index 0000000000..cb7481017f --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsNoVariableTypeHints_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsNoVariableTypeHints(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 123;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: false}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsOverloadCall1_test.go b/internal/fourslash/tests/gen/inlayHintsOverloadCall1_test.go new file mode 100644 index 0000000000..8bf12f3ea0 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsOverloadCall1_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsOverloadCall1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface Call { + (a: number): void + (b: number, c: number): void + new (d: number): Call +} +declare const call: Call; +call(1); +call(1, 2); +new call(1); +declare function foo(w: number): void +declare function foo(a: number, b: number): void; +declare function foo(a: number | undefined, b: number | undefined): void; +foo(1) +foo(1, 2) +class Class { + constructor(a: number); + constructor(b: number, c: number); + constructor(b: number, c?: number) { } +} +new Class(1) +new Class(1, 2)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsOverloadCall2_test.go b/internal/fourslash/tests/gen/inlayHintsOverloadCall2_test.go new file mode 100644 index 0000000000..1010a69ec5 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsOverloadCall2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsOverloadCall2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type HasID = { + id: number; +} + +type Numbers = { + n: number[]; +} + +declare function func(bad1: number, bad2: HasID): void; +declare function func(ok_1: Numbers, ok_2: HasID): void; + +func( + { n: [1, 2, 3] }, + { + id: 1, + }, +);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsParameterNames_test.go b/internal/fourslash/tests/gen/inlayHintsParameterNames_test.go new file mode 100644 index 0000000000..57956f7d37 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsParameterNames_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsParameterNames(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` function foo1 (a: number, b: number) {} + foo1(1, 2); + function foo2 (a: number, { c }: any) {} + foo2(1, { c: 1 }); +function foo3(a: any, b: number) {} +foo3({}, 1); +const foo3 = (a = 1) => class { } +const C1 = class extends foo3(1) { } +class C2 extends foo3(1) { } +function foo4(a: number, b: number, c: number, d: number) {} +foo4(1, +1, -1, +"1"); +function foo5( + a: string, + b: undefined, + c: null, + d: boolean, + e: boolean, + f: number, + g: number, + h: number, + i: RegExp, + j: bigint, +) { +} +foo5( + "hello", + undefined, + null, + true, + false, + Infinity, + -Infinity, + NaN, + /hello/g, + 123n, +); + declare const unknownCall: any; + unknownCall(); +function trace(message: string) {} +trace(` + "`" + `${1}` + "`" + `); +trace(` + "`" + `` + "`" + `); +function func( + param1: number, + param2: string, + param3: boolean, +) {} +const param1 = 1; +func( + param1, + 'foo', + true, +)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsPropertyDeclarations2_test.go b/internal/fourslash/tests/gen/inlayHintsPropertyDeclarations2_test.go new file mode 100644 index 0000000000..aae68cc833 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsPropertyDeclarations2_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsPropertyDeclarations2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @target: esnext +class C { + accessor a = 1 + accessor b: number = 2 + accessor c; + accessor d; + + constructor(value: number) { + this.d = value; + if (value <= 0) { + this.d = null; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayPropertyDeclarationTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsPropertyDeclarations_test.go b/internal/fourslash/tests/gen/inlayHintsPropertyDeclarations_test.go new file mode 100644 index 0000000000..74563d31cc --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsPropertyDeclarations_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsPropertyDeclarations(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +class C { + a = 1 + b: number = 2 + c; + d; + + constructor(value: number) { + this.d = value; + if (value <= 0) { + this.d = null; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayPropertyDeclarationTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsQuotePreference1_test.go b/internal/fourslash/tests/gen/inlayHintsQuotePreference1_test.go new file mode 100644 index 0000000000..dadb6cd887 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsQuotePreference1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsQuotePreference1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a1: '"' = '"'; +const b1: '\\' = '\\'; +export function fn(a = a1, b = b1) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true, QuotePreference: lsutil.QuotePreference("double")}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsQuotePreference2_test.go b/internal/fourslash/tests/gen/inlayHintsQuotePreference2_test.go new file mode 100644 index 0000000000..79a16194a2 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsQuotePreference2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsQuotePreference2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a1: "'" = "'"; +const b1: "\\" = "\\"; +export function fn(a = a1, b = b1) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true, QuotePreference: lsutil.QuotePreference("single")}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsRestParameters1_test.go b/internal/fourslash/tests/gen/inlayHintsRestParameters1_test.go new file mode 100644 index 0000000000..490e23a5db --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsRestParameters1_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsRestParameters1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1(a: number, ...b: number[]) {} +foo1(1, 1, 1, 1); +type Args2 = [a: number, b: number] +declare function foo2(c: number, ...args: Args2); +foo2(1, 2, 3) +type Args3 = [number, number] +declare function foo3(c: number, ...args: Args3); +foo3(1, 2, 3)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsLiterals}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsRestParameters2_test.go b/internal/fourslash/tests/gen/inlayHintsRestParameters2_test.go new file mode 100644 index 0000000000..a87ed1068f --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsRestParameters2_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsRestParameters2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(a: unknown, b: unknown, c: unknown) { } +function foo1(...x: [number, number | undefined]) { + foo(...x, 3); +} +function foo2(...x: []) { + foo(...x, 1, 2, 3); +} +function foo3(...x: [number, number?]) { + foo(1, ...x); +} +function foo4(...x: [number, number?]) { + foo(...x, 3); +} +function foo5(...x: [number, number]) { + foo(...x, 3); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsReturnType_test.go b/internal/fourslash/tests/gen/inlayHintsReturnType_test.go new file mode 100644 index 0000000000..7ba162ef73 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsReturnType_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsReturnType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1 () { + return 1 +} +function foo2 (): number { + return 1 +} +class C { + foo() { + return 1 + } +} +const a = () => 1 +const b = function () { return 1 } +const c = (b) => 1 +const d = b => 1` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionLikeReturnTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsThisParameter_test.go b/internal/fourslash/tests/gen/inlayHintsThisParameter_test.go new file mode 100644 index 0000000000..2f301b0424 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsThisParameter_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsThisParameter(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + a: number; +} + +declare function fn( + callback: (a: number, b: string) => void +): void; + + +fn(function (this, a, b) { }); +fn(function (this: I, a, b) { });` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayFunctionParameterTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsTypeMatchesName_test.go b/internal/fourslash/tests/gen/inlayHintsTypeMatchesName_test.go new file mode 100644 index 0000000000..d1d9fe6394 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsTypeMatchesName_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsTypeMatchesName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type Client = {}; +function getClient(): Client { return {}; }; +const client = getClient();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayVariableTypeHintsWhenTypeMatchesName: false}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsVariableTypes1_test.go b/internal/fourslash/tests/gen/inlayHintsVariableTypes1_test.go new file mode 100644 index 0000000000..6143393855 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsVariableTypes1_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsVariableTypes1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +namespace N { export class Foo {} } +interface Foo {} +const a = "a"; +const b = 1; +const c = true; +const d = {} as Foo; +const e = {}; +const f = {} as const; +const g = (({} as const)); +const h = new C(); +const i = new N.C(); +const j = ((((new C())))); +const k = { a: 1, b: 1 }; +const l = ((({ a: 1, b: 1 }))); + const m = () => 123; + const n;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsVariableTypes2_test.go b/internal/fourslash/tests/gen/inlayHintsVariableTypes2_test.go new file mode 100644 index 0000000000..186cbee3cd --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsVariableTypes2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsVariableTypes2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const object = { foo: 1, bar: 2 } +const array = [1, 2] +const a = object; +const { foo, bar } = object; +const {} = object; +const b = array; +const [ first, second ] = array; +const [] = array; +declare function foo(t: T): T +const x = foo(1)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsVariableTypes3_test.go b/internal/fourslash/tests/gen/inlayHintsVariableTypes3_test.go new file mode 100644 index 0000000000..3c2a1f1c53 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsVariableTypes3_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsVariableTypes3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @target: esnext +interface DivElement {} +declare var DivElementCtor: { + prototype: DivElement; + new(): DivElement; +}; +interface ElementMap { + div: typeof DivElementCtor; +} +declare function getCtor(tagName: K): ElementMap[K] | undefined; +const div = getCtor("div");` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true}) +} diff --git a/internal/fourslash/tests/gen/inlayHintsWithClosures_test.go b/internal/fourslash/tests/gen/inlayHintsWithClosures_test.go new file mode 100644 index 0000000000..74972a825b --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsWithClosures_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsWithClosures(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1(a: number) { + return (b: number) => { + return a + b + } +} +foo1(1)(2); +function foo2(a: (b: number) => number) { + return a(1) + 2 +} +foo2((c: number) => c + 1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}) +} diff --git a/internal/fourslash/tests/gen/isDefinitionAcrossGlobalProjects_test.go b/internal/fourslash/tests/gen/isDefinitionAcrossGlobalProjects_test.go index cdcdc26f23..899c50a933 100644 --- a/internal/fourslash/tests/gen/isDefinitionAcrossGlobalProjects_test.go +++ b/internal/fourslash/tests/gen/isDefinitionAcrossGlobalProjects_test.go @@ -93,5 +93,6 @@ const ic: I = { FC() {} }; } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1", "2", "3", "4", "5", "6", "7", "8", "9") } diff --git a/internal/fourslash/tests/gen/isDefinitionAcrossModuleProjects_test.go b/internal/fourslash/tests/gen/isDefinitionAcrossModuleProjects_test.go index 98a8ee14d6..1fc91e1930 100644 --- a/internal/fourslash/tests/gen/isDefinitionAcrossModuleProjects_test.go +++ b/internal/fourslash/tests/gen/isDefinitionAcrossModuleProjects_test.go @@ -132,5 +132,6 @@ const ic: I = { FC() {} }; } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12") } diff --git a/internal/fourslash/tests/gen/issue57429_test.go b/internal/fourslash/tests/gen/issue57429_test.go new file mode 100644 index 0000000000..26985271fd --- /dev/null +++ b/internal/fourslash/tests/gen/issue57429_test.go @@ -0,0 +1,41 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestIssue57429(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +function Builder(def: I) { + return def; +} + +interface IThing { + doThing: (args: { value: object }) => string + doAnotherThing: () => void +} + +Builder({ + doThing(args: { value: object }) { + const { v/*1*/alue } = this.[|args|] + return ` + "`" + `${value}` + "`" + ` + }, + doAnotherThing() { }, +})` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "const value: any", "") + f.VerifyNonSuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Message: "Property 'args' does not exist on type 'IThing'.", + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](2339)}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/issue57585-2_test.go b/internal/fourslash/tests/gen/issue57585-2_test.go new file mode 100644 index 0000000000..480c3837ab --- /dev/null +++ b/internal/fourslash/tests/gen/issue57585-2_test.go @@ -0,0 +1,87 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestIssue57585_2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @target: esnext +// @lib: esnext +declare const EffectTypeId: unique symbol; + +type Covariant = (_: never) => A; + +interface VarianceStruct { + readonly _V: string; + readonly _A: Covariant; + readonly _E: Covariant; + readonly _R: Covariant; +} + +interface Variance { + readonly [EffectTypeId]: VarianceStruct; +} + +type Success> = [T] extends [ + Effect, +] + ? _A + : never; + +declare const YieldWrapTypeId: unique symbol; + +class YieldWrap { + readonly #value: T; + constructor(value: T) { + this.#value = value; + } + [YieldWrapTypeId](): T { + return this.#value; + } +} + +interface EffectGenerator> { + next(...args: ReadonlyArray): IteratorResult, Success>; +} + +interface Effect + extends Variance { + [Symbol.iterator](): EffectGenerator>; +} + +declare const gen: { + >, AEff>( + f: () => Generator, + ): Effect< + AEff, + [Eff] extends [never] + ? never + : [Eff] extends [YieldWrap>] + ? E + : never, + [Eff] extends [never] + ? never + : [Eff] extends [YieldWrap>] + ? R + : never + >; +}; + +declare const succeed: (value: A) => Effect; + +gen(function* () { + const a = yield* succeed(1); + const b/*1*/ = yield* succeed(2); + return a + b; +});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "const b: number", "") + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/javaScriptClass3_test.go b/internal/fourslash/tests/gen/javaScriptClass3_test.go index 29cf8f2e05..2edced2609 100644 --- a/internal/fourslash/tests/gen/javaScriptClass3_test.go +++ b/internal/fourslash/tests/gen/javaScriptClass3_test.go @@ -24,5 +24,5 @@ var x = new Foo(); x.[|alpha/*src1*/|]; x.[|beta/*src2*/|];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "src1", "src2") + f.VerifyBaselineGoToDefinition(t, true, "src1", "src2") } diff --git a/internal/fourslash/tests/gen/javascriptModules21_test.go b/internal/fourslash/tests/gen/javascriptModules21_test.go index 9e73e2b5d2..0f3c99ff0d 100644 --- a/internal/fourslash/tests/gen/javascriptModules21_test.go +++ b/internal/fourslash/tests/gen/javascriptModules21_test.go @@ -12,7 +12,7 @@ import ( func TestJavascriptModules21(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true // @module: system diff --git a/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go b/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go index 5ddc19a411..8a52d74992 100644 --- a/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go +++ b/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go @@ -10,7 +10,7 @@ import ( func TestJavascriptModulesTypeImport(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true // @Filename: types.js diff --git a/internal/fourslash/tests/gen/jsDocAugmentsAndExtends_test.go b/internal/fourslash/tests/gen/jsDocAugmentsAndExtends_test.go new file mode 100644 index 0000000000..e5faf61d71 --- /dev/null +++ b/internal/fourslash/tests/gen/jsDocAugmentsAndExtends_test.go @@ -0,0 +1,43 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsDocAugmentsAndExtends(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: dummy.js +/** + * @augments {Thing} + * [|@extends {Thing}|] + */ +class MyStringThing extends Thing { + constructor() { + super(); + var x = this.mine; + x/**/; + } +} +// @Filename: declarations.d.ts +declare class Thing { + mine: T; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyQuickInfoIs(t, "(local var) x: number", "") + f.VerifyNonSuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Message: "Class declarations cannot have more than one '@augments' or '@extends' tag.", + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](8025)}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsDocSee1_test.go b/internal/fourslash/tests/gen/jsDocSee1_test.go index ad82961ab3..b4889ae927 100644 --- a/internal/fourslash/tests/gen/jsDocSee1_test.go +++ b/internal/fourslash/tests/gen/jsDocSee1_test.go @@ -30,5 +30,5 @@ const [|/*def3*/d|] = "" /** @see /*use5*/[|d|] dd*/ const e = ""` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use1", "use2", "use3", "use4", "use5") + f.VerifyBaselineGoToDefinition(t, false, "use1", "use2", "use3", "use4", "use5") } diff --git a/internal/fourslash/tests/gen/jsDocSee2_test.go b/internal/fourslash/tests/gen/jsDocSee2_test.go index fb43ab1d26..5228017d01 100644 --- a/internal/fourslash/tests/gen/jsDocSee2_test.go +++ b/internal/fourslash/tests/gen/jsDocSee2_test.go @@ -26,5 +26,5 @@ const f = "" /** @see d@{/*use7*/[|fff|]} partial reference */ const g = ""` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use1", "use2", "use3", "use4", "use5", "use6", "use7") + f.VerifyBaselineGoToDefinition(t, true, "use1", "use2", "use3", "use4", "use5", "use6", "use7") } diff --git a/internal/fourslash/tests/gen/jsDocSee3_test.go b/internal/fourslash/tests/gen/jsDocSee3_test.go index ec36a4d074..83b49dc727 100644 --- a/internal/fourslash/tests/gen/jsDocSee3_test.go +++ b/internal/fourslash/tests/gen/jsDocSee3_test.go @@ -19,5 +19,5 @@ func TestJsDocSee3(t *testing.T) { } }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use1") + f.VerifyBaselineGoToDefinition(t, false, "use1") } diff --git a/internal/fourslash/tests/gen/jsDocSee4_test.go b/internal/fourslash/tests/gen/jsDocSee4_test.go index 4054acfb82..dc7fb7f415 100644 --- a/internal/fourslash/tests/gen/jsDocSee4_test.go +++ b/internal/fourslash/tests/gen/jsDocSee4_test.go @@ -28,5 +28,5 @@ const t2 = 1 */ const t3 = 1` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "use1", "use2", "use3") + f.VerifyBaselineGoToDefinition(t, false, "use1", "use2", "use3") } diff --git a/internal/fourslash/tests/gen/jsDocServices_test.go b/internal/fourslash/tests/gen/jsDocServices_test.go new file mode 100644 index 0000000000..80c50fd5e0 --- /dev/null +++ b/internal/fourslash/tests/gen/jsDocServices_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsDocServices(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface /*I*/I {} + +/** + * @param /*use*/[|foo|] I pity the foo + */ +function f([|[|/*def*/{| "contextRangeIndex": 1 |}foo|]: I|]) { + return /*use2*/[|foo|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "use") + f.VerifyQuickInfoIs(t, "(parameter) foo: I", "I pity the foo") + f.VerifyBaselineFindAllReferences(t, "use", "def", "use2") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[0], f.Ranges()[2], f.Ranges()[3]) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0], f.Ranges()[2], f.Ranges()[3]) + f.VerifyBaselineGoToTypeDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, false, "use") +} diff --git a/internal/fourslash/tests/gen/jsFileImportNoTypes2_test.go b/internal/fourslash/tests/gen/jsFileImportNoTypes2_test.go new file mode 100644 index 0000000000..df3805e2b4 --- /dev/null +++ b/internal/fourslash/tests/gen/jsFileImportNoTypes2_test.go @@ -0,0 +1,83 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsFileImportNoTypes2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /default.ts +export default class TestDefaultClass {} +// @Filename: /defaultType.ts +export default interface TestDefaultInterface {} +// @Filename: /reExport/toReExport.ts +export class TestClassReExport {} +export interface TestInterfaceReExport {} +// @Filename: /reExport/index.ts +export { TestClassReExport, TestInterfaceReExport } from './toReExport'; +// @Filename: /exportList.ts +class TestClassExportList {}; +interface TestInterfaceExportList {}; +export { TestClassExportList, TestInterfaceExportList }; +// @Filename: /baseline.ts +export class TestClassBaseline {} +export interface TestInterfaceBaseline {} +// @Filename: /a.js +import /**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "TestClassBaseline", + InsertText: PtrTo("import { TestClassBaseline } from \"./baseline\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./baseline", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "TestClassExportList", + InsertText: PtrTo("import { TestClassExportList } from \"./exportList\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./exportList", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "TestClassReExport", + InsertText: PtrTo("import { TestClassReExport } from \"./reExport\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./reExport", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "TestDefaultClass", + InsertText: PtrTo("import TestDefaultClass from \"./default\";"), + Data: &lsproto.CompletionItemData{ + AutoImport: &lsproto.AutoImportData{ + ModuleSpecifier: "./default", + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsdocCallbackTagRename01_test.go b/internal/fourslash/tests/gen/jsdocCallbackTagRename01_test.go index 1a7111c69a..9787d53837 100644 --- a/internal/fourslash/tests/gen/jsdocCallbackTagRename01_test.go +++ b/internal/fourslash/tests/gen/jsdocCallbackTagRename01_test.go @@ -22,5 +22,6 @@ func TestJsdocCallbackTagRename01(t *testing.T) { /** @type {/*1*/[|FooCallback|]} */ var t;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1]) } diff --git a/internal/fourslash/tests/gen/jsdocCallbackTag_test.go b/internal/fourslash/tests/gen/jsdocCallbackTag_test.go index 0a2845f5b7..dcc7183c34 100644 --- a/internal/fourslash/tests/gen/jsdocCallbackTag_test.go +++ b/internal/fourslash/tests/gen/jsdocCallbackTag_test.go @@ -36,6 +36,7 @@ var t/*1*/; var t2/*2*/; t(/*4*/"!", /*5*/12, /*6*/false);` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "1") f.VerifyQuickInfoIs(t, "var t: FooHandler", "") f.GoToMarker(t, "2") diff --git a/internal/fourslash/tests/gen/jsdocDeprecated_suggestion22_test.go b/internal/fourslash/tests/gen/jsdocDeprecated_suggestion22_test.go new file mode 100644 index 0000000000..ae9c7f20d8 --- /dev/null +++ b/internal/fourslash/tests/gen/jsdocDeprecated_suggestion22_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsdocDeprecated_suggestion22(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /a.ts +const foo: { + /** + * @deprecated + */ + (a: string, b: string): string; + (a: string, b: number): string; +} = (a: string, b: string | number) => a + b; + +[|foo|](1, 1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsdocDeprecated_suggestion5_test.go b/internal/fourslash/tests/gen/jsdocDeprecated_suggestion5_test.go new file mode 100644 index 0000000000..11c6cac6f2 --- /dev/null +++ b/internal/fourslash/tests/gen/jsdocDeprecated_suggestion5_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsdocDeprecated_suggestion5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @checkJs: true +// @allowJs: true +// @Filename: jsdocDeprecated_suggestion5.js +/** @typedef {{ email: string, nickName?: string }} U2 */ +/** @type {U2} */ +const u2 = { email: "" } +/** + * @callback K + * @param {any} ctx + * @return {void} + */ +/** @type {K} */ +const cc = _k => {} +/** @enum {number} */ +const DOOM = { e: 1, m: 1 } +/** @type {DOOM} */ +const kneeDeep = DOOM.e` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsdocDeprecated_suggestion7_test.go b/internal/fourslash/tests/gen/jsdocDeprecated_suggestion7_test.go new file mode 100644 index 0000000000..3576d35c72 --- /dev/null +++ b/internal/fourslash/tests/gen/jsdocDeprecated_suggestion7_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsdocDeprecated_suggestion7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum Direction { + Left = -1, + Right = 1, +} +type T = Direction.Left +/** @deprecated */ +const x = 1 +type x = string +var y: x = 'hi'` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsdocParamTagSpecialKeywords_test.go b/internal/fourslash/tests/gen/jsdocParamTagSpecialKeywords_test.go index fb79362df2..aedce38af1 100644 --- a/internal/fourslash/tests/gen/jsdocParamTagSpecialKeywords_test.go +++ b/internal/fourslash/tests/gen/jsdocParamTagSpecialKeywords_test.go @@ -21,6 +21,7 @@ function test(type) { type./**/ }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/jsdocParam_suggestion1_test.go b/internal/fourslash/tests/gen/jsdocParam_suggestion1_test.go new file mode 100644 index 0000000000..d11af52b5e --- /dev/null +++ b/internal/fourslash/tests/gen/jsdocParam_suggestion1_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsdocParam_suggestion1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +/** + * @param options - whatever + * @param options.zone - equally bad + */ +declare function bad(options: any): void + +/** + * @param {number} obtuse + */ +function worse(): void { + arguments +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "a.ts") + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsdocTypedefTag1_test.go b/internal/fourslash/tests/gen/jsdocTypedefTag1_test.go index c8bf9b0835..f39b7b8cb6 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTag1_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTag1_test.go @@ -26,6 +26,7 @@ function a(my) { my.yes./*1*/ }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/jsdocTypedefTag2_test.go b/internal/fourslash/tests/gen/jsdocTypedefTag2_test.go index 25244841a1..fa892122eb 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTag2_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTag2_test.go @@ -32,6 +32,7 @@ function b(my2) { my2.yes./*2*/ }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagGoToDefinition_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagGoToDefinition_test.go index 7cb4093f34..412999af5d 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagGoToDefinition_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagGoToDefinition_test.go @@ -29,5 +29,6 @@ var person; person.[|personName/*3*/|] /** @type {Animal} */ var animal; animal.[|animalName/*4*/|]` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "3", "4") + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToDefinition(t, true, "3", "4") } diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagNamespace_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagNamespace_test.go index 700956e582..085d27d180 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagNamespace_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagNamespace_test.go @@ -28,6 +28,7 @@ var x1; x1./*2*/; /** @type {T.People} */ var x1; x1./*3*/;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, []string{"1", "3"}, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagRename01_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagRename01_test.go index 47ef05dc8c..8d1c9c8e5b 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagRename01_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagRename01_test.go @@ -23,5 +23,6 @@ func TestJsdocTypedefTagRename01(t *testing.T) { /** @type {[|NumberLike|]} */ var numberLike;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineRename(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) } diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagRename02_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagRename02_test.go index 2fbe40851c..a0515e6d7f 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagRename02_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagRename02_test.go @@ -20,5 +20,6 @@ func TestJsdocTypedefTagRename02(t *testing.T) { /** @type {[|NumberLike|]} */ var numberLike;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineRename(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) } diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagRename03_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagRename03_test.go index 94c632a2ee..df2250f595 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagRename03_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagRename03_test.go @@ -25,6 +25,7 @@ func TestJsdocTypedefTagRename03(t *testing.T) { /** @type {/*2*/[|Person|]} */ var person;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToFile(t, "jsDocTypedef_form3.js") f.VerifyBaselineRename(t, nil /*preferences*/, ToAny(f.GetRangesByText().Get("Person"))...) } diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagRename04_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagRename04_test.go index 5e8b871a75..5321f95570 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagRename04_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagRename04_test.go @@ -27,6 +27,7 @@ function test2() { var n/*2*/umberLike2; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "2") f.VerifyQuickInfoExists(t) f.GoToMarker(t, "1") diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go index 9cfe690620..5f2a24c378 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go @@ -28,5 +28,5 @@ const product = null;` f.VerifyBaselineFindAllReferences(t, "use", "def") f.VerifyBaselineRename(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) - f.VerifyBaselineGoToDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, true, "use") } diff --git a/internal/fourslash/tests/gen/jsdocTypedefTag_test.go b/internal/fourslash/tests/gen/jsdocTypedefTag_test.go index bf281d7383..06d7625846 100644 --- a/internal/fourslash/tests/gen/jsdocTypedefTag_test.go +++ b/internal/fourslash/tests/gen/jsdocTypedefTag_test.go @@ -62,6 +62,7 @@ var d;d./*dog*/; d.dogName./*dogName*/; d.dogAge./*dogAge*/;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "numberLike", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/jsxElementExtendsNoCrash1_test.go b/internal/fourslash/tests/gen/jsxElementExtendsNoCrash1_test.go new file mode 100644 index 0000000000..2831a1ee38 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxElementExtendsNoCrash1_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxElementExtendsNoCrash1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: index.tsx +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsxElementExtendsNoCrash2_test.go b/internal/fourslash/tests/gen/jsxElementExtendsNoCrash2_test.go new file mode 100644 index 0000000000..6be1dca04d --- /dev/null +++ b/internal/fourslash/tests/gen/jsxElementExtendsNoCrash2_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxElementExtendsNoCrash2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: index.tsx +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsxElementExtendsNoCrash3_test.go b/internal/fourslash/tests/gen/jsxElementExtendsNoCrash3_test.go new file mode 100644 index 0000000000..ba8dde6417 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxElementExtendsNoCrash3_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxElementExtendsNoCrash3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: index.tsx +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/jsxSpreadReference_test.go b/internal/fourslash/tests/gen/jsxSpreadReference_test.go index f602955d29..d94658e82f 100644 --- a/internal/fourslash/tests/gen/jsxSpreadReference_test.go +++ b/internal/fourslash/tests/gen/jsxSpreadReference_test.go @@ -29,5 +29,5 @@ class MyClass { var x = ;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyBaselineRenameAtRangesWithText(t, nil /*preferences*/, "nn") - f.VerifyBaselineGoToDefinition(t, "src") + f.VerifyBaselineGoToDefinition(t, true, "src") } diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionClosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionClosed_test.go new file mode 100644 index 0000000000..9358ac1196 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionClosed_test.go @@ -0,0 +1,145 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionClosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +interface NestedInterface { + Foo: NestedInterface; + (props: {}): any; +} + +declare const Foo: NestedInterface; + +function fn1() { + return + + +} +function fn2() { + return + + +} +function fn3() { + return + + +} +function fn4() { + return + + +} +function fn5() { + return + + +} +function fn6() { + return + + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionUnclosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionUnclosed_test.go new file mode 100644 index 0000000000..78ab4a048d --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionUnclosed_test.go @@ -0,0 +1,145 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionUnclosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +interface NestedInterface { + Foo: NestedInterface; + (props: {}): any; +} + +declare const Foo: NestedInterface; + +function fn1() { + return + +} +function fn2() { + return + +} +function fn3() { + return + +} +function fn4() { + return + +} +function fn5() { + return + +} +function fn6() { + return + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementClosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementClosed_test.go new file mode 100644 index 0000000000..8e509858f3 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementClosed_test.go @@ -0,0 +1,84 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionUnderElementClosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +declare namespace JSX { + interface IntrinsicElements { + button: any; + div: any; + } +} +function fn() { + return <> + + ; +} +function fn2() { + return <> + preceding junk + ; +} +function fn3() { + return <> + + ; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementUnclosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementUnclosed_test.go new file mode 100644 index 0000000000..568c195177 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementUnclosed_test.go @@ -0,0 +1,84 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionUnderElementUnclosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +declare namespace JSX { + interface IntrinsicElements { + button: any; + div: any; + } +} +function fn() { + return <> + ; +} +function fn2() { + return <> + preceding junk ; +} +function fn3() { + return <> + ; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/moduleDeclarationDeprecated_suggestion2_test.go b/internal/fourslash/tests/gen/moduleDeclarationDeprecated_suggestion2_test.go new file mode 100644 index 0000000000..acb0a5dfc8 --- /dev/null +++ b/internal/fourslash/tests/gen/moduleDeclarationDeprecated_suggestion2_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestModuleDeclarationDeprecated_suggestion2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +declare module` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/moduleNodeNextAutoImport1_test.go b/internal/fourslash/tests/gen/moduleNodeNextAutoImport1_test.go new file mode 100644 index 0000000000..6434da678c --- /dev/null +++ b/internal/fourslash/tests/gen/moduleNodeNextAutoImport1_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestModuleNodeNextAutoImport1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "module": "nodenext" } } +// @Filename: /package.json +{ "type": "module" } +// @Filename: /mobx.d.ts +export declare function autorun(): void; +// @Filename: /index.ts +autorun/**/ +// @Filename: /utils.ts +import "./mobx.js";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { autorun } from "./mobx.js"; + +autorun`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/moduleNodeNextAutoImport2_test.go b/internal/fourslash/tests/gen/moduleNodeNextAutoImport2_test.go new file mode 100644 index 0000000000..0803a88deb --- /dev/null +++ b/internal/fourslash/tests/gen/moduleNodeNextAutoImport2_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestModuleNodeNextAutoImport2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "module": "nodenext" } } +// @Filename: /package.json +{ "type": "module" } +// @Filename: /mobx.d.cts +export declare function autorun(): void; +// @Filename: /index.ts +autorun/**/ +// @Filename: /utils.ts +import "./mobx.cjs";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { autorun } from "./mobx.cjs"; + +autorun`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/moduleNodeNextAutoImport3_test.go b/internal/fourslash/tests/gen/moduleNodeNextAutoImport3_test.go new file mode 100644 index 0000000000..79a3a1c638 --- /dev/null +++ b/internal/fourslash/tests/gen/moduleNodeNextAutoImport3_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestModuleNodeNextAutoImport3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ "compilerOptions": { "module": "nodenext" } } +// @Filename: /package.json +{ "type": "module" } +// @Filename: /mobx.d.mts +export declare function autorun(): void; +// @Filename: /index.ts +autorun/**/ +// @Filename: /utils.ts +import "./mobx.mjs";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyImportFixAtPosition(t, []string{ + `import { autorun } from "./mobx.mjs"; + +autorun`, + }, nil /*preferences*/) +} diff --git a/internal/fourslash/tests/gen/navigateItemsLet_test.go b/internal/fourslash/tests/gen/navigateItemsLet_test.go new file mode 100644 index 0000000000..b9ee83d2e0 --- /dev/null +++ b/internal/fourslash/tests/gen/navigateItemsLet_test.go @@ -0,0 +1,46 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigateItemsLet(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +let [|c = 10|]; +function foo() { + let [|d = 10|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "c", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "c", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, { + Pattern: "d", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "d", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("foo"), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigateToImport_test.go b/internal/fourslash/tests/gen/navigateToImport_test.go new file mode 100644 index 0000000000..bd96c10a74 --- /dev/null +++ b/internal/fourslash/tests/gen/navigateToImport_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigateToImport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: library.ts +[|export function foo() {}|] +[|export function bar() {}|] +// @Filename: user.ts +import {foo, [|bar as baz|]} from './library';` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "foo", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "foo", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, { + Pattern: "bar", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "bar", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[1].LSLocation(), + }, + }), + }, { + Pattern: "baz", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "baz", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[2].LSLocation(), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go new file mode 100644 index 0000000000..0ec211a53a --- /dev/null +++ b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigateToSymbolIterator(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + [|[Symbol.iterator]() {}|] +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "iterator", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "iterator", + Kind: lsproto.SymbolKindMethod, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("C"), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go new file mode 100644 index 0000000000..bf5a3d8940 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsInConstructorsExactMatch(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +class Test { + [|private search1: number;|] + constructor([|public search2: boolean|], [|readonly search3: string|], search4: string) { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "search", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "search1", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("Test"), + }, + { + Name: "search2", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("Test"), + }, + { + Name: "search3", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Test"), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go new file mode 100644 index 0000000000..aed3cc0848 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go @@ -0,0 +1,94 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsPrefixMatch2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Shapes { + export class Point { + [|private originality = 0.0;|] + [|private distanceFromOrig = 0.0;|] + [|get distanceFarFarAway(distanceFarFarAwayParam: number): number { + var [|distanceFarFarAwayLocal|]; + return 0; + }|] + } +} +var pointsSquareBox = new Shapes.Point(); +function PointsFunc(): void { + var pointFuncLocal; +} +[|interface OriginI { + 123; + [|origin1;|] + [|public _distance(distanceParam): void;|] +}|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "origin", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "origin1", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[5].LSLocation(), + ContainerName: PtrTo("OriginI"), + }, + { + Name: "originality", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "OriginI", + Kind: lsproto.SymbolKindInterface, + Location: f.Ranges()[4].LSLocation(), + }, + }), + }, { + Pattern: "distance", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "distanceFarFarAway", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "distanceFarFarAwayLocal", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[3].LSLocation(), + ContainerName: PtrTo("distanceFarFarAway"), + }, + { + Name: "distanceFromOrig", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "_distance", + Kind: lsproto.SymbolKindMethod, + Location: f.Ranges()[6].LSLocation(), + ContainerName: PtrTo("OriginI"), + }, + }), + }, { + Pattern: "mPointThatIJustInitiated wrongKeyWord", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{}), + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_emptyPattern_test.go b/internal/fourslash/tests/gen/navto_emptyPattern_test.go new file mode 100644 index 0000000000..5c3702e9e2 --- /dev/null +++ b/internal/fourslash/tests/gen/navto_emptyPattern_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_emptyPattern(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: foo.ts +const [|x: number = 1|]; +[|function y(x: string): string { return x; }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "x", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + { + Name: "y", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[1].LSLocation(), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_excludeLib3_test.go b/internal/fourslash/tests/gen/navto_excludeLib3_test.go new file mode 100644 index 0000000000..7fbae17d69 --- /dev/null +++ b/internal/fourslash/tests/gen/navto_excludeLib3_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /index.ts +[|function parseInt(s: string): number {}|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "parseInt", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "parseInt", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/gen/ngProxy1_test.go b/internal/fourslash/tests/gen/ngProxy1_test.go index 7c23c1665b..5dc4381f4e 100644 --- a/internal/fourslash/tests/gen/ngProxy1_test.go +++ b/internal/fourslash/tests/gen/ngProxy1_test.go @@ -25,6 +25,7 @@ let x = [1, 2]; x/**/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "") f.VerifyQuickInfoIs(t, "Proxied x: number[]hello world", "") } diff --git a/internal/fourslash/tests/gen/ngProxy2_test.go b/internal/fourslash/tests/gen/ngProxy2_test.go index e53421a96c..99095ba7f9 100644 --- a/internal/fourslash/tests/gen/ngProxy2_test.go +++ b/internal/fourslash/tests/gen/ngProxy2_test.go @@ -25,6 +25,7 @@ let x = [1, 2]; x/**/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "") f.VerifyQuickInfoIs(t, "let x: number[]", "") } diff --git a/internal/fourslash/tests/gen/ngProxy3_test.go b/internal/fourslash/tests/gen/ngProxy3_test.go index 82eadb4b9a..e7c63ac793 100644 --- a/internal/fourslash/tests/gen/ngProxy3_test.go +++ b/internal/fourslash/tests/gen/ngProxy3_test.go @@ -25,6 +25,7 @@ let x = [1, 2]; x/**/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "") f.VerifyQuickInfoIs(t, "let x: number[]", "") } diff --git a/internal/fourslash/tests/gen/occurrences01_test.go b/internal/fourslash/tests/gen/occurrences01_test.go index a50d465552..ec88fd7643 100644 --- a/internal/fourslash/tests/gen/occurrences01_test.go +++ b/internal/fourslash/tests/gen/occurrences01_test.go @@ -22,5 +22,6 @@ func TestOccurrences01(t *testing.T) { continue foo; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) } diff --git a/internal/fourslash/tests/gen/occurrences02_test.go b/internal/fourslash/tests/gen/occurrences02_test.go index c58ac51a81..030e4e5cca 100644 --- a/internal/fourslash/tests/gen/occurrences02_test.go +++ b/internal/fourslash/tests/gen/occurrences02_test.go @@ -16,5 +16,6 @@ func TestOccurrences02(t *testing.T) { [|f|]([|f|]); }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) } diff --git a/internal/fourslash/tests/gen/packageJsonImportsFailedLookups_test.go b/internal/fourslash/tests/gen/packageJsonImportsFailedLookups_test.go index 365843622a..5323ef6e47 100644 --- a/internal/fourslash/tests/gen/packageJsonImportsFailedLookups_test.go +++ b/internal/fourslash/tests/gen/packageJsonImportsFailedLookups_test.go @@ -25,5 +25,6 @@ export function add(a: number, b: number): number; // @Filename: /a/b/c/d/e/index.ts import { add } from "#utils";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToFile(t, "/a/b/c/d/e/index.ts") } diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard1_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard1_test.go index f8235bb257..a9d3722505 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard1_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard1_test.go @@ -49,6 +49,7 @@ export const arguments = 0; // @Filename: /home/src/workspaces/project/src/m.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard2_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard2_test.go index b7e9f9eeec..2ec3035bf9 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard2_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard2_test.go @@ -38,6 +38,7 @@ export const actionRenderer = 0; // @Filename: /home/src/workspaces/project/src/index.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard3_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard3_test.go index 2c0e1ed65a..f73d73aed2 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard3_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard3_test.go @@ -42,6 +42,7 @@ export const one = 0; // @Filename: /home/src/workspaces/project/src/a.ts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard4_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard4_test.go index 3049b80acd..27315790d6 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard4_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard4_test.go @@ -44,6 +44,7 @@ export const one = 0; // @Filename: /home/src/workspaces/project/src/a.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard5_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard5_test.go index 3b71292027..ef93cdf3d3 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard5_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard5_test.go @@ -60,6 +60,7 @@ export const onlyInCjs = 0; // @Filename: /home/src/workspaces/project/src/index.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard6_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard6_test.go index e369dd185e..3f98e516b2 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard6_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard6_test.go @@ -38,6 +38,7 @@ export const blah = 0; // @Filename: /home/src/workspaces/project/src/m.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard7_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard7_test.go index f373400a89..ca80aa3fcf 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard7_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard7_test.go @@ -33,6 +33,7 @@ export const blah = 0; // @Filename: /home/src/workspaces/project/src/index.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard8_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard8_test.go index ea9fa0a684..3c5591ada3 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard8_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard8_test.go @@ -33,6 +33,7 @@ export const blah = 0; // @Filename: /home/src/workspaces/project/src/index.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard9_test.go b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard9_test.go index 3cacb1bd30..d4d872350d 100644 --- a/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard9_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsPackageJsonImportsSrcNoDistWildcard9_test.go @@ -34,6 +34,7 @@ export const blah = 0; // @Filename: /home/src/workspaces/project/src/index.mts import { } from "/**/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go index 558efd2c05..7f60525520 100644 --- a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go @@ -13,6 +13,7 @@ func TestPathCompletionsTypesVersionsWildcard2(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @module: commonjs +// @resolveJsonModule: false // @Filename: /node_modules/foo/package.json { "types": "index.d.ts", diff --git a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go index 8d63214eea..d8f8688a88 100644 --- a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go @@ -13,6 +13,7 @@ func TestPathCompletionsTypesVersionsWildcard3(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @module: commonjs +// @resolveJsonModule: false // @Filename: /node_modules/foo/package.json { "types": "index.d.ts", diff --git a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go index 320a68bfb2..d9f83bb7be 100644 --- a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go @@ -13,6 +13,7 @@ func TestPathCompletionsTypesVersionsWildcard4(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @module: commonjs +// @resolveJsonModule: false // @Filename: /node_modules/foo/package.json { "types": "index.d.ts", diff --git a/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go b/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go index 6acc245a7b..67e2077134 100644 --- a/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go +++ b/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go @@ -40,5 +40,5 @@ var x = Alpha.[|{| "name" : "mem" |}x|]` }, }) f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "import") - f.VerifyBaselineGoToDefinition(t, "import") + f.VerifyBaselineGoToDefinition(t, false, "import") } diff --git a/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go b/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go index cffaadcafc..7ce07026be 100644 --- a/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go +++ b/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go @@ -9,7 +9,7 @@ import ( func TestQuickInfoFromContextualType(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: quickInfoExportAssignmentOfGenericInterface_0.ts interface I { diff --git a/internal/fourslash/tests/gen/quickInfoJsPropertyAssignedAfterMethodDeclaration_test.go b/internal/fourslash/tests/gen/quickInfoJsPropertyAssignedAfterMethodDeclaration_test.go index fec1804e5b..44bde5ac76 100644 --- a/internal/fourslash/tests/gen/quickInfoJsPropertyAssignedAfterMethodDeclaration_test.go +++ b/internal/fourslash/tests/gen/quickInfoJsPropertyAssignedAfterMethodDeclaration_test.go @@ -9,7 +9,7 @@ import ( func TestQuickInfoJsPropertyAssignedAfterMethodDeclaration(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @noLib: true // @allowJs: true diff --git a/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go b/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go index aa599f2a08..60a3ef6150 100644 --- a/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go +++ b/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go @@ -9,7 +9,7 @@ import ( func TestQuickInfoMappedTypeMethods(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `type M = { [K in 'one']: any }; const x: M = { diff --git a/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go b/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go index f917e01054..203d4dc986 100644 --- a/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go +++ b/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go @@ -11,7 +11,7 @@ import ( func TestQuickInfoOnNarrowedType(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @strictNullChecks: true function foo(strOrNum: string | number) { diff --git a/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go b/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go index db39343a15..f4fbac65dc 100644 --- a/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go +++ b/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go @@ -9,7 +9,7 @@ import ( func TestQuickInfoUnion_discriminated(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: quickInfoJsDocTags.ts type U = A | B; diff --git a/internal/fourslash/tests/gen/quickinfo01_test.go b/internal/fourslash/tests/gen/quickinfo01_test.go index 729ced2175..dcd078181b 100644 --- a/internal/fourslash/tests/gen/quickinfo01_test.go +++ b/internal/fourslash/tests/gen/quickinfo01_test.go @@ -26,6 +26,7 @@ var /*1*/x : One | Two; x./*2*/commonProperty; x./*3*/commonFunction;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyQuickInfoAt(t, "1", "var x: One | Two", "") f.VerifyQuickInfoAt(t, "2", "(property) commonProperty: string | number", "") f.VerifyQuickInfoAt(t, "3", "(method) commonFunction(): number", "") diff --git a/internal/fourslash/tests/gen/quickinfoWrongComment_test.go b/internal/fourslash/tests/gen/quickinfoWrongComment_test.go index c6210f6e38..d93e547faa 100644 --- a/internal/fourslash/tests/gen/quickinfoWrongComment_test.go +++ b/internal/fourslash/tests/gen/quickinfoWrongComment_test.go @@ -25,6 +25,7 @@ type F = A | B const f: F = { colour: "green" } f.colour/*1*/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "1") f.VerifyQuickInfoIs(t, "(property) colour: \"green\" | \"red\" | \"yellow\"", "The colour") } diff --git a/internal/fourslash/tests/gen/reallyLargeFile_test.go b/internal/fourslash/tests/gen/reallyLargeFile_test.go index db3bfb2fd9..e4033fab63 100644 --- a/internal/fourslash/tests/gen/reallyLargeFile_test.go +++ b/internal/fourslash/tests/gen/reallyLargeFile_test.go @@ -583719,5 +583719,5 @@ namespace /*1*/Foo { }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "1") + f.VerifyBaselineGoToDefinition(t, false, "1") } diff --git a/internal/fourslash/tests/gen/refactorConvertToEsModule_notAtTopLevel_test.go b/internal/fourslash/tests/gen/refactorConvertToEsModule_notAtTopLevel_test.go new file mode 100644 index 0000000000..5538b18a20 --- /dev/null +++ b/internal/fourslash/tests/gen/refactorConvertToEsModule_notAtTopLevel_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRefactorConvertToEsModule_notAtTopLevel(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @target: esnext +// @Filename: /a.js +(function() { + module.exports = 0; +})();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/refactorConvertToEsModule_notInCommonjsProject_test.go b/internal/fourslash/tests/gen/refactorConvertToEsModule_notInCommonjsProject_test.go new file mode 100644 index 0000000000..ef1e05ee19 --- /dev/null +++ b/internal/fourslash/tests/gen/refactorConvertToEsModule_notInCommonjsProject_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRefactorConvertToEsModule_notInCommonjsProject(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +exports.x = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/referenceToEmptyObject_test.go b/internal/fourslash/tests/gen/referenceToEmptyObject_test.go index ddd33ebfbf..bb7fe5b3bc 100644 --- a/internal/fourslash/tests/gen/referenceToEmptyObject_test.go +++ b/internal/fourslash/tests/gen/referenceToEmptyObject_test.go @@ -13,5 +13,6 @@ func TestReferenceToEmptyObject(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `const obj = {}/*1*/;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1") } diff --git a/internal/fourslash/tests/gen/references01_test.go b/internal/fourslash/tests/gen/references01_test.go index a0930537a1..cb20271504 100644 --- a/internal/fourslash/tests/gen/references01_test.go +++ b/internal/fourslash/tests/gen/references01_test.go @@ -19,5 +19,6 @@ class /*0*/globalClass { /// var c = /*1*/globalClass();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1") } diff --git a/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go b/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go index fcec2a2070..bde9db9024 100644 --- a/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go +++ b/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go @@ -9,7 +9,7 @@ import ( func TestReferencesForStatementKeywords(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @filename: /main.ts // import ... = ... diff --git a/internal/fourslash/tests/gen/referencesInConfiguredProject_test.go b/internal/fourslash/tests/gen/referencesInConfiguredProject_test.go index 618ebb7428..05e161123a 100644 --- a/internal/fourslash/tests/gen/referencesInConfiguredProject_test.go +++ b/internal/fourslash/tests/gen/referencesInConfiguredProject_test.go @@ -20,5 +20,6 @@ var c = /*1*/globalClass(); // @Filename: /home/src/workspaces/project/tsconfig.json { "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1") } diff --git a/internal/fourslash/tests/gen/referencesInEmptyFileWithMultipleProjects_test.go b/internal/fourslash/tests/gen/referencesInEmptyFileWithMultipleProjects_test.go index 04141f4343..59d73dd0c3 100644 --- a/internal/fourslash/tests/gen/referencesInEmptyFileWithMultipleProjects_test.go +++ b/internal/fourslash/tests/gen/referencesInEmptyFileWithMultipleProjects_test.go @@ -21,5 +21,6 @@ func TestReferencesInEmptyFileWithMultipleProjects(t *testing.T) { // @Filename: /home/src/workspaces/project/b/b.ts /*2*/;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1", "2") } diff --git a/internal/fourslash/tests/gen/referencesInEmptyFile_test.go b/internal/fourslash/tests/gen/referencesInEmptyFile_test.go index 7afa6fcc96..775c13d3f5 100644 --- a/internal/fourslash/tests/gen/referencesInEmptyFile_test.go +++ b/internal/fourslash/tests/gen/referencesInEmptyFile_test.go @@ -13,5 +13,6 @@ func TestReferencesInEmptyFile(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `/*1*/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1") } diff --git a/internal/fourslash/tests/gen/referencesInStringLiteralValueWithMultipleProjects_test.go b/internal/fourslash/tests/gen/referencesInStringLiteralValueWithMultipleProjects_test.go index 2cbc1cc5d7..faef0508cf 100644 --- a/internal/fourslash/tests/gen/referencesInStringLiteralValueWithMultipleProjects_test.go +++ b/internal/fourslash/tests/gen/referencesInStringLiteralValueWithMultipleProjects_test.go @@ -21,5 +21,6 @@ const str: string = "hello/*1*/"; // @Filename: /home/src/workspaces/project/b/b.ts const str2: string = "hello/*2*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1", "2") } diff --git a/internal/fourslash/tests/gen/referencesToNonPropertyNameStringLiteral_test.go b/internal/fourslash/tests/gen/referencesToNonPropertyNameStringLiteral_test.go index 43e383c407..470e79dffd 100644 --- a/internal/fourslash/tests/gen/referencesToNonPropertyNameStringLiteral_test.go +++ b/internal/fourslash/tests/gen/referencesToNonPropertyNameStringLiteral_test.go @@ -13,5 +13,6 @@ func TestReferencesToNonPropertyNameStringLiteral(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `const str: string = "hello/*1*/";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1") } diff --git a/internal/fourslash/tests/gen/referencesToStringLiteralValue_test.go b/internal/fourslash/tests/gen/referencesToStringLiteralValue_test.go index 8db6a6fca4..c3fa40cba2 100644 --- a/internal/fourslash/tests/gen/referencesToStringLiteralValue_test.go +++ b/internal/fourslash/tests/gen/referencesToStringLiteralValue_test.go @@ -13,5 +13,6 @@ func TestReferencesToStringLiteralValue(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `const s: string = "some /*1*/ string";` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineFindAllReferences(t, "1") } diff --git a/internal/fourslash/tests/gen/rename01_test.go b/internal/fourslash/tests/gen/rename01_test.go index ba3cf9437d..2dfc07f89b 100644 --- a/internal/fourslash/tests/gen/rename01_test.go +++ b/internal/fourslash/tests/gen/rename01_test.go @@ -17,5 +17,6 @@ func TestRename01(t *testing.T) { "this is a reference to [|Bar|] in a string" }|]` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1]) } diff --git a/internal/fourslash/tests/gen/renameExportSpecifier2_test.go b/internal/fourslash/tests/gen/renameExportSpecifier2_test.go index 404830405a..2568eab221 100644 --- a/internal/fourslash/tests/gen/renameExportSpecifier2_test.go +++ b/internal/fourslash/tests/gen/renameExportSpecifier2_test.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -20,5 +20,5 @@ export { name/**/ }; import { name } from './a'; const x = name.toString();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSFalse}, "") + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSFalse}, "") } diff --git a/internal/fourslash/tests/gen/renameExportSpecifier_test.go b/internal/fourslash/tests/gen/renameExportSpecifier_test.go index 0b4207e579..7f8c4191c4 100644 --- a/internal/fourslash/tests/gen/renameExportSpecifier_test.go +++ b/internal/fourslash/tests/gen/renameExportSpecifier_test.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -20,5 +20,5 @@ export { name as name/**/ }; import { name } from './a'; const x = name.toString();` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSFalse}, "") + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSFalse}, "") } diff --git a/internal/fourslash/tests/gen/renameInConfiguredProject_test.go b/internal/fourslash/tests/gen/renameInConfiguredProject_test.go index 4e9262843d..ef954a230a 100644 --- a/internal/fourslash/tests/gen/renameInConfiguredProject_test.go +++ b/internal/fourslash/tests/gen/renameInConfiguredProject_test.go @@ -19,5 +19,6 @@ var y = [|globalName|]; // @Filename: tsconfig.json { "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineRename(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) } diff --git a/internal/fourslash/tests/gen/renameModuleExportsProperties1_test.go b/internal/fourslash/tests/gen/renameModuleExportsProperties1_test.go index 012d2fc57c..2bfa3a1cfe 100644 --- a/internal/fourslash/tests/gen/renameModuleExportsProperties1_test.go +++ b/internal/fourslash/tests/gen/renameModuleExportsProperties1_test.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -16,5 +16,5 @@ func TestRenameModuleExportsProperties1(t *testing.T) { const content = `[|class [|{| "contextRangeIndex": 0 |}A|] {}|] module.exports = { [|A|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[2]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[2]) } diff --git a/internal/fourslash/tests/gen/renameModuleExportsProperties3_test.go b/internal/fourslash/tests/gen/renameModuleExportsProperties3_test.go index 35eca115e1..6219a95c04 100644 --- a/internal/fourslash/tests/gen/renameModuleExportsProperties3_test.go +++ b/internal/fourslash/tests/gen/renameModuleExportsProperties3_test.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -18,5 +18,5 @@ func TestRenameModuleExportsProperties3(t *testing.T) { [|class [|{| "contextRangeIndex": 0 |}A|] {}|] module.exports = { [|A|] }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[2]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[2]) } diff --git a/internal/fourslash/tests/gen/renameNamedImport_test.go b/internal/fourslash/tests/gen/renameNamedImport_test.go index 7a9df3f016..64486a2227 100644 --- a/internal/fourslash/tests/gen/renameNamedImport_test.go +++ b/internal/fourslash/tests/gen/renameNamedImport_test.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -26,7 +26,8 @@ someExportedVariable; // @Filename: /home/src/workspaces/project/tsconfig.json {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToFile(t, "/home/src/workspaces/project/lib/index.ts") f.GoToFile(t, "/home/src/workspaces/project/src/index.ts") - f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, "i") + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSTrue}, "i") } diff --git a/internal/fourslash/tests/gen/renameNamespaceImport_test.go b/internal/fourslash/tests/gen/renameNamespaceImport_test.go index f70dbbd6a4..3a022789be 100644 --- a/internal/fourslash/tests/gen/renameNamespaceImport_test.go +++ b/internal/fourslash/tests/gen/renameNamespaceImport_test.go @@ -24,6 +24,7 @@ lib.someExportedVariable; // @Filename: /home/src/workspaces/project/tsconfig.json {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToFile(t, "/home/src/workspaces/project/lib/index.ts") f.GoToFile(t, "/home/src/workspaces/project/src/index.ts") f.VerifyBaselineRename(t, nil /*preferences*/, "i") diff --git a/internal/fourslash/tests/gen/renameNumericalIndexSingleQuoted_test.go b/internal/fourslash/tests/gen/renameNumericalIndexSingleQuoted_test.go index f02f765d71..fba05fbfba 100644 --- a/internal/fourslash/tests/gen/renameNumericalIndexSingleQuoted_test.go +++ b/internal/fourslash/tests/gen/renameNumericalIndexSingleQuoted_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -15,5 +15,5 @@ func TestRenameNumericalIndexSingleQuoted(t *testing.T) { const content = `const foo = { [|0|]: true }; foo[[|0|]];` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineRenameAtRangesWithText(t, &ls.UserPreferences{QuotePreference: ls.QuotePreference("single")}, "0") + f.VerifyBaselineRenameAtRangesWithText(t, &lsutil.UserPreferences{QuotePreference: lsutil.QuotePreference("single")}, "0") } diff --git a/internal/fourslash/tests/gen/renameRestBindingElement_test.go b/internal/fourslash/tests/gen/renameRestBindingElement_test.go index c4c4200e56..2b3067e157 100644 --- a/internal/fourslash/tests/gen/renameRestBindingElement_test.go +++ b/internal/fourslash/tests/gen/renameRestBindingElement_test.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -22,5 +22,5 @@ function foo([|{ a, ...[|{| "contextRangeIndex": 0 |}rest|] }: I|]) { [|rest|]; }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1]) + f.VerifyBaselineRename(t, &lsutil.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1]) } diff --git a/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences1_test.go b/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences1_test.go new file mode 100644 index 0000000000..d53850c093 --- /dev/null +++ b/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences1_test.go @@ -0,0 +1,59 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRewriteRelativeImportExtensionsProjectReferences1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: packages/common/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "rootDir": "src", + "outDir": "dist", + "module": "nodenext", + "resolveJsonModule": false, + } +} +// @Filename: packages/common/package.json +{ + "name": "common", + "version": "1.0.0", + "type": "module", + "exports": { + ".": { + "source": "./src/index.ts", + "default": "./dist/index.js" + } + } +} +// @Filename: packages/common/src/index.ts +export {}; +// @Filename: packages/main/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext", + "rewriteRelativeImportExtensions": true, + "rootDir": "src", + "outDir": "dist", + "resolveJsonModule": false, + }, + "references": [ + { "path": "../common" } + ] +} +// @Filename: packages/main/package.json +{ "type": "module" } +// @Filename: packages/main/src/index.ts +import {} from "../../common/src/index.ts";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToFile(t, "/packages/main/src/index.ts") + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences2_test.go b/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences2_test.go new file mode 100644 index 0000000000..f545a320c3 --- /dev/null +++ b/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences2_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRewriteRelativeImportExtensionsProjectReferences2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: src/tsconfig-base.json +{ + "compilerOptions": { + "module": "nodenext", + "composite": true, + "rootDir": ".", + "outDir": "../dist", + "rewriteRelativeImportExtensions": true, + } +} +// @Filename: src/compiler/tsconfig.json +{ + "extends": "../tsconfig-base.json", + "compilerOptions": {} +} +// @Filename: src/compiler/parser.ts +export {}; +// @Filename: src/services/tsconfig.json +{ + "extends": "../tsconfig-base.json", + "compilerOptions": {}, + "references": [ + { "path": "../compiler" } + ] +} +// @Filename: src/services/services.ts +import {} from "../compiler/parser.ts";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToFile(t, "/src/services/services.ts") + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences3_test.go b/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences3_test.go new file mode 100644 index 0000000000..4cb792e776 --- /dev/null +++ b/internal/fourslash/tests/gen/rewriteRelativeImportExtensionsProjectReferences3_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRewriteRelativeImportExtensionsProjectReferences3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: src/tsconfig-base.json +{ + "compilerOptions": { + "module": "nodenext", + "composite": true, + "rewriteRelativeImportExtensions": true, + } +} +// @Filename: src/compiler/tsconfig.json +{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../../dist/compiler", +} +// @Filename: src/compiler/parser.ts +export {}; +// @Filename: src/services/tsconfig.json +{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../../dist/services", + }, + "references": [ + { "path": "../compiler" } + ] +} +// @Filename: src/services/services.ts +import {} from "../compiler/parser.ts";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToFile(t, "/src/services/services.ts") + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/sideEffectImportsSuggestion1_test.go b/internal/fourslash/tests/gen/sideEffectImportsSuggestion1_test.go new file mode 100644 index 0000000000..2d648c21ed --- /dev/null +++ b/internal/fourslash/tests/gen/sideEffectImportsSuggestion1_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSideEffectImportsSuggestion1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @noEmit: true +// @module: commonjs +// @noUncheckedSideEffectImports: true +// @filename: moduleA/a.js +import "b"; +import "c"; +// @filename: node_modules/b.ts +var a = 10; +// @filename: node_modules/c.js +exports.a = 10; +c = 10;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifySuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/signatureHelpJSDocCallbackTag_test.go b/internal/fourslash/tests/gen/signatureHelpJSDocCallbackTag_test.go index 4c5acb9335..d77d30d807 100644 --- a/internal/fourslash/tests/gen/signatureHelpJSDocCallbackTag_test.go +++ b/internal/fourslash/tests/gen/signatureHelpJSDocCallbackTag_test.go @@ -36,5 +36,6 @@ var t; var t2; t(/*4*/"!", /*5*/12, /*6*/false);` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyBaselineSignatureHelp(t) } diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go new file mode 100644 index 0000000000..a323c1da47 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags10(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @template T + * @extends {/**/Set} + */ +class A extends B { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go new file mode 100644 index 0000000000..1eedc0f74c --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags11(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const x = 1; +type Foo = { + /** comment */ + /*2*/readonly /*1*/status: number; +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go new file mode 100644 index 0000000000..7ec86103a2 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags12(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type B = {}; +type A = { + a(/** Comment */ /*1*/p0: number, /** Comment */ /*2*/p1: number, /** Comment */ /*3*/p2: number): string; +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go new file mode 100644 index 0000000000..a3c4b2d4c6 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags13(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let a; +let b: { + /** Comment */ /*1*/p0: number + /** Comment */ /*2*/p1: number + /** Comment */ /*3*/p2: number +}; +let c;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go new file mode 100644 index 0000000000..fcc56e525a --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @returns {Array<{ value: /**/string }>} + */ +function foo() { return [] }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go new file mode 100644 index 0000000000..0db6205655 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @type {/**/string} + */ +const foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go new file mode 100644 index 0000000000..fb4b5ecdaf --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @param {/**/string} x + */ +function foo(x) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go new file mode 100644 index 0000000000..7d1d7bb0fc --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {/**/number} c + */ + +/** @type {Foo} */ +const foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go new file mode 100644 index 0000000000..c14320ca6a --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @callback Foo + * @param {string} data + * @param {/**/number} [index] - comment + * @return {boolean} + */ + +/** @type {Foo} */ +const foo = s => !(s.length % 2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go new file mode 100644 index 0000000000..ac7904a3b6 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @template T + * @param {/**/T} x + * @return {T} + */ +function foo(x) { + return x; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go new file mode 100644 index 0000000000..fbfc577b24 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @constructor + * @param {/**/number} data + */ +function Foo(data) { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go new file mode 100644 index 0000000000..7a6dbfa501 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @this {/*1*/Foo} + * @param {/*2*/*} e + */ +function callback(e) { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go new file mode 100644 index 0000000000..cd4cfd9672 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags9(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** @enum {/**/number} */ +const Foo = { + x: 0, + y: 1, +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go b/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go new file mode 100644 index 0000000000..df80bc98fc --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDoc(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Not a JSDoc comment +/** + * @param {number} x The number to square + */ +function /**/square(x) { + return x * x; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go b/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go new file mode 100644 index 0000000000..60616d9619 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_behindCaret(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let/**/ x: string` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go b/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go new file mode 100644 index 0000000000..2af1ad8ece --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_bindingPatterns(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const { /*1*/x, y: /*2*/a, .../*3*/zs = {} } = {};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_comment1_test.go b/internal/fourslash/tests/gen/smartSelection_comment1_test.go new file mode 100644 index 0000000000..07ce0c89a1 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_comment1_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_comment1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 1; ///**/comment content` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_comment2_test.go b/internal/fourslash/tests/gen/smartSelection_comment2_test.go new file mode 100644 index 0000000000..5f85d31719 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_comment2_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_comment2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 1; //a b/**/c d` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_complex_test.go b/internal/fourslash/tests/gen/smartSelection_complex_test.go new file mode 100644 index 0000000000..f5e70e3505 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_complex_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_complex(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = IsExactlyAny

extends true ? T : ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[/**/K] : P[K]; } & Pick>)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go b/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go new file mode 100644 index 0000000000..bfe284f963 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_emptyRanges(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class HomePage { + componentDidMount(/*1*/) { + if (this.props.username/*2*/) { + return '/*3*/'; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function1_test.go b/internal/fourslash/tests/gen/smartSelection_function1_test.go new file mode 100644 index 0000000000..69f55b9433 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const f1 = () => { + /**/ +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function2_test.go b/internal/fourslash/tests/gen/smartSelection_function2_test.go new file mode 100644 index 0000000000..ae9342a804 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f2() { + /**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function3_test.go b/internal/fourslash/tests/gen/smartSelection_function3_test.go new file mode 100644 index 0000000000..277f17a16e --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function3_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const f3 = function () { + /**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go b/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go new file mode 100644 index 0000000000..9e72094748 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_functionParams1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(/*1*/p, /*2*/q?, /*3*/...r: any[] = []) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go b/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go new file mode 100644 index 0000000000..23742a790c --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_functionParams2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f( + a, + /**/b +) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_imports_test.go b/internal/fourslash/tests/gen/smartSelection_imports_test.go new file mode 100644 index 0000000000..fb6fdaf283 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_imports_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_imports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import { /**/x as y, z } from './z'; +import { b } from './'; + +console.log(1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go b/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go new file mode 100644 index 0000000000..707384913d --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_lastBlankLine(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go b/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go new file mode 100644 index 0000000000..da1f4af3a8 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_loneVariableDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const /**/x = 3;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go b/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go new file mode 100644 index 0000000000..7467f4d8eb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_mappedTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type M = { /*1*/-re/*2*/adonly /*3*/[K in ke/*4*/yof any]/*5*/-/*6*/?: any };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go b/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go new file mode 100644 index 0000000000..98fa38286b --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_objectTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = { + /*1*/foo?: string; + /*2*/readonly /*3*/bar: { x: num/*4*/ber }; + /*5*/meh +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go b/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go new file mode 100644 index 0000000000..d63add6b39 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_punctuationPriority(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `console/**/.log();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_simple1_test.go b/internal/fourslash/tests/gen/smartSelection_simple1_test.go new file mode 100644 index 0000000000..e24d9bb2bb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_simple1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_simple1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + bar(a, b) { + if (/*1*/a === b) { + return tr/*2*/ue; + } + return false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_simple2_test.go b/internal/fourslash/tests/gen/smartSelection_simple2_test.go new file mode 100644 index 0000000000..a2b31dfe05 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_simple2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_simple2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export interface IService { + _serviceBrand: any; + + open(ho/*1*/st: number, data: any): Promise; + bar(): void/*2*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go b/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go new file mode 100644 index 0000000000..789cac8a04 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_stringLiteral(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 'a'; +const b = /**/'b';` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go b/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go new file mode 100644 index 0000000000..fa210cb690 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_templateStrings2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `a ${b} /**/c` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go b/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go new file mode 100644 index 0000000000..ef7a4d7fbb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_templateStrings(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `a /*1*/b ${ + '/*2*/c' +} d` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/suggestionNoDuplicates_test.go b/internal/fourslash/tests/gen/suggestionNoDuplicates_test.go new file mode 100644 index 0000000000..873d115ecd --- /dev/null +++ b/internal/fourslash/tests/gen/suggestionNoDuplicates_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSuggestionNoDuplicates(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: false +// @Filename: foo.ts +import { f } from [|'m'|] +f +// @Filename: node_modules/m/index.js +module.exports.f = function (x) { return x }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNonSuggestionDiagnostics(t, nil) + f.VerifySuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](7016)}, + Message: "Could not find a declaration file for module 'm'. '/node_modules/m/index.js' implicitly has an 'any' type.", + }, + }) +} diff --git a/internal/fourslash/tests/gen/suggestionOfUnusedVariableWithExternalModule_test.go b/internal/fourslash/tests/gen/suggestionOfUnusedVariableWithExternalModule_test.go new file mode 100644 index 0000000000..a18d6ac801 --- /dev/null +++ b/internal/fourslash/tests/gen/suggestionOfUnusedVariableWithExternalModule_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSuggestionOfUnusedVariableWithExternalModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@allowJs: true +// @Filename: /mymodule.js +(function ([|root|], factory) { + module.exports = factory(); +}(this, function () { + var [|unusedVar|] = "something"; + return {}; +})); +// @Filename: /app.js +//@ts-check +require("./mymodule");` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/app.js") + f.VerifySuggestionDiagnostics(t, nil) + f.GoToFile(t, "/mymodule.js") + f.VerifySuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Message: "'root' is declared but its value is never read.", + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](6133)}, + Range: f.Ranges()[0].LSRange, + Tags: &[]lsproto.DiagnosticTag{lsproto.DiagnosticTagUnnecessary}, + }, + { + Message: "'unusedVar' is declared but its value is never read.", + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](6133)}, + Range: f.Ranges()[1].LSRange, + Tags: &[]lsproto.DiagnosticTag{lsproto.DiagnosticTagUnnecessary}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/tsconfigComputedPropertyError_test.go b/internal/fourslash/tests/gen/tsconfigComputedPropertyError_test.go new file mode 100644 index 0000000000..b8e99cb695 --- /dev/null +++ b/internal/fourslash/tests/gen/tsconfigComputedPropertyError_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestTsconfigComputedPropertyError(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: tsconfig.json +{ + ["oops!" + 42]: "true", + "files": [ + "nonexistentfile.ts" + ], + "compileOnSave": true +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyNonSuggestionDiagnostics(t, nil) +} diff --git a/internal/fourslash/tests/gen/tsxCompletion14_test.go b/internal/fourslash/tests/gen/tsxCompletion14_test.go index 364cf42fc3..bf1f8cb687 100644 --- a/internal/fourslash/tests/gen/tsxCompletion14_test.go +++ b/internal/fourslash/tests/gen/tsxCompletion14_test.go @@ -10,7 +10,7 @@ import ( func TestTsxCompletion14(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `//@module: commonjs //@jsx: preserve diff --git a/internal/fourslash/tests/gen/tsxCompletion15_test.go b/internal/fourslash/tests/gen/tsxCompletion15_test.go index 90478f63fd..63de791a39 100644 --- a/internal/fourslash/tests/gen/tsxCompletion15_test.go +++ b/internal/fourslash/tests/gen/tsxCompletion15_test.go @@ -10,7 +10,7 @@ import ( func TestTsxCompletion15(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `//@module: commonjs //@jsx: preserve diff --git a/internal/fourslash/tests/gen/tsxGoToDefinitionClasses_test.go b/internal/fourslash/tests/gen/tsxGoToDefinitionClasses_test.go index eae08d8b2a..683e2cbb4c 100644 --- a/internal/fourslash/tests/gen/tsxGoToDefinitionClasses_test.go +++ b/internal/fourslash/tests/gen/tsxGoToDefinitionClasses_test.go @@ -26,5 +26,5 @@ var x = <[|My/*c*/Class|] />; var y = ; var z = <[|MyCl/*w*/ass|] wrong= 'hello' />;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "c", "p", "w") + f.VerifyBaselineGoToDefinition(t, true, "c", "p", "w") } diff --git a/internal/fourslash/tests/gen/tsxGoToDefinitionIntrinsics_test.go b/internal/fourslash/tests/gen/tsxGoToDefinitionIntrinsics_test.go index 3004b81b24..a7bc0b8a2a 100644 --- a/internal/fourslash/tests/gen/tsxGoToDefinitionIntrinsics_test.go +++ b/internal/fourslash/tests/gen/tsxGoToDefinitionIntrinsics_test.go @@ -26,5 +26,5 @@ var x = <[|di/*ds*/v|] />; var y = <[|s/*ss*/pan|] />; var z =

;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "ds", "ss", "ps") + f.VerifyBaselineGoToDefinition(t, true, "ds", "ss", "ps") } diff --git a/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction1_test.go b/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction1_test.go index 5a3fa3be7a..43722cd861 100644 --- a/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction1_test.go +++ b/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction1_test.go @@ -31,5 +31,5 @@ let opt1 = <[|Op/*two*/t|] [|pr/*p1*/opx|]={100} />; let opt2 = <[|Op/*three*/t|] propx={100} [|opt/*p2*/ional|] />; let opt3 = <[|Op/*four*/t|] wr/*p3*/ong />;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "one", "two", "three", "four", "p1", "p2") + f.VerifyBaselineGoToDefinition(t, true, "one", "two", "three", "four", "p1", "p2") } diff --git a/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction2_test.go b/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction2_test.go index 542014f9c3..9c3ee6e942 100644 --- a/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction2_test.go +++ b/internal/fourslash/tests/gen/tsxGoToDefinitionStatelessFunction2_test.go @@ -40,5 +40,5 @@ let opt = <[|Main/*fourthTarget*/Button|] onClick={()=>{}} ignore-prop />; let opt = <[|Main/*fifthTarget*/Button|] goTo="goTo" />; let opt = <[|Main/*sixthTarget*/Button|] wrong />;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "firstTarget", "secondTarget", "thirdTarget", "fourthTarget", "fifthTarget", "sixthTarget") + f.VerifyBaselineGoToDefinition(t, true, "firstTarget", "secondTarget", "thirdTarget", "fourthTarget", "fifthTarget", "sixthTarget") } diff --git a/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType1_test.go b/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType1_test.go index 0278a88ab6..3b549806b5 100644 --- a/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType1_test.go +++ b/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType1_test.go @@ -29,5 +29,5 @@ function SFC2(prop: { x: boolean }) { var /*def*/SFCComp = SFC1 || SFC2; <[|SFC/*one*/Comp|] x />` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "one") + f.VerifyBaselineGoToDefinition(t, true, "one") } diff --git a/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType2_test.go b/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType2_test.go index f6a91c8869..3b96e6d142 100644 --- a/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType2_test.go +++ b/internal/fourslash/tests/gen/tsxGoToDefinitionUnionElementType2_test.go @@ -28,5 +28,5 @@ class RC2 extends React.Component<{}, {}> { var /*pt1*/RCComp = RC1 || RC2; <[|RC/*one*/Comp|] />` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineGoToDefinition(t, "one") + f.VerifyBaselineGoToDefinition(t, true, "one") } diff --git a/internal/fourslash/tests/gen/tsxIncrementalServer_test.go b/internal/fourslash/tests/gen/tsxIncrementalServer_test.go index 30ef797b14..ca2911826c 100644 --- a/internal/fourslash/tests/gen/tsxIncrementalServer_test.go +++ b/internal/fourslash/tests/gen/tsxIncrementalServer_test.go @@ -13,6 +13,7 @@ func TestTsxIncrementalServer(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `/**/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.GoToMarker(t, "") f.Insert(t, "<") f.Insert(t, "div") diff --git a/internal/fourslash/tests/gen/typeErrorAfterStringCompletionsInNestedCall2_test.go b/internal/fourslash/tests/gen/typeErrorAfterStringCompletionsInNestedCall2_test.go new file mode 100644 index 0000000000..0ff56db36a --- /dev/null +++ b/internal/fourslash/tests/gen/typeErrorAfterStringCompletionsInNestedCall2_test.go @@ -0,0 +1,80 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestTypeErrorAfterStringCompletionsInNestedCall2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true + +type ActionFunction< + TExpressionEvent extends { type: string }, + out TEvent extends { type: string } +> = { + ({ event }: { event: TExpressionEvent }): void; + _out_TEvent?: TEvent; +}; + +interface MachineConfig { + types: { + events: TEvent; + }; + on: { + [K in TEvent["type"]]?: ActionFunction< + Extract, + TEvent + >; + }; +} + +declare function raise< + TExpressionEvent extends { type: string }, + TEvent extends { type: string } +>( + resolve: ({ event }: { event: TExpressionEvent }) => TEvent +): { + ({ event }: { event: TExpressionEvent }): void; + _out_TEvent?: TEvent; +}; + +declare function createMachine( + config: MachineConfig +): void; + +createMachine({ + types: { + events: {} as { type: "FOO" } | { type: "BAR" }, + }, + on: { + [|/*error*/FOO|]: raise(({ event }) => { + return { + type: "BAR/*1*/" as const, + }; + }), + }, +});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.Insert(t, "x") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "BAR", + "FOO", + }, + }, + }) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/fourslash/tests/gen/typeErrorAfterStringCompletionsInNestedCall_test.go b/internal/fourslash/tests/gen/typeErrorAfterStringCompletionsInNestedCall_test.go new file mode 100644 index 0000000000..4026b74c4a --- /dev/null +++ b/internal/fourslash/tests/gen/typeErrorAfterStringCompletionsInNestedCall_test.go @@ -0,0 +1,62 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestTypeErrorAfterStringCompletionsInNestedCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true + +type GreetingEvent = + | { type: "MORNING" } + | { type: "LUNCH_TIME" } + | { type: "ALOHA" }; + +interface RaiseActionObject { + type: "raise"; + event: TEvent; +} + +declare function raise( + ev: TEvent +): RaiseActionObject; + +declare function createMachine(config: { + actions: RaiseActionObject; +}): void; + +createMachine({ + [|/*error*/actions|]: raise({ type: "ALOHA/*1*/" }), +});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.Insert(t, "x") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "ALOHA", + "LUNCH_TIME", + "MORNING", + }, + }, + }) + f.VerifyNonSuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](2322)}, + Message: "Type 'RaiseActionObject<{ type: \"ALOHAx\"; }>' is not assignable to type 'RaiseActionObject'.\n Type '{ type: \"ALOHAx\"; }' is not assignable to type 'GreetingEvent'.\n Type '{ type: \"ALOHAx\"; }' is not assignable to type '{ type: \"ALOHA\"; }'.\n Types of property 'type' are incompatible.\n Type '\"ALOHAx\"' is not assignable to type '\"ALOHA\"'.", + }, + }) +} diff --git a/internal/fourslash/tests/gen/typeReferenceOnServer_test.go b/internal/fourslash/tests/gen/typeReferenceOnServer_test.go index 39abae2258..5b10594eb4 100644 --- a/internal/fourslash/tests/gen/typeReferenceOnServer_test.go +++ b/internal/fourslash/tests/gen/typeReferenceOnServer_test.go @@ -16,6 +16,7 @@ func TestTypeReferenceOnServer(t *testing.T) { var x: number; x./*1*/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ diff --git a/internal/fourslash/tests/gen/typedefinition01_test.go b/internal/fourslash/tests/gen/typedefinition01_test.go new file mode 100644 index 0000000000..89526e6290 --- /dev/null +++ b/internal/fourslash/tests/gen/typedefinition01_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestTypedefinition01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: b.ts +import n = require('./a'); +var x/*1*/ = new n.Foo(); +// @Filename: a.ts +export class /*2*/Foo {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.VerifyBaselineGoToTypeDefinition(t, "1") +} diff --git a/internal/fourslash/tests/inlayHintsTupleTypeCrash_test.go b/internal/fourslash/tests/inlayHintsTupleTypeCrash_test.go new file mode 100644 index 0000000000..5df5b06667 --- /dev/null +++ b/internal/fourslash/tests/inlayHintsTupleTypeCrash_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsTupleTypeCrash(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function iterateTuples(tuples: [string][]): void { + tuples.forEach((l) => {}) +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{ + IncludeInlayFunctionParameterTypeHints: true, + }) +} diff --git a/internal/fourslash/tests/manual/inlayHintsInteractiveParameterNamesInSpan1_test.go b/internal/fourslash/tests/manual/inlayHintsInteractiveParameterNamesInSpan1_test.go new file mode 100644 index 0000000000..c74850752a --- /dev/null +++ b/internal/fourslash/tests/manual/inlayHintsInteractiveParameterNamesInSpan1_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveParameterNamesInSpan1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1 (a: number, b: number) {} +function foo2 (c: number, d: number) {} +function foo3 (e: number, f: number) {} +function foo4 (g: number, h: number) {} +function foo5 (i: number, j: number) {} +function foo6 (k: number, i: number) {} + +function c1 () { foo1(/*a*/1, /*b*/2); } +function c2 () { foo2(/*c*/1, /*d*/2); } +function c3 () { foo3(/*e*/1, /*f*/2); } +function c4 () { foo4(/*g*/1, /*h*/2); } +function c5 () { foo5(/*i*/1, /*j*/2); } +function c6 () { foo6(/*k*/1, /*l*/2); }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + start := f.MarkerByName(t, "c") + end := f.MarkerByName(t, "h") + span := &lsproto.Range{Start: start.LSPosition, End: end.LSPosition} + f.VerifyBaselineInlayHints(t, span, &lsutil.UserPreferences{IncludeInlayParameterNameHints: "literals"}) +} diff --git a/internal/fourslash/tests/manual/inlayHintsInteractiveParameterNamesInSpan2_test.go b/internal/fourslash/tests/manual/inlayHintsInteractiveParameterNamesInSpan2_test.go new file mode 100644 index 0000000000..0a2ec656d5 --- /dev/null +++ b/internal/fourslash/tests/manual/inlayHintsInteractiveParameterNamesInSpan2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsInteractiveParameterNamesInSpan2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1 (a: number, b: number) {} +function foo2 (c: number, d: number) {} +function foo3 (e: number, f: number) {} +function foo4 (g: number, h: number) {} +function foo5 (i: number, j: number) {} +function foo6 (k: number, l: number) {} + +foo1(/*a*/1, /*b*/2); +foo2(/*c*/1, /*d*/2); +foo3(/*e*/1, /*f*/2); +foo4(/*g*/1, /*h*/2); +foo5(/*i*/1, /*j*/2); +foo6(/*k*/1, /*l*/2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + start := f.MarkerByName(t, "c") + end := f.MarkerByName(t, "h") + span := &lsproto.Range{Start: start.LSPosition, End: end.LSPosition} + f.VerifyBaselineInlayHints(t, span, &lsutil.UserPreferences{IncludeInlayParameterNameHints: "literals"}) +} diff --git a/internal/fourslash/tests/manual/navigationItemsExactMatch2_test.go b/internal/fourslash/tests/manual/navigationItemsExactMatch2_test.go new file mode 100644 index 0000000000..fc19b34f6c --- /dev/null +++ b/internal/fourslash/tests/manual/navigationItemsExactMatch2_test.go @@ -0,0 +1,101 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsExactMatch2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Shapes { + [|class Point { + [|private _origin = 0.0;|] + [|private distanceFromA = 0.0;|] + + [|get distance1(distanceParam): number { + var [|distanceLocal|]; + return 0; + }|] + }|] +} + +var [|point = new Shapes.Point()|]; +[|function distance2(distanceParam1): void { + var [|distanceLocal1|]; +}|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "point", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "Point", + Kind: lsproto.SymbolKindClass, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("Shapes"), + }, + { + Name: "point", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[5].LSLocation(), + }, + }), + }, { + Pattern: "distance", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "distance1", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[3].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "distance2", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[6].LSLocation(), + }, + { + Name: "distanceFromA", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "distanceLocal", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[4].LSLocation(), + ContainerName: PtrTo("distance1"), + }, + { + Name: "distanceLocal1", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[7].LSLocation(), + ContainerName: PtrTo("distance2"), + }, + }), + }, { + Pattern: "origin", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "_origin", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("Point"), + }, + }), + }, { + Pattern: "square", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{}), + }, + }) +} diff --git a/internal/fourslash/tests/manual/navigationItemsSpecialPropertyAssignment_test.go b/internal/fourslash/tests/manual/navigationItemsSpecialPropertyAssignment_test.go new file mode 100644 index 0000000000..61608dec68 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationItemsSpecialPropertyAssignment_test.go @@ -0,0 +1,92 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsSpecialPropertyAssignment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @allowJs: true +// @Filename: /a.js +[|exports.x = 0|]; +[|exports.z = function() {}|]; +function Cls() { + [|this.instanceProp = 0|]; +} +[|Cls.staticMethod = function() {}|]; +[|Cls.staticProperty = 0|]; +[|Cls.prototype.instanceMethod = function() {}|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "x", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "x", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, { + Pattern: "z", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "z", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[1].LSLocation(), + }, + }), + }, { + Pattern: "instanceProp", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "instanceProp", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Cls"), + }, + }), + }, { + Pattern: "staticMethod", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "staticMethod", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[3].LSLocation(), + }, + }), + }, { + Pattern: "staticProperty", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "staticProperty", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[4].LSLocation(), + }, + }), + }, { + Pattern: "instanceMethod", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "instanceMethod", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[5].LSLocation(), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/manual/navto_excludeLib1_test.go b/internal/fourslash/tests/manual/navto_excludeLib1_test.go new file mode 100644 index 0000000000..dfb5a9861e --- /dev/null +++ b/internal/fourslash/tests/manual/navto_excludeLib1_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /index.ts +import { weirdName as otherName } from "bar"; +const [|weirdName: number = 1|]; +// @filename: /tsconfig.json +{} +// @filename: /node_modules/bar/index.d.ts +export const [|weirdName: number|]; +// @filename: /node_modules/bar/package.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "weirdName", + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[1].LSLocation(), + }, + }), + }, + }) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "weirdName", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/manual/navto_excludeLib2_test.go b/internal/fourslash/tests/manual/navto_excludeLib2_test.go new file mode 100644 index 0000000000..6d13284b2b --- /dev/null +++ b/internal/fourslash/tests/manual/navto_excludeLib2_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /index.ts +import { [|someName as weirdName|] } from "bar"; +// @filename: /tsconfig.json +{} +// @filename: /node_modules/bar/index.d.ts +export const someName: number; +// @filename: /node_modules/bar/package.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "weirdName", + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, + }) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "weirdName", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), + }, + }) +} diff --git a/internal/fourslash/tests/manual/parserCorruptionAfterMapInClass_test.go b/internal/fourslash/tests/manual/parserCorruptionAfterMapInClass_test.go new file mode 100644 index 0000000000..7de5ecef19 --- /dev/null +++ b/internal/fourslash/tests/manual/parserCorruptionAfterMapInClass_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestParserCorruptionAfterMapInClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @lib: es2015 +// @strict: true +class C { + map = new Set<[|string, number|]>/*$*/ + + foo() { + + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "$") + f.Insert(t, "()") + f.VerifyNonSuggestionDiagnostics(t, []*lsproto.Diagnostic{ + { + Code: &lsproto.IntegerOrString{Integer: PtrTo[int32](2558)}, + Message: "Expected 1 type arguments, but got 2.", + }, + }) +} diff --git a/internal/fourslash/tests/gen/quickInfoForOverloadOnConst1_test.go b/internal/fourslash/tests/manual/quickInfoForOverloadOnConst1_test.go similarity index 97% rename from internal/fourslash/tests/gen/quickInfoForOverloadOnConst1_test.go rename to internal/fourslash/tests/manual/quickInfoForOverloadOnConst1_test.go index 13b73259bc..765a52a878 100644 --- a/internal/fourslash/tests/gen/quickInfoForOverloadOnConst1_test.go +++ b/internal/fourslash/tests/manual/quickInfoForOverloadOnConst1_test.go @@ -31,7 +31,7 @@ c.x1(1, (x/*10*/x) => { return 1; } );` f.VerifyQuickInfoAt(t, "1", "(method) I.x1(a: number, callback: (x: \"hi\") => number): any", "") f.VerifyQuickInfoAt(t, "2", "(method) C.x1(a: number, callback: (x: \"hi\") => number): any", "") f.VerifyQuickInfoAt(t, "3", "(parameter) callback: (x: \"hi\") => number", "") - f.VerifyQuickInfoAt(t, "4", "(method) C.x1(a: number, callback: (x: \"hi\") => number): any", "") + f.VerifyQuickInfoAt(t, "4", "(method) C.x1(a: number, callback: (x: string) => number): void", "") f.VerifyQuickInfoAt(t, "5", "(parameter) callback: (x: string) => number", "") f.VerifyQuickInfoAt(t, "6", "(parameter) callback: (x: string) => number", "") f.VerifyQuickInfoAt(t, "7", "(method) C.x1(a: number, callback: (x: \"hi\") => number): any", "") diff --git a/internal/fourslash/tests/quickInfoFunction_test.go b/internal/fourslash/tests/quickInfoFunction_test.go new file mode 100644 index 0000000000..29548269e4 --- /dev/null +++ b/internal/fourslash/tests/quickInfoFunction_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestQuickInfoFunction(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/function foo() { return "hi"; }` + + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "", "function foo(): string", "") +} diff --git a/internal/fourslash/tests/statedeclarationmaps_test.go b/internal/fourslash/tests/statedeclarationmaps_test.go new file mode 100644 index 0000000000..a7585759ce --- /dev/null +++ b/internal/fourslash/tests/statedeclarationmaps_test.go @@ -0,0 +1,380 @@ +package fourslash_test + +import ( + "fmt" + "strings" + "testing" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDeclarationMapsOpeningOriginalLocationProject(t *testing.T) { + t.Parallel() + for _, disableSourceOfProjectReferenceRedirect := range []bool{false, true} { + t.Run("TestDeclarationMapsOpeningOriginalLocationProject"+core.IfElse(disableSourceOfProjectReferenceRedirect, "DisableSourceOfProjectReferenceRedirect", ""), func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := fmt.Sprintf(` +// @stateBaseline: true +// @Filename: a/a.ts +export class A { } +// @Filename: a/tsconfig.json +{} +// @Filename: a/a.d.ts +export declare class A { +} +//# sourceMappingURL=a.d.ts.map +// @Filename: a/a.d.ts.map +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["./a.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;CAAI" +} +// @Filename: b/b.ts +import {A} from "../a/a"; +new /*1*/A(); +// @Filename: b/tsconfig.json +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": %t + }, + "references": [ + { "path": "../a" } + ] +}`, disableSourceOfProjectReferenceRedirect) + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineFindAllReferences(t, "1") + }) + } +} + +func TestDeclarationMapTestCasesForMaps(t *testing.T) { + t.Parallel() + type testCase struct { + name string + goToMarker string + opMarker string + } + tests := []testCase{ + {"FindAllRefs", "userFnA", "userFnA"}, + {"FindAllRefsStartingAtDefinition", "userFnA", "fnADef"}, + {"FindAllRefsTargetDoesNotExist", "userFnB", "userFnB"}, + {"Rename", "userFnA", "userFnA"}, + {"RenameStartingAtDefinition", "userFnA", "fnADef"}, + {"RenameTargetDoesNotExist", "userFnB", "userFnB"}, + } + for _, tc := range tests { + t.Run("TestDeclarationMaps"+tc.name, func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: a/a.ts +export function /*fnADef*/fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +// @Filename: a/tsconfig.json +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +// @Filename: a/bin/a.d.ts.map +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +// @Filename: a/bin/a.d.ts +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +// @Filename: b/tsconfig.json +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +// @Filename: b/bin/b.d.ts.map +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +// @Filename: b/bin/b.d.ts +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +// @Filename: user/user.ts +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a./*userFnA*/fnA(); b./*userFnB*/fnB(); a.instanceA; } +// @Filename: dummy/dummy.ts +/*dummy*/export const a = 10; +// @Filename: dummy/tsconfig.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, tc.goToMarker) + // Ref projects are loaded after as part of this command + if strings.HasPrefix(tc.name, "Rename") { + f.VerifyBaselineRename(t, nil /*preferences*/, tc.opMarker) + } else { + f.VerifyBaselineFindAllReferences(t, tc.opMarker) + } + // Open temp file and verify all projects alive + f.CloseFileOfMarker(t, tc.goToMarker) + f.GoToMarker(t, "dummy") + }) + } +} + +func TestDeclarationMapsWorkspaceSymbols(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := `// @stateBaseline: true +// @Filename: a/a.ts +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +// @Filename: a/tsconfig.json +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +// @Filename: a/bin/a.d.ts.map +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +// @Filename: a/bin/a.d.ts +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +// @Filename: b/b.ts +export function fnB() {} +// @Filename: b/c.ts +export function fnC() {} +// @Filename: b/tsconfig.json +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +// @Filename: b/bin/b.d.ts.map +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +// @Filename: b/bin/b.d.ts +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +// @Filename: user/user.ts +/*user*/import * as a from "../a/a"; +import * as b from "../b/b"; +export function fnUser() { + a.fnA(); + b.fnB(); + a.instanceA; +} +// @Filename: user/tsconfig.json +{ + "references": [ + { "path": "../a" }, + { "path": "../b" } + ] +} +// @Filename: dummy/dummy.ts +/*dummy*/export const a = 10; +// @Filename: dummy/tsconfig.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "user") + // Ref projects are loaded after as part of this command + f.VerifyBaselineWorkspaceSymbol(t, "fn") + // Open temp file and verify all projects alive + f.CloseFileOfMarker(t, "user") + f.GoToMarker(t, "dummy") +} + +func TestDeclarationMapsFindAllRefsDefinitionInMappedFile(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +//@Filename: a/a.ts +export function f() {} +// @Filename: a/tsconfig.json +{ + "compilerOptions": { + "outDir": "../bin", + "declarationMap": true, + "composite": true + } +} +//@Filename: b/b.ts +import { f } from "../bin/a"; +/*1*/f(); +// @Filename: b/tsconfig.json +{ + "references": [ + { "path": "../a" } + ] +} +// @Filename: bin/a.d.ts +export declare function f(): void; +//# sourceMappingURL=a.d.ts.map +// @Filename: bin/a.d.ts.map +{ + "version":3, + "file":"a.d.ts", + "sourceRoot":"", + "sources":["a.ts"], + "names":[], + "mappings":"AAAA,wBAAgB,CAAC,SAAK" +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineFindAllReferences(t, "1") +} + +func TestDeclarationMapsRename(t *testing.T) { + t.Parallel() + type testCase struct { + name string + dontBuild bool + mainWithNoRef bool + disableSourceOfProjectReferenceRedirect bool + tsconfigNotSolution bool + } + for _, tc := range []testCase{ + {name: "ProjectReferences", dontBuild: true}, + {name: "DisableSourceOfProjectReferenceRedirect", disableSourceOfProjectReferenceRedirect: true}, + {name: "SourceMaps", mainWithNoRef: true}, + {name: "SourceMapsNotSolution", mainWithNoRef: true, tsconfigNotSolution: true}, + } { + buildStr := core.IfElse(!tc.dontBuild, "// @tsc: --build /myproject/dependency,--build /myproject/main", "") + mainRefsStr := core.IfElse(!tc.mainWithNoRef, `"references": [{ "path": "../dependency" }]`, "") + filesStr := core.IfElse(!tc.tsconfigNotSolution, `"files": [],`, "") + content := fmt.Sprintf(` +// @stateBaseline: true +%s +//@Filename: myproject/dependency/FnS.ts +/*firstLine*/export function fn1() { } +export function fn2() { } +export function /*rename*/fn3() { } +export function fn4() { } +export function fn5() { } +/*lastLine*/ +// @Filename: myproject/dependency/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//@Filename: myproject/main/main.ts +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +// @Filename: myproject/main/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": %t + }, + %s +} +// @Filename: myproject/tsconfig.json +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": %t + }, + %s + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +// @Filename: random/random.ts +/*dummy*/export const a = 10; +// @Filename: random/tsconfig.json +{}`, buildStr, tc.disableSourceOfProjectReferenceRedirect, mainRefsStr, tc.disableSourceOfProjectReferenceRedirect, filesStr) + t.Run("TestDeclarationMapsRenameWith"+tc.name, func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "dummy") + // Ref projects are loaded after as part of this command + f.VerifyBaselineRename(t, nil /*preferences*/, "rename") + // Collecting at this point retains dependency.d.ts and map + f.CloseFileOfMarker(t, "dummy") + f.GoToMarker(t, "dummy") + // Closing open file, removes dependencies too + f.CloseFileOfMarker(t, "rename") + f.CloseFileOfMarker(t, "dummy") + f.GoToMarker(t, "dummy") + }) + t.Run("TestDeclarationMapsRenameWith"+tc.name+"Edit", func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ref projects are loaded after as part of this command + f.VerifyBaselineRename(t, nil /*preferences*/, "rename") + f.GoToMarker(t, "firstLine") + f.Insert(t, "function fooBar() { }\n") + f.VerifyBaselineRename(t, nil /*preferences*/, "rename") + }) + t.Run("TestDeclarationMapsRenameWith"+tc.name+"EditEnd", func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ref projects are loaded after as part of this command + f.VerifyBaselineRename(t, nil /*preferences*/, "rename") + f.GoToMarker(t, "lastLine") + f.Insert(t, "const x = 10;") + f.VerifyBaselineRename(t, nil /*preferences*/, "rename") + }) + } +} diff --git a/internal/fourslash/tests/statefindallrefs_test.go b/internal/fourslash/tests/statefindallrefs_test.go new file mode 100644 index 0000000000..960483d198 --- /dev/null +++ b/internal/fourslash/tests/statefindallrefs_test.go @@ -0,0 +1,1120 @@ +package fourslash_test + +import ( + "fmt" + "strings" + "testing" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" + "github.com/microsoft/typescript-go/internal/testutil/stringtestutil" +) + +func TestFindAllRefsSolutionReferencingDefaultProjectDirectly(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @tsc: --build /myproject/tsconfig.json +// @Filename: dummy/dummy.ts +/*dummy*/const x = 1; +// @Filename: dummy/tsconfig.json +{ } +// @Filename: myproject/tsconfig.json +{ + "files": [], + "references": [{ "path": "./tsconfig-src.json" }] +} +// @Filename: myproject/tsconfig-src.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +// @Filename: myproject/src/main.ts +import { foo } from './helpers/functions'; +export { /*mainFoo*/foo }; +// @Filename: myproject/src/helpers/functions.ts +export function foo() { return 1; } +// @Filename: myproject/indirect3/tsconfig.json +{ } +// @Filename: myproject/indirect3/main.ts +import { /*fooIndirect3Import*/foo } from '../target/src/main'; +foo() +export function bar() {} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ensure configured project is found for open file + f.GoToMarker(t, "mainFoo") + // !!! TODO Verify errors + f.GoToMarker(t, "dummy") + + // Projects lifetime + f.CloseFileOfMarker(t, "dummy") + f.CloseFileOfMarker(t, "mainFoo") + f.GoToMarker(t, "dummy") + + f.CloseFileOfMarker(t, "dummy") + + // Find all refs in default project + f.VerifyBaselineFindAllReferences(t, "mainFoo") + + f.CloseFileOfMarker(t, "mainFoo") + + // Find all ref in non default project + f.VerifyBaselineFindAllReferences(t, "fooIndirect3Import") +} + +func TestFindAllRefsSolutionReferencingDefaultProjectIndirectly(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @tsc: --build /myproject/tsconfig.json +// @Filename: dummy/dummy.ts +/*dummy*/const x = 1; +// @Filename: dummy/tsconfig.json +{ } +// @Filename: myproject/tsconfig.json +{ + "files": [], + "references": [ + { "path": "./tsconfig-indirect1.json" }, + { "path": "./tsconfig-indirect2.json" }, + ] +} +// @Filename: myproject/tsconfig-src.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +// @Filename: myproject/src/main.ts +import { foo } from './helpers/functions'; +export { /*mainFoo*/foo }; +// @Filename: myproject/src/helpers/functions.ts +export function foo() { return 1; } +// @Filename: myproject/indirect3/tsconfig.json +{ } +// @Filename: myproject/indirect3/main.ts +import { /*fooIndirect3Import*/foo } from '../target/src/main'; +foo() +export function bar() {} +// @FileName: myproject/indirect1/main.ts +export const indirect = 1; +// @Filename: myproject/tsconfig-indirect1.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + }, + "files": [ + "./indirect1/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +// @FileName: myproject/indirect2/main.ts +export const indirect = 1; +// @Filename: myproject/tsconfig-indirect2.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + }, + "files": [ + "./indirect2/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ensure configured project is found for open file + f.GoToMarker(t, "mainFoo") + // !!! TODO Verify errors + f.GoToMarker(t, "dummy") + + // Projects lifetime + f.CloseFileOfMarker(t, "dummy") + f.CloseFileOfMarker(t, "mainFoo") + f.GoToMarker(t, "dummy") + + f.CloseFileOfMarker(t, "dummy") + + // Find all refs in default project + f.VerifyBaselineFindAllReferences(t, "mainFoo") + + f.CloseFileOfMarker(t, "mainFoo") + + // Find all ref in non default project + f.VerifyBaselineFindAllReferences(t, "fooIndirect3Import") +} + +func TestFindAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @tsc: --build /myproject/tsconfig.json +// @Filename: dummy/dummy.ts +/*dummy*/const x = 1; +// @Filename: dummy/tsconfig.json +{ } +// @Filename: myproject/tsconfig.json +{ + "compilerOptions": { + "disableReferencedProjectLoad": true + }, + "files": [], + "references": [{ "path": "./tsconfig-src.json" }] +} +// @Filename: myproject/tsconfig-src.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +// @Filename: myproject/src/main.ts +import { foo } from './helpers/functions'; +export { /*mainFoo*/foo }; +// @Filename: myproject/src/helpers/functions.ts +export function foo() { return 1; } +// @Filename: myproject/indirect3/tsconfig.json +{ } +// @Filename: myproject/indirect3/main.ts +import { /*fooIndirect3Import*/foo } from '../target/src/main'; +foo() +export function bar() {} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ensure configured project is found for open file + f.GoToMarker(t, "mainFoo") + // !!! TODO Verify errors + f.GoToMarker(t, "dummy") + + // Projects lifetime + f.CloseFileOfMarker(t, "dummy") + f.CloseFileOfMarker(t, "mainFoo") + f.GoToMarker(t, "dummy") + + f.CloseFileOfMarker(t, "dummy") + + // Find all refs in default project + f.VerifyBaselineFindAllReferences(t, "mainFoo") + + f.CloseFileOfMarker(t, "mainFoo") + + // Find all ref in non default project + f.VerifyBaselineFindAllReferences(t, "fooIndirect3Import") +} + +func TestFindAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @tsc: --build /myproject/tsconfig.json +// @Filename: dummy/dummy.ts +/*dummy*/const x = 1; +// @Filename: dummy/tsconfig.json +{ } +// @Filename: myproject/tsconfig.json +{ + "files": [], + "references": [ + { "path": "./tsconfig-indirect1.json" }, + { "path": "./tsconfig-indirect2.json" }, + ] +} +// @Filename: myproject/tsconfig-src.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +// @Filename: myproject/src/main.ts +import { foo } from './helpers/functions'; +export { /*mainFoo*/foo }; +// @Filename: myproject/src/helpers/functions.ts +export function foo() { return 1; } +// @Filename: myproject/indirect3/tsconfig.json +{ } +// @Filename: myproject/indirect3/main.ts +import { /*fooIndirect3Import*/foo } from '../target/src/main'; +foo() +export function bar() {} +// @FileName: myproject/indirect1/main.ts +export const indirect = 1; +// @Filename: myproject/tsconfig-indirect1.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + "disableReferencedProjectLoad": true, + }, + "files": [ + "./indirect1/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +// @FileName: myproject/indirect2/main.ts +export const indirect = 1; +// @Filename: myproject/tsconfig-indirect2.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + "disableReferencedProjectLoad": true, + }, + "files": [ + "./indirect2/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ensure configured project is found for open file + f.GoToMarker(t, "mainFoo") + // !!! TODO Verify errors + f.GoToMarker(t, "dummy") + + // Projects lifetime + f.CloseFileOfMarker(t, "dummy") + f.CloseFileOfMarker(t, "mainFoo") + f.GoToMarker(t, "dummy") + + f.CloseFileOfMarker(t, "dummy") + + // Find all refs in default project + f.VerifyBaselineFindAllReferences(t, "mainFoo") + + f.CloseFileOfMarker(t, "mainFoo") + + // Find all ref in non default project + f.VerifyBaselineFindAllReferences(t, "fooIndirect3Import") +} + +func TestFindAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @tsc: --build /myproject/tsconfig.json +// @Filename: dummy/dummy.ts +/*dummy*/const x = 1; +// @Filename: dummy/tsconfig.json +{ } +// @Filename: myproject/tsconfig.json +{ + "files": [], + "references": [ + { "path": "./tsconfig-indirect1.json" }, + { "path": "./tsconfig-indirect2.json" }, + ] +} +// @Filename: myproject/tsconfig-src.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +// @Filename: myproject/src/main.ts +import { foo } from './helpers/functions'; +export { /*mainFoo*/foo }; +// @Filename: myproject/src/helpers/functions.ts +export function foo() { return 1; } +// @Filename: myproject/indirect3/tsconfig.json +{ } +// @Filename: myproject/indirect3/main.ts +import { /*fooIndirect3Import*/foo } from '../target/src/main'; +foo() +export function bar() {} +// @FileName: myproject/indirect1/main.ts +export const indirect = 1; +// @Filename: myproject/tsconfig-indirect1.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + "disableReferencedProjectLoad": true, + }, + "files": [ + "./indirect1/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +// @FileName: myproject/indirect2/main.ts +export const indirect = 1; +// @Filename: myproject/tsconfig-indirect2.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + }, + "files": [ + "./indirect2/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ensure configured project is found for open file + f.GoToMarker(t, "mainFoo") + // !!! TODO Verify errors + f.GoToMarker(t, "dummy") + + // Projects lifetime + f.CloseFileOfMarker(t, "dummy") + f.CloseFileOfMarker(t, "mainFoo") + f.GoToMarker(t, "dummy") + + f.CloseFileOfMarker(t, "dummy") + + // Find all refs in default project + f.VerifyBaselineFindAllReferences(t, "mainFoo") + + f.CloseFileOfMarker(t, "mainFoo") + + // Find all ref in non default project + f.VerifyBaselineFindAllReferences(t, "fooIndirect3Import") +} + +func TestFindAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @tsc: --build /myproject/tsconfig.json +// @Filename: dummy/dummy.ts +/*dummy*/const x = 1; +// @Filename: dummy/tsconfig.json +{ } +// @Filename: myproject/tsconfig.json +{ + "files": ["./own/main.ts"], + "references": [{ "path": "./tsconfig-src.json" }] +} +// @Filename: myproject/own/main.ts +import { foo } from '../target/src/main'; +foo(); +export function bar() {} +// @Filename: myproject/tsconfig-src.json +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +// @Filename: myproject/src/main.ts +import { foo } from './helpers/functions'; +export { /*mainFoo*/foo }; +// @Filename: myproject/src/helpers/functions.ts +export function foo() { return 1; } +// @Filename: myproject/indirect3/tsconfig.json +{ } +// @Filename: myproject/indirect3/main.ts +import { /*fooIndirect3Import*/foo } from '../target/src/main'; +foo() +export function bar() {} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Ensure configured project is found for open file + f.GoToMarker(t, "mainFoo") + // !!! TODO Verify errors + f.GoToMarker(t, "dummy") + + // Projects lifetime + f.CloseFileOfMarker(t, "dummy") + f.CloseFileOfMarker(t, "mainFoo") + f.GoToMarker(t, "dummy") + + f.CloseFileOfMarker(t, "dummy") + + // Find all refs in default project + f.VerifyBaselineFindAllReferences(t, "mainFoo") + + f.CloseFileOfMarker(t, "mainFoo") + + // Find all ref in non default project + f.VerifyBaselineFindAllReferences(t, "fooIndirect3Import") +} + +func TestFindAllRefsRootOfReferencedProject(t *testing.T) { + t.Parallel() + for _, disableSourceOfProjectReferenceRedirect := range []bool{false, true} { + t.Run("TestFindAllRefsRootOfReferencedProject"+core.IfElse(disableSourceOfProjectReferenceRedirect, "DeclarationMaps", ""), func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := fmt.Sprintf(` +// @stateBaseline: true +%s +// @Filename: src/common/input/keyboard.ts +function bar() { return "just a random function so .d.ts location doesnt match"; } +export function /*keyboard*/evaluateKeyboardEvent() { } +// @Filename: src/common/input/keyboard.test.ts +import { evaluateKeyboardEvent } from 'common/input/keyboard'; +function testEvaluateKeyboardEvent() { + return evaluateKeyboardEvent(); +} +// @Filename: src/terminal.ts +/*terminal*/import { evaluateKeyboardEvent } from 'common/input/keyboard'; +function foo() { + return evaluateKeyboardEvent(); +} +// @Filename: /src/common/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "outDir": "../../out", + "disableSourceOfProjectReferenceRedirect": %v, + "paths": { + "*": ["../*"], + }, + }, + "include": ["./\**/*"] +} +// @Filename: src/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "outDir": "../out", + "disableSourceOfProjectReferenceRedirect": %v, + "paths": { + "common/*": ["./common/*"], + }, + "tsBuildInfoFile": "../out/src.tsconfig.tsbuildinfo" + }, + "include": ["./\**/*"], + "references": [ + { "path": "./common" }, + ], +}`, core.IfElse(disableSourceOfProjectReferenceRedirect, "// @tsc: --build /src/tsconfig.json", ""), disableSourceOfProjectReferenceRedirect, disableSourceOfProjectReferenceRedirect) + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "keyboard") + f.GoToMarker(t, "terminal") + // Find all ref in default project + f.VerifyBaselineFindAllReferences(t, "keyboard") + }) + } +} + +func TestFindAllRefsAncestorSiblingProjectsLoading(t *testing.T) { + t.Parallel() + for _, disableSolutionSearching := range []bool{false, true} { + t.Run("TestFindAllRefsAncestorSiblingProjectsLoading"+core.IfElse(disableSolutionSearching, "DisableSolutionSearching", ""), func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := fmt.Sprintf(` +// @stateBaseline: true +// @Filename: solution/tsconfig.json +{ + "files": [], + "include": [], + "references": [ + { "path": "./compiler" }, + { "path": "./services" }, + ], +} +// @Filename: solution/compiler/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "disableSolutionSearching": %t, + }, + "files": ["./types.ts", "./program.ts"] +} +// @Filename: solution/compiler/types.ts +namespace ts { + export interface Program { + getSourceFiles(): string[]; + } +} +// @Filename: solution/compiler/program.ts +namespace ts { + export const program: Program = { + /*notLocal*/getSourceFiles: () => [/*local*/getSourceFile()] + }; + function getSourceFile() { return "something"; } +} +// @Filename: solution/services/tsconfig.json +{ + "compilerOptions": { + "composite": true + }, + "files": ["./services.ts"], + "references": [ + { "path": "../compiler" }, + ], +} +// @Filename: solution/services/services.ts +/// +/// +namespace ts { + const result = program.getSourceFiles(); +}`, disableSolutionSearching) + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + // Find all references for getSourceFile + // Shouldnt load more projects + f.VerifyBaselineFindAllReferences(t, "local") + + // Find all references for getSourceFiles + // Should load more projects only if disableSolutionSearching is not set to true + f.VerifyBaselineFindAllReferences(t, "notLocal") + }) + } +} + +func TestFindAllRefsOverlappingProjects(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: solution/tsconfig.json +{ + "files": [], + "include": [], + "references": [ + { "path": "./a" }, + { "path": "./b" }, + { "path": "./c" }, + { "path": "./d" }, + ], +} +// @Filename: solution/a/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "files": ["./index.ts"] +} +// @Filename: solution/a/index.ts +export interface I { + M(): void; +} +// @Filename: solution/b/tsconfig.json +{ + "compilerOptions": { + "composite": true + }, + "files": ["./index.ts"], + "references": [ + { "path": "../a" }, + ], +} +// @Filename: solution/b/index.ts +import { I } from "../a"; +export class B implements /**/I { + M() {} +} +// @Filename: solution/c/tsconfig.json +{ + "compilerOptions": { + "composite": true + }, + "files": ["./index.ts"], + "references": [ + { "path": "../b" }, + ], +} +// @Filename: solution/c/index.ts +import { I } from "../a"; +import { B } from "../b"; +export const C: I = new B(); +// @Filename: solution/d/tsconfig.json +{ + "compilerOptions": { + "composite": true + }, + "files": ["./index.ts"], + "references": [ + { "path": "../c" }, + ], +} +// @Filename: solution/d/index.ts +import { I } from "../a"; +import { C } from "../c"; +export const D: I = C; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + + // The first search will trigger project loads + f.VerifyBaselineFindAllReferences(t, "") + + // The second search starts with the projects already loaded + // Formerly, this would search some projects multiple times + f.VerifyBaselineFindAllReferences(t, "") +} + +func TestFindAllRefsTwoProjectsOpenAndOneProjectReferences(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: /myproject/main/src/file1.ts +/*main*/export const mainConst = 10; +// @Filename: /myproject/main/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + { "path": "../indirect" }, + { "path": "../noCoreRef1" }, + { "path": "../indirectDisabledChildLoad1" }, + { "path": "../indirectDisabledChildLoad2" }, + { "path": "../refToCoreRef3" }, + { "path": "../indirectNoCoreRef" } + ] +} +// @Filename: /myproject/core/src/file1.ts +export const /*find*/coreConst = 10; +// @Filename: /myproject/core/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, +} +// @Filename: /myproject/noCoreRef1/src/file1.ts +export const noCoreRef1Const = 10; +// @Filename: /myproject/noCoreRef1/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, +} +// @Filename: /myproject/indirect/src/file1.ts +export const indirectConst = 10; +// @Filename: /myproject/indirect/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../coreRef1" }, + ] +} +// @Filename: /myproject/coreRef1/src/file1.ts +export const coreRef1Const = 10; +// @Filename: /myproject/coreRef1/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + ] +} +// @Filename: /myproject/indirectDisabledChildLoad1/src/file1.ts +export const indirectDisabledChildLoad1Const = 10; +// @Filename: /myproject/indirectDisabledChildLoad1/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "disableReferencedProjectLoad": true, + }, + "references": [ + { "path": "../coreRef2" }, + ] +} +// @Filename: /myproject/coreRef2/src/file1.ts +export const coreRef2Const = 10; +// @Filename: /myproject/coreRef2/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + ] +} +// @Filename: /myproject/indirectDisabledChildLoad2/src/file1.ts +export const indirectDisabledChildLoad2Const = 10; +// @Filename: /myproject/indirectDisabledChildLoad2/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "disableReferencedProjectLoad": true, + }, + "references": [ + { "path": "../coreRef3" }, + ] +} +// @Filename: /myproject/coreRef3/src/file1.ts +export const coreRef3Const = 10; +// @Filename: /myproject/coreRef3/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + ] +} +// @Filename: /myproject/refToCoreRef3/src/file1.ts +export const refToCoreRef3Const = 10; +// @Filename: /myproject/refToCoreRef3/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../coreRef3" }, + ] +} +// @Filename: /myproject/indirectNoCoreRef/src/file1.ts +export const indirectNoCoreRefConst = 10; +// @Filename: /myproject/indirectNoCoreRef/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../noCoreRef2" }, + ] +} +// @Filename: /myproject/noCoreRef2/src/file1.ts +export const noCoreRef2Const = 10; +// @Filename: /myproject/noCoreRef2/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "main") + f.VerifyBaselineFindAllReferences(t, "find") +} + +func TestFindAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: /packages/babel-loader/tsconfig.json +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "composite": true, + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"], + "references": [{"path": "../core"}] +} +// @Filename: /packages/babel-loader/src/index.ts +/*change*/import type { Foo } from "../../core/src/index.js"; +// @Filename: /packages/core/tsconfig.json +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "composite": true, + "rootDir": "./src", + "outDir": "./dist", + }, + "include": ["./src"] +} +// @Filename: /packages/core/src/index.ts +import { Bar } from "./loading-indicator.js"; +export type Foo = {}; +const bar: Bar = { + /*prop*/prop: 0 +} +// @Filename: /packages/core/src/loading-indicator.ts +export interface Bar { + prop: number; +} +const bar: Bar = { + prop: 1 +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "change") + f.GoToMarker(t, "prop") + + // Now change `babel-loader` project to no longer import `core` project + f.GoToMarker(t, "change") + f.Insert(t, "// comment") + + // At this point, we haven't updated `babel-loader` project yet, + // so `babel-loader` is still a containing project of `loading-indicator` file. + // When calling find all references, + // we shouldn't crash due to using outdated information on a file's containing projects. + f.VerifyBaselineFindAllReferences(t, "prop") +} + +func TestFindAllRefsOpenFileInConfiguredProjectThatWillBeRemoved(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: /myproject/playground/tsconfig.json +{} +// @Filename: /myproject/playground/tests.ts +/*tests*/export function foo() {} +// @Filename: /myproject/playground/tsconfig-json/tsconfig.json +{ + "include": ["./src"] +} +// @Filename: /myproject/playground/tsconfig-json/src/src.ts +export function foobar() {} +// @Filename: /myproject/playground/tsconfig-json/tests/spec.ts +export function /*find*/bar() { } +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "tests") + f.CloseFileOfMarker(t, "tests") + f.VerifyBaselineFindAllReferences(t, "find") +} + +func TestFindAllRefsSpecialHandlingOfLocalness(t *testing.T) { + t.Parallel() + type testCase struct { + name string + definition string + usage string + referenceTerm string + } + + for _, tc := range []testCase{ + { + "ArrowFunctionAssignment", + `export const dog = () => { };`, + `shared.dog();`, + "dog", + }, + { + "ArrowFunctionAsObjectLiteralPropertyTypes", + `export const foo = { bar: () => { } };`, + `shared.foo.bar();`, + "bar", + }, + { + "ObjectLiteralProperty", + `export const foo = { baz: "BAZ" };`, + `shared.foo.baz;`, + "baz", + }, + { + "MethodOfClassExpression", + `export const foo = class { fly() {} };`, + stringtestutil.Dedent(` + const instance = new shared.foo(); + instance.fly();`), + "fly", + }, + { + // when using arrow function as object literal property is loaded through indirect assignment with original declaration local to project is treated as local + "ArrowFunctionAsObjectLiteralProperty", + stringtestutil.Dedent(` + const local = { bar: () => { } }; + export const foo = local;`), + `shared.foo.bar();`, + "bar", + }, + } { + t.Run("TestFindAllRefsSpecialHandlingOfLocalness"+tc.name, func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + usageWithMarker := tc.usage[:strings.Index(tc.usage, tc.referenceTerm)] + "/*ref*/" + tc.usage[strings.Index(tc.usage, tc.referenceTerm):] + content := ` +// @stateBaseline: true +// @Filename: /solution/tsconfig.json +{ + "files": [], + "references": [ + { "path": "./api" }, + { "path": "./app" }, + ], +} +// @Filename: /solution/api/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +// @Filename: /solution/api/src/server.ts +import * as shared from "../../shared/dist" +` + usageWithMarker + ` +// @Filename: /solution/app/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +// @Filename: /solution/app/src/app.ts +import * as shared from "../../shared/dist" +` + tc.usage + ` +// @Filename: /solution/app/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +// @Filename: /solution/shared/tsconfig.json +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], +} +// @Filename: /solution/shared/src/index.ts +` + tc.definition + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineFindAllReferences(t, "ref") + }) + } +} + +func TestFindAllRefsDeclarationInOtherProject(t *testing.T) { + t.Parallel() + type testCase struct { + projectAlreadyLoaded bool + disableReferencedProjectLoad bool + disableSourceOfProjectReferenceRedirect bool + dtsMapPresent bool + } + // Pre-loaded = A file from project B is already open when FindAllRefs is invoked + // dRPL = Project A has disableReferencedProjectLoad + // dSOPRR = Project A has disableSourceOfProjectReferenceRedirect + // Map = The declaration map file b/lib/index.d.ts.map exists + // B refs = files under directory b in which references are found (all scenarios find all references in a/index.ts) + //Pre-loaded |dRPL|dSOPRR|Map| B state | Notes | B refs | Notes + //-----------+----+------+- -+------------------+--------------+---------------------+--------------------------------------------------- + for _, tc := range []testCase{ + {true, true, true, true}, // Pre-loaded | | index.ts, helper.ts | Via map and pre-loaded project + {true, true, true, false}, // Pre-loaded | | lib/index.d.ts | Even though project is loaded + {true, true, false, true}, // Pre-loaded | | index.ts, helper.ts | + {true, true, false, false}, // Pre-loaded | | index.ts, helper.ts | + {true, false, true, true}, // Pre-loaded | | index.ts, helper.ts | Via map and pre-loaded project + {true, false, true, false}, // Pre-loaded | | lib/index.d.ts | Even though project is loaded + {true, false, false, true}, // Pre-loaded | | index.ts, helper.ts | + {true, false, false, false}, // Pre-loaded | | index.ts, helper.ts | + {false, true, true, true}, // Not loaded | | lib/index.d.ts | Even though map is present + {false, true, true, false}, // Not loaded | | lib/index.d.ts | + {false, true, false, true}, // Not loaded | | index.ts | But not helper.ts, which is not referenced from a + {false, true, false, false}, // Not loaded | | index.ts | But not helper.ts, which is not referenced from a + {false, false, true, true}, // Loaded | Via map | index.ts, helper.ts | Via map and newly loaded project + {false, false, true, false}, // Not loaded | | lib/index.d.ts | + {false, false, false, true}, // Loaded | Via redirect | index.ts, helper.ts | + {false, false, false, false}, // Loaded | Via redirect | index.ts, helper.ts | + } { + subScenario := fmt.Sprintf(`Proj%sLoaded`, core.IfElse(tc.projectAlreadyLoaded, "Is", "IsNot")) + + `RefdProjLoadingIs` + core.IfElse(tc.disableReferencedProjectLoad, "Disabled", "Enabled") + + `ProjRefRedirectsAre` + core.IfElse(tc.disableSourceOfProjectReferenceRedirect, "Disabled", "Enabled") + + `DeclMapIs` + core.IfElse(tc.dtsMapPresent, "Present", "Missing") + t.Run("TestFindAllRefsDeclarationInOtherProject"+subScenario, func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := fmt.Sprintf(` +// @stateBaseline: true +// @Filename: /myproject/a/tsconfig.json +{ + "disableReferencedProjectLoad": %t, + "disableSourceOfProjectReferenceRedirect": %t, + "composite": true +} +// @Filename: /myproject/a/index.ts +import { B } from "../b/lib"; +const b: /*ref*/B = new B(); +// @Filename: /myproject/b/tsconfig.json +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} +// @Filename: /myproject/b/index.ts +export class B { + M() {} +} +// @Filename: /myproject/b/helper.ts +/*bHelper*/import { B } from "."; +const b: B = new B(); +// @Filename: /myproject/b/lib/index.d.ts +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map`, tc.disableReferencedProjectLoad, tc.disableSourceOfProjectReferenceRedirect) + if tc.dtsMapPresent { + content += ` +// @Filename: /myproject/b/lib/index.d.ts.map +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +}` + } + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + if tc.projectAlreadyLoaded { + f.GoToMarker(t, "ref") + f.GoToMarker(t, "bHelper") + } + f.VerifyBaselineFindAllReferences(t, "ref") + }) + } +} diff --git a/internal/fourslash/tests/staterename_test.go b/internal/fourslash/tests/staterename_test.go new file mode 100644 index 0000000000..c00e734f99 --- /dev/null +++ b/internal/fourslash/tests/staterename_test.go @@ -0,0 +1,132 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRenameAncestorProjectRefMangement(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: /projects/temp/temp.ts +/*temp*/let x = 10 +// @Filename: /projects/temp/tsconfig.json +{} +// @Filename: /projects/container/lib/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + references: [], + files: [ + "index.ts", + ], +} +// @Filename: /projects/container/lib/index.ts +export const myConst = 30; +// @Filename: /projects/container/exec/tsconfig.json +{ + "files": ["./index.ts"], + "references": [ + { "path": "../lib" }, + ], +} +// @Filename: /projects/container/exec/index.ts +import { myConst } from "../lib"; +export function getMyConst() { + return myConst; +} +// @Filename: /projects/container/compositeExec/tsconfig.json +{ + "compilerOptions": { + "composite": true, + }, + "files": ["./index.ts"], + "references": [ + { "path": "../lib" }, + ], +} +// @Filename: /projects/container/compositeExec/index.ts +import { /*find*/myConst } from "../lib"; +export function getMyConst() { + return myConst; +} +// @Filename: /projects/container/tsconfig.json +{ + "files": [], + "include": [], + "references": [ + { "path": "./exec" }, + { "path": "./compositeExec" }, + ], +} +// @Filename: /projects/container/tsconfig.json +{ + "files": [], + "include": [], + "references": [ + { "path": "./exec" }, + { "path": "./compositeExec" }, + ], +} +// @Filename: /projects/container/tsconfig.json +{ + "files": [], + "include": [], + "references": [ + { "path": "./exec" }, + { "path": "./compositeExec" }, + ], +} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "find") + // Open temp file and verify all projects alive + f.GoToMarker(t, "temp") + + // Ref projects are loaded after as part of this command + f.VerifyBaselineRename(t, nil /*preferences*/, "find") + + // Open temp file and verify all projects alive + f.CloseFileOfMarker(t, "temp") + f.GoToMarker(t, "temp") + + // Close all files and open temp file, only inferred project should be alive + f.CloseFileOfMarker(t, "find") + f.CloseFileOfMarker(t, "temp") + f.GoToMarker(t, "temp") +} + +func TestRenameInCommonFile(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + content := ` +// @stateBaseline: true +// @Filename: /projects/a/a.ts +/*aTs*/import {C} from "./c/fc"; +console.log(C) +// @Filename: /projects/a/tsconfig.json +{} +// @link: /projects/c -> /projects/a/c +// @Filename: /projects/b/b.ts +/*bTs*/import {C} from "../c/fc"; +console.log(C) +// @Filename: /projects/b/tsconfig.json +{} +// @link: /projects/c -> /projects/b/c +// @Filename: /projects/c/fc.ts +export const /*find*/C = 42; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "aTs") + f.GoToMarker(t, "bTs") + findMarker := f.MarkerByName(t, "find") + aFcMarker := findMarker.MakerWithSymlink("/projects/a/c/fc.ts") + f.GoToMarkerOrRange(t, aFcMarker) + f.GoToMarkerOrRange(t, findMarker.MakerWithSymlink("/projects/b/c/fc.ts")) + f.VerifyBaselineRename(t, nil /*preferences*/, aFcMarker) +} diff --git a/internal/fourslash/tests/unreachableCodeDiagnostics_test.go b/internal/fourslash/tests/unreachableCodeDiagnostics_test.go new file mode 100644 index 0000000000..fcdf875597 --- /dev/null +++ b/internal/fourslash/tests/unreachableCodeDiagnostics_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestUnreachableCodeDiagnostics(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowUnreachableCode: false +throw new Error(); + +(() => {})(); + ` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineNonSuggestionDiagnostics(t) +} diff --git a/internal/glob/glob.go b/internal/glob/glob.go index f54f691a0d..39df996428 100644 --- a/internal/glob/glob.go +++ b/internal/glob/glob.go @@ -217,7 +217,7 @@ func (g *Glob) Match(input string) bool { } func match(elems []element, input string) (ok bool) { - var elem interface{} + var elem any for len(elems) > 0 { elem, elems = elems[0], elems[1:] switch elem := elem.(type) { diff --git a/internal/locale/locale.go b/internal/locale/locale.go new file mode 100644 index 0000000000..20d6e14a3d --- /dev/null +++ b/internal/locale/locale.go @@ -0,0 +1,28 @@ +package locale + +import ( + "context" + + "golang.org/x/text/language" +) + +type contextKey int + +type Locale language.Tag + +var Default Locale + +func WithLocale(ctx context.Context, locale Locale) context.Context { + return context.WithValue(ctx, contextKey(0), locale) +} + +func FromContext(ctx context.Context) Locale { + locale, _ := ctx.Value(contextKey(0)).(Locale) + return locale +} + +func Parse(localeStr string) (locale Locale, ok bool) { + // Parse gracefully fails. + tag, err := language.Parse(localeStr) + return Locale(tag), err == nil +} diff --git a/internal/ls/api.go b/internal/ls/api.go index 67be3d1f0c..32d0741523 100644 --- a/internal/ls/api.go +++ b/internal/ls/api.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/locale" ) var ( @@ -78,12 +79,13 @@ type Diagnostic struct { type diagnosticList struct { diagnostics []*Diagnostic + locale locale.Locale } func (d *diagnosticList) addDiagnostic(diagnostic *ast.Diagnostic, ls *LanguageService, shouldAdd bool) *Diagnostic { startPos := diagnostic.Loc().Pos() startPosLineCol := getPosition(diagnostic.File(), startPos, ls) - lineMap := ls.converters.getLineMap(diagnostic.File().FileName()) + lineMap := ls.converters.GetLineMap(diagnostic.File().FileName()) lineStartPos := lineMap.LineStarts[startPosLineCol.Line] var lineEndPos int if int(startPosLineCol.Line+1) >= len(lineMap.LineStarts) { @@ -102,7 +104,7 @@ func (d *diagnosticList) addDiagnostic(diagnostic *ast.Diagnostic, ls *LanguageS SourceLine: sourceLine, Code: diagnostic.Code(), Category: diagnostic.Category().Name(), - Message: diagnostic.Message(), + Message: diagnostic.Localize(d.locale), MessageChain: make([]*Diagnostic, 0, len(diagnostic.MessageChain())), RelatedInformation: make([]*Diagnostic, 0, len(diagnostic.RelatedInformation())), } @@ -137,6 +139,7 @@ func (l *LanguageService) GetDiagnostics(ctx context.Context, fileNames []string } diagnosticList := &diagnosticList{ diagnostics: make([]*Diagnostic, 0), + locale: program.CommandLine().Locale(), } diagnostics := make([]*ast.Diagnostic, 0, len(sourceFiles)) for _, sourceFile := range sourceFiles { diff --git a/internal/ls/autoImports_stringer_generated.go b/internal/ls/autoImports_stringer_generated.go index d39f19211e..99243828a3 100644 --- a/internal/ls/autoImports_stringer_generated.go +++ b/internal/ls/autoImports_stringer_generated.go @@ -20,8 +20,9 @@ const _ExportKind_name = "ExportKindNamedExportKindDefaultExportKindExportEquals var _ExportKind_index = [...]uint8{0, 15, 32, 54, 67, 83} func (i ExportKind) String() string { - if i < 0 || i >= ExportKind(len(_ExportKind_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_ExportKind_index)-1 { return "ExportKind(" + strconv.FormatInt(int64(i), 10) + ")" } - return _ExportKind_name[_ExportKind_index[i]:_ExportKind_index[i+1]] + return _ExportKind_name[_ExportKind_index[idx]:_ExportKind_index[idx+1]] } diff --git a/internal/ls/autoimportfixes.go b/internal/ls/autoimportfixes.go index 4aa8104bb1..e05dec1efe 100644 --- a/internal/ls/autoimportfixes.go +++ b/internal/ls/autoimportfixes.go @@ -1,10 +1,16 @@ package ls import ( + "slices" + "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" + "github.com/microsoft/typescript-go/internal/ls/change" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/ls/organizeimports" + "github.com/microsoft/typescript-go/internal/stringutil" ) type Import struct { @@ -14,17 +20,17 @@ type Import struct { propertyName string // Use when needing to generate an `ImportSpecifier with a `propertyName`; the name preceding "as" keyword (propertyName = "" when "as" is absent) } -func (ct *changeTracker) addNamespaceQualifier(sourceFile *ast.SourceFile, qualification *Qualification) { - ct.insertText(sourceFile, qualification.usagePosition, qualification.namespacePrefix+".") +func addNamespaceQualifier(ct *change.Tracker, sourceFile *ast.SourceFile, qualification *Qualification) { + ct.InsertText(sourceFile, qualification.usagePosition, qualification.namespacePrefix+".") } -func (ct *changeTracker) doAddExistingFix( +func (ls *LanguageService) doAddExistingFix( + ct *change.Tracker, sourceFile *ast.SourceFile, clause *ast.Node, // ImportClause | ObjectBindingPattern, defaultImport *Import, namedImports []*Import, // removeExistingImportSpecifiers *core.Set[ImportSpecifier | BindingElement] // !!! remove imports not implemented - preferences *UserPreferences, ) { switch clause.Kind { case ast.KindObjectBindingPattern: @@ -51,10 +57,10 @@ func (ct *changeTracker) doAddExistingFix( // return // } if defaultImport != nil { - ct.addElementToBindingPattern(sourceFile, clause, defaultImport.name, ptrTo("default")) + addElementToBindingPattern(ct, sourceFile, clause, defaultImport.name, ptrTo("default")) } for _, specifier := range namedImports { - ct.addElementToBindingPattern(sourceFile, clause, specifier.name, &specifier.propertyName) + addElementToBindingPattern(ct, sourceFile, clause, specifier.name, &specifier.propertyName) } return } @@ -77,23 +83,23 @@ func (ct *changeTracker) doAddExistingFix( if defaultImport != nil { debug.Assert(clause.Name() == nil, "Cannot add a default import to an import clause that already has one") - ct.insertNodeAt(sourceFile, core.TextPos(astnav.GetStartOfNode(clause, sourceFile, false)), ct.NodeFactory.NewIdentifier(defaultImport.name), changeNodeOptions{suffix: ", "}) + ct.InsertNodeAt(sourceFile, core.TextPos(astnav.GetStartOfNode(clause, sourceFile, false)), ct.NodeFactory.NewIdentifier(defaultImport.name), change.NodeOptions{Suffix: ", "}) } if len(namedImports) > 0 { - // !!! OrganizeImports not yet implemented - // specifierComparer, isSorted := OrganizeImports.getNamedImportSpecifierComparerWithDetection(importClause.Parent, preferences, sourceFile); + specifierComparer, isSorted := organizeimports.GetNamedImportSpecifierComparerWithDetection(importClause.Parent, sourceFile, ls.UserPreferences()) newSpecifiers := core.Map(namedImports, func(namedImport *Import) *ast.Node { var identifier *ast.Node if namedImport.propertyName != "" { identifier = ct.NodeFactory.NewIdentifier(namedImport.propertyName).AsIdentifier().AsNode() } return ct.NodeFactory.NewImportSpecifier( - (!importClause.IsTypeOnly() || promoteFromTypeOnly) && shouldUseTypeOnly(namedImport.addAsTypeOnly, preferences), + (!importClause.IsTypeOnly() || promoteFromTypeOnly) && shouldUseTypeOnly(namedImport.addAsTypeOnly, ls.UserPreferences()), identifier, ct.NodeFactory.NewIdentifier(namedImport.name), ) - }) // !!! sort with specifierComparer + }) + slices.SortFunc(newSpecifiers, specifierComparer) // !!! remove imports not implemented // if (removeExistingImportSpecifiers) { @@ -108,80 +114,113 @@ func (ct *changeTracker) doAddExistingFix( // append(core.Filter(existingSpecifiers, func (s *ast.ImportSpecifier) bool {return !removeExistingImportSpecifiers.Has(s)}), newSpecifiers...), // !!! sort with specifierComparer // ), // ); - // } else if (len(existingSpecifiers) > 0 && isSorted != false) { - // !!! OrganizeImports not implemented - // The sorting preference computed earlier may or may not have validated that these particular - // import specifiers are sorted. If they aren't, `getImportSpecifierInsertionIndex` will return - // nonsense. So if there are existing specifiers, even if we know the sorting preference, we - // need to ensure that the existing specifiers are sorted according to the preference in order - // to do a sorted insertion. - // changed to check if existing specifiers are sorted - // if we're promoting the clause from type-only, we need to transform the existing imports before attempting to insert the new named imports - // transformedExistingSpecifiers := existingSpecifiers - // if promoteFromTypeOnly && existingSpecifiers { - // transformedExistingSpecifiers = ct.NodeFactory.updateNamedImports( - // importClause.NamedBindings.AsNamedImports(), - // core.SameMap(existingSpecifiers, func(e *ast.ImportSpecifier) *ast.ImportSpecifier { - // return ct.NodeFactory.updateImportSpecifier(e, /*isTypeOnly*/ true, e.propertyName, e.name) - // }), - // ).elements - // } - // for _, spec := range newSpecifiers { - // insertionIndex := OrganizeImports.getImportSpecifierInsertionIndex(transformedExistingSpecifiers, spec, specifierComparer); - // ct.insertImportSpecifierAtIndex(sourceFile, spec, importClause.namedBindings as NamedImports, insertionIndex); - // } - // } else - if len(existingSpecifiers) > 0 { + // + if len(existingSpecifiers) > 0 && isSorted != core.TSFalse { + // The sorting preference computed earlier may or may not have validated that these particular + // import specifiers are sorted. If they aren't, `getImportSpecifierInsertionIndex` will return + // nonsense. So if there are existing specifiers, even if we know the sorting preference, we + // need to ensure that the existing specifiers are sorted according to the preference in order + // to do a sorted insertion. + + // If we're promoting the clause from type-only, we need to transform the existing imports + // before attempting to insert the new named imports (for comparison purposes only) + specsToCompareAgainst := existingSpecifiers + if promoteFromTypeOnly && len(existingSpecifiers) > 0 { + specsToCompareAgainst = core.Map(existingSpecifiers, func(e *ast.Node) *ast.Node { + spec := e.AsImportSpecifier() + var propertyName *ast.Node + if spec.PropertyName != nil { + propertyName = spec.PropertyName + } + syntheticSpec := ct.NodeFactory.NewImportSpecifier( + true, // isTypeOnly + propertyName, + spec.Name(), + ) + return syntheticSpec + }) + } + + for _, spec := range newSpecifiers { + insertionIndex := organizeimports.GetImportSpecifierInsertionIndex(specsToCompareAgainst, spec, specifierComparer) + ct.InsertImportSpecifierAtIndex(sourceFile, spec, importClause.NamedBindings, insertionIndex) + } + } else if len(existingSpecifiers) > 0 && isSorted.IsTrue() { + // Existing specifiers are sorted, so insert each new specifier at the correct position for _, spec := range newSpecifiers { - ct.insertNodeInListAfter(sourceFile, existingSpecifiers[len(existingSpecifiers)-1], spec.AsNode(), existingSpecifiers) + insertionIndex := organizeimports.GetImportSpecifierInsertionIndex(existingSpecifiers, spec, specifierComparer) + if insertionIndex >= len(existingSpecifiers) { + // Insert at the end + ct.InsertNodeInListAfter(sourceFile, existingSpecifiers[len(existingSpecifiers)-1], spec.AsNode(), existingSpecifiers) + } else { + // Insert before the element at insertionIndex + ct.InsertNodeInListAfter(sourceFile, existingSpecifiers[insertionIndex], spec.AsNode(), existingSpecifiers) + } + } + } else if len(existingSpecifiers) > 0 { + // Existing specifiers may not be sorted, append to the end + for _, spec := range newSpecifiers { + ct.InsertNodeInListAfter(sourceFile, existingSpecifiers[len(existingSpecifiers)-1], spec.AsNode(), existingSpecifiers) } } else { if len(newSpecifiers) > 0 { namedImports := ct.NodeFactory.NewNamedImports(ct.NodeFactory.NewNodeList(newSpecifiers)) if importClause.NamedBindings != nil { - ct.replaceNode(sourceFile, importClause.NamedBindings, namedImports, nil) + ct.ReplaceNode(sourceFile, importClause.NamedBindings, namedImports, nil) } else { if clause.Name() == nil { panic("Import clause must have either named imports or a default import") } - ct.insertNodeAfter(sourceFile, clause.Name(), namedImports) + ct.InsertNodeAfter(sourceFile, clause.Name(), namedImports) } } } } if promoteFromTypeOnly { - // !!! promote type-only imports not implemented + // Delete the 'type' keyword from the import clause + typeKeyword := getTypeKeywordOfTypeOnlyImport(importClause, sourceFile) + ct.Delete(sourceFile, typeKeyword) - // ct.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(clause, sourceFile)); - // if (existingSpecifiers) { - // // We used to convert existing specifiers to type-only only if compiler options indicated that - // // would be meaningful (see the `importNameElisionDisabled` utility function), but user - // // feedback indicated a preference for preserving the type-onlyness of existing specifiers - // // regardless of whether it would make a difference in emit. - // for _, specifier := range existingSpecifiers { - // ct.insertModifierBefore(sourceFile, SyntaxKind.TypeKeyword, specifier); - // } - // } + // Add 'type' modifier to existing specifiers (not newly added ones) + // We preserve the type-onlyness of existing specifiers regardless of whether + // it would make a difference in emit (user preference). + if len(existingSpecifiers) > 0 { + for _, specifier := range existingSpecifiers { + if !specifier.AsImportSpecifier().IsTypeOnly { + ct.InsertModifierBefore(sourceFile, ast.KindTypeKeyword, specifier) + } + } + } } default: panic("Unsupported clause kind: " + clause.Kind.String() + "for doAddExistingFix") } } -func (ct *changeTracker) addElementToBindingPattern(sourceFile *ast.SourceFile, bindingPattern *ast.Node, name string, propertyName *string) { - element := ct.newBindingElementFromNameAndPropertyName(name, propertyName) +func getTypeKeywordOfTypeOnlyImport(importClause *ast.ImportClause, sourceFile *ast.SourceFile) *ast.Node { + debug.Assert(importClause.IsTypeOnly(), "import clause must be type-only") + // The first child of a type-only import clause is the 'type' keyword + // import type { foo } from './bar' + // ^^^^ + typeKeyword := astnav.FindChildOfKind(importClause.AsNode(), ast.KindTypeKeyword, sourceFile) + debug.Assert(typeKeyword != nil, "type-only import clause should have a type keyword") + return typeKeyword +} + +func addElementToBindingPattern(ct *change.Tracker, sourceFile *ast.SourceFile, bindingPattern *ast.Node, name string, propertyName *string) { + element := newBindingElementFromNameAndPropertyName(ct, name, propertyName) if len(bindingPattern.Elements()) > 0 { - ct.insertNodeInListAfter(sourceFile, bindingPattern.Elements()[len(bindingPattern.Elements())-1], element, nil) + ct.InsertNodeInListAfter(sourceFile, bindingPattern.Elements()[len(bindingPattern.Elements())-1], element, nil) } else { - ct.replaceNode(sourceFile, bindingPattern, ct.NodeFactory.NewBindingPattern( + ct.ReplaceNode(sourceFile, bindingPattern, ct.NodeFactory.NewBindingPattern( ast.KindObjectBindingPattern, ct.NodeFactory.NewNodeList([]*ast.Node{element}), ), nil) } } -func (ct *changeTracker) newBindingElementFromNameAndPropertyName(name string, propertyName *string) *ast.Node { +func newBindingElementFromNameAndPropertyName(ct *change.Tracker, name string, propertyName *string) *ast.Node { var newPropertyNameIdentifier *ast.Node if propertyName != nil { newPropertyNameIdentifier = ct.NodeFactory.NewIdentifier(*propertyName) @@ -194,7 +233,7 @@ func (ct *changeTracker) newBindingElementFromNameAndPropertyName(name string, p ) } -func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*ast.Statement, blankLineBetween bool, preferences *UserPreferences) { +func (ls *LanguageService) insertImports(ct *change.Tracker, sourceFile *ast.SourceFile, imports []*ast.Statement, blankLineBetween bool) { var existingImportStatements []*ast.Statement if imports[0].Kind == ast.KindVariableStatement { @@ -202,10 +241,11 @@ func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*as } else { existingImportStatements = core.Filter(sourceFile.Statements.Nodes, ast.IsAnyImportSyntax) } - // !!! OrganizeImports - // { comparer, isSorted } := OrganizeImports.getOrganizeImportsStringComparerWithDetection(existingImportStatements, preferences); - // sortedNewImports := isArray(imports) ? toSorted(imports, (a, b) => OrganizeImports.compareImportsOrRequireStatements(a, b, comparer)) : [imports]; - sortedNewImports := imports + comparer, isSorted := organizeimports.GetOrganizeImportsStringComparerWithDetection(existingImportStatements, ls.UserPreferences()) + sortedNewImports := slices.Clone(imports) + slices.SortFunc(sortedNewImports, func(a, b *ast.Statement) int { + return organizeimports.CompareImportsOrRequireStatements(a, b, comparer) + }) // !!! FutureSourceFile // if !isFullSourceFile(sourceFile) { // for _, newImport := range sortedNewImports { @@ -216,29 +256,28 @@ func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*as // return; // } - // if len(existingImportStatements) > 0 && isSorted { - // for _, newImport := range sortedNewImports { - // insertionIndex := OrganizeImports.getImportDeclarationInsertionIndex(existingImportStatements, newImport, comparer) - // if insertionIndex == 0 { - // // If the first import is top-of-file, insert after the leading comment which is likely the header. - // options := existingImportStatements[0] == sourceFile.statements[0] ? { leadingTriviaOption: textchanges.LeadingTriviaOption.Exclude } : {}; - // ct.insertNodeBefore(sourceFile, existingImportStatements[0], newImport, /*blankLineBetween*/ false, options); - // } else { - // prevImport := existingImportStatements[insertionIndex - 1] - // ct.insertNodeAfter(sourceFile, prevImport, newImport); - // } - // } - // return - // } - - if len(existingImportStatements) > 0 { - ct.insertNodesAfter(sourceFile, existingImportStatements[len(existingImportStatements)-1], sortedNewImports) + if len(existingImportStatements) > 0 && isSorted { + // Existing imports are sorted, insert each new import at the correct position + for _, newImport := range sortedNewImports { + insertionIndex := organizeimports.GetImportDeclarationInsertIndex(existingImportStatements, newImport, func(a, b *ast.Statement) stringutil.Comparison { + return organizeimports.CompareImportsOrRequireStatements(a, b, comparer) + }) + if insertionIndex == 0 { + // If the first import is top-of-file, insert after the leading comment which is likely the header + ct.InsertNodeAt(sourceFile, core.TextPos(astnav.GetStartOfNode(existingImportStatements[0], sourceFile, false)), newImport.AsNode(), change.NodeOptions{}) + } else { + prevImport := existingImportStatements[insertionIndex-1] + ct.InsertNodeAfter(sourceFile, prevImport.AsNode(), newImport.AsNode()) + } + } + } else if len(existingImportStatements) > 0 { + ct.InsertNodesAfter(sourceFile, existingImportStatements[len(existingImportStatements)-1], sortedNewImports) } else { - ct.insertAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween) + ct.InsertAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween) } } -func (ct *changeTracker) makeImport(defaultImport *ast.IdentifierNode, namedImports []*ast.Node, moduleSpecifier *ast.Expression, isTypeOnly bool) *ast.Statement { +func makeImport(ct *change.Tracker, defaultImport *ast.IdentifierNode, namedImports []*ast.Node, moduleSpecifier *ast.Expression, isTypeOnly bool) *ast.Statement { var newNamedImports *ast.Node if len(namedImports) > 0 { newNamedImports = ct.NodeFactory.NewNamedImports(ct.NodeFactory.NewNodeList(namedImports)) @@ -250,37 +289,41 @@ func (ct *changeTracker) makeImport(defaultImport *ast.IdentifierNode, namedImpo return ct.NodeFactory.NewImportDeclaration( /*modifiers*/ nil, importClause, moduleSpecifier, nil /*attributes*/) } -func (ct *changeTracker) getNewImports( +func (ls *LanguageService) getNewImports( + ct *change.Tracker, moduleSpecifier string, - // quotePreference quotePreference, // !!! quotePreference + quotePreference quotePreference, defaultImport *Import, namedImports []*Import, namespaceLikeImport *Import, // { importKind: ImportKind.CommonJS | ImportKind.Namespace; } compilerOptions *core.CompilerOptions, - preferences *UserPreferences, ) []*ast.Statement { moduleSpecifierStringLiteral := ct.NodeFactory.NewStringLiteral(moduleSpecifier) + if quotePreference == quotePreferenceSingle { + moduleSpecifierStringLiteral.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } var statements []*ast.Statement // []AnyImportSyntax if defaultImport != nil || len(namedImports) > 0 { // `verbatimModuleSyntax` should prefer top-level `import type` - // even though it's not an error, it would add unnecessary runtime emit. topLevelTypeOnly := (defaultImport == nil || needsTypeOnly(defaultImport.addAsTypeOnly)) && core.Every(namedImports, func(i *Import) bool { return needsTypeOnly(i.addAsTypeOnly) }) || - (compilerOptions.VerbatimModuleSyntax.IsTrue() || preferences.PreferTypeOnlyAutoImports) && - defaultImport != nil && defaultImport.addAsTypeOnly != AddAsTypeOnlyNotAllowed && !core.Some(namedImports, func(i *Import) bool { return i.addAsTypeOnly == AddAsTypeOnlyNotAllowed }) + (compilerOptions.VerbatimModuleSyntax.IsTrue() || ls.UserPreferences().PreferTypeOnlyAutoImports) && + (defaultImport == nil || defaultImport.addAsTypeOnly != AddAsTypeOnlyNotAllowed) && + !core.Some(namedImports, func(i *Import) bool { return i.addAsTypeOnly == AddAsTypeOnlyNotAllowed }) var defaultImportNode *ast.Node if defaultImport != nil { defaultImportNode = ct.NodeFactory.NewIdentifier(defaultImport.name) } - statements = append(statements, ct.makeImport(defaultImportNode, core.Map(namedImports, func(namedImport *Import) *ast.Node { + statements = append(statements, makeImport(ct, defaultImportNode, core.Map(namedImports, func(namedImport *Import) *ast.Node { var namedImportPropertyName *ast.Node if namedImport.propertyName != "" { namedImportPropertyName = ct.NodeFactory.NewIdentifier(namedImport.propertyName) } return ct.NodeFactory.NewImportSpecifier( - !topLevelTypeOnly && shouldUseTypeOnly(namedImport.addAsTypeOnly, preferences), + !topLevelTypeOnly && shouldUseTypeOnly(namedImport.addAsTypeOnly, ls.UserPreferences()), namedImportPropertyName, ct.NodeFactory.NewIdentifier(namedImport.name), ) @@ -292,7 +335,7 @@ func (ct *changeTracker) getNewImports( if namespaceLikeImport.kind == ImportKindCommonJS { declaration = ct.NodeFactory.NewImportEqualsDeclaration( /*modifiers*/ nil, - shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, preferences), + shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, ls.UserPreferences()), ct.NodeFactory.NewIdentifier(namespaceLikeImport.name), ct.NodeFactory.NewExternalModuleReference(moduleSpecifierStringLiteral), ) @@ -300,7 +343,7 @@ func (ct *changeTracker) getNewImports( declaration = ct.NodeFactory.NewImportDeclaration( /*modifiers*/ nil, ct.NodeFactory.NewImportClause( - /*phaseModifier*/ core.IfElse(shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, preferences), ast.KindTypeKeyword, ast.KindUnknown), + /*phaseModifier*/ core.IfElse(shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, ls.UserPreferences()), ast.KindTypeKeyword, ast.KindUnknown), /*name*/ nil, ct.NodeFactory.NewNamespaceImport(ct.NodeFactory.NewIdentifier(namespaceLikeImport.name)), ), @@ -320,6 +363,6 @@ func needsTypeOnly(addAsTypeOnly AddAsTypeOnly) bool { return addAsTypeOnly == AddAsTypeOnlyRequired } -func shouldUseTypeOnly(addAsTypeOnly AddAsTypeOnly, preferences *UserPreferences) bool { +func shouldUseTypeOnly(addAsTypeOnly AddAsTypeOnly, preferences *lsutil.UserPreferences) bool { return needsTypeOnly(addAsTypeOnly) || addAsTypeOnly != AddAsTypeOnlyNotAllowed && preferences.PreferTypeOnlyAutoImports } diff --git a/internal/ls/autoimports.go b/internal/ls/autoimports.go index 781d7edac6..3e9dc29dba 100644 --- a/internal/ls/autoimports.go +++ b/internal/ls/autoimports.go @@ -14,9 +14,13 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/locale" + "github.com/microsoft/typescript-go/internal/ls/change" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/modulespecifiers" + "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -35,17 +39,10 @@ type symbolExportEntry struct { moduleSymbol *ast.Symbol } -type ExportInfoMapKey struct { - SymbolName string - SymbolId ast.SymbolId - AmbientModuleName string - ModuleFile tspath.Path -} - -func newExportInfoMapKey(importedName string, symbol *ast.Symbol, ambientModuleNameKey string, ch *checker.Checker) ExportInfoMapKey { - return ExportInfoMapKey{ +func newExportInfoMapKey(importedName string, symbol *ast.Symbol, ambientModuleNameKey string, ch *checker.Checker) lsproto.ExportInfoMapKey { + return lsproto.ExportInfoMapKey{ SymbolName: importedName, - SymbolId: ast.GetSymbolId(ch.SkipAlias(symbol)), + SymbolId: uint64(ast.GetSymbolId(ch.SkipAlias(symbol))), AmbientModuleName: ambientModuleNameKey, } } @@ -68,8 +65,8 @@ type CachedSymbolExportInfo struct { isFromPackageJson bool } -type exportInfoMap struct { - exportInfo collections.MultiMap[ExportInfoMapKey, CachedSymbolExportInfo] +type ExportInfoMap struct { + exportInfo collections.OrderedMap[lsproto.ExportInfoMapKey, []*CachedSymbolExportInfo] symbols map[int]symbolExportEntry exportInfoId int usableByFileName tspath.Path @@ -81,20 +78,20 @@ type exportInfoMap struct { // !!! onFileChanged func(oldSourceFile *ast.SourceFile, newSourceFile *ast.SourceFile, typeAcquisitionEnabled bool) bool } -func (e *exportInfoMap) clear() { +func (e *ExportInfoMap) clear() { e.symbols = map[int]symbolExportEntry{} - e.exportInfo = collections.MultiMap[ExportInfoMapKey, CachedSymbolExportInfo]{} + e.exportInfo = collections.OrderedMap[lsproto.ExportInfoMapKey, []*CachedSymbolExportInfo]{} e.usableByFileName = "" } -func (e *exportInfoMap) get(importingFile tspath.Path, ch *checker.Checker, key ExportInfoMapKey) []*SymbolExportInfo { +func (e *ExportInfoMap) get(importingFile tspath.Path, ch *checker.Checker, key lsproto.ExportInfoMapKey) []*SymbolExportInfo { if e.usableByFileName != importingFile { return nil } - return core.Map(e.exportInfo.Get(key), func(info CachedSymbolExportInfo) *SymbolExportInfo { return e.rehydrateCachedInfo(ch, info) }) + return core.Map(e.exportInfo.GetOrZero(key), func(info *CachedSymbolExportInfo) *SymbolExportInfo { return e.rehydrateCachedInfo(ch, info) }) } -func (e *exportInfoMap) add( +func (e *ExportInfoMap) add( importingFile tspath.Path, symbol *ast.Symbol, symbolTableKey string, @@ -164,7 +161,8 @@ func (e *exportInfoMap) add( } moduleName := stringutil.StripQuotes(moduleSymbol.Name) - id := e.exportInfoId + 1 + e.exportInfoId++ + id := e.exportInfoId target := ch.SkipAlias(symbol) if flagMatch != nil && !flagMatch(target.Flags) { @@ -193,7 +191,9 @@ func (e *exportInfoMap) add( if moduleFile != nil { moduleFileName = moduleFile.FileName() } - e.exportInfo.Add(newExportInfoMapKey(symbolName, symbol, moduleKey, ch), CachedSymbolExportInfo{ + key := newExportInfoMapKey(symbolName, symbol, moduleKey, ch) + infos := e.exportInfo.GetOrZero(key) + infos = append(infos, &CachedSymbolExportInfo{ id: id, symbolTableKey: symbolTableKey, symbolName: symbolName, @@ -209,25 +209,26 @@ func (e *exportInfoMap) add( targetFlags: target.Flags, isFromPackageJson: isFromPackageJson, }) + e.exportInfo.Set(key, infos) } -func (e *exportInfoMap) search( +func (e *ExportInfoMap) search( ch *checker.Checker, importingFile tspath.Path, preferCapitalized bool, matches func(name string, targetFlags ast.SymbolFlags) bool, - action func(info []*SymbolExportInfo, symbolName string, isFromAmbientModule bool, key ExportInfoMapKey) []*SymbolExportInfo, + action func(info []*SymbolExportInfo, symbolName string, isFromAmbientModule bool, key lsproto.ExportInfoMapKey) []*SymbolExportInfo, ) []*SymbolExportInfo { if importingFile != e.usableByFileName { return nil } - for key, info := range e.exportInfo.M { + for key, info := range e.exportInfo.Entries() { symbolName, ambientModuleName := key.SymbolName, key.AmbientModuleName if preferCapitalized && info[0].capitalizedSymbolName != "" { symbolName = info[0].capitalizedSymbolName } if matches(symbolName, info[0].targetFlags) { - rehydrated := core.Map(info, func(info CachedSymbolExportInfo) *SymbolExportInfo { + rehydrated := core.Map(info, func(info *CachedSymbolExportInfo) *SymbolExportInfo { return e.rehydrateCachedInfo(ch, info) }) filtered := core.FilterIndex(rehydrated, func(r *SymbolExportInfo, i int, _ []*SymbolExportInfo) bool { @@ -243,7 +244,7 @@ func (e *exportInfoMap) search( return nil } -func (e *exportInfoMap) isNotShadowedByDeeperNodeModulesPackage(info *SymbolExportInfo, packageName string) bool { +func (e *ExportInfoMap) isNotShadowedByDeeperNodeModulesPackage(info *SymbolExportInfo, packageName string) bool { if packageName == "" || info.moduleFileName == "" { return true } @@ -254,7 +255,7 @@ func (e *exportInfoMap) isNotShadowedByDeeperNodeModulesPackage(info *SymbolExpo return !ok || strings.HasPrefix(info.moduleFileName, packageDeepestNodeModulesPath) } -func (e *exportInfoMap) rehydrateCachedInfo(ch *checker.Checker, info CachedSymbolExportInfo) *SymbolExportInfo { +func (e *ExportInfoMap) rehydrateCachedInfo(ch *checker.Checker, info *CachedSymbolExportInfo) *SymbolExportInfo { if info.symbol != nil && info.moduleSymbol != nil { return &SymbolExportInfo{ symbol: info.symbol, @@ -340,32 +341,6 @@ type packageJsonFilterResult struct { importable bool packageName string } -type projectPackageJsonInfo struct { - fileName string - parseable bool - dependencies map[string]string - devDependencies map[string]string - peerDependencies map[string]string - optionalDependencies map[string]string -} - -func (info *projectPackageJsonInfo) has(dependencyName string) bool { - if _, ok := info.dependencies[dependencyName]; ok { - return true - } - if _, ok := info.devDependencies[dependencyName]; ok { - return true - } - - if _, ok := info.peerDependencies[dependencyName]; ok { - return true - } - if _, ok := info.optionalDependencies[dependencyName]; ok { - return true - } - - return false -} func (l *LanguageService) getImportCompletionAction( ctx context.Context, @@ -374,33 +349,32 @@ func (l *LanguageService) getImportCompletionAction( moduleSymbol *ast.Symbol, sourceFile *ast.SourceFile, position int, - exportMapKey ExportInfoMapKey, - symbolName string, // !!! needs *string ? + exportMapKey lsproto.ExportInfoMapKey, + symbolName string, isJsxTagName bool, // formatContext *formattingContext, - preferences *UserPreferences, ) (string, codeAction) { var exportInfos []*SymbolExportInfo // `exportMapKey` should be in the `itemData` of each auto-import completion entry and sent in resolving completion entry requests - exportInfos = l.getExportInfos(ctx, ch, sourceFile, preferences, exportMapKey) + exportInfos = l.getExportInfoMap(ctx, ch, sourceFile, exportMapKey) if len(exportInfos) == 0 { panic("Some exportInfo should match the specified exportMapKey") } isValidTypeOnlyUseSite := ast.IsValidTypeOnlyAliasUseSite(astnav.GetTokenAtPosition(sourceFile, position)) - fix := l.getImportFixForSymbol(ch, sourceFile, exportInfos, position, ptrTo(isValidTypeOnlyUseSite), preferences) + fix := l.getImportFixForSymbol(ch, sourceFile, exportInfos, position, ptrTo(isValidTypeOnlyUseSite)) if fix == nil { lineAndChar := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(position)) panic(fmt.Sprintf("expected importFix at %s: (%v,%v)", sourceFile.FileName(), lineAndChar.Line, lineAndChar.Character)) } - return fix.moduleSpecifier, l.codeActionForFix(ctx, sourceFile, symbolName, fix /*includeSymbolNameInDescription*/, false, preferences) + return fix.moduleSpecifier, l.codeActionForFix(ctx, sourceFile, symbolName, fix /*includeSymbolNameInDescription*/, false) } -func NewExportInfoMap(globalsTypingCacheLocation string) *exportInfoMap { - return &exportInfoMap{ +func NewExportInfoMap(globalsTypingCacheLocation string) *ExportInfoMap { + return &ExportInfoMap{ packages: map[string]string{}, symbols: map[int]symbolExportEntry{}, - exportInfo: collections.MultiMap[ExportInfoMapKey, CachedSymbolExportInfo]{}, + exportInfo: collections.OrderedMap[lsproto.ExportInfoMapKey, []*CachedSymbolExportInfo]{}, globalTypingsCacheLocation: globalsTypingCacheLocation, } } @@ -409,7 +383,6 @@ func (l *LanguageService) isImportable( fromFile *ast.SourceFile, toFile *ast.SourceFile, toModule *ast.Symbol, - preferences *UserPreferences, packageJsonFilter *packageJsonImportFilter, // moduleSpecifierResolutionHost ModuleSpecifierResolutionHost, // moduleSpecifierCache ModuleSpecifierCache, @@ -421,7 +394,7 @@ func (l *LanguageService) isImportable( if toFile == nil { moduleName := stringutil.StripQuotes(toModule.Name) if _, ok := core.NodeCoreModules()[moduleName]; ok { - if useNodePrefix := shouldUseUriStyleNodeCoreModules(fromFile, l.GetProgram()); useNodePrefix { + if useNodePrefix := lsutil.ShouldUseUriStyleNodeCoreModules(fromFile, l.GetProgram()); useNodePrefix { return useNodePrefix == strings.HasPrefix(moduleName, "node:") } } @@ -503,7 +476,7 @@ func fileContainsPackageImport(sourceFile *ast.SourceFile, packageName string) b } func isImportableSymbol(symbol *ast.Symbol, ch *checker.Checker) bool { - return !ch.IsUndefinedSymbol(symbol) && !ch.IsUnknownSymbol(symbol) && !checker.IsKnownSymbol(symbol) // !!! && !checker.IsPrivateIdentifierSymbol(symbol); + return !ch.IsUndefinedSymbol(symbol) && !ch.IsUnknownSymbol(symbol) && !checker.IsKnownSymbol(symbol) && !checker.IsPrivateIdentifierSymbol(symbol) } func getDefaultLikeExportInfo(moduleSymbol *ast.Symbol, ch *checker.Checker) *ExportInfo { @@ -522,14 +495,14 @@ func getDefaultLikeExportInfo(moduleSymbol *ast.Symbol, ch *checker.Checker) *Ex type importSpecifierResolverForCompletions struct { *ast.SourceFile // importingFile - *UserPreferences + *lsutil.UserPreferences l *LanguageService filter *packageJsonImportFilter } func (r *importSpecifierResolverForCompletions) packageJsonImportFilter() *packageJsonImportFilter { if r.filter == nil { - r.filter = r.l.createPackageJsonImportFilter(r.SourceFile, *r.UserPreferences) + r.filter = r.l.createPackageJsonImportFilter(r.SourceFile) } return r.filter } @@ -542,15 +515,9 @@ func (i *importSpecifierResolverForCompletions) getModuleSpecifierForBestExportI ) *ImportFix { // !!! caching // used in completions, usually calculated once per `getCompletionData` call - var userPreferences UserPreferences - if i.UserPreferences == nil { - userPreferences = UserPreferences{} - } else { - userPreferences = *i.UserPreferences - } packageJsonImportFilter := i.packageJsonImportFilter() - _, fixes := i.l.getImportFixes(ch, exportInfo, ptrTo(i.l.converters.PositionToLineAndCharacter(i.SourceFile, core.TextPos(position))), ptrTo(isValidTypeOnlyUseSite), ptrTo(false), i.SourceFile, userPreferences, false /* fromCacheOnly */) - return i.l.getBestFix(fixes, i.SourceFile, packageJsonImportFilter.allowsImportingSpecifier, userPreferences) + _, fixes := i.l.getImportFixes(ch, exportInfo, ptrTo(i.l.converters.PositionToLineAndCharacter(i.SourceFile, core.TextPos(position))), ptrTo(isValidTypeOnlyUseSite), ptrTo(false), i.SourceFile, false /* fromCacheOnly */) + return i.l.getBestFix(fixes, i.SourceFile, packageJsonImportFilter.allowsImportingSpecifier) } func (l *LanguageService) getImportFixForSymbol( @@ -559,23 +526,17 @@ func (l *LanguageService) getImportFixForSymbol( exportInfos []*SymbolExportInfo, position int, isValidTypeOnlySite *bool, - preferences *UserPreferences, ) *ImportFix { - var userPreferences UserPreferences - if preferences != nil { - userPreferences = *preferences - } - if isValidTypeOnlySite == nil { isValidTypeOnlySite = ptrTo(ast.IsValidTypeOnlyAliasUseSite(astnav.GetTokenAtPosition(sourceFile, position))) } - useRequire := getShouldUseRequire(sourceFile, l.GetProgram()) - packageJsonImportFilter := l.createPackageJsonImportFilter(sourceFile, userPreferences) - _, fixes := l.getImportFixes(ch, exportInfos, ptrTo(l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(position))), isValidTypeOnlySite, &useRequire, sourceFile, userPreferences, false /* fromCacheOnly */) - return l.getBestFix(fixes, sourceFile, packageJsonImportFilter.allowsImportingSpecifier, userPreferences) + useRequire := shouldUseRequire(sourceFile, l.GetProgram()) + packageJsonImportFilter := l.createPackageJsonImportFilter(sourceFile) + _, fixes := l.getImportFixes(ch, exportInfos, ptrTo(l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(position))), isValidTypeOnlySite, &useRequire, sourceFile, false /* fromCacheOnly */) + return l.getBestFix(fixes, sourceFile, packageJsonImportFilter.allowsImportingSpecifier) } -func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceFile, allowsImportingSpecifier func(moduleSpecifier string) bool, preferences UserPreferences) *ImportFix { +func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceFile, allowsImportingSpecifier func(moduleSpecifier string) bool) *ImportFix { if len(fixes) == 0 { return nil } @@ -588,12 +549,10 @@ func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceF best := fixes[0] for _, fix := range fixes { // Takes true branch of conditional if `fix` is better than `best` - if compareModuleSpecifiers( + if l.compareModuleSpecifiers( fix, best, sourceFile, - l.GetProgram(), - preferences, allowsImportingSpecifier, func(fileName string) tspath.Path { return tspath.ToPath(fileName, l.GetProgram().GetCurrentDirectory(), l.GetProgram().UseCaseSensitiveFileNames()) @@ -606,6 +565,85 @@ func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceF return best } +// returns `-1` if `a` is better than `b` +// +// note: this sorts in descending order of preference; different than convention in other cmp-like functions +func (l *LanguageService) compareModuleSpecifiers( + a *ImportFix, // !!! ImportFixWithModuleSpecifier + b *ImportFix, // !!! ImportFixWithModuleSpecifier + importingFile *ast.SourceFile, // | FutureSourceFile, + allowsImportingSpecifier func(specifier string) bool, + toPath func(fileName string) tspath.Path, +) int { + if a.kind != ImportFixKindUseNamespace && b.kind != ImportFixKindUseNamespace { + if comparison := core.CompareBooleans( + b.moduleSpecifierKind != modulespecifiers.ResultKindNodeModules || allowsImportingSpecifier(b.moduleSpecifier), + a.moduleSpecifierKind != modulespecifiers.ResultKindNodeModules || allowsImportingSpecifier(a.moduleSpecifier), + ); comparison != 0 { + return comparison + } + if comparison := compareModuleSpecifierRelativity(a, b, l.UserPreferences()); comparison != 0 { + return comparison + } + if comparison := compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, l.GetProgram()); comparison != 0 { + return comparison + } + if comparison := core.CompareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile.Path(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile.Path(), toPath)); comparison != 0 { + return comparison + } + if comparison := tspath.CompareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); comparison != 0 { + return comparison + } + } + return 0 +} + +func compareNodeCoreModuleSpecifiers(a, b string, importingFile *ast.SourceFile, program *compiler.Program) int { + if strings.HasPrefix(a, "node:") && !strings.HasPrefix(b, "node:") { + if lsutil.ShouldUseUriStyleNodeCoreModules(importingFile, program) { + return -1 + } + return 1 + } + if strings.HasPrefix(b, "node:") && !strings.HasPrefix(a, "node:") { + if lsutil.ShouldUseUriStyleNodeCoreModules(importingFile, program) { + return 1 + } + return -1 + } + return 0 +} + +// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. +// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. +// This can produce false positives or negatives if re-exports cross into sibling directories +// (e.g. `export * from "../whatever"`) or are not named "index". +func isFixPossiblyReExportingImportingFile(fix *ImportFix, importingFilePath tspath.Path, toPath func(fileName string) tspath.Path) bool { + if fix.isReExport != nil && *(fix.isReExport) && + fix.exportInfo != nil && fix.exportInfo.moduleFileName != "" && isIndexFileName(fix.exportInfo.moduleFileName) { + reExportDir := toPath(tspath.GetDirectoryPath(fix.exportInfo.moduleFileName)) + return strings.HasPrefix(string(importingFilePath), string(reExportDir)) + } + return false +} + +func isIndexFileName(fileName string) bool { + fileName = tspath.GetBaseFileName(fileName) + if tspath.FileExtensionIsOneOf(fileName, []string{".js", ".jsx", ".d.ts", ".ts", ".tsx"}) { + fileName = tspath.RemoveFileExtension(fileName) + } + return fileName == "index" +} + +// returns `-1` if `a` is better than `b` +func compareModuleSpecifierRelativity(a *ImportFix, b *ImportFix, preferences *lsutil.UserPreferences) int { + switch preferences.ImportModuleSpecifierPreference { + case modulespecifiers.ImportModuleSpecifierPreferenceNonRelative, modulespecifiers.ImportModuleSpecifierPreferenceProjectRelative: + return core.CompareBooleans(a.moduleSpecifierKind == modulespecifiers.ResultKindRelative, b.moduleSpecifierKind == modulespecifiers.ResultKindRelative) + } + return 0 +} + func (l *LanguageService) getImportFixes( ch *checker.Checker, exportInfos []*SymbolExportInfo, // | FutureSymbolExportInfo[], @@ -613,7 +651,6 @@ func (l *LanguageService) getImportFixes( isValidTypeOnlyUseSite *bool, useRequire *bool, sourceFile *ast.SourceFile, // | FutureSourceFile, - preferences UserPreferences, // importMap *importMap, fromCacheOnly bool, ) (int, []*ImportFix) { @@ -642,7 +679,6 @@ func (l *LanguageService) getImportFixes( usagePosition, *isValidTypeOnlyUseSite, *useRequire, - preferences, fromCacheOnly, ) computedWithoutCacheCount := 0 @@ -652,11 +688,24 @@ func (l *LanguageService) getImportFixes( return computedWithoutCacheCount, append(useNamespace, result...) } -func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile, preferences UserPreferences) *packageJsonImportFilter { - packageJsons := []*projectPackageJsonInfo{} - // packageJsons := ( - // (host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host) - // ).filter(p => p.parseable); +func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile) *packageJsonImportFilter { + // !!! The program package.json cache may not have every relevant package.json. + // This should eventually be integrated with the session. + var packageJsons []*packagejson.PackageJson + dir := tspath.GetDirectoryPath(fromFile.FileName()) + for { + packageJsonDir := l.GetProgram().GetNearestAncestorDirectoryWithPackageJson(dir) + if packageJsonDir == "" { + break + } + if packageJson := l.GetProgram().GetPackageJsonInfo(tspath.CombinePaths(packageJsonDir, "package.json")).GetContents(); packageJson != nil && packageJson.Parseable { + packageJsons = append(packageJsons, packageJson) + } + dir = tspath.GetDirectoryPath(packageJsonDir) + if dir == packageJsonDir { + break + } + } var usesNodeCoreModules *bool ambientModuleCache := map[*ast.Symbol]bool{} @@ -674,7 +723,7 @@ func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile moduleSpecifierIsCoveredByPackageJson := func(specifier string) bool { packageName := getNodeModuleRootSpecifier(specifier) for _, packageJson := range packageJsons { - if packageJson.has(packageName) || packageJson.has(module.GetTypesPackageName(packageName)) { + if packageJson.HasDependency(packageName) || packageJson.HasDependency(module.GetTypesPackageName(packageName)) { return true } } @@ -706,7 +755,7 @@ func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile fromFile, importedFileName, moduleSpecifierResolutionHost, - preferences.ModuleSpecifierPreferences(), + l.UserPreferences().ModuleSpecifierPreferences(), modulespecifiers.ModuleSpecifierOptions{}, ) if specifier == "" { @@ -721,7 +770,7 @@ func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile } allowsImportingAmbientModule := func(moduleSymbol *ast.Symbol, moduleSpecifierResolutionHost modulespecifiers.ModuleSpecifierGenerationHost) bool { - if len(packageJsons) > 0 || moduleSymbol.ValueDeclaration == nil { + if len(packageJsons) == 0 || moduleSymbol.ValueDeclaration == nil { return true } @@ -855,29 +904,9 @@ func tryUseExistingNamespaceImport(existingImports []*FixAddToExistingImportInfo if existingImport.importKind != ImportKindNamed { continue } - var namespacePrefix string - declaration := existingImport.declaration - switch declaration.Kind { - case ast.KindVariableDeclaration, ast.KindImportEqualsDeclaration: - name := declaration.Name() - if declaration.Kind == ast.KindVariableDeclaration && (name == nil || name.Kind != ast.KindIdentifier) { - continue - } - namespacePrefix = name.Text() - case ast.KindJSDocImportTag, ast.KindImportDeclaration: - importClause := ast.GetImportClauseOfDeclaration(declaration) - if importClause == nil || importClause.NamedBindings == nil || importClause.NamedBindings.Kind != ast.KindNamespaceImport { - continue - } - namespacePrefix = importClause.NamedBindings.Name().Text() - default: - debug.AssertNever(declaration) - } - if namespacePrefix == "" { - continue - } - moduleSpecifier := checker.TryGetModuleSpecifierFromDeclaration(declaration) - if moduleSpecifier != nil && moduleSpecifier.Text() != "" { + namespacePrefix := getNamespaceLikeImportText(existingImport.declaration) + moduleSpecifier := checker.TryGetModuleSpecifierFromDeclaration(existingImport.declaration) + if namespacePrefix != "" && moduleSpecifier != nil && moduleSpecifier.Text() != "" { return getUseNamespaceImport( moduleSpecifier.Text(), modulespecifiers.ResultKindNone, @@ -889,6 +918,28 @@ func tryUseExistingNamespaceImport(existingImports []*FixAddToExistingImportInfo return nil } +func getNamespaceLikeImportText(declaration *ast.Statement) string { + switch declaration.Kind { + case ast.KindVariableDeclaration: + name := declaration.Name() + if name != nil && name.Kind == ast.KindIdentifier { + return name.Text() + } + return "" + case ast.KindImportEqualsDeclaration: + return declaration.Name().Text() + case ast.KindJSDocImportTag, ast.KindImportDeclaration: + importClause := declaration.ImportClause() + if importClause != nil && importClause.AsImportClause().NamedBindings != nil && importClause.AsImportClause().NamedBindings.Kind == ast.KindNamespaceImport { + return importClause.AsImportClause().NamedBindings.Name().Text() + } + return "" + default: + debug.AssertNever(declaration) + return "" + } +} + func tryAddToExistingImport(existingImports []*FixAddToExistingImportInfo, isValidTypeOnlyUseSite *bool, ch *checker.Checker, compilerOptions *core.CompilerOptions) *ImportFix { var best *ImportFix @@ -934,11 +985,11 @@ func (info *FixAddToExistingImportInfo) getAddToExistingImportFix(isValidTypeOnl return nil } - importClause := ast.GetImportClauseOfDeclaration(info.declaration) + importClause := info.declaration.ImportClause() if importClause == nil || !ast.IsStringLiteralLike(info.declaration.ModuleSpecifier()) { return nil } - namedBindings := importClause.NamedBindings + namedBindings := importClause.AsImportClause().NamedBindings // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. if importClause.IsTypeOnly() && !(info.importKind == ImportKindNamed && namedBindings != nil) { @@ -978,7 +1029,6 @@ func (l *LanguageService) getFixesForAddImport( usagePosition *lsproto.Position, isValidTypeOnlyUseSite bool, useRequire bool, - preferences UserPreferences, fromCacheOnly bool, ) []*ImportFix { // tries to create a new import statement using an existing import specifier @@ -995,7 +1045,7 @@ func (l *LanguageService) getFixesForAddImport( return []*ImportFix{importWithExistingSpecifier} } - return l.getNewImportFixes(ch, sourceFile, usagePosition, isValidTypeOnlyUseSite, useRequire, exportInfos, preferences, fromCacheOnly) + return l.getNewImportFixes(ch, sourceFile, usagePosition, isValidTypeOnlyUseSite, useRequire, exportInfos, fromCacheOnly) } func (l *LanguageService) getNewImportFixes( @@ -1005,7 +1055,6 @@ func (l *LanguageService) getNewImportFixes( isValidTypeOnlyUseSite bool, useRequire bool, exportInfos []*SymbolExportInfo, // !!! (SymbolExportInfo | FutureSymbolExportInfo)[], - preferences UserPreferences, fromCacheOnly bool, ) []*ImportFix /* FixAddNewImport | FixAddJsdocTypeImport */ { isJs := tspath.HasJSFileExtension(sourceFile.FileName()) @@ -1014,7 +1063,7 @@ func (l *LanguageService) getNewImportFixes( // getChecker := createGetChecker(program, host)// memoized typechecker based on `isFromPackageJson` bool getModuleSpecifiers := func(moduleSymbol *ast.Symbol, checker *checker.Checker) ([]string, modulespecifiers.ResultKind) { - return modulespecifiers.GetModuleSpecifiersWithInfo(moduleSymbol, checker, compilerOptions, sourceFile, l.GetProgram(), preferences.ModuleSpecifierPreferences(), modulespecifiers.ModuleSpecifierOptions{}, true /*forAutoImport*/) + return modulespecifiers.GetModuleSpecifiersWithInfo(moduleSymbol, checker, compilerOptions, sourceFile, l.GetProgram(), l.UserPreferences().ModuleSpecifierPreferences(), modulespecifiers.ModuleSpecifierOptions{}, true /*forAutoImport*/) } // fromCacheOnly // ? (exportInfo: SymbolExportInfo | FutureSymbolExportInfo) => moduleSpecifiers.tryGetModuleSpecifiersFromCache(exportInfo.moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences) @@ -1107,7 +1156,7 @@ func getAddAsTypeOnly( return AddAsTypeOnlyAllowed } -func getShouldUseRequire( +func shouldUseRequire( sourceFile *ast.SourceFile, // !!! | FutureSourceFile program *compiler.Program, ) bool { @@ -1329,7 +1378,6 @@ func getDefaultLikeExportNameFromDeclaration(symbol *ast.Symbol) string { func forEachExternalModuleToImportFrom( ch *checker.Checker, program *compiler.Program, - preferences *UserPreferences, // useAutoImportProvider bool, cb func(module *ast.Symbol, moduleFile *ast.SourceFile, checker *checker.Checker, isFromPackageJson bool), ) { @@ -1390,49 +1438,69 @@ func (l *LanguageService) codeActionForFix( symbolName string, fix *ImportFix, includeSymbolNameInDescription bool, - preferences *UserPreferences, ) codeAction { - tracker := l.newChangeTracker(ctx) // !!! changetracker.with - diag := l.codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, preferences) - changes := tracker.getChanges()[sourceFile.FileName()] - return codeAction{description: diag.Message(), changes: changes} + tracker := change.NewTracker(ctx, l.GetProgram().Options(), l.FormatOptions(), l.converters) // !!! changetracker.with + diag := l.codeActionForFixWorker(ctx, tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription) + changes := tracker.GetChanges()[sourceFile.FileName()] + return codeAction{description: diag, changes: changes} } func (l *LanguageService) codeActionForFixWorker( - changeTracker *changeTracker, + ctx context.Context, + changeTracker *change.Tracker, sourceFile *ast.SourceFile, symbolName string, fix *ImportFix, includeSymbolNameInDescription bool, - preferences *UserPreferences, -) *diagnostics.Message { +) string { + locale := locale.FromContext(ctx) + switch fix.kind { case ImportFixKindUseNamespace: - changeTracker.addNamespaceQualifier(sourceFile, fix.qualification()) - return diagnostics.FormatMessage(diagnostics.Change_0_to_1, symbolName, `${fix.namespacePrefix}.${symbolName}`) + addNamespaceQualifier(changeTracker, sourceFile, fix.qualification()) + return diagnostics.Change_0_to_1.Localize(locale, symbolName, fmt.Sprintf("%s.%s", *fix.namespacePrefix, symbolName)) case ImportFixKindJsdocTypeImport: - // !!! not implemented - // changeTracker.addImportType(changeTracker, sourceFile, fix, quotePreference); - // return diagnostics.FormatMessage(diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName); + if fix.usagePosition == nil { + return "" + } + quotePreference := getQuotePreference(sourceFile, l.UserPreferences()) + quoteChar := "\"" + if quotePreference == quotePreferenceSingle { + quoteChar = "'" + } + importTypePrefix := fmt.Sprintf("import(%s%s%s).", quoteChar, fix.moduleSpecifier, quoteChar) + changeTracker.InsertText(sourceFile, *fix.usagePosition, importTypePrefix) + return diagnostics.Change_0_to_1.Localize(locale, symbolName, importTypePrefix+symbolName) case ImportFixKindAddToExisting: - changeTracker.doAddExistingFix( + var defaultImport *Import + var namedImports []*Import + if fix.importKind == ImportKindDefault { + defaultImport = &Import{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly} + } else if fix.importKind == ImportKindNamed { + namedImports = []*Import{{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly, propertyName: fix.propertyName}} + } + l.doAddExistingFix( + changeTracker, sourceFile, fix.importClauseOrBindingPattern, - core.IfElse(fix.importKind == ImportKindDefault, &Import{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly}, nil), - core.IfElse(fix.importKind == ImportKindNamed, []*Import{{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly}}, nil), - // nil /*removeExistingImportSpecifiers*/, - preferences, + defaultImport, + namedImports, ) moduleSpecifierWithoutQuotes := stringutil.StripQuotes(fix.moduleSpecifier) if includeSymbolNameInDescription { - return diagnostics.FormatMessage(diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes) + return diagnostics.Import_0_from_1.Localize(locale, symbolName, moduleSpecifierWithoutQuotes) } - return diagnostics.FormatMessage(diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes) + return diagnostics.Update_import_from_0.Localize(locale, moduleSpecifierWithoutQuotes) case ImportFixKindAddNew: var declarations []*ast.Statement - defaultImport := core.IfElse(fix.importKind == ImportKindDefault, &Import{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly}, nil) - namedImports := core.IfElse(fix.importKind == ImportKindNamed, []*Import{{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly}}, nil) + var defaultImport *Import + var namedImports []*Import var namespaceLikeImport *Import + if fix.importKind == ImportKindDefault { + defaultImport = &Import{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly} + } else if fix.importKind == ImportKindNamed { + namedImports = []*Import{{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly, propertyName: fix.propertyName}} + } qualification := fix.qualification() if fix.importKind == ImportKindNamespace || fix.importKind == ImportKindCommonJS { namespaceLikeImport = &Import{kind: fix.importKind, addAsTypeOnly: fix.addAsTypeOnly, name: symbolName} @@ -1442,39 +1510,122 @@ func (l *LanguageService) codeActionForFixWorker( } if fix.useRequire { - // !!! require - // declarations = getNewRequires(fixAddNew.moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options(), preferences) + declarations = getNewRequires(changeTracker, fix.moduleSpecifier, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) } else { - declarations = changeTracker.getNewImports(fix.moduleSpecifier, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options(), preferences) + declarations = l.getNewImports(changeTracker, fix.moduleSpecifier, getQuotePreference(sourceFile, l.UserPreferences()), defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) } - changeTracker.insertImports( + l.insertImports( + changeTracker, sourceFile, declarations, /*blankLineBetween*/ true, - preferences, ) if qualification != nil { - changeTracker.addNamespaceQualifier(sourceFile, qualification) + addNamespaceQualifier(changeTracker, sourceFile, qualification) } if includeSymbolNameInDescription { - return diagnostics.FormatMessage(diagnostics.Import_0_from_1, symbolName, fix.moduleSpecifier) + return diagnostics.Import_0_from_1.Localize(locale, symbolName, fix.moduleSpecifier) } - return diagnostics.FormatMessage(diagnostics.Add_import_from_0, fix.moduleSpecifier) + return diagnostics.Add_import_from_0.Localize(locale, fix.moduleSpecifier) case ImportFixKindPromoteTypeOnly: - // !!! type only - // promotedDeclaration := promoteFromTypeOnly(changes, fix.typeOnlyAliasDeclaration, program, sourceFile, preferences); - // if promotedDeclaration.Kind == ast.KindImportSpecifier { - // return diagnostics.FormatMessage(diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)) - // } - // return diagnostics.FormatMessage(diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)); + promotedDeclaration := promoteFromTypeOnly(changeTracker, fix.typeOnlyAliasDeclaration, l.GetProgram(), sourceFile, l) + if promotedDeclaration.Kind == ast.KindImportSpecifier { + moduleSpec := getModuleSpecifierText(promotedDeclaration.Parent.Parent) + return diagnostics.Remove_type_from_import_of_0_from_1.Localize(locale, symbolName, moduleSpec) + } + moduleSpec := getModuleSpecifierText(promotedDeclaration) + return diagnostics.Remove_type_from_import_declaration_from_0.Localize(locale, moduleSpec) default: panic(fmt.Sprintf(`Unexpected fix kind %v`, fix.kind)) } - return nil } -func getModuleSpecifierText(promotedDeclaration *ast.ImportDeclaration) string { +func getNewRequires( + changeTracker *change.Tracker, + moduleSpecifier string, + defaultImport *Import, + namedImports []*Import, + namespaceLikeImport *Import, + compilerOptions *core.CompilerOptions, +) []*ast.Statement { + quotedModuleSpecifier := changeTracker.NodeFactory.NewStringLiteral(moduleSpecifier) + var statements []*ast.Statement + + // const { default: foo, bar, etc } = require('./mod'); + if defaultImport != nil || len(namedImports) > 0 { + bindingElements := []*ast.Node{} + for _, namedImport := range namedImports { + var propertyName *ast.Node + if namedImport.propertyName != "" { + propertyName = changeTracker.NodeFactory.NewIdentifier(namedImport.propertyName) + } + bindingElements = append(bindingElements, changeTracker.NodeFactory.NewBindingElement( + /*dotDotDotToken*/ nil, + propertyName, + changeTracker.NodeFactory.NewIdentifier(namedImport.name), + /*initializer*/ nil, + )) + } + if defaultImport != nil { + bindingElements = append([]*ast.Node{ + changeTracker.NodeFactory.NewBindingElement( + /*dotDotDotToken*/ nil, + changeTracker.NodeFactory.NewIdentifier("default"), + changeTracker.NodeFactory.NewIdentifier(defaultImport.name), + /*initializer*/ nil, + ), + }, bindingElements...) + } + declaration := createConstEqualsRequireDeclaration( + changeTracker, + changeTracker.NodeFactory.NewBindingPattern( + ast.KindObjectBindingPattern, + changeTracker.NodeFactory.NewNodeList(bindingElements), + ), + quotedModuleSpecifier, + ) + statements = append(statements, declaration) + } + + // const foo = require('./mod'); + if namespaceLikeImport != nil { + declaration := createConstEqualsRequireDeclaration( + changeTracker, + changeTracker.NodeFactory.NewIdentifier(namespaceLikeImport.name), + quotedModuleSpecifier, + ) + statements = append(statements, declaration) + } + + debug.AssertIsDefined(statements) + return statements +} + +func createConstEqualsRequireDeclaration(changeTracker *change.Tracker, name *ast.Node, quotedModuleSpecifier *ast.Node) *ast.Statement { + return changeTracker.NodeFactory.NewVariableStatement( + /*modifiers*/ nil, + changeTracker.NodeFactory.NewVariableDeclarationList( + ast.NodeFlagsConst, + changeTracker.NodeFactory.NewNodeList([]*ast.Node{ + changeTracker.NodeFactory.NewVariableDeclaration( + name, + /*exclamationToken*/ nil, + /*type*/ nil, + changeTracker.NodeFactory.NewCallExpression( + changeTracker.NodeFactory.NewIdentifier("require"), + /*questionDotToken*/ nil, + /*typeArguments*/ nil, + changeTracker.NodeFactory.NewNodeList([]*ast.Node{quotedModuleSpecifier}), + ast.NodeFlagsNone, + ), + ), + }), + ), + ) +} + +func getModuleSpecifierText(promotedDeclaration *ast.Node) string { if promotedDeclaration.Kind == ast.KindImportEqualsDeclaration { importEqualsDeclaration := promotedDeclaration.AsImportEqualsDeclaration() if ast.IsExternalModuleReference(importEqualsDeclaration.ModuleReference) { @@ -1488,3 +1639,7 @@ func getModuleSpecifierText(promotedDeclaration *ast.ImportDeclaration) string { } return promotedDeclaration.Parent.ModuleSpecifier().Text() } + +func ptrTo[T any](v T) *T { + return &v +} diff --git a/internal/ls/autoimportsexportinfo.go b/internal/ls/autoimportsexportinfo.go index 65de5e82ad..1ff751d50b 100644 --- a/internal/ls/autoimportsexportinfo.go +++ b/internal/ls/autoimportsexportinfo.go @@ -7,15 +7,16 @@ import ( "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" ) -func (l *LanguageService) getExportInfos( +func (l *LanguageService) getExportInfoMap( ctx context.Context, ch *checker.Checker, importingFile *ast.SourceFile, - preferences *UserPreferences, - exportMapKey ExportInfoMapKey, + exportMapKey lsproto.ExportInfoMapKey, ) []*SymbolExportInfo { expInfoMap := NewExportInfoMap(l.GetProgram().GetGlobalTypingsCacheLocation()) moduleCount := 0 @@ -25,13 +26,12 @@ func (l *LanguageService) getExportInfos( forEachExternalModuleToImportFrom( ch, l.GetProgram(), - preferences, // /*useAutoImportProvider*/ true, func(moduleSymbol *ast.Symbol, moduleFile *ast.SourceFile, ch *checker.Checker, isFromPackageJson bool) { if moduleCount = moduleCount + 1; moduleCount%100 == 0 && ctx.Err() != nil { return } - if moduleFile == nil && moduleSymbol.Name != exportMapKey.AmbientModuleName { + if moduleFile == nil && stringutil.StripQuotes(moduleSymbol.Name) != exportMapKey.AmbientModuleName { return } seenExports := collections.Set[string]{} @@ -80,12 +80,11 @@ func (l *LanguageService) searchExportInfosForCompletions( ctx context.Context, ch *checker.Checker, importingFile *ast.SourceFile, - preferences *UserPreferences, isForImportStatementCompletion bool, isRightOfOpenTag bool, isTypeOnlyLocation bool, lowerCaseTokenText string, - action func([]*SymbolExportInfo, string, bool, ExportInfoMapKey) []*SymbolExportInfo, + action func([]*SymbolExportInfo, string, bool, lsproto.ExportInfoMapKey) []*SymbolExportInfo, ) { symbolNameMatches := map[string]bool{} symbolNameMatch := func(symbolName string) bool { @@ -124,7 +123,6 @@ func (l *LanguageService) searchExportInfosForCompletions( forEachExternalModuleToImportFrom( ch, l.GetProgram(), - preferences, // /*useAutoImportProvider*/ true, func(moduleSymbol *ast.Symbol, moduleFile *ast.SourceFile, ch *checker.Checker, isFromPackageJson bool) { if moduleCount = moduleCount + 1; moduleCount%100 == 0 && ctx.Err() != nil { diff --git a/internal/ls/change/delete.go b/internal/ls/change/delete.go new file mode 100644 index 0000000000..a001cdbcdc --- /dev/null +++ b/internal/ls/change/delete.go @@ -0,0 +1,270 @@ +package change + +import ( + "slices" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/debug" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" +) + +// deleteDeclaration deletes a node with smart handling for different node types. +// This handles special cases like import specifiers in lists, parameters, etc. +func deleteDeclaration(t *Tracker, deletedNodesInLists map[*ast.Node]bool, sourceFile *ast.SourceFile, node *ast.Node) { + switch node.Kind { + case ast.KindParameter: + oldFunction := node.Parent + if oldFunction.Kind == ast.KindArrowFunction && + len(oldFunction.AsArrowFunction().Parameters.Nodes) == 1 && + astnav.FindChildOfKind(oldFunction, ast.KindOpenParenToken, sourceFile) == nil { + // Lambdas with exactly one parameter are special because, after removal, there + // must be an empty parameter list (i.e. `()`) and this won't necessarily be the + // case if the parameter is simply removed (e.g. in `x => 1`). + t.ReplaceRangeWithText(sourceFile, t.getAdjustedRange(sourceFile, node, node, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude), "()") + } else { + deleteNodeInList(t, deletedNodesInLists, sourceFile, node) + } + + case ast.KindImportDeclaration, ast.KindImportEqualsDeclaration: + imports := sourceFile.Imports() + isFirstImport := len(imports) > 0 && node == imports[0].Parent || + node == core.Find(sourceFile.Statements.Nodes, func(s *ast.Node) bool { return ast.IsAnyImportSyntax(s) }) + // For first import, leave header comment in place, otherwise only delete JSDoc comments + leadingTrivia := LeadingTriviaOptionStartLine + if isFirstImport { + leadingTrivia = LeadingTriviaOptionExclude + } else if hasJSDocNodes(node) { + leadingTrivia = LeadingTriviaOptionJSDoc + } + deleteNode(t, sourceFile, node, leadingTrivia, TrailingTriviaOptionInclude) + + case ast.KindBindingElement: + pattern := node.Parent + preserveComma := pattern.Kind == ast.KindArrayBindingPattern && + node != pattern.AsBindingPattern().Elements.Nodes[len(pattern.AsBindingPattern().Elements.Nodes)-1] + if preserveComma { + deleteNode(t, sourceFile, node, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionExclude) + } else { + deleteNodeInList(t, deletedNodesInLists, sourceFile, node) + } + + case ast.KindVariableDeclaration: + deleteVariableDeclaration(t, deletedNodesInLists, sourceFile, node) + + case ast.KindTypeParameter: + deleteNodeInList(t, deletedNodesInLists, sourceFile, node) + + case ast.KindImportSpecifier: + namedImports := node.Parent + if len(namedImports.AsNamedImports().Elements.Nodes) == 1 { + deleteImportBinding(t, sourceFile, namedImports) + } else { + deleteNodeInList(t, deletedNodesInLists, sourceFile, node) + } + + case ast.KindNamespaceImport: + deleteImportBinding(t, sourceFile, node) + + case ast.KindSemicolonToken: + deleteNode(t, sourceFile, node, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionExclude) + + case ast.KindTypeKeyword: + // For type keyword in import clauses, we need to delete the keyword and any trailing space + // The trailing space is part of the next token's leading trivia, so we include it + deleteNode(t, sourceFile, node, LeadingTriviaOptionExclude, TrailingTriviaOptionInclude) + + case ast.KindFunctionKeyword: + deleteNode(t, sourceFile, node, LeadingTriviaOptionExclude, TrailingTriviaOptionInclude) + + case ast.KindClassDeclaration, ast.KindFunctionDeclaration: + leadingTrivia := LeadingTriviaOptionStartLine + if hasJSDocNodes(node) { + leadingTrivia = LeadingTriviaOptionJSDoc + } + deleteNode(t, sourceFile, node, leadingTrivia, TrailingTriviaOptionInclude) + + default: + if node.Parent == nil { + // a misbehaving client can reach here with the SourceFile node + deleteNode(t, sourceFile, node, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + } else if node.Parent.Kind == ast.KindImportClause && node.Parent.AsImportClause().Name() == node { + deleteDefaultImport(t, sourceFile, node.Parent) + } else if node.Parent.Kind == ast.KindCallExpression && slices.Contains(node.Parent.AsCallExpression().Arguments.Nodes, node) { + deleteNodeInList(t, deletedNodesInLists, sourceFile, node) + } else { + deleteNode(t, sourceFile, node, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + } + } +} + +func deleteDefaultImport(t *Tracker, sourceFile *ast.SourceFile, importClause *ast.Node) { + clause := importClause.AsImportClause() + if clause.NamedBindings == nil { + // Delete the whole import + deleteNode(t, sourceFile, importClause.Parent, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + } else { + // import |d,| * as ns from './file' + name := clause.Name() + start := astnav.GetStartOfNode(name, sourceFile, false) + nextToken := astnav.GetTokenAtPosition(sourceFile, name.End()) + if nextToken != nil && nextToken.Kind == ast.KindCommaToken { + // shift first non-whitespace position after comma to the start position of the node + end := scanner.SkipTriviaEx(sourceFile.Text(), nextToken.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: false, StopAtComments: true}) + startPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(start)) + endPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(end)) + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: startPos, End: endPos}, "") + } else { + deleteNode(t, sourceFile, name, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + } + } +} + +func deleteImportBinding(t *Tracker, sourceFile *ast.SourceFile, node *ast.Node) { + importClause := node.Parent.AsImportClause() + if importClause.Name() != nil { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + previousToken := astnav.GetTokenAtPosition(sourceFile, node.Pos()-1) + debug.Assert(previousToken != nil, "previousToken should not be nil") + startPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(astnav.GetStartOfNode(previousToken, sourceFile, false))) + endPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(node.End())) + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: startPos, End: endPos}, "") + } else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + importDecl := ast.FindAncestorKind(node, ast.KindImportDeclaration) + debug.Assert(importDecl != nil, "importDecl should not be nil") + deleteNode(t, sourceFile, importDecl, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + } +} + +func deleteVariableDeclaration(t *Tracker, deletedNodesInLists map[*ast.Node]bool, sourceFile *ast.SourceFile, node *ast.Node) { + parent := node.Parent + + if parent.Kind == ast.KindCatchClause { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + openParen := astnav.FindChildOfKind(parent, ast.KindOpenParenToken, sourceFile) + closeParen := astnav.FindChildOfKind(parent, ast.KindCloseParenToken, sourceFile) + debug.Assert(openParen != nil && closeParen != nil, "catch clause should have parens") + t.DeleteNodeRange(sourceFile, openParen, closeParen, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + return + } + + if len(parent.AsVariableDeclarationList().Declarations.Nodes) != 1 { + deleteNodeInList(t, deletedNodesInLists, sourceFile, node) + return + } + + gp := parent.Parent + switch gp.Kind { + case ast.KindForOfStatement, ast.KindForInStatement: + t.ReplaceNode(sourceFile, node, t.NodeFactory.NewObjectLiteralExpression(t.NodeFactory.NewNodeList([]*ast.Node{}), false), nil) + + case ast.KindForStatement: + deleteNode(t, sourceFile, parent, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + + case ast.KindVariableStatement: + leadingTrivia := LeadingTriviaOptionStartLine + if hasJSDocNodes(gp) { + leadingTrivia = LeadingTriviaOptionJSDoc + } + deleteNode(t, sourceFile, gp, leadingTrivia, TrailingTriviaOptionInclude) + + default: + debug.Fail("Unexpected grandparent kind: " + gp.Kind.String()) + } +} + +// deleteNode deletes a node with the specified trivia options. +// Warning: This deletes comments too. +func deleteNode(t *Tracker, sourceFile *ast.SourceFile, node *ast.Node, leadingTrivia LeadingTriviaOption, trailingTrivia TrailingTriviaOption) { + startPosition := t.getAdjustedStartPosition(sourceFile, node, leadingTrivia, false) + endPosition := t.getAdjustedEndPosition(sourceFile, node, trailingTrivia) + startPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(startPosition)) + endPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(endPosition)) + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: startPos, End: endPos}, "") +} + +func deleteNodeInList(t *Tracker, deletedNodesInLists map[*ast.Node]bool, sourceFile *ast.SourceFile, node *ast.Node) { + containingList := format.GetContainingList(node, sourceFile) + debug.Assert(containingList != nil, "containingList should not be nil") + index := slices.Index(containingList.Nodes, node) + debug.Assert(index != -1, "node should be in containing list") + + if len(containingList.Nodes) == 1 { + deleteNode(t, sourceFile, node, LeadingTriviaOptionIncludeAll, TrailingTriviaOptionInclude) + return + } + + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by finishTrailingCommaAfterDeletingNodesInList. + debug.Assert(!deletedNodesInLists[node], "Deleting a node twice") + deletedNodesInLists[node] = true + + startPos := t.startPositionToDeleteNodeInList(sourceFile, node) + var endPos int + if index == len(containingList.Nodes)-1 { + endPos = t.getAdjustedEndPosition(sourceFile, node, TrailingTriviaOptionInclude) + } else { + prevNode := (*ast.Node)(nil) + if index > 0 { + prevNode = containingList.Nodes[index-1] + } + endPos = t.endPositionToDeleteNodeInList(sourceFile, node, prevNode, containingList.Nodes[index+1]) + } + + startLSPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(startPos)) + endLSPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(endPos)) + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: startLSPos, End: endLSPos}, "") +} + +// startPositionToDeleteNodeInList finds the first non-whitespace position in the leading trivia of the node +func (t *Tracker) startPositionToDeleteNodeInList(sourceFile *ast.SourceFile, node *ast.Node) int { + start := t.getAdjustedStartPosition(sourceFile, node, LeadingTriviaOptionIncludeAll, false) + return scanner.SkipTriviaEx(sourceFile.Text(), start, &scanner.SkipTriviaOptions{StopAfterLineBreak: false, StopAtComments: true}) +} + +func (t *Tracker) endPositionToDeleteNodeInList(sourceFile *ast.SourceFile, node *ast.Node, prevNode *ast.Node, nextNode *ast.Node) int { + end := t.startPositionToDeleteNodeInList(sourceFile, nextNode) + if prevNode == nil || positionsAreOnSameLine(t.getAdjustedEndPosition(sourceFile, node, TrailingTriviaOptionInclude), end, sourceFile) { + return end + } + token := astnav.FindPrecedingToken(sourceFile, astnav.GetStartOfNode(nextNode, sourceFile, false)) + if isSeparator(node, token) { + prevToken := astnav.FindPrecedingToken(sourceFile, astnav.GetStartOfNode(node, sourceFile, false)) + if isSeparator(prevNode, prevToken) { + pos := scanner.SkipTriviaEx(sourceFile.Text(), token.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: true}) + if positionsAreOnSameLine(astnav.GetStartOfNode(prevToken, sourceFile, false), astnav.GetStartOfNode(token, sourceFile, false), sourceFile) { + if pos > 0 && stringutil.IsLineBreak(rune(sourceFile.Text()[pos-1])) { + return pos - 1 + } + return pos + } + if stringutil.IsLineBreak(rune(sourceFile.Text()[pos])) { + return pos + } + } + } + return end +} + +func positionsAreOnSameLine(pos1, pos2 int, sourceFile *ast.SourceFile) bool { + return format.GetLineStartPositionForPosition(pos1, sourceFile) == format.GetLineStartPositionForPosition(pos2, sourceFile) +} + +// hasJSDocNodes checks if a node has JSDoc comments +func hasJSDocNodes(node *ast.Node) bool { + if node == nil { + return false + } + // nil is ok for JSDoc - it will return empty slice if not available + jsdocs := node.JSDoc(nil) + return len(jsdocs) > 0 +} diff --git a/internal/ls/change/tracker.go b/internal/ls/change/tracker.go new file mode 100644 index 0000000000..28c5c65205 --- /dev/null +++ b/internal/ls/change/tracker.go @@ -0,0 +1,486 @@ +package change + +import ( + "context" + "slices" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/printer" + "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" +) + +type NodeOptions struct { + // Text to be inserted before the new node + Prefix string + + // Text to be inserted after the new node + Suffix string + + // Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node + indentation *int + + // Text of inserted node will be formatted with this delta, otherwise delta will be inferred from the new node kind + delta *int + + LeadingTriviaOption + TrailingTriviaOption + joiner string +} + +type LeadingTriviaOption int + +const ( + LeadingTriviaOptionNone LeadingTriviaOption = 0 + LeadingTriviaOptionExclude LeadingTriviaOption = 1 + LeadingTriviaOptionIncludeAll LeadingTriviaOption = 2 + LeadingTriviaOptionJSDoc LeadingTriviaOption = 3 + LeadingTriviaOptionStartLine LeadingTriviaOption = 4 +) + +type TrailingTriviaOption int + +const ( + TrailingTriviaOptionNone TrailingTriviaOption = 0 + TrailingTriviaOptionExclude TrailingTriviaOption = 1 + TrailingTriviaOptionExcludeWhitespace TrailingTriviaOption = 2 + TrailingTriviaOptionInclude TrailingTriviaOption = 3 +) + +type trackerEditKind int + +const ( + trackerEditKindText trackerEditKind = 1 + trackerEditKindRemove trackerEditKind = 2 + trackerEditKindReplaceWithSingleNode trackerEditKind = 3 + trackerEditKindReplaceWithMultipleNodes trackerEditKind = 4 +) + +type trackerEdit struct { + kind trackerEditKind + lsproto.Range + + NewText string // kind == text + + *ast.Node // single + nodes []*ast.Node // multiple + options NodeOptions +} + +type Tracker struct { + // initialized with + formatSettings *format.FormatCodeSettings + newLine string + converters *lsconv.Converters + ctx context.Context + *printer.EmitContext + + *ast.NodeFactory + changes *collections.MultiMap[*ast.SourceFile, *trackerEdit] + deletedNodes []deletedNode + + // created during call to getChanges + writer *printer.ChangeTrackerWriter + // printer +} + +type deletedNode struct { + sourceFile *ast.SourceFile + node *ast.Node +} + +func NewTracker(ctx context.Context, compilerOptions *core.CompilerOptions, formatOptions *format.FormatCodeSettings, converters *lsconv.Converters) *Tracker { + emitContext := printer.NewEmitContext() + newLine := compilerOptions.NewLine.GetNewLineCharacter() + ctx = format.WithFormatCodeSettings(ctx, formatOptions, newLine) // !!! formatSettings in context? + return &Tracker{ + EmitContext: emitContext, + NodeFactory: &emitContext.Factory.NodeFactory, + changes: &collections.MultiMap[*ast.SourceFile, *trackerEdit]{}, + ctx: ctx, + converters: converters, + formatSettings: formatOptions, + newLine: newLine, + } +} + +// GetChanges returns the accumulated text edits. +// Note: after calling this, the Tracker object must be discarded! +func (t *Tracker) GetChanges() map[string][]*lsproto.TextEdit { + t.finishDeleteDeclarations() + // !!! finishClassesWithNodesInsertedAtStart + changes := t.getTextChangesFromChanges() + // !!! changes for new files + return changes +} + +func (t *Tracker) ReplaceNode(sourceFile *ast.SourceFile, oldNode *ast.Node, newNode *ast.Node, options *NodeOptions) { + if options == nil { + // defaults to `useNonAdjustedPositions` + options = &NodeOptions{ + LeadingTriviaOption: LeadingTriviaOptionExclude, + TrailingTriviaOption: TrailingTriviaOptionExclude, + } + } + t.ReplaceRange(sourceFile, t.getAdjustedRange(sourceFile, oldNode, oldNode, options.LeadingTriviaOption, options.TrailingTriviaOption), newNode, *options) +} + +func (t *Tracker) ReplaceRange(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNode *ast.Node, options NodeOptions) { + t.changes.Add(sourceFile, &trackerEdit{kind: trackerEditKindReplaceWithSingleNode, Range: lsprotoRange, options: options, Node: newNode}) +} + +func (t *Tracker) ReplaceRangeWithText(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, text string) { + t.changes.Add(sourceFile, &trackerEdit{kind: trackerEditKindText, Range: lsprotoRange, NewText: text}) +} + +func (t *Tracker) ReplaceRangeWithNodes(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNodes []*ast.Node, options NodeOptions) { + if len(newNodes) == 1 { + t.ReplaceRange(sourceFile, lsprotoRange, newNodes[0], options) + return + } + t.changes.Add(sourceFile, &trackerEdit{kind: trackerEditKindReplaceWithMultipleNodes, Range: lsprotoRange, nodes: newNodes, options: options}) +} + +func (t *Tracker) InsertText(sourceFile *ast.SourceFile, pos lsproto.Position, text string) { + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: pos, End: pos}, text) +} + +func (t *Tracker) InsertNodeAt(sourceFile *ast.SourceFile, pos core.TextPos, newNode *ast.Node, options NodeOptions) { + lsPos := t.converters.PositionToLineAndCharacter(sourceFile, pos) + t.ReplaceRange(sourceFile, lsproto.Range{Start: lsPos, End: lsPos}, newNode, options) +} + +func (t *Tracker) InsertNodesAt(sourceFile *ast.SourceFile, pos core.TextPos, newNodes []*ast.Node, options NodeOptions) { + lsPos := t.converters.PositionToLineAndCharacter(sourceFile, pos) + t.ReplaceRangeWithNodes(sourceFile, lsproto.Range{Start: lsPos, End: lsPos}, newNodes, options) +} + +func (t *Tracker) InsertNodeAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node) { + endPosition := t.endPosForInsertNodeAfter(sourceFile, after, newNode) + t.InsertNodeAt(sourceFile, endPosition, newNode, t.getInsertNodeAfterOptions(sourceFile, after)) +} + +func (t *Tracker) InsertNodesAfter(sourceFile *ast.SourceFile, after *ast.Node, newNodes []*ast.Node) { + endPosition := t.endPosForInsertNodeAfter(sourceFile, after, newNodes[0]) + t.InsertNodesAt(sourceFile, endPosition, newNodes, t.getInsertNodeAfterOptions(sourceFile, after)) +} + +func (t *Tracker) InsertNodeBefore(sourceFile *ast.SourceFile, before *ast.Node, newNode *ast.Node, blankLineBetween bool) { + t.InsertNodeAt(sourceFile, core.TextPos(t.getAdjustedStartPosition(sourceFile, before, LeadingTriviaOptionNone, false)), newNode, t.getOptionsForInsertNodeBefore(before, newNode, blankLineBetween)) +} + +// InsertModifierBefore inserts a modifier token (like 'type') before a node with a trailing space. +func (t *Tracker) InsertModifierBefore(sourceFile *ast.SourceFile, modifier ast.Kind, before *ast.Node) { + pos := astnav.GetStartOfNode(before, sourceFile, false) + token := sourceFile.GetOrCreateToken(modifier, pos, pos, before.Parent) + t.InsertNodeAt(sourceFile, core.TextPos(pos), token, NodeOptions{Suffix: " "}) +} + +// Delete queues a node for deletion with smart handling of list items, imports, etc. +// The actual deletion happens in finishDeleteDeclarations during GetChanges. +func (t *Tracker) Delete(sourceFile *ast.SourceFile, node *ast.Node) { + t.deletedNodes = append(t.deletedNodes, deletedNode{sourceFile: sourceFile, node: node}) +} + +// DeleteRange deletes a text range from the source file. +func (t *Tracker) DeleteRange(sourceFile *ast.SourceFile, textRange core.TextRange) { + lspRange := t.converters.ToLSPRange(sourceFile, textRange) + t.ReplaceRangeWithText(sourceFile, lspRange, "") +} + +// DeleteNode deletes a node immediately with specified trivia options. +// Stop! Consider using Delete instead, which has logic for deleting nodes from delimited lists. +func (t *Tracker) DeleteNode(sourceFile *ast.SourceFile, node *ast.Node, leadingTrivia LeadingTriviaOption, trailingTrivia TrailingTriviaOption) { + rng := t.getAdjustedRange(sourceFile, node, node, leadingTrivia, trailingTrivia) + t.ReplaceRangeWithText(sourceFile, rng, "") +} + +// DeleteNodeRange deletes a range of nodes with specified trivia options. +func (t *Tracker) DeleteNodeRange(sourceFile *ast.SourceFile, startNode *ast.Node, endNode *ast.Node, leadingTrivia LeadingTriviaOption, trailingTrivia TrailingTriviaOption) { + startPosition := t.getAdjustedStartPosition(sourceFile, startNode, leadingTrivia, false) + endPosition := t.getAdjustedEndPosition(sourceFile, endNode, trailingTrivia) + startPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(startPosition)) + endPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(endPosition)) + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: startPos, End: endPos}, "") +} + +// finishDeleteDeclarations processes all queued deletions with smart handling for lists and trailing commas. +func (t *Tracker) finishDeleteDeclarations() { + deletedNodesInLists := make(map[*ast.Node]bool) + + for _, deleted := range t.deletedNodes { + // Skip if this node is contained within another deleted node + isContained := false + for _, other := range t.deletedNodes { + if other.sourceFile == deleted.sourceFile && other.node != deleted.node && + rangeContainsRangeExclusive(other.node, deleted.node) { + isContained = true + break + } + } + if isContained { + continue + } + + deleteDeclaration(t, deletedNodesInLists, deleted.sourceFile, deleted.node) + } + + // Handle trailing commas for last elements in lists + for node := range deletedNodesInLists { + sourceFile := ast.GetSourceFileOfNode(node) + list := format.GetContainingList(node, sourceFile) + if list == nil || node != list.Nodes[len(list.Nodes)-1] { + continue + } + + lastNonDeletedIndex := -1 + for i := len(list.Nodes) - 2; i >= 0; i-- { + if !deletedNodesInLists[list.Nodes[i]] { + lastNonDeletedIndex = i + break + } + } + + if lastNonDeletedIndex != -1 { + startPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(list.Nodes[lastNonDeletedIndex].End())) + endPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(t.startPositionToDeleteNodeInList(sourceFile, list.Nodes[lastNonDeletedIndex+1]))) + t.ReplaceRangeWithText(sourceFile, lsproto.Range{Start: startPos, End: endPos}, "") + } + } +} + +func (t *Tracker) endPosForInsertNodeAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node) core.TextPos { + if (needSemicolonBetween(after, newNode)) && (rune(sourceFile.Text()[after.End()-1]) != ';') { + // check if previous statement ends with semicolon + // if not - insert semicolon to preserve the code from changing the meaning due to ASI + endPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(after.End())) + t.ReplaceRange(sourceFile, + lsproto.Range{Start: endPos, End: endPos}, + sourceFile.GetOrCreateToken(ast.KindSemicolonToken, after.End(), after.End(), after.Parent), + NodeOptions{}, + ) + } + return core.TextPos(t.getAdjustedEndPosition(sourceFile, after, TrailingTriviaOptionNone)) +} + +/** +* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, +* i.e. arguments in arguments lists, parameters in parameter lists etc. +* Note that separators are part of the node in statements and class elements. + */ +func (t *Tracker) InsertNodeInListAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node, containingList []*ast.Node) { + if len(containingList) == 0 { + containingList = format.GetContainingList(after, sourceFile).Nodes + } + index := slices.Index(containingList, after) + if index < 0 { + return + } + if index != len(containingList)-1 { + // any element except the last one + // use next sibling as an anchor + if nextToken := astnav.GetTokenAtPosition(sourceFile, after.End()); nextToken != nil && isSeparator(after, nextToken) { + // for list + // a, b, c + // create change for adding 'e' after 'a' as + // - find start of next element after a (it is b) + // - use next element start as start and end position in final change + // - build text of change by formatting the text of node + whitespace trivia of b + + // in multiline case it will work as + // a, + // b, + // c, + // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') + // a, + // insertedtext# + // ###b, + // c, + nextNode := containingList[index+1] + startPos := scanner.SkipTriviaEx(sourceFile.Text(), nextNode.Pos(), &scanner.SkipTriviaOptions{StopAfterLineBreak: false, StopAtComments: true}) + + // write separator and leading trivia of the next element as suffix + suffix := scanner.TokenToString(nextToken.Kind) + sourceFile.Text()[nextToken.End():startPos] + t.InsertNodeAt(sourceFile, core.TextPos(startPos), newNode, NodeOptions{Suffix: suffix}) + } + return + } + + afterStart := astnav.GetStartOfNode(after, sourceFile, false) + afterStartLinePosition := format.GetLineStartPositionForPosition(afterStart, sourceFile) + + // insert element after the last element in the list that has more than one item + // pick the element preceding the after element to: + // - pick the separator + // - determine if list is a multiline + multilineList := false + + // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise + // i.e. var x = 1 // this is x + // | new element will be inserted at this position + separator := ast.KindCommaToken // SyntaxKind.CommaToken | SyntaxKind.SemicolonToken + if len(containingList) != 1 { + // otherwise, if list has more than one element, pick separator from the list + tokenBeforeInsertPosition := astnav.FindPrecedingToken(sourceFile, after.Pos()) + separator = core.IfElse(isSeparator(after, tokenBeforeInsertPosition), tokenBeforeInsertPosition.Kind, ast.KindCommaToken) + // determine if list is multiline by checking lines of after element and element that precedes it. + afterMinusOneStartLinePosition := format.GetLineStartPositionForPosition(astnav.GetStartOfNode(containingList[index-1], sourceFile, false), sourceFile) + multilineList = afterMinusOneStartLinePosition != afterStartLinePosition + } + if hasCommentsBeforeLineBreak(sourceFile.Text(), after.End()) || printer.GetLinesBetweenPositions(sourceFile, containingList[0].Pos(), containingList[len(containingList)-1].End()) != 0 { + // in this case we'll always treat containing list as multiline + multilineList = true + } + + separatorString := scanner.TokenToString(separator) + end := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(after.End())) + if !multilineList { + t.ReplaceRange(sourceFile, lsproto.Range{Start: end, End: end}, newNode, NodeOptions{Prefix: separatorString}) + return + } + + // insert separator immediately following the 'after' node to preserve comments in trailing trivia + // !!! formatcontext + t.ReplaceRange(sourceFile, lsproto.Range{Start: end, End: end}, sourceFile.GetOrCreateToken(separator, after.End(), after.End()+len(separatorString), after.Parent), NodeOptions{}) + // use the same indentation as 'after' item + indentation := format.FindFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, t.formatSettings) + // insert element before the line break on the line that contains 'after' element + insertPos := scanner.SkipTriviaEx(sourceFile.Text(), after.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: false}) + // find position before "\n" or "\r\n" + for insertPos != after.End() && stringutil.IsLineBreak(rune(sourceFile.Text()[insertPos-1])) { + insertPos-- + } + insertLSPos := t.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(insertPos)) + t.ReplaceRange( + sourceFile, + lsproto.Range{Start: insertLSPos, End: insertLSPos}, + newNode, + NodeOptions{ + indentation: ptrTo(indentation), + Prefix: t.newLine, + }, + ) +} + +// InsertImportSpecifierAtIndex inserts a new import specifier at the specified index in a NamedImports list +func (t *Tracker) InsertImportSpecifierAtIndex(sourceFile *ast.SourceFile, newSpecifier *ast.Node, namedImports *ast.Node, index int) { + namedImportsNode := namedImports.AsNamedImports() + elements := namedImportsNode.Elements.Nodes + + if index >= len(elements) { + // Insert at the end (after the last element) + t.InsertNodeInListAfter(sourceFile, elements[len(elements)-1], newSpecifier, elements) + } else if index > 0 { + // Insert after the element at index-1 + t.InsertNodeInListAfter(sourceFile, elements[index-1], newSpecifier, elements) + } else { + // Insert before the first element + firstElement := elements[0] + multiline := printer.GetLinesBetweenPositions(sourceFile, firstElement.Pos(), namedImports.Parent.Parent.Pos()) != 0 + t.InsertNodeBefore(sourceFile, firstElement, newSpecifier, multiline) + } +} + +func (t *Tracker) InsertAtTopOfFile(sourceFile *ast.SourceFile, insert []*ast.Statement, blankLineBetween bool) { + if len(insert) == 0 { + return + } + + pos := t.getInsertionPositionAtSourceFileTop(sourceFile) + options := NodeOptions{} + if pos != 0 { + options.Prefix = t.newLine + } + if len(sourceFile.Text()) == 0 || !stringutil.IsLineBreak(rune(sourceFile.Text()[pos])) { + options.Suffix = t.newLine + } + if blankLineBetween { + options.Suffix += t.newLine + } + + if len(insert) == 1 { + t.InsertNodeAt(sourceFile, core.TextPos(pos), insert[0], options) + } else { + t.InsertNodesAt(sourceFile, core.TextPos(pos), insert, options) + } +} + +func (t *Tracker) getInsertNodeAfterOptions(sourceFile *ast.SourceFile, node *ast.Node) NodeOptions { + newLineChar := t.newLine + var options NodeOptions + switch node.Kind { + case ast.KindParameter: + // default opts + options = NodeOptions{} + case ast.KindClassDeclaration, ast.KindModuleDeclaration: + options = NodeOptions{Prefix: newLineChar, Suffix: newLineChar} + + case ast.KindVariableDeclaration, ast.KindStringLiteral, ast.KindIdentifier: + options = NodeOptions{Prefix: ", "} + + case ast.KindPropertyAssignment: + options = NodeOptions{Suffix: "," + newLineChar} + + case ast.KindExportKeyword: + options = NodeOptions{Prefix: " "} + + default: + if !(ast.IsStatement(node) || ast.IsClassOrTypeElement(node)) { + // Else we haven't handled this kind of node yet -- add it + panic("unimplemented node type " + node.Kind.String() + " in changeTracker.getInsertNodeAfterOptions") + } + options = NodeOptions{Suffix: newLineChar} + } + if node.End() == sourceFile.End() && ast.IsStatement(node) { + options.Prefix = "\n" + options.Prefix + } + + return options +} + +func (t *Tracker) getOptionsForInsertNodeBefore(before *ast.Node, inserted *ast.Node, blankLineBetween bool) NodeOptions { + if ast.IsStatement(before) || ast.IsClassOrTypeElement(before) { + if blankLineBetween { + return NodeOptions{Suffix: t.newLine + t.newLine} + } + return NodeOptions{Suffix: t.newLine} + } else if before.Kind == ast.KindVariableDeclaration { + // insert `x = 1, ` into `const x = 1, y = 2; + return NodeOptions{Suffix: ", "} + } else if before.Kind == ast.KindParameter { + if inserted.Kind == ast.KindParameter { + return NodeOptions{Suffix: ", "} + } + return NodeOptions{} + } else if (before.Kind == ast.KindStringLiteral && before.Parent != nil && before.Parent.Kind == ast.KindImportDeclaration) || before.Kind == ast.KindNamedImports { + return NodeOptions{Suffix: ", "} + } else if before.Kind == ast.KindImportSpecifier { + suffix := "," + if blankLineBetween { + suffix += t.newLine + } else { + suffix += " " + } + return NodeOptions{Suffix: suffix} + } + // We haven't handled this kind of node yet -- add it + panic("unimplemented node type " + before.Kind.String() + " in changeTracker.getOptionsForInsertNodeBefore") +} + +func ptrTo[T any](v T) *T { + return &v +} + +func rangeContainsRangeExclusive(outer *ast.Node, inner *ast.Node) bool { + return outer.Pos() < inner.Pos() && inner.End() < outer.End() +} + +func isSeparator(node *ast.Node, candidate *ast.Node) bool { + return candidate != nil && node.Parent != nil && (candidate.Kind == ast.KindCommaToken || (candidate.Kind == ast.KindSemicolonToken && node.Parent.Kind == ast.KindObjectLiteralExpression)) +} diff --git a/internal/ls/change/trackerimpl.go b/internal/ls/change/trackerimpl.go new file mode 100644 index 0000000000..d39c5422c8 --- /dev/null +++ b/internal/ls/change/trackerimpl.go @@ -0,0 +1,416 @@ +package change + +import ( + "fmt" + "slices" + "strings" + "unicode" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/parser" + "github.com/microsoft/typescript-go/internal/printer" + "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" +) + +func (t *Tracker) getTextChangesFromChanges() map[string][]*lsproto.TextEdit { + changes := map[string][]*lsproto.TextEdit{} + for sourceFile, changesInFile := range t.changes.M { + // order changes by start position + // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. + slices.SortStableFunc(changesInFile, func(a, b *trackerEdit) int { return lsproto.CompareRanges(ptrTo(a.Range), ptrTo(b.Range)) }) + // verify that change intervals do not overlap, except possibly at end points. + for i := range len(changesInFile) - 1 { + if lsproto.ComparePositions(changesInFile[i].Range.End, changesInFile[i+1].Range.Start) > 0 { + // assert change[i].End <= change[i + 1].Start + panic(fmt.Sprintf("changes overlap: %v and %v", changesInFile[i].Range, changesInFile[i+1].Range)) + } + } + + textChanges := core.MapNonNil(changesInFile, func(change *trackerEdit) *lsproto.TextEdit { + // !!! targetSourceFile + + newText := t.computeNewText(change, sourceFile, sourceFile) + // span := createTextSpanFromRange(c.Range) + // !!! + // Filter out redundant changes. + // if (span.length == newText.length && stringContainsAt(targetSourceFile.text, newText, span.start)) { return nil } + + return &lsproto.TextEdit{ + NewText: newText, + Range: change.Range, + } + }) + + if len(textChanges) > 0 { + changes[sourceFile.FileName()] = textChanges + } + } + return changes +} + +func (t *Tracker) computeNewText(change *trackerEdit, targetSourceFile *ast.SourceFile, sourceFile *ast.SourceFile) string { + switch change.kind { + case trackerEditKindRemove: + return "" + case trackerEditKindText: + return change.NewText + } + + pos := int(t.converters.LineAndCharacterToPosition(sourceFile, change.Range.Start)) + formatNode := func(n *ast.Node) string { + return t.getFormattedTextOfNode(n, targetSourceFile, sourceFile, pos, change.options) + } + + var text string + switch change.kind { + + case trackerEditKindReplaceWithMultipleNodes: + if change.options.joiner == "" { + change.options.joiner = t.newLine + } + text = strings.Join(core.Map(change.nodes, func(n *ast.Node) string { return strings.TrimSuffix(formatNode(n), t.newLine) }), change.options.joiner) + case trackerEditKindReplaceWithSingleNode: + text = formatNode(change.Node) + default: + panic(fmt.Sprintf("change kind %d should have been handled earlier", change.kind)) + } + // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line + noIndent := text + if !(change.options.indentation != nil && *change.options.indentation != 0 || format.GetLineStartPositionForPosition(pos, targetSourceFile) == pos) { + noIndent = strings.TrimLeftFunc(text, unicode.IsSpace) + } + return change.options.Prefix + noIndent + core.IfElse(strings.HasSuffix(noIndent, change.options.Suffix), "", change.options.Suffix) +} + +/** Note: this may mutate `nodeIn`. */ +func (t *Tracker) getFormattedTextOfNode(nodeIn *ast.Node, targetSourceFile *ast.SourceFile, sourceFile *ast.SourceFile, pos int, options NodeOptions) string { + text, sourceFileLike := t.getNonformattedText(nodeIn, targetSourceFile) + // !!! if (validate) validate(node, text); + formatOptions := getFormatCodeSettingsForWriting(t.formatSettings, targetSourceFile) + + var initialIndentation, delta int + if options.indentation == nil { + // !!! indentation for position + // initialIndentation = format.GetIndentationForPos(pos, sourceFile, formatOptions, options.prefix == ct.newLine || scanner.GetLineStartPositionForPosition(pos, targetFileLineMap) == pos); + } else { + initialIndentation = *options.indentation + } + + if options.delta != nil { + delta = *options.delta + } else if formatOptions.IndentSize != 0 && format.ShouldIndentChildNode(formatOptions, nodeIn, nil, nil) { + delta = formatOptions.IndentSize + } + + changes := format.FormatNodeGivenIndentation(t.ctx, sourceFileLike, sourceFileLike.AsSourceFile(), targetSourceFile.LanguageVariant, initialIndentation, delta) + return core.ApplyBulkEdits(text, changes) +} + +func getFormatCodeSettingsForWriting(options *format.FormatCodeSettings, sourceFile *ast.SourceFile) *format.FormatCodeSettings { + shouldAutoDetectSemicolonPreference := options.Semicolons == format.SemicolonPreferenceIgnore + shouldRemoveSemicolons := options.Semicolons == format.SemicolonPreferenceRemove || shouldAutoDetectSemicolonPreference && !lsutil.ProbablyUsesSemicolons(sourceFile) + if shouldRemoveSemicolons { + options.Semicolons = format.SemicolonPreferenceRemove + } + + return options +} + +func (t *Tracker) getNonformattedText(node *ast.Node, sourceFile *ast.SourceFile) (string, *ast.Node) { + nodeIn := node + eofToken := t.Factory.NewToken(ast.KindEndOfFile) + if ast.IsStatement(node) { + nodeIn = t.Factory.NewSourceFile( + ast.SourceFileParseOptions{FileName: sourceFile.FileName(), Path: sourceFile.Path()}, + "", + t.Factory.NewNodeList([]*ast.Node{node}), + t.Factory.NewToken(ast.KindEndOfFile), + ) + } + writer := printer.NewChangeTrackerWriter(t.newLine) + printer.NewPrinter( + printer.PrinterOptions{ + NewLine: core.GetNewLineKind(t.newLine), + NeverAsciiEscape: true, + PreserveSourceNewlines: true, + TerminateUnterminatedLiterals: true, + }, + writer.GetPrintHandlers(), + t.EmitContext, + ).Write(nodeIn, sourceFile, writer, nil) + + text := writer.String() + text = strings.TrimSuffix(text, t.newLine) // Newline artifact from printing a SourceFile instead of a node + + nodeOut := writer.AssignPositionsToNode(nodeIn, t.NodeFactory) + var sourceFileLike *ast.Node + if !ast.IsStatement(node) { + nodeList := t.Factory.NewNodeList([]*ast.Node{nodeOut}) + nodeList.Loc = nodeOut.Loc + eofToken.Loc = core.NewTextRange(nodeOut.End(), nodeOut.End()) + sourceFileLike = t.Factory.NewSourceFile( + ast.SourceFileParseOptions{FileName: sourceFile.FileName(), Path: sourceFile.Path()}, + text, + nodeList, + eofToken, + ) + sourceFileLike.ForEachChild(func(child *ast.Node) bool { + child.Parent = sourceFileLike + return true + }) + sourceFileLike.Loc = nodeOut.Loc + } else { + sourceFileLike = nodeOut + } + return text, sourceFileLike +} + +// method on the changeTracker because use of converters +func (t *Tracker) getAdjustedRange(sourceFile *ast.SourceFile, startNode *ast.Node, endNode *ast.Node, leadingOption LeadingTriviaOption, trailingOption TrailingTriviaOption) lsproto.Range { + return t.converters.ToLSPRange( + sourceFile, + core.NewTextRange( + t.getAdjustedStartPosition(sourceFile, startNode, leadingOption, false), + t.getAdjustedEndPosition(sourceFile, endNode, trailingOption), + ), + ) +} + +// method on the changeTracker because use of converters +func (t *Tracker) getAdjustedStartPosition(sourceFile *ast.SourceFile, node *ast.Node, leadingOption LeadingTriviaOption, hasTrailingComment bool) int { + if leadingOption == LeadingTriviaOptionJSDoc { + if JSDocComments := parser.GetJSDocCommentRanges(t.NodeFactory, nil, node, sourceFile.Text()); len(JSDocComments) > 0 { + return format.GetLineStartPositionForPosition(JSDocComments[0].Pos(), sourceFile) + } + } + + start := astnav.GetStartOfNode(node, sourceFile, false) + startOfLinePos := format.GetLineStartPositionForPosition(start, sourceFile) + + switch leadingOption { + case LeadingTriviaOptionExclude: + return start + case LeadingTriviaOptionStartLine: + if node.Loc.ContainsInclusive(startOfLinePos) { + return startOfLinePos + } + return start + } + + fullStart := node.Pos() + if fullStart == start { + return start + } + lineStarts := sourceFile.ECMALineMap() + fullStartLineIndex := scanner.ComputeLineOfPosition(lineStarts, fullStart) + fullStartLinePos := int(lineStarts[fullStartLineIndex]) + if startOfLinePos == fullStartLinePos { + // full start and start of the node are on the same line + // a, b; + // ^ ^ + // | start + // fullstart + // when b is replaced - we usually want to keep the leading trvia + // when b is deleted - we delete it + if leadingOption == LeadingTriviaOptionIncludeAll { + return fullStart + } + return start + } + + // if node has a trailing comments, use comment end position as the text has already been included. + if hasTrailingComment { + // Check first for leading comments as if the node is the first import, we want to exclude the trivia; + // otherwise we get the trailing comments. + comments := slices.Collect(scanner.GetLeadingCommentRanges(t.NodeFactory, sourceFile.Text(), fullStart)) + if len(comments) == 0 { + comments = slices.Collect(scanner.GetTrailingCommentRanges(t.NodeFactory, sourceFile.Text(), fullStart)) + } + if len(comments) > 0 { + return scanner.SkipTriviaEx(sourceFile.Text(), comments[0].End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: true}) + } + } + + // get start position of the line following the line that contains fullstart position + // (but only if the fullstart isn't the very beginning of the file) + nextLineStart := core.IfElse(fullStart > 0, 1, 0) + adjustedStartPosition := int(lineStarts[fullStartLineIndex+nextLineStart]) + // skip whitespaces/newlines + adjustedStartPosition = scanner.SkipTriviaEx(sourceFile.Text(), adjustedStartPosition, &scanner.SkipTriviaOptions{StopAtComments: true}) + return int(lineStarts[scanner.ComputeLineOfPosition(lineStarts, adjustedStartPosition)]) +} + +// method on the changeTracker because of converters +// Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; +func (t *Tracker) getEndPositionOfMultilineTrailingComment(sourceFile *ast.SourceFile, node *ast.Node, trailingOpt TrailingTriviaOption) int { + if trailingOpt == TrailingTriviaOptionInclude { + // If the trailing comment is a multiline comment that extends to the next lines, + // return the end of the comment and track it for the next nodes to adjust. + lineStarts := sourceFile.ECMALineMap() + nodeEndLine := scanner.ComputeLineOfPosition(lineStarts, node.End()) + for comment := range scanner.GetTrailingCommentRanges(t.NodeFactory, sourceFile.Text(), node.End()) { + // Single line can break the loop as trivia will only be this line. + // Comments on subsequest lines are also ignored. + if comment.Kind == ast.KindSingleLineCommentTrivia || scanner.ComputeLineOfPosition(lineStarts, comment.Pos()) > nodeEndLine { + break + } + + // Get the end line of the comment and compare against the end line of the node. + // If the comment end line position and the multiline comment extends to multiple lines, + // then is safe to return the end position. + if commentEndLine := scanner.ComputeLineOfPosition(lineStarts, comment.End()); commentEndLine > nodeEndLine { + return scanner.SkipTriviaEx(sourceFile.Text(), comment.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: true}) + } + } + } + + return 0 +} + +// method on the changeTracker because of converters +func (t *Tracker) getAdjustedEndPosition(sourceFile *ast.SourceFile, node *ast.Node, TrailingTriviaOption TrailingTriviaOption) int { + if TrailingTriviaOption == TrailingTriviaOptionExclude { + return node.End() + } + if TrailingTriviaOption == TrailingTriviaOptionExcludeWhitespace { + if comments := slices.AppendSeq( + slices.Collect(scanner.GetTrailingCommentRanges(t.NodeFactory, sourceFile.Text(), node.End())), + scanner.GetLeadingCommentRanges(t.NodeFactory, sourceFile.Text(), node.End()), + ); len(comments) > 0 { + if realEnd := comments[len(comments)-1].End(); realEnd != 0 { + return realEnd + } + } + return node.End() + } + + if multilineEndPosition := t.getEndPositionOfMultilineTrailingComment(sourceFile, node, TrailingTriviaOption); multilineEndPosition != 0 { + return multilineEndPosition + } + + newEnd := scanner.SkipTriviaEx(sourceFile.Text(), node.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true}) + + if newEnd != node.End() && (TrailingTriviaOption == TrailingTriviaOptionInclude || stringutil.IsLineBreak(rune(sourceFile.Text()[newEnd-1]))) { + return newEnd + } + return node.End() +} + +// ============= utilities ============= + +func hasCommentsBeforeLineBreak(text string, start int) bool { + for _, ch := range []rune(text[start:]) { + if !stringutil.IsWhiteSpaceSingleLine(ch) { + return ch == '/' + } + } + return false +} + +func needSemicolonBetween(a, b *ast.Node) bool { + return (ast.IsPropertySignatureDeclaration(a) || ast.IsPropertyDeclaration(a)) && + ast.IsClassOrTypeElement(b) && + b.Name().Kind == ast.KindComputedPropertyName || + ast.IsStatementButNotDeclaration(a) && + ast.IsStatementButNotDeclaration(b) // TODO: only if b would start with a `(` or `[` +} + +func (t *Tracker) getInsertionPositionAtSourceFileTop(sourceFile *ast.SourceFile) int { + var lastPrologue *ast.Node + for _, node := range sourceFile.Statements.Nodes { + if ast.IsPrologueDirective(node) { + lastPrologue = node + } else { + break + } + } + + position := 0 + text := sourceFile.Text() + advancePastLineBreak := func() { + if position >= len(text) { + return + } + if char := rune(text[position]); stringutil.IsLineBreak(char) { + position++ + if position < len(text) && char == '\r' && rune(text[position]) == '\n' { + position++ + } + } + } + if lastPrologue != nil { + position = lastPrologue.End() + advancePastLineBreak() + return position + } + + shebang := scanner.GetShebang(text) + if shebang != "" { + position = len(shebang) + advancePastLineBreak() + } + + ranges := slices.Collect(scanner.GetLeadingCommentRanges(t.NodeFactory, text, position)) + if len(ranges) == 0 { + return position + } + // Find the first attached comment to the first node and add before it + var lastComment *ast.CommentRange + pinnedOrTripleSlash := false + firstNodeLine := -1 + + lenStatements := len(sourceFile.Statements.Nodes) + lineMap := sourceFile.ECMALineMap() + for _, r := range ranges { + if r.Kind == ast.KindMultiLineCommentTrivia { + if printer.IsPinnedComment(text, r) { + lastComment = &r + pinnedOrTripleSlash = true + continue + } + } else if printer.IsRecognizedTripleSlashComment(text, r) { + lastComment = &r + pinnedOrTripleSlash = true + continue + } + + if lastComment != nil { + // Always insert after pinned or triple slash comments + if pinnedOrTripleSlash { + break + } + + // There was a blank line between the last comment and this comment. + // This comment is not part of the copyright comments + commentLine := scanner.ComputeLineOfPosition(lineMap, r.Pos()) + lastCommentEndLine := scanner.ComputeLineOfPosition(lineMap, lastComment.End()) + if commentLine >= lastCommentEndLine+2 { + break + } + } + + if lenStatements > 0 { + if firstNodeLine == -1 { + firstNodeLine = scanner.ComputeLineOfPosition(lineMap, astnav.GetStartOfNode(sourceFile.Statements.Nodes[0], sourceFile, false)) + } + commentEndLine := scanner.ComputeLineOfPosition(lineMap, r.End()) + if firstNodeLine < commentEndLine+2 { + break + } + } + lastComment = &r + pinnedOrTripleSlash = false + } + + if lastComment != nil { + position = lastComment.End() + advancePastLineBreak() + } + return position +} diff --git a/internal/ls/changetracker.go b/internal/ls/changetracker.go deleted file mode 100644 index 34397aa546..0000000000 --- a/internal/ls/changetracker.go +++ /dev/null @@ -1,336 +0,0 @@ -package ls - -import ( - "context" - "slices" - - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/astnav" - "github.com/microsoft/typescript-go/internal/collections" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/format" - "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/printer" - "github.com/microsoft/typescript-go/internal/scanner" - "github.com/microsoft/typescript-go/internal/stringutil" -) - -type changeNodeOptions struct { - // Text to be inserted before the new node - prefix string - - // Text to be inserted after the new node - suffix string - - // Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node - indentation *int - - // Text of inserted node will be formatted with this delta, otherwise delta will be inferred from the new node kind - delta *int - - leadingTriviaOption - trailingTriviaOption - joiner string -} - -type leadingTriviaOption int - -const ( - leadingTriviaOptionNone leadingTriviaOption = 0 - leadingTriviaOptionExclude leadingTriviaOption = 1 - leadingTriviaOptionIncludeAll leadingTriviaOption = 2 - leadingTriviaOptionJSDoc leadingTriviaOption = 3 - leadingTriviaOptionStartLine leadingTriviaOption = 4 -) - -type trailingTriviaOption int - -const ( - trailingTriviaOptionNone trailingTriviaOption = 0 - trailingTriviaOptionExclude trailingTriviaOption = 1 - trailingTriviaOptionExcludeWhitespace trailingTriviaOption = 2 - trailingTriviaOptionInclude trailingTriviaOption = 3 -) - -type trackerEditKind int - -const ( - trackerEditKindText trackerEditKind = 1 - trackerEditKindRemove trackerEditKind = 2 - trackerEditKindReplaceWithSingleNode trackerEditKind = 3 - trackerEditKindReplaceWithMultipleNodes trackerEditKind = 4 -) - -type trackerEdit struct { - kind trackerEditKind - lsproto.Range - - NewText string // kind == text - - *ast.Node // single - nodes []*ast.Node // multiple - options changeNodeOptions -} - -type changeTracker struct { - // initialized with - formatSettings *format.FormatCodeSettings - newLine string - ls *LanguageService - ctx context.Context - *printer.EmitContext - - *ast.NodeFactory - changes *collections.MultiMap[*ast.SourceFile, *trackerEdit] - - // created during call to getChanges - writer *printer.ChangeTrackerWriter - // printer -} - -func (ls *LanguageService) newChangeTracker(ctx context.Context) *changeTracker { - emitContext := printer.NewEmitContext() - newLine := ls.GetProgram().Options().NewLine.GetNewLineCharacter() - formatCodeSettings := format.GetDefaultFormatCodeSettings(newLine) // !!! format.GetFormatCodeSettingsFromContext(ctx), - ctx = format.WithFormatCodeSettings(ctx, formatCodeSettings, newLine) - return &changeTracker{ - ls: ls, - EmitContext: emitContext, - NodeFactory: &emitContext.Factory.NodeFactory, - changes: &collections.MultiMap[*ast.SourceFile, *trackerEdit]{}, - ctx: ctx, - formatSettings: formatCodeSettings, - newLine: newLine, - } -} - -// !!! address strada note -// - Note: after calling this, the TextChanges object must be discarded! -func (ct *changeTracker) getChanges() map[string][]*lsproto.TextEdit { - // !!! finishDeleteDeclarations - // !!! finishClassesWithNodesInsertedAtStart - changes := ct.getTextChangesFromChanges() - // !!! changes for new files - return changes -} - -func (ct *changeTracker) replaceNode(sourceFile *ast.SourceFile, oldNode *ast.Node, newNode *ast.Node, options *changeNodeOptions) { - if options == nil { - // defaults to `useNonAdjustedPositions` - options = &changeNodeOptions{ - leadingTriviaOption: leadingTriviaOptionExclude, - trailingTriviaOption: trailingTriviaOptionExclude, - } - } - ct.replaceRange(sourceFile, ct.getAdjustedRange(sourceFile, oldNode, oldNode, options.leadingTriviaOption, options.trailingTriviaOption), newNode, *options) -} - -func (ct *changeTracker) replaceRange(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNode *ast.Node, options changeNodeOptions) { - ct.changes.Add(sourceFile, &trackerEdit{kind: trackerEditKindReplaceWithSingleNode, Range: lsprotoRange, options: options, Node: newNode}) -} - -func (ct *changeTracker) replaceRangeWithText(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, text string) { - ct.changes.Add(sourceFile, &trackerEdit{kind: trackerEditKindText, Range: lsprotoRange, NewText: text}) -} - -func (ct *changeTracker) replaceRangeWithNodes(sourceFile *ast.SourceFile, lsprotoRange lsproto.Range, newNodes []*ast.Node, options changeNodeOptions) { - if len(newNodes) == 1 { - ct.replaceRange(sourceFile, lsprotoRange, newNodes[0], options) - return - } - ct.changes.Add(sourceFile, &trackerEdit{kind: trackerEditKindReplaceWithMultipleNodes, Range: lsprotoRange, nodes: newNodes, options: options}) -} - -func (ct *changeTracker) insertText(sourceFile *ast.SourceFile, pos lsproto.Position, text string) { - ct.replaceRangeWithText(sourceFile, lsproto.Range{Start: pos, End: pos}, text) -} - -func (ct *changeTracker) insertNodeAt(sourceFile *ast.SourceFile, pos core.TextPos, newNode *ast.Node, options changeNodeOptions) { - lsPos := ct.ls.converters.PositionToLineAndCharacter(sourceFile, pos) - ct.replaceRange(sourceFile, lsproto.Range{Start: lsPos, End: lsPos}, newNode, options) -} - -func (ct *changeTracker) insertNodesAt(sourceFile *ast.SourceFile, pos core.TextPos, newNodes []*ast.Node, options changeNodeOptions) { - lsPos := ct.ls.converters.PositionToLineAndCharacter(sourceFile, pos) - ct.replaceRangeWithNodes(sourceFile, lsproto.Range{Start: lsPos, End: lsPos}, newNodes, options) -} - -func (ct *changeTracker) insertNodeAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node) { - endPosition := ct.endPosForInsertNodeAfter(sourceFile, after, newNode) - ct.insertNodeAt(sourceFile, endPosition, newNode, ct.getInsertNodeAfterOptions(sourceFile, after)) -} - -func (ct *changeTracker) insertNodesAfter(sourceFile *ast.SourceFile, after *ast.Node, newNodes []*ast.Node) { - endPosition := ct.endPosForInsertNodeAfter(sourceFile, after, newNodes[0]) - ct.insertNodesAt(sourceFile, endPosition, newNodes, ct.getInsertNodeAfterOptions(sourceFile, after)) -} - -func (ct *changeTracker) endPosForInsertNodeAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node) core.TextPos { - if (needSemicolonBetween(after, newNode)) && (rune(sourceFile.Text()[after.End()-1]) != ';') { - // check if previous statement ends with semicolon - // if not - insert semicolon to preserve the code from changing the meaning due to ASI - endPos := ct.ls.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(after.End())) - ct.replaceRange(sourceFile, - lsproto.Range{Start: endPos, End: endPos}, - sourceFile.GetOrCreateToken(ast.KindSemicolonToken, after.End(), after.End(), after.Parent), - changeNodeOptions{}, - ) - } - return core.TextPos(ct.getAdjustedEndPosition(sourceFile, after, trailingTriviaOptionNone)) -} - -/** -* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, -* i.e. arguments in arguments lists, parameters in parameter lists etc. -* Note that separators are part of the node in statements and class elements. - */ -func (ct *changeTracker) insertNodeInListAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node, containingList []*ast.Node) { - if len(containingList) == 0 { - containingList = format.GetContainingList(after, sourceFile).Nodes - } - index := slices.Index(containingList, after) - if index < 0 { - return - } - if index != len(containingList)-1 { - // any element except the last one - // use next sibling as an anchor - if nextToken := astnav.GetTokenAtPosition(sourceFile, after.End()); nextToken != nil && isSeparator(after, nextToken) { - // for list - // a, b, c - // create change for adding 'e' after 'a' as - // - find start of next element after a (it is b) - // - use next element start as start and end position in final change - // - build text of change by formatting the text of node + whitespace trivia of b - - // in multiline case it will work as - // a, - // b, - // c, - // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') - // a, - // insertedtext# - // ###b, - // c, - nextNode := containingList[index+1] - startPos := scanner.SkipTriviaEx(sourceFile.Text(), nextNode.Pos(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: false}) - - // write separator and leading trivia of the next element as suffix - suffix := scanner.TokenToString(nextToken.Kind) + sourceFile.Text()[nextNode.End():startPos] - ct.insertNodeAt(sourceFile, core.TextPos(startPos), newNode, changeNodeOptions{suffix: suffix}) - } - return - } - - afterStart := astnav.GetStartOfNode(after, sourceFile, false) - afterStartLinePosition := format.GetLineStartPositionForPosition(afterStart, sourceFile) - - // insert element after the last element in the list that has more than one item - // pick the element preceding the after element to: - // - pick the separator - // - determine if list is a multiline - multilineList := false - - // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise - // i.e. var x = 1 // this is x - // | new element will be inserted at this position - separator := ast.KindCommaToken // SyntaxKind.CommaToken | SyntaxKind.SemicolonToken - if len(containingList) != 1 { - // otherwise, if list has more than one element, pick separator from the list - tokenBeforeInsertPosition := astnav.FindPrecedingToken(sourceFile, after.Pos()) - separator = core.IfElse(isSeparator(after, tokenBeforeInsertPosition), tokenBeforeInsertPosition.Kind, ast.KindCommaToken) - // determine if list is multiline by checking lines of after element and element that precedes it. - afterMinusOneStartLinePosition := format.GetLineStartPositionForPosition(astnav.GetStartOfNode(containingList[index-1], sourceFile, false), sourceFile) - multilineList = afterMinusOneStartLinePosition != afterStartLinePosition - } - if hasCommentsBeforeLineBreak(sourceFile.Text(), after.End()) || printer.GetLinesBetweenPositions(sourceFile, containingList[0].Pos(), containingList[len(containingList)-1].End()) != 0 { - // in this case we'll always treat containing list as multiline - multilineList = true - } - - separatorString := scanner.TokenToString(separator) - end := ct.ls.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(after.End())) - if !multilineList { - ct.replaceRange(sourceFile, lsproto.Range{Start: end, End: end}, newNode, changeNodeOptions{prefix: separatorString}) - return - } - - // insert separator immediately following the 'after' node to preserve comments in trailing trivia - // !!! formatcontext - ct.replaceRange(sourceFile, lsproto.Range{Start: end, End: end}, sourceFile.GetOrCreateToken(separator, after.End(), after.End()+len(separatorString), after.Parent), changeNodeOptions{}) - // use the same indentation as 'after' item - indentation := format.FindFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, ct.formatSettings) - // insert element before the line break on the line that contains 'after' element - insertPos := scanner.SkipTriviaEx(sourceFile.Text(), after.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: false}) - // find position before "\n" or "\r\n" - for insertPos != after.End() && stringutil.IsLineBreak(rune(sourceFile.Text()[insertPos-1])) { - insertPos-- - } - insertLSPos := ct.ls.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(insertPos)) - ct.replaceRange( - sourceFile, - lsproto.Range{Start: insertLSPos, End: insertLSPos}, - newNode, - changeNodeOptions{ - indentation: ptrTo(indentation), - prefix: ct.newLine, - }, - ) -} - -func (ct *changeTracker) insertAtTopOfFile(sourceFile *ast.SourceFile, insert []*ast.Statement, blankLineBetween bool) { - if len(insert) == 0 { - return - } - - pos := ct.getInsertionPositionAtSourceFileTop(sourceFile) - options := changeNodeOptions{} - if pos != 0 { - options.prefix = ct.newLine - } - if !stringutil.IsLineBreak(rune(sourceFile.Text()[pos])) { - options.suffix = ct.newLine - } - if blankLineBetween { - options.suffix += ct.newLine - } - - if len(insert) == 1 { - ct.insertNodeAt(sourceFile, core.TextPos(pos), insert[0], options) - } else { - ct.insertNodesAt(sourceFile, core.TextPos(pos), insert, options) - } -} - -func (ct *changeTracker) getInsertNodeAfterOptions(sourceFile *ast.SourceFile, node *ast.Node) changeNodeOptions { - newLineChar := ct.newLine - var options changeNodeOptions - switch node.Kind { - case ast.KindParameter: - // default opts - options = changeNodeOptions{} - case ast.KindClassDeclaration, ast.KindModuleDeclaration: - options = changeNodeOptions{prefix: newLineChar, suffix: newLineChar} - - case ast.KindVariableDeclaration, ast.KindStringLiteral, ast.KindIdentifier: - options = changeNodeOptions{prefix: ", "} - - case ast.KindPropertyAssignment: - options = changeNodeOptions{suffix: "," + newLineChar} - - case ast.KindExportKeyword: - options = changeNodeOptions{prefix: " "} - - default: - if !(ast.IsStatement(node) || ast.IsClassOrTypeElement(node)) { - // Else we haven't handled this kind of node yet -- add it - panic("unimplemented node type " + node.Kind.String() + " in changeTracker.getInsertNodeAfterOptions") - } - options = changeNodeOptions{suffix: newLineChar} - } - if node.End() == sourceFile.End() && ast.IsStatement(node) { - options.prefix = "\n" + options.prefix - } - - return options -} diff --git a/internal/ls/changetrackerimpl.go b/internal/ls/changetrackerimpl.go deleted file mode 100644 index e8f3d13e69..0000000000 --- a/internal/ls/changetrackerimpl.go +++ /dev/null @@ -1,413 +0,0 @@ -package ls - -import ( - "fmt" - "slices" - "strings" - "unicode" - - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/astnav" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/format" - "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/parser" - "github.com/microsoft/typescript-go/internal/printer" - "github.com/microsoft/typescript-go/internal/scanner" - "github.com/microsoft/typescript-go/internal/stringutil" -) - -func (ct *changeTracker) getTextChangesFromChanges() map[string][]*lsproto.TextEdit { - changes := map[string][]*lsproto.TextEdit{} - for sourceFile, changesInFile := range ct.changes.M { - // order changes by start position - // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. - slices.SortStableFunc(changesInFile, func(a, b *trackerEdit) int { return CompareRanges(ptrTo(a.Range), ptrTo(b.Range)) }) - // verify that change intervals do not overlap, except possibly at end points. - for i := range len(changesInFile) - 1 { - if ComparePositions(changesInFile[i].Range.End, changesInFile[i+1].Range.Start) > 0 { - // assert change[i].End <= change[i + 1].Start - panic(fmt.Sprintf("changes overlap: %v and %v", changesInFile[i].Range, changesInFile[i+1].Range)) - } - } - - textChanges := core.MapNonNil(changesInFile, func(change *trackerEdit) *lsproto.TextEdit { - // !!! targetSourceFile - - newText := ct.computeNewText(change, sourceFile, sourceFile) - // span := createTextSpanFromRange(c.Range) - // !!! - // Filter out redundant changes. - // if (span.length == newText.length && stringContainsAt(targetSourceFile.text, newText, span.start)) { return nil } - - return &lsproto.TextEdit{ - NewText: newText, - Range: change.Range, - } - }) - - if len(textChanges) > 0 { - changes[sourceFile.FileName()] = textChanges - } - } - return changes -} - -func (ct *changeTracker) computeNewText(change *trackerEdit, targetSourceFile *ast.SourceFile, sourceFile *ast.SourceFile) string { - switch change.kind { - case trackerEditKindRemove: - return "" - case trackerEditKindText: - return change.NewText - } - - pos := int(ct.ls.converters.LineAndCharacterToPosition(sourceFile, change.Range.Start)) - formatNode := func(n *ast.Node) string { - return ct.getFormattedTextOfNode(n, targetSourceFile, sourceFile, pos, change.options) - } - - var text string - switch change.kind { - - case trackerEditKindReplaceWithMultipleNodes: - if change.options.joiner == "" { - change.options.joiner = ct.newLine - } - text = strings.Join(core.Map(change.nodes, func(n *ast.Node) string { return strings.TrimSuffix(formatNode(n), ct.newLine) }), change.options.joiner) - case trackerEditKindReplaceWithSingleNode: - text = formatNode(change.Node) - default: - panic(fmt.Sprintf("change kind %d should have been handled earlier", change.kind)) - } - // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line - noIndent := text - if !(change.options.indentation != nil && *change.options.indentation != 0 || format.GetLineStartPositionForPosition(pos, targetSourceFile) == pos) { - noIndent = strings.TrimLeftFunc(text, unicode.IsSpace) - } - return change.options.prefix + noIndent // !!! +((!options.suffix || endsWith(noIndent, options.suffix)) ? "" : options.suffix); -} - -/** Note: this may mutate `nodeIn`. */ -func (ct *changeTracker) getFormattedTextOfNode(nodeIn *ast.Node, targetSourceFile *ast.SourceFile, sourceFile *ast.SourceFile, pos int, options changeNodeOptions) string { - text, sourceFileLike := ct.getNonformattedText(nodeIn, targetSourceFile) - // !!! if (validate) validate(node, text); - formatOptions := getFormatCodeSettingsForWriting(ct.formatSettings, targetSourceFile) - - var initialIndentation, delta int - if options.indentation == nil { - // !!! indentation for position - // initialIndentation = format.GetIndentationForPos(pos, sourceFile, formatOptions, options.prefix == ct.newLine || scanner.GetLineStartPositionForPosition(pos, targetFileLineMap) == pos); - } else { - initialIndentation = *options.indentation - } - - if options.delta != nil { - delta = *options.delta - } else if formatOptions.IndentSize != 0 && format.ShouldIndentChildNode(formatOptions, nodeIn, nil, nil) { - delta = formatOptions.IndentSize - } - - changes := format.FormatNodeGivenIndentation(ct.ctx, sourceFileLike, sourceFileLike.AsSourceFile(), targetSourceFile.LanguageVariant, initialIndentation, delta) - return core.ApplyBulkEdits(text, changes) -} - -func getFormatCodeSettingsForWriting(options *format.FormatCodeSettings, sourceFile *ast.SourceFile) *format.FormatCodeSettings { - shouldAutoDetectSemicolonPreference := options.Semicolons == format.SemicolonPreferenceIgnore - shouldRemoveSemicolons := options.Semicolons == format.SemicolonPreferenceRemove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile) - if shouldRemoveSemicolons { - options.Semicolons = format.SemicolonPreferenceRemove - } - - return options -} - -/** Note: output node may be mutated input node. */ -func (ct *changeTracker) getNonformattedText(node *ast.Node, sourceFile *ast.SourceFile) (string, *ast.Node) { - nodeIn := node - eofToken := ct.Factory.NewToken(ast.KindEndOfFile) - if ast.IsStatement(node) { - nodeIn = ct.Factory.NewSourceFile( - ast.SourceFileParseOptions{FileName: sourceFile.FileName(), Path: sourceFile.Path()}, - "", - ct.Factory.NewNodeList([]*ast.Node{node}), - ct.Factory.NewToken(ast.KindEndOfFile), - ) - } - writer := printer.NewChangeTrackerWriter(ct.newLine) - printer.NewPrinter( - printer.PrinterOptions{ - NewLine: core.GetNewLineKind(ct.newLine), - NeverAsciiEscape: true, - PreserveSourceNewlines: true, - TerminateUnterminatedLiterals: true, - }, - writer.GetPrintHandlers(), - ct.EmitContext, - ).Write(nodeIn, sourceFile, writer, nil) - - text := writer.String() - - nodeOut := writer.AssignPositionsToNode(nodeIn, ct.NodeFactory) - var sourceFileLike *ast.Node - if !ast.IsStatement(node) { - nodeList := ct.Factory.NewNodeList([]*ast.Node{nodeOut}) - nodeList.Loc = nodeOut.Loc - eofToken.Loc = core.NewTextRange(nodeOut.End(), nodeOut.End()) - sourceFileLike = ct.Factory.NewSourceFile( - ast.SourceFileParseOptions{FileName: sourceFile.FileName(), Path: sourceFile.Path()}, - text, - nodeList, - eofToken, - ) - sourceFileLike.ForEachChild(func(child *ast.Node) bool { - child.Parent = sourceFileLike - return true - }) - sourceFileLike.Loc = nodeOut.Loc - } else { - sourceFileLike = nodeOut - } - return text, sourceFileLike -} - -// method on the changeTracker because use of converters -func (ct *changeTracker) getAdjustedRange(sourceFile *ast.SourceFile, startNode *ast.Node, endNode *ast.Node, leadingOption leadingTriviaOption, trailingOption trailingTriviaOption) lsproto.Range { - return *ct.ls.createLspRangeFromBounds( - ct.getAdjustedStartPosition(sourceFile, startNode, leadingOption, false), - ct.getAdjustedEndPosition(sourceFile, endNode, trailingOption), - sourceFile, - ) -} - -// method on the changeTracker because use of converters -func (ct *changeTracker) getAdjustedStartPosition(sourceFile *ast.SourceFile, node *ast.Node, leadingOption leadingTriviaOption, hasTrailingComment bool) int { - if leadingOption == leadingTriviaOptionJSDoc { - if JSDocComments := parser.GetJSDocCommentRanges(ct.NodeFactory, nil, node, sourceFile.Text()); len(JSDocComments) > 0 { - return format.GetLineStartPositionForPosition(JSDocComments[0].Pos(), sourceFile) - } - } - - start := astnav.GetStartOfNode(node, sourceFile, false) - startOfLinePos := format.GetLineStartPositionForPosition(start, sourceFile) - - switch leadingOption { - case leadingTriviaOptionExclude: - return start - case leadingTriviaOptionStartLine: - if node.Loc.ContainsInclusive(startOfLinePos) { - return startOfLinePos - } - return start - } - - fullStart := node.Pos() - if fullStart == start { - return start - } - lineStarts := sourceFile.ECMALineMap() - fullStartLineIndex := scanner.ComputeLineOfPosition(lineStarts, fullStart) - fullStartLinePos := int(lineStarts[fullStartLineIndex]) - if startOfLinePos == fullStartLinePos { - // full start and start of the node are on the same line - // a, b; - // ^ ^ - // | start - // fullstart - // when b is replaced - we usually want to keep the leading trvia - // when b is deleted - we delete it - if leadingOption == leadingTriviaOptionIncludeAll { - return fullStart - } - return start - } - - // if node has a trailing comments, use comment end position as the text has already been included. - if hasTrailingComment { - // Check first for leading comments as if the node is the first import, we want to exclude the trivia; - // otherwise we get the trailing comments. - comments := slices.Collect(scanner.GetLeadingCommentRanges(ct.NodeFactory, sourceFile.Text(), fullStart)) - if len(comments) == 0 { - comments = slices.Collect(scanner.GetTrailingCommentRanges(ct.NodeFactory, sourceFile.Text(), fullStart)) - } - if len(comments) > 0 { - return scanner.SkipTriviaEx(sourceFile.Text(), comments[0].End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: true}) - } - } - - // get start position of the line following the line that contains fullstart position - // (but only if the fullstart isn't the very beginning of the file) - nextLineStart := core.IfElse(fullStart > 0, 1, 0) - adjustedStartPosition := int(lineStarts[fullStartLineIndex+nextLineStart]) - // skip whitespaces/newlines - adjustedStartPosition = scanner.SkipTriviaEx(sourceFile.Text(), adjustedStartPosition, &scanner.SkipTriviaOptions{StopAtComments: true}) - return int(lineStarts[scanner.ComputeLineOfPosition(lineStarts, adjustedStartPosition)]) -} - -// method on the changeTracker because of converters -// Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; -func (ct *changeTracker) getEndPositionOfMultilineTrailingComment(sourceFile *ast.SourceFile, node *ast.Node, trailingOpt trailingTriviaOption) int { - if trailingOpt == trailingTriviaOptionInclude { - // If the trailing comment is a multiline comment that extends to the next lines, - // return the end of the comment and track it for the next nodes to adjust. - lineStarts := sourceFile.ECMALineMap() - nodeEndLine := scanner.ComputeLineOfPosition(lineStarts, node.End()) - for comment := range scanner.GetTrailingCommentRanges(ct.NodeFactory, sourceFile.Text(), node.End()) { - // Single line can break the loop as trivia will only be this line. - // Comments on subsequest lines are also ignored. - if comment.Kind == ast.KindSingleLineCommentTrivia || scanner.ComputeLineOfPosition(lineStarts, comment.Pos()) > nodeEndLine { - break - } - - // Get the end line of the comment and compare against the end line of the node. - // If the comment end line position and the multiline comment extends to multiple lines, - // then is safe to return the end position. - if commentEndLine := scanner.ComputeLineOfPosition(lineStarts, comment.End()); commentEndLine > nodeEndLine { - return scanner.SkipTriviaEx(sourceFile.Text(), comment.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: true}) - } - } - } - - return 0 -} - -// method on the changeTracker because of converters -func (ct *changeTracker) getAdjustedEndPosition(sourceFile *ast.SourceFile, node *ast.Node, trailingTriviaOption trailingTriviaOption) int { - if trailingTriviaOption == trailingTriviaOptionExclude { - return node.End() - } - if trailingTriviaOption == trailingTriviaOptionExcludeWhitespace { - if comments := slices.AppendSeq( - slices.Collect(scanner.GetTrailingCommentRanges(ct.NodeFactory, sourceFile.Text(), node.End())), - scanner.GetLeadingCommentRanges(ct.NodeFactory, sourceFile.Text(), node.End()), - ); len(comments) > 0 { - if realEnd := comments[len(comments)-1].End(); realEnd != 0 { - return realEnd - } - } - return node.End() - } - - if multilineEndPosition := ct.getEndPositionOfMultilineTrailingComment(sourceFile, node, trailingTriviaOption); multilineEndPosition != 0 { - return multilineEndPosition - } - - newEnd := scanner.SkipTriviaEx(sourceFile.Text(), node.End(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true}) - - if newEnd != node.End() && (trailingTriviaOption == trailingTriviaOptionInclude || stringutil.IsLineBreak(rune(sourceFile.Text()[newEnd-1]))) { - return newEnd - } - return node.End() -} - -// ============= utilities ============= - -func hasCommentsBeforeLineBreak(text string, start int) bool { - for _, ch := range []rune(text[start:]) { - if !stringutil.IsWhiteSpaceSingleLine(ch) { - return ch == '/' - } - } - return false -} - -func needSemicolonBetween(a, b *ast.Node) bool { - return (ast.IsPropertySignatureDeclaration(a) || ast.IsPropertyDeclaration(a)) && - ast.IsClassOrTypeElement(b) && - b.Name().Kind == ast.KindComputedPropertyName || - ast.IsStatementButNotDeclaration(a) && - ast.IsStatementButNotDeclaration(b) // TODO: only if b would start with a `(` or `[` -} - -func (ct *changeTracker) getInsertionPositionAtSourceFileTop(sourceFile *ast.SourceFile) int { - var lastPrologue *ast.Node - for _, node := range sourceFile.Statements.Nodes { - if ast.IsPrologueDirective(node) { - lastPrologue = node - } else { - break - } - } - - position := 0 - text := sourceFile.Text() - advancePastLineBreak := func() { - if position >= len(text) { - return - } - if char := rune(text[position]); stringutil.IsLineBreak(char) { - position++ - if position < len(text) && char == '\r' && rune(text[position]) == '\n' { - position++ - } - } - } - if lastPrologue != nil { - position = lastPrologue.End() - advancePastLineBreak() - return position - } - - shebang := scanner.GetShebang(text) - if shebang != "" { - position = len(shebang) - advancePastLineBreak() - } - - ranges := slices.Collect(scanner.GetLeadingCommentRanges(ct.NodeFactory, text, position)) - if len(ranges) == 0 { - return position - } - // Find the first attached comment to the first node and add before it - var lastComment *ast.CommentRange - pinnedOrTripleSlash := false - firstNodeLine := -1 - - lenStatements := len(sourceFile.Statements.Nodes) - lineMap := sourceFile.ECMALineMap() - for _, r := range ranges { - if r.Kind == ast.KindMultiLineCommentTrivia { - if printer.IsPinnedComment(text, r) { - lastComment = &r - pinnedOrTripleSlash = true - continue - } - } else if printer.IsRecognizedTripleSlashComment(text, r) { - lastComment = &r - pinnedOrTripleSlash = true - continue - } - - if lastComment != nil { - // Always insert after pinned or triple slash comments - if pinnedOrTripleSlash { - break - } - - // There was a blank line between the last comment and this comment. - // This comment is not part of the copyright comments - commentLine := scanner.ComputeLineOfPosition(lineMap, r.Pos()) - lastCommentEndLine := scanner.ComputeLineOfPosition(lineMap, lastComment.End()) - if commentLine >= lastCommentEndLine+2 { - break - } - } - - if lenStatements > 0 { - if firstNodeLine == -1 { - firstNodeLine = scanner.ComputeLineOfPosition(lineMap, astnav.GetStartOfNode(sourceFile.Statements.Nodes[0], sourceFile, false)) - } - commentEndLine := scanner.ComputeLineOfPosition(lineMap, r.End()) - if firstNodeLine < commentEndLine+2 { - break - } - } - lastComment = &r - pinnedOrTripleSlash = false - } - - if lastComment != nil { - position = lastComment.End() - advancePastLineBreak() - } - return position -} diff --git a/internal/ls/codeactions.go b/internal/ls/codeactions.go new file mode 100644 index 0000000000..a85a9d32ba --- /dev/null +++ b/internal/ls/codeactions.go @@ -0,0 +1,126 @@ +package ls + +import ( + "context" + "slices" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" +) + +// CodeFixProvider represents a provider for a specific type of code fix +type CodeFixProvider struct { + ErrorCodes []int32 + GetCodeActions func(ctx context.Context, fixContext *CodeFixContext) []CodeAction + FixIds []string + GetAllCodeActions func(ctx context.Context, fixContext *CodeFixContext) *CombinedCodeActions +} + +// CodeFixContext contains the context needed to generate code fixes +type CodeFixContext struct { + SourceFile *ast.SourceFile + Span core.TextRange + ErrorCode int32 + Program *compiler.Program + Checker *checker.Checker + LS *LanguageService + Diagnostic *lsproto.Diagnostic + Params *lsproto.CodeActionParams +} + +// CodeAction represents a single code action fix +type CodeAction struct { + Description string + Changes []*lsproto.TextEdit +} + +// CombinedCodeActions represents combined code actions for fix-all scenarios +type CombinedCodeActions struct { + Description string + Changes []*lsproto.TextEdit +} + +// codeFixProviders is the list of all registered code fix providers +var codeFixProviders = []*CodeFixProvider{ + ImportFixProvider, + // Add more code fix providers here as they are implemented +} + +// ProvideCodeActions returns code actions for the given range and context +func (l *LanguageService) ProvideCodeActions(ctx context.Context, params *lsproto.CodeActionParams) (lsproto.CodeActionResponse, error) { + program, file := l.getProgramAndFile(params.TextDocument.Uri) + + // Get the type checker + ch, done := program.GetTypeCheckerForFile(ctx, file) + if done != nil { + defer done() + } + + var actions []lsproto.CommandOrCodeAction + + // Process diagnostics in the context to generate quick fixes + if params.Context != nil && params.Context.Diagnostics != nil { + for _, diag := range params.Context.Diagnostics { + if diag.Code == nil || diag.Code.Integer == nil { + continue + } + + errorCode := *diag.Code.Integer + + // Check all code fix providers + for _, provider := range codeFixProviders { + if !containsErrorCode(provider.ErrorCodes, errorCode) { + continue + } + + // Create context for the provider + position := l.converters.LineAndCharacterToPosition(file, diag.Range.Start) + endPosition := l.converters.LineAndCharacterToPosition(file, diag.Range.End) + fixContext := &CodeFixContext{ + SourceFile: file, + Span: core.NewTextRange(int(position), int(endPosition)), + ErrorCode: errorCode, + Program: program, + Checker: ch, + LS: l, + Diagnostic: diag, + Params: params, + } + + // Get code actions from the provider + providerActions := provider.GetCodeActions(ctx, fixContext) + for _, action := range providerActions { + actions = append(actions, convertToLSPCodeAction(&action, diag, params.TextDocument.Uri)) + } + } + } + } + + return lsproto.CommandOrCodeActionArrayOrNull{CommandOrCodeActionArray: &actions}, nil +} + +// containsErrorCode checks if the error code is in the list +func containsErrorCode(codes []int32, code int32) bool { + return slices.Contains(codes, code) +} + +// convertToLSPCodeAction converts an internal CodeAction to an LSP CodeAction +func convertToLSPCodeAction(action *CodeAction, diag *lsproto.Diagnostic, uri lsproto.DocumentUri) lsproto.CommandOrCodeAction { + kind := lsproto.CodeActionKindQuickFix + changes := map[lsproto.DocumentUri][]*lsproto.TextEdit{ + uri: action.Changes, + } + diagnostics := []*lsproto.Diagnostic{diag} + + return lsproto.CommandOrCodeAction{ + CodeAction: &lsproto.CodeAction{ + Title: action.Description, + Kind: &kind, + Edit: &lsproto.WorkspaceEdit{Changes: &changes}, + Diagnostics: &diagnostics, + }, + } +} diff --git a/internal/ls/codeactions_importfixes.go b/internal/ls/codeactions_importfixes.go new file mode 100644 index 0000000000..96e9f0d59f --- /dev/null +++ b/internal/ls/codeactions_importfixes.go @@ -0,0 +1,641 @@ +package ls + +import ( + "cmp" + "context" + "fmt" + "slices" + "strings" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/ls/change" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/ls/organizeimports" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/outputpaths" + "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/tspath" +) + +var importFixErrorCodes = []int32{ + diagnostics.Cannot_find_name_0.Code(), + diagnostics.Cannot_find_name_0_Did_you_mean_1.Code(), + diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.Code(), + diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.Code(), + diagnostics.Cannot_find_namespace_0.Code(), + diagnostics.X_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.Code(), + diagnostics.X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here.Code(), + diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.Code(), + diagnostics.X_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig.Code(), + diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode.Code(), + diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig.Code(), + diagnostics.Cannot_find_namespace_0_Did_you_mean_1.Code(), + diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.Code(), + diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found.Code(), +} + +const ( + importFixID = "fixMissingImport" +) + +// ImportFixProvider is the CodeFixProvider for import-related fixes +var ImportFixProvider = &CodeFixProvider{ + ErrorCodes: importFixErrorCodes, + GetCodeActions: getImportCodeActions, + FixIds: []string{importFixID}, +} + +type fixInfo struct { + fix *ImportFix + symbolName string + errorIdentifierText string + isJsxNamespaceFix bool +} + +func getImportCodeActions(ctx context.Context, fixContext *CodeFixContext) []CodeAction { + info := getFixInfos(ctx, fixContext, fixContext.ErrorCode, fixContext.Span.Pos(), true /* useAutoImportProvider */) + if len(info) == 0 { + return nil + } + + var actions []CodeAction + for _, fixInfo := range info { + tracker := change.NewTracker(ctx, fixContext.Program.Options(), fixContext.LS.FormatOptions(), fixContext.LS.converters) + msg := fixContext.LS.codeActionForFixWorker( + ctx, + tracker, + fixContext.SourceFile, + fixInfo.symbolName, + fixInfo.fix, + fixInfo.symbolName != fixInfo.errorIdentifierText, + ) + + if msg != "" { + // Convert changes to LSP edits + changes := tracker.GetChanges() + var edits []*lsproto.TextEdit + for _, fileChanges := range changes { + edits = append(edits, fileChanges...) + } + + actions = append(actions, CodeAction{ + Description: msg, + Changes: edits, + }) + } + } + return actions +} + +func getFixInfos(ctx context.Context, fixContext *CodeFixContext, errorCode int32, pos int, useAutoImportProvider bool) []*fixInfo { + symbolToken := astnav.GetTokenAtPosition(fixContext.SourceFile, pos) + + var info []*fixInfo + + if errorCode == diagnostics.X_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.Code() { + info = getFixesInfoForUMDImport(ctx, fixContext, symbolToken) + } else if !ast.IsIdentifier(symbolToken) { + return nil + } else if errorCode == diagnostics.X_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.Code() { + // Handle type-only import promotion + ch, done := fixContext.Program.GetTypeChecker(ctx) + defer done() + compilerOptions := fixContext.Program.Options() + symbolNames := getSymbolNamesToImport(fixContext.SourceFile, ch, symbolToken, compilerOptions) + if len(symbolNames) != 1 { + panic("Expected exactly one symbol name for type-only import promotion") + } + symbolName := symbolNames[0] + fix := getTypeOnlyPromotionFix(ctx, fixContext.SourceFile, symbolToken, symbolName, fixContext.Program) + if fix != nil { + return []*fixInfo{{fix: fix, symbolName: symbolName, errorIdentifierText: symbolToken.Text()}} + } + return nil + } else { + info = getFixesInfoForNonUMDImport(ctx, fixContext, symbolToken, useAutoImportProvider) + } + + // Sort fixes by preference + return sortFixInfo(info, fixContext) +} + +func getFixesInfoForUMDImport(ctx context.Context, fixContext *CodeFixContext, token *ast.Node) []*fixInfo { + ch, done := fixContext.Program.GetTypeChecker(ctx) + defer done() + + umdSymbol := getUmdSymbol(token, ch) + if umdSymbol == nil { + return nil + } + + symbol := ch.GetAliasedSymbol(umdSymbol) + symbolName := umdSymbol.Name + exportInfo := []*SymbolExportInfo{{ + symbol: umdSymbol, + moduleSymbol: symbol, + moduleFileName: "", + exportKind: ExportKindUMD, + targetFlags: symbol.Flags, + isFromPackageJson: false, + }} + + useRequire := shouldUseRequire(fixContext.SourceFile, fixContext.Program) + // `usagePosition` is undefined because `token` may not actually be a usage of the symbol we're importing. + // For example, we might need to import `React` in order to use an arbitrary JSX tag. We could send a position + // for other UMD imports, but `usagePosition` is currently only used to insert a namespace qualification + // before a named import, like converting `writeFile` to `fs.writeFile` (whether `fs` is already imported or + // not), and this function will only be called for UMD symbols, which are necessarily an `export =`, not a + // named export. + _, fixes := fixContext.LS.getImportFixes( + ch, + exportInfo, + nil, // usagePosition undefined for UMD + ptrTo(false), + &useRequire, + fixContext.SourceFile, + false, // fromCacheOnly + ) + + var result []*fixInfo + for _, fix := range fixes { + errorIdentifierText := "" + if ast.IsIdentifier(token) { + errorIdentifierText = token.Text() + } + result = append(result, &fixInfo{ + fix: fix, + symbolName: symbolName, + errorIdentifierText: errorIdentifierText, + }) + } + return result +} + +func getUmdSymbol(token *ast.Node, ch *checker.Checker) *ast.Symbol { + // try the identifier to see if it is the umd symbol + var umdSymbol *ast.Symbol + if ast.IsIdentifier(token) { + umdSymbol = ch.GetResolvedSymbol(token) + } + if isUMDExportSymbol(umdSymbol) { + return umdSymbol + } + + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + parent := token.Parent + if (ast.IsJsxOpeningLikeElement(parent) && parent.TagName() == token) || + ast.IsJsxOpeningFragment(parent) { + var location *ast.Node + if ast.IsJsxOpeningLikeElement(parent) { + location = token + } else { + location = parent + } + jsxNamespace := ch.GetJsxNamespace(parent) + parentSymbol := ch.ResolveName(jsxNamespace, location, ast.SymbolFlagsValue, false /* excludeGlobals */) + if isUMDExportSymbol(parentSymbol) { + return parentSymbol + } + } + return nil +} + +func isUMDExportSymbol(symbol *ast.Symbol) bool { + return symbol != nil && len(symbol.Declarations) > 0 && + symbol.Declarations[0] != nil && + ast.IsNamespaceExportDeclaration(symbol.Declarations[0]) +} + +func getFixesInfoForNonUMDImport(ctx context.Context, fixContext *CodeFixContext, symbolToken *ast.Node, useAutoImportProvider bool) []*fixInfo { + ch, done := fixContext.Program.GetTypeChecker(ctx) + defer done() + compilerOptions := fixContext.Program.Options() + + symbolNames := getSymbolNamesToImport(fixContext.SourceFile, ch, symbolToken, compilerOptions) + var allInfo []*fixInfo + + for _, symbolName := range symbolNames { + // "default" is a keyword and not a legal identifier for the import + if symbolName == "default" { + continue + } + + isValidTypeOnlyUseSite := ast.IsValidTypeOnlyAliasUseSite(symbolToken) + useRequire := shouldUseRequire(fixContext.SourceFile, fixContext.Program) + exportInfosMap := getExportInfos( + ctx, + symbolName, + ast.IsJsxTagName(symbolToken), + getMeaningFromLocation(symbolToken), + fixContext.SourceFile, + fixContext.Program, + fixContext.LS, + ) + + // Flatten all export infos from the map into a single slice + var allExportInfos []*SymbolExportInfo + for exportInfoList := range exportInfosMap.Values() { + allExportInfos = append(allExportInfos, exportInfoList...) + } + + // Sort by moduleFileName to ensure deterministic iteration order + // TODO: This might not work 100% of the time; need to revisit this + slices.SortStableFunc(allExportInfos, func(a, b *SymbolExportInfo) int { + return strings.Compare(a.moduleFileName, b.moduleFileName) + }) + + if len(allExportInfos) > 0 { + usagePos := scanner.GetTokenPosOfNode(symbolToken, fixContext.SourceFile, false) + lspPos := fixContext.LS.converters.PositionToLineAndCharacter(fixContext.SourceFile, core.TextPos(usagePos)) + _, fixes := fixContext.LS.getImportFixes( + ch, + allExportInfos, + &lspPos, + &isValidTypeOnlyUseSite, + &useRequire, + fixContext.SourceFile, + false, // fromCacheOnly + ) + + for _, fix := range fixes { + allInfo = append(allInfo, &fixInfo{ + fix: fix, + symbolName: symbolName, + errorIdentifierText: symbolToken.Text(), + isJsxNamespaceFix: symbolName != symbolToken.Text(), + }) + } + } + } + + return allInfo +} + +func getTypeOnlyPromotionFix(ctx context.Context, sourceFile *ast.SourceFile, symbolToken *ast.Node, symbolName string, program *compiler.Program) *ImportFix { + ch, done := program.GetTypeChecker(ctx) + defer done() + + // Get the symbol at the token location + symbol := ch.ResolveName(symbolName, symbolToken, ast.SymbolFlagsValue, true /* excludeGlobals */) + if symbol == nil { + return nil + } + + // Get the type-only alias declaration + typeOnlyAliasDeclaration := ch.GetTypeOnlyAliasDeclaration(symbol) + if typeOnlyAliasDeclaration == nil || ast.GetSourceFileOfNode(typeOnlyAliasDeclaration) != sourceFile { + return nil + } + + return &ImportFix{ + kind: ImportFixKindPromoteTypeOnly, + typeOnlyAliasDeclaration: typeOnlyAliasDeclaration, + } +} + +func getSymbolNamesToImport(sourceFile *ast.SourceFile, ch *checker.Checker, symbolToken *ast.Node, compilerOptions *core.CompilerOptions) []string { + parent := symbolToken.Parent + if (ast.IsJsxOpeningLikeElement(parent) || ast.IsJsxClosingElement(parent)) && + parent.TagName() == symbolToken && + jsxModeNeedsExplicitImport(compilerOptions.Jsx) { + jsxNamespace := ch.GetJsxNamespace(sourceFile.AsNode()) + if needsJsxNamespaceFix(jsxNamespace, symbolToken, ch) { + needsComponentNameFix := !scanner.IsIntrinsicJsxName(symbolToken.Text()) && + ch.ResolveName(symbolToken.Text(), symbolToken, ast.SymbolFlagsValue, false /* excludeGlobals */) == nil + if needsComponentNameFix { + return []string{symbolToken.Text(), jsxNamespace} + } + return []string{jsxNamespace} + } + } + return []string{symbolToken.Text()} +} + +func needsJsxNamespaceFix(jsxNamespace string, symbolToken *ast.Node, ch *checker.Checker) bool { + if scanner.IsIntrinsicJsxName(symbolToken.Text()) { + return true + } + namespaceSymbol := ch.ResolveName(jsxNamespace, symbolToken, ast.SymbolFlagsValue, true /* excludeGlobals */) + if namespaceSymbol == nil { + return true + } + // Check if all declarations are type-only + if slices.ContainsFunc(namespaceSymbol.Declarations, ast.IsTypeOnlyImportOrExportDeclaration) { + return (namespaceSymbol.Flags & ast.SymbolFlagsValue) == 0 + } + return false +} + +func jsxModeNeedsExplicitImport(jsx core.JsxEmit) bool { + return jsx == core.JsxEmitReact || jsx == core.JsxEmitReactNative +} + +func getExportInfos( + ctx context.Context, + symbolName string, + isJsxTagName bool, + currentTokenMeaning ast.SemanticMeaning, + fromFile *ast.SourceFile, + program *compiler.Program, + ls *LanguageService, +) *collections.MultiMap[ast.SymbolId, *SymbolExportInfo] { + // For each original symbol, keep all re-exports of that symbol together + // Maps symbol id to info for modules providing that symbol (original export + re-exports) + originalSymbolToExportInfos := &collections.MultiMap[ast.SymbolId, *SymbolExportInfo]{} + + ch, done := program.GetTypeChecker(ctx) + defer done() + + packageJsonFilter := ls.createPackageJsonImportFilter(fromFile) + + // Helper to add a symbol to the results map + addSymbol := func(moduleSymbol *ast.Symbol, toFile *ast.SourceFile, exportedSymbol *ast.Symbol, exportKind ExportKind, isFromPackageJson bool) { + if !ls.isImportable(fromFile, toFile, moduleSymbol, packageJsonFilter) { + return + } + + // Get unique ID for the exported symbol + symbolID := ast.GetSymbolId(exportedSymbol) + + moduleFileName := "" + if toFile != nil { + moduleFileName = toFile.FileName() + } + + originalSymbolToExportInfos.Add(symbolID, &SymbolExportInfo{ + symbol: exportedSymbol, + moduleSymbol: moduleSymbol, + moduleFileName: moduleFileName, + exportKind: exportKind, + targetFlags: ch.SkipAlias(exportedSymbol).Flags, + isFromPackageJson: isFromPackageJson, + }) + } + + // Iterate through all external modules + forEachExternalModuleToImportFrom( + ch, + program, + func(moduleSymbol *ast.Symbol, sourceFile *ast.SourceFile, checker *checker.Checker, isFromPackageJson bool) { + // Check for cancellation + if ctx.Err() != nil { + return + } + + compilerOptions := program.Options() + + // Check default export + defaultInfo := getDefaultLikeExportInfo(moduleSymbol, checker) + if defaultInfo != nil && + symbolFlagsHaveMeaning(checker.GetSymbolFlags(defaultInfo.exportingModuleSymbol), currentTokenMeaning) && + forEachNameOfDefaultExport(defaultInfo.exportingModuleSymbol, checker, compilerOptions.GetEmitScriptTarget(), func(name, capitalizedName string) string { + actualName := name + if isJsxTagName && capitalizedName != "" { + actualName = capitalizedName + } + if actualName == symbolName { + return actualName + } + return "" + }) != "" { + addSymbol(moduleSymbol, sourceFile, defaultInfo.exportingModuleSymbol, defaultInfo.exportKind, isFromPackageJson) + } + // Check for named export with identical name + exportSymbol := checker.TryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol) + if exportSymbol != nil && symbolFlagsHaveMeaning(checker.GetSymbolFlags(exportSymbol), currentTokenMeaning) { + addSymbol(moduleSymbol, sourceFile, exportSymbol, ExportKindNamed, isFromPackageJson) + } + }, + ) + + return originalSymbolToExportInfos +} + +func sortFixInfo(fixes []*fixInfo, fixContext *CodeFixContext) []*fixInfo { + if len(fixes) == 0 { + return fixes + } + + // Create a copy to avoid modifying the original + sorted := make([]*fixInfo, len(fixes)) + copy(sorted, fixes) + + // Create package.json filter for import filtering + packageJsonFilter := fixContext.LS.createPackageJsonImportFilter(fixContext.SourceFile) + + // Sort by: + // 1. JSX namespace fixes last + // 2. Fix kind (UseNamespace and AddToExisting preferred) + // 3. Module specifier comparison + slices.SortFunc(sorted, func(a, b *fixInfo) int { + // JSX namespace fixes should come last + if cmp := core.CompareBooleans(a.isJsxNamespaceFix, b.isJsxNamespaceFix); cmp != 0 { + return cmp + } + + // Compare fix kinds (lower is better) + if cmp := cmp.Compare(int(a.fix.kind), int(b.fix.kind)); cmp != 0 { + return cmp + } + + // Compare module specifiers + return fixContext.LS.compareModuleSpecifiers( + a.fix, + b.fix, + fixContext.SourceFile, + packageJsonFilter.allowsImportingSpecifier, + func(fileName string) tspath.Path { return tspath.Path(fileName) }, + ) + }) + + return sorted +} + +func promoteFromTypeOnly( + changes *change.Tracker, + aliasDeclaration *ast.Declaration, + program *compiler.Program, + sourceFile *ast.SourceFile, + ls *LanguageService, +) *ast.Declaration { + compilerOptions := program.Options() + // See comment in `doAddExistingFix` on constant with the same name. + convertExistingToTypeOnly := compilerOptions.VerbatimModuleSyntax + + switch aliasDeclaration.Kind { + case ast.KindImportSpecifier: + spec := aliasDeclaration.AsImportSpecifier() + if spec.IsTypeOnly { + if spec.Parent != nil && spec.Parent.Kind == ast.KindNamedImports { + // TypeScript creates a new specifier with isTypeOnly=false, computes insertion index, + // and if different from current position, deletes and re-inserts at new position. + // For now, we just delete the range from the first token (type keyword) to the property name or name. + firstToken := lsutil.GetFirstToken(aliasDeclaration, sourceFile) + typeKeywordPos := scanner.GetTokenPosOfNode(firstToken, sourceFile, false) + var targetNode *ast.DeclarationName + if spec.PropertyName != nil { + targetNode = spec.PropertyName + } else { + targetNode = spec.Name() + } + targetPos := scanner.GetTokenPosOfNode(targetNode.AsNode(), sourceFile, false) + changes.DeleteRange(sourceFile, core.NewTextRange(typeKeywordPos, targetPos)) + } + return aliasDeclaration + } else { + // The parent import clause is type-only + if spec.Parent == nil || spec.Parent.Kind != ast.KindNamedImports { + panic("ImportSpecifier parent must be NamedImports") + } + if spec.Parent.Parent == nil || spec.Parent.Parent.Kind != ast.KindImportClause { + panic("NamedImports parent must be ImportClause") + } + promoteImportClause(changes, spec.Parent.Parent.AsImportClause(), program, sourceFile, ls, convertExistingToTypeOnly, aliasDeclaration) + return spec.Parent.Parent + } + + case ast.KindImportClause: + promoteImportClause(changes, aliasDeclaration.AsImportClause(), program, sourceFile, ls, convertExistingToTypeOnly, aliasDeclaration) + return aliasDeclaration + + case ast.KindNamespaceImport: + // Promote the parent import clause + if aliasDeclaration.Parent == nil || aliasDeclaration.Parent.Kind != ast.KindImportClause { + panic("NamespaceImport parent must be ImportClause") + } + promoteImportClause(changes, aliasDeclaration.Parent.AsImportClause(), program, sourceFile, ls, convertExistingToTypeOnly, aliasDeclaration) + return aliasDeclaration.Parent + + case ast.KindImportEqualsDeclaration: + // Remove the 'type' keyword (which is the second token: 'import' 'type' name '=' ...) + importEqDecl := aliasDeclaration.AsImportEqualsDeclaration() + // The type keyword is after 'import' and before the name + scan := scanner.GetScannerForSourceFile(sourceFile, importEqDecl.Pos()) + // Skip 'import' keyword to get to 'type' + scan.Scan() + deleteTypeKeyword(changes, sourceFile, scan.TokenStart()) + return aliasDeclaration + default: + panic(fmt.Sprintf("Unexpected alias declaration kind: %v", aliasDeclaration.Kind)) + } +} + +// promoteImportClause removes the type keyword from an import clause +func promoteImportClause( + changes *change.Tracker, + importClause *ast.ImportClause, + program *compiler.Program, + sourceFile *ast.SourceFile, + ls *LanguageService, + convertExistingToTypeOnly core.Tristate, + aliasDeclaration *ast.Declaration, +) { + // Delete the 'type' keyword + if importClause.PhaseModifier == ast.KindTypeKeyword { + deleteTypeKeyword(changes, sourceFile, importClause.Pos()) + } + + // Handle .ts extension conversion to .js if necessary + compilerOptions := program.Options() + if compilerOptions.AllowImportingTsExtensions.IsFalse() { + moduleSpecifier := checker.TryGetModuleSpecifierFromDeclaration(importClause.Parent) + if moduleSpecifier != nil { + resolvedModule := program.GetResolvedModuleFromModuleSpecifier(sourceFile, moduleSpecifier) + if resolvedModule != nil && resolvedModule.ResolvedUsingTsExtension { + moduleText := moduleSpecifier.AsStringLiteral().Text + changedExtension := tspath.ChangeExtension( + moduleText, + outputpaths.GetOutputExtension(moduleText, compilerOptions.Jsx), + ) + // Replace the module specifier with the new extension + newStringLiteral := changes.NewStringLiteral(changedExtension) + changes.ReplaceNode(sourceFile, moduleSpecifier, newStringLiteral, nil) + } + } + } + + // Handle verbatimModuleSyntax conversion + // If convertExistingToTypeOnly is true, we need to add 'type' to other specifiers + // in the same import declaration + if convertExistingToTypeOnly.IsTrue() { + namedImports := importClause.NamedBindings + if namedImports != nil && namedImports.Kind == ast.KindNamedImports { + namedImportsData := namedImports.AsNamedImports() + if len(namedImportsData.Elements.Nodes) > 1 { + // Check if the list is sorted and if we need to reorder + _, isSorted := organizeimports.GetNamedImportSpecifierComparerWithDetection( + importClause.Parent, + sourceFile, + ls.UserPreferences(), + ) + + // If the alias declaration is an ImportSpecifier and the list is sorted, + // move it to index 0 (since it will be the only non-type-only import) + if isSorted.IsFalse() == false && // isSorted !== false + aliasDeclaration != nil && + aliasDeclaration.Kind == ast.KindImportSpecifier { + // Find the index of the alias declaration + aliasIndex := -1 + for i, element := range namedImportsData.Elements.Nodes { + if element == aliasDeclaration { + aliasIndex = i + break + } + } + // If not already at index 0, move it there + if aliasIndex > 0 { + // Delete the specifier from its current position + changes.Delete(sourceFile, aliasDeclaration) + // Insert it at index 0 + changes.InsertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0) + } + } + + // Add 'type' keyword to all other import specifiers that aren't already type-only + for _, element := range namedImportsData.Elements.Nodes { + spec := element.AsImportSpecifier() + // Skip the specifier being promoted (if aliasDeclaration is an ImportSpecifier) + if aliasDeclaration != nil && aliasDeclaration.Kind == ast.KindImportSpecifier { + if element == aliasDeclaration { + continue + } + } + // Skip if already type-only + if !spec.IsTypeOnly { + changes.InsertModifierBefore(sourceFile, ast.KindTypeKeyword, element) + } + } + } + } + } +} + +// deleteTypeKeyword deletes the 'type' keyword token starting at the given position, +// including any trailing whitespace. +func deleteTypeKeyword(changes *change.Tracker, sourceFile *ast.SourceFile, startPos int) { + scan := scanner.GetScannerForSourceFile(sourceFile, startPos) + if scan.Token() != ast.KindTypeKeyword { + return + } + typeStart := scan.TokenStart() + typeEnd := scan.TokenEnd() + // Skip trailing whitespace + text := sourceFile.Text() + for typeEnd < len(text) && (text[typeEnd] == ' ' || text[typeEnd] == '\t') { + typeEnd++ + } + changes.DeleteRange(sourceFile, core.NewTextRange(typeStart, typeEnd)) +} diff --git a/internal/ls/completions.go b/internal/ls/completions.go index 74d31b48bf..611ab2fdae 100644 --- a/internal/ls/completions.go +++ b/internal/ls/completions.go @@ -11,7 +11,6 @@ import ( "unicode" "unicode/utf8" - "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/binder" @@ -22,8 +21,8 @@ import ( "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/format" "github.com/microsoft/typescript-go/internal/jsnum" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/lsutil" "github.com/microsoft/typescript-go/internal/nodebuilder" "github.com/microsoft/typescript-go/internal/printer" "github.com/microsoft/typescript-go/internal/scanner" @@ -36,8 +35,6 @@ func (l *LanguageService) ProvideCompletion( documentURI lsproto.DocumentUri, LSPPosition lsproto.Position, context *lsproto.CompletionContext, - clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, ) (lsproto.CompletionResponse, error) { _, file := l.getProgramAndFile(documentURI) var triggerCharacter *string @@ -50,8 +47,6 @@ func (l *LanguageService) ProvideCompletion( file, position, triggerCharacter, - preferences, - clientOptions, ) completionList = ensureItemData(file.FileName(), position, completionList) return lsproto.CompletionItemsOrListOrNull{List: completionList}, nil @@ -63,12 +58,11 @@ func ensureItemData(fileName string, pos int, list *lsproto.CompletionList) *lsp } for _, item := range list.Items { if item.Data == nil { - var data any = &itemData{ + item.Data = &lsproto.CompletionItemData{ FileName: fileName, - Position: pos, + Position: int32(pos), Name: item.Label, } - item.Data = &data } } return list @@ -87,8 +81,8 @@ type completionDataData struct { location *ast.Node keywordFilters KeywordCompletionFilters literals []literalValue - symbolToOriginInfoMap map[ast.SymbolId]*symbolOriginInfo - symbolToSortTextMap map[ast.SymbolId]sortText + symbolToOriginInfoMap map[int]*symbolOriginInfo + symbolToSortTextMap map[ast.SymbolId]SortText recommendedCompletion *ast.Symbol previousToken *ast.Node contextToken *ast.Node @@ -179,25 +173,25 @@ var noCommaCommitCharacters = []string{".", ";"} var emptyCommitCharacters = []string{} -type sortText string +type SortText string const ( - SortTextLocalDeclarationPriority sortText = "10" - SortTextLocationPriority sortText = "11" - SortTextOptionalMember sortText = "12" - SortTextMemberDeclaredBySpreadAssignment sortText = "13" - SortTextSuggestedClassMembers sortText = "14" - SortTextGlobalsOrKeywords sortText = "15" - SortTextAutoImportSuggestions sortText = "16" - SortTextClassMemberSnippets sortText = "17" - SortTextJavascriptIdentifiers sortText = "18" + SortTextLocalDeclarationPriority SortText = "10" + SortTextLocationPriority SortText = "11" + SortTextOptionalMember SortText = "12" + SortTextMemberDeclaredBySpreadAssignment SortText = "13" + SortTextSuggestedClassMembers SortText = "14" + SortTextGlobalsOrKeywords SortText = "15" + SortTextAutoImportSuggestions SortText = "16" + SortTextClassMemberSnippets SortText = "17" + SortTextJavascriptIdentifiers SortText = "18" ) -func DeprecateSortText(original sortText) sortText { +func DeprecateSortText(original SortText) SortText { return "z" + original } -func sortBelow(original sortText) sortText { +func sortBelow(original SortText) SortText { return original + "1" } @@ -246,25 +240,21 @@ func (origin *symbolOriginInfo) moduleSymbol() *ast.Symbol { } } -func (origin *symbolOriginInfo) toCompletionEntryData() *completionEntryData { +func (origin *symbolOriginInfo) toCompletionEntryData() *lsproto.AutoImportData { debug.Assert(origin.kind&symbolOriginInfoKindExport != 0, fmt.Sprintf("completionEntryData is not generated for symbolOriginInfo of type %T", origin.data)) - var ambientModuleName *string + var ambientModuleName string if origin.fileName == "" { - ambientModuleName = strPtrTo(stringutil.StripQuotes(origin.moduleSymbol().Name)) - } - var isPackageJsonImport core.Tristate - if origin.isFromPackageJson { - isPackageJsonImport = core.TSTrue + ambientModuleName = stringutil.StripQuotes(origin.moduleSymbol().Name) } data := origin.data.(*symbolOriginInfoExport) - return &completionEntryData{ + return &lsproto.AutoImportData{ ExportName: data.exportName, ExportMapKey: data.exportMapKey, ModuleSpecifier: data.moduleSpecifier, AmbientModuleName: ambientModuleName, - FileName: strPtrTo(origin.fileName), - IsPackageJsonImport: isPackageJsonImport, + FileName: origin.fileName, + IsPackageJsonImport: origin.isFromPackageJson, } } @@ -272,7 +262,7 @@ type symbolOriginInfoExport struct { symbolName string moduleSymbol *ast.Symbol exportName string - exportMapKey ExportInfoMapKey + exportMapKey lsproto.ExportInfoMapKey moduleSpecifier string } @@ -344,8 +334,6 @@ func (l *LanguageService) getCompletionsAtPosition( file *ast.SourceFile, position int, triggerCharacter *string, - preferences *UserPreferences, - clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { _, previousToken := getRelevantTokens(position, file) if triggerCharacter != nil && !IsInString(file, position, previousToken) && !isValidTrigger(file, *triggerCharacter, previousToken, position) { @@ -354,7 +342,7 @@ func (l *LanguageService) getCompletionsAtPosition( if triggerCharacter != nil && *triggerCharacter == " " { // `isValidTrigger` ensures we are at `import |` - if preferences.IncludeCompletionsForImportStatements.IsTrue() { + if l.UserPreferences().IncludeCompletionsForImportStatements.IsTrue() { return &lsproto.CompletionList{ IsIncomplete: true, } @@ -372,8 +360,6 @@ func (l *LanguageService) getCompletionsAtPosition( position, previousToken, compilerOptions, - preferences, - clientOptions, ) if stringCompletions != nil { return stringCompletions @@ -384,8 +370,8 @@ func (l *LanguageService) getCompletionsAtPosition( previousToken.Kind == ast.KindIdentifier) && ast.IsBreakOrContinueStatement(previousToken.Parent) { return l.getLabelCompletionsAtPosition( + ctx, previousToken.Parent, - clientOptions, file, position, l.getOptionalReplacementSpan(previousToken, file), @@ -394,6 +380,7 @@ func (l *LanguageService) getCompletionsAtPosition( checker, done := l.GetProgram().GetTypeCheckerForFile(ctx, file) defer done() + preferences := l.UserPreferences() data := l.getCompletionData(ctx, checker, file, position, preferences) if data == nil { return nil @@ -408,9 +395,7 @@ func (l *LanguageService) getCompletionsAtPosition( file, compilerOptions, data, - preferences, position, - clientOptions, optionalReplacementSpan, ) // !!! check if response is incomplete @@ -418,7 +403,7 @@ func (l *LanguageService) getCompletionsAtPosition( case *completionDataKeyword: optionalReplacementSpan := l.getOptionalReplacementSpan(previousToken, file) return l.specificKeywordCompletionInfo( - clientOptions, + ctx, position, file, data.keywordCompletions, @@ -429,7 +414,7 @@ func (l *LanguageService) getCompletionsAtPosition( // If the current position is a jsDoc tag name, only tag names should be provided for completion items := getJSDocTagNameCompletions() items = append(items, getJSDocParameterCompletions( - clientOptions, + ctx, file, position, checker, @@ -437,12 +422,12 @@ func (l *LanguageService) getCompletionsAtPosition( preferences, /*tagNameOnly*/ true, )...) - return l.jsDocCompletionInfo(clientOptions, position, file, items) + return l.jsDocCompletionInfo(ctx, position, file, items) case *completionDataJSDocTag: // If the current position is a jsDoc tag, only tags should be provided for completion items := getJSDocTagCompletions() items = append(items, getJSDocParameterCompletions( - clientOptions, + ctx, file, position, checker, @@ -450,9 +435,9 @@ func (l *LanguageService) getCompletionsAtPosition( preferences, /*tagNameOnly*/ false, )...) - return l.jsDocCompletionInfo(clientOptions, position, file, items) + return l.jsDocCompletionInfo(ctx, position, file, items) case *completionDataJSDocParameterName: - return l.jsDocCompletionInfo(clientOptions, position, file, getJSDocParameterNameCompletions(data.tag)) + return l.jsDocCompletionInfo(ctx, position, file, getJSDocParameterNameCompletions(data.tag)) default: panic("getCompletionData() returned unexpected type: " + fmt.Sprintf("%T", data)) } @@ -463,7 +448,7 @@ func (l *LanguageService) getCompletionData( typeChecker *checker.Checker, file *ast.SourceFile, position int, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, ) completionData { inCheckedFile := isCheckedFile(file, l.GetProgram().Options()) @@ -711,8 +696,9 @@ func (l *LanguageService) getCompletionData( hasUnresolvedAutoImports := false // This also gets mutated in nested-functions after the return var symbols []*ast.Symbol - symbolToOriginInfoMap := map[ast.SymbolId]*symbolOriginInfo{} - symbolToSortTextMap := map[ast.SymbolId]sortText{} + // Keys are indexes of `symbols`. + symbolToOriginInfoMap := map[int]*symbolOriginInfo{} + symbolToSortTextMap := map[ast.SymbolId]SortText{} var seenPropertySymbols collections.Set[ast.SymbolId] importSpecifierResolver := &importSpecifierResolverForCompletions{SourceFile: file, UserPreferences: preferences, l: l} isTypeOnlyLocation := insideJSDocTagTypeExpression || insideJsDocImportTag || @@ -725,9 +711,9 @@ func (l *LanguageService) getCompletionData( addSymbolOriginInfo := func(symbol *ast.Symbol, insertQuestionDot bool, insertAwait bool) { symbolId := ast.GetSymbolId(symbol) if insertAwait && seenPropertySymbols.AddIfAbsent(symbolId) { - symbolToOriginInfoMap[symbolId] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindPromise, insertQuestionDot)} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindPromise, insertQuestionDot)} } else if insertQuestionDot { - symbolToOriginInfoMap[symbolId] = &symbolOriginInfo{kind: symbolOriginInfoKindNullable} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: symbolOriginInfoKindNullable} } } @@ -772,7 +758,7 @@ func (l *LanguageService) getCompletionData( if moduleSymbol == nil || !checker.IsExternalModuleSymbol(moduleSymbol) || typeChecker.TryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.Name, moduleSymbol) != firstAccessibleSymbol { - symbolToOriginInfoMap[firstAccessibleSymbolId] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindSymbolMemberNoExport, insertQuestionDot)} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindSymbolMemberNoExport, insertQuestionDot)} } else { var fileName string if tspath.IsExternalModuleNameRelative(stringutil.StripQuotes(moduleSymbol.Name)) { @@ -793,11 +779,11 @@ func (l *LanguageService) getCompletionData( ) if result != nil { - symbolToOriginInfoMap[ast.GetSymbolId(symbol)] = &symbolOriginInfo{ + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{ kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindSymbolMemberExport, insertQuestionDot), isDefaultExport: false, fileName: fileName, - data: symbolOriginInfoExport{ + data: &symbolOriginInfoExport{ moduleSymbol: moduleSymbol, symbolName: firstAccessibleSymbol.Name, exportName: firstAccessibleSymbol.Name, @@ -1054,10 +1040,7 @@ func (l *LanguageService) getCompletionData( numberIndexType := typeChecker.GetNumberIndexType(t) isNewIdentifierLocation = stringIndexType != nil || numberIndexType != nil typeMembers = getPropertiesForObjectExpression(instantiatedType, completionsType, objectLikeContainer, typeChecker) - properties := objectLikeContainer.AsObjectLiteralExpression().Properties - if properties != nil { - existingMembers = properties.Nodes - } + existingMembers = objectLikeContainer.Properties() if len(typeMembers) == 0 { // Edge case: If NumberIndexType exists @@ -1110,10 +1093,7 @@ func (l *LanguageService) getCompletionData( ) }, ) - elements := objectLikeContainer.AsBindingPattern().Elements - if elements != nil { - existingMembers = elements.Nodes - } + existingMembers = objectLikeContainer.Elements() } } @@ -1189,7 +1169,7 @@ func (l *LanguageService) getCompletionData( // !!! moduleSpecifierCache := host.getModuleSpecifierCache(); // !!! packageJsonAutoImportProvider := host.getPackageJsonAutoImportProvider(); - addSymbolToList := func(info []*SymbolExportInfo, symbolName string, isFromAmbientModule bool, exportMapKey ExportInfoMapKey) []*SymbolExportInfo { + addSymbolToList := func(info []*SymbolExportInfo, symbolName string, isFromAmbientModule bool, exportMapKey lsproto.ExportInfoMapKey) []*SymbolExportInfo { // Do a relatively cheap check to bail early if all re-exports are non-importable // due to file location or package.json dependency filtering. For non-node16+ // module resolution modes, getting past this point guarantees that we'll be @@ -1204,7 +1184,6 @@ func (l *LanguageService) getCompletionData( file, toFile, i.moduleSymbol, - preferences, importSpecifierResolver.packageJsonImportFilter(), ) }) @@ -1262,7 +1241,7 @@ func (l *LanguageService) getCompletionData( moduleSpecifier: moduleSpecifier, }, } - symbolToOriginInfoMap[symbolId] = originInfo + symbolToOriginInfoMap[len(symbols)] = originInfo symbolToSortTextMap[symbolId] = core.IfElse(importStatementCompletion != nil, SortTextLocationPriority, SortTextAutoImportSuggestions) symbols = append(symbols, symbol) return nil @@ -1270,7 +1249,6 @@ func (l *LanguageService) getCompletionData( l.searchExportInfosForCompletions(ctx, typeChecker, file, - preferences, importStatementCompletion != nil, isRightOfOpenTag, isTypeOnlyLocation, @@ -1530,17 +1508,16 @@ func (l *LanguageService) getCompletionData( symbols = append(symbols, filterClassMembersList(baseSymbols, decl.Members(), classElementModifierFlags, file, position)...) - for _, symbol := range symbols { + for index, symbol := range symbols { declaration := symbol.ValueDeclaration if declaration != nil && ast.IsClassElement(declaration) && declaration.Name() != nil && ast.IsComputedPropertyName(declaration.Name()) { - symbolId := ast.GetSymbolId(symbol) origin := &symbolOriginInfo{ kind: symbolOriginInfoKindComputedPropertyName, data: &symbolOriginInfoComputedPropertyName{symbolName: typeChecker.SymbolToString(symbol)}, } - symbolToOriginInfoMap[symbolId] = origin + symbolToOriginInfoMap[index] = origin } } } @@ -1647,7 +1624,7 @@ func (l *LanguageService) getCompletionData( symbols = append(symbols, typeChecker.GetSymbolsInScope(scopeNode, symbolMeanings)...) core.CheckEachDefined(symbols, "getSymbolsInScope() should all be defined") - for _, symbol := range symbols { + for index, symbol := range symbols { symbolId := ast.GetSymbolId(symbol) if !typeChecker.IsArgumentsSymbol(symbol) && !core.Some(symbol.Declarations, func(decl *ast.Declaration) bool { @@ -1662,7 +1639,7 @@ func (l *LanguageService) getCompletionData( kind: symbolOriginInfoKindTypeOnlyAlias, data: &symbolOriginInfoTypeOnlyAlias{declaration: typeOnlyAliasDeclaration}, } - symbolToOriginInfoMap[symbolId] = origin + symbolToOriginInfoMap[index] = origin } } } @@ -1677,7 +1654,7 @@ func (l *LanguageService) getCompletionData( for _, symbol := range getPropertiesForCompletion(thisType, typeChecker) { symbolId := ast.GetSymbolId(symbol) symbols = append(symbols, symbol) - symbolToOriginInfoMap[symbolId] = &symbolOriginInfo{kind: symbolOriginInfoKindThisType} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: symbolOriginInfoKindThisType} symbolToSortTextMap[symbolId] = SortTextSuggestedClassMembers } } @@ -1829,19 +1806,18 @@ func (l *LanguageService) completionInfoFromData( file *ast.SourceFile, compilerOptions *core.CompilerOptions, data *completionDataData, - preferences *UserPreferences, position int, - clientOptions *lsproto.CompletionClientCapabilities, optionalReplacementSpan *lsproto.Range, ) *lsproto.CompletionList { keywordFilters := data.keywordFilters isNewIdentifierLocation := data.isNewIdentifierLocation contextToken := data.contextToken literals := data.literals + preferences := l.UserPreferences() // Verify if the file is JSX language variant if file.LanguageVariant == core.LanguageVariantJSX { - list := l.getJsxClosingTagCompletion(data.location, file, position, clientOptions) + list := l.getJsxClosingTagCompletion(ctx, data.location, file, position) if list != nil { return list } @@ -1879,9 +1855,7 @@ func (l *LanguageService) completionInfoFromData( nil, /*replacementToken*/ position, file, - preferences, compilerOptions, - clientOptions, ) if data.keywordFilters != KeywordCompletionFiltersNone { @@ -1922,7 +1896,7 @@ func (l *LanguageService) completionInfoFromData( // !!! exhaustive case completions itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, sortedEntries, @@ -1943,12 +1917,10 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( replacementToken *ast.Node, position int, file *ast.SourceFile, - preferences *UserPreferences, compilerOptions *core.CompilerOptions, - clientOptions *lsproto.CompletionClientCapabilities, ) (uniqueNames collections.Set[string], sortedEntries []*lsproto.CompletionItem) { closestSymbolDeclaration := getClosestSymbolDeclaration(data.contextToken, data.location) - useSemicolons := probablyUsesSemicolons(file) + useSemicolons := lsutil.ProbablyUsesSemicolons(file) typeChecker, done := l.GetProgram().GetTypeCheckerForFile(ctx, file) defer done() isMemberCompletion := isMemberCompletionKind(data.completionKind) @@ -1957,9 +1929,8 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. uniques := make(uniqueNamesMap) - for _, symbol := range data.symbols { - symbolId := ast.GetSymbolId(symbol) - origin := data.symbolToOriginInfoMap[symbolId] + for index, symbol := range data.symbols { + origin := data.symbolToOriginInfoMap[index] name, needsConvertPropertyAccess := getCompletionEntryDisplayNameForSymbol( symbol, origin, @@ -1983,7 +1954,7 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( originalSortText = SortTextLocationPriority } - var sortText sortText + var sortText SortText if isDeprecated(symbol, typeChecker) { sortText = DeprecateSortText(originalSortText) } else { @@ -2003,8 +1974,6 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( origin, useSemicolons, compilerOptions, - preferences, - clientOptions, isMemberCompletion, ) if entry == nil { @@ -2028,7 +1997,7 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( func completionNameForLiteral( file *ast.SourceFile, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, literal literalValue, ) string { switch literal := literal.(type) { @@ -2045,7 +2014,7 @@ func completionNameForLiteral( func createCompletionItemForLiteral( file *ast.SourceFile, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, literal literalValue, ) *lsproto.CompletionItem { return &lsproto.CompletionItem{ @@ -2060,7 +2029,7 @@ func (l *LanguageService) createCompletionItem( ctx context.Context, typeChecker *checker.Checker, symbol *ast.Symbol, - sortText sortText, + sortText SortText, replacementToken *ast.Node, data *completionDataData, position int, @@ -2070,10 +2039,9 @@ func (l *LanguageService) createCompletionItem( origin *symbolOriginInfo, useSemicolons bool, compilerOptions *core.CompilerOptions, - preferences *UserPreferences, - clientOptions *lsproto.CompletionClientCapabilities, isMemberCompletion bool, ) *lsproto.CompletionItem { + clientOptions := lsproto.GetClientCapabilities(ctx).TextDocument.Completion contextToken := data.contextToken var insertText string var filterText string @@ -2081,7 +2049,7 @@ func (l *LanguageService) createCompletionItem( var isSnippet, hasAction bool source := getSourceFromOrigin(origin) var labelDetails *lsproto.CompletionItemLabelDetails - + preferences := l.UserPreferences() insertQuestionDot := originIsNullableMember(origin) useBraces := originIsSymbolMember(origin) || needsConvertPropertyAccess if originIsThisType(origin) { @@ -2109,7 +2077,7 @@ func (l *LanguageService) createCompletionItem( insertText = name } - if insertQuestionDot || data.propertyAccessToConvert.AsPropertyAccessExpression().QuestionDotToken != nil { + if insertQuestionDot || data.propertyAccessToConvert.QuestionDotToken() != nil { insertText = "?." + insertText } @@ -2190,7 +2158,7 @@ func (l *LanguageService) createCompletionItem( if data.importStatementCompletion.isTopLevelTypeOnly { insertText += typeOnlyText } - tabStop := core.IfElse(ptrIsTrue(clientOptions.CompletionItem.SnippetSupport), "$1", "") + tabStop := core.IfElse(clientOptions.CompletionItem.SnippetSupport, "$1", "") importKind := getImportKind(file, exportKind, l.GetProgram(), true /*forceImportKeyword*/) escapedSnippet := escapeSnippetText(name) suffix := core.IfElse(useSemicolons, ";", "") @@ -2207,7 +2175,7 @@ func (l *LanguageService) createCompletionItem( } replacementSpan = data.importStatementCompletion.replacementSpan - isSnippet = ptrIsTrue(clientOptions.CompletionItem.SnippetSupport) + isSnippet = clientOptions.CompletionItem.SnippetSupport } } @@ -2251,7 +2219,7 @@ func (l *LanguageService) createCompletionItem( insertText = origin.asObjectLiteralMethod().insertText isSnippet = origin.asObjectLiteralMethod().isSnippet labelDetails = origin.asObjectLiteralMethod().labelDetails // !!! check if this can conflict with case above where we set label details - if !clientSupportsItemLabelDetails(clientOptions) { + if !clientSupportsItemLabelDetails(ctx) { name = name + *origin.asObjectLiteralMethod().labelDetails.Detail labelDetails = nil } @@ -2261,14 +2229,14 @@ func (l *LanguageService) createCompletionItem( if data.isJsxIdentifierExpected && !data.isRightOfOpenTag && - clientSupportsItemSnippet(clientOptions) && - preferences.JsxAttributeCompletionStyle != JsxAttributeCompletionStyleNone && + clientSupportsItemSnippet(ctx) && + preferences.JsxAttributeCompletionStyle != lsutil.JsxAttributeCompletionStyleNone && !(ast.IsJsxAttribute(data.location.Parent) && data.location.Parent.Initializer() != nil) { - useBraces := preferences.JsxAttributeCompletionStyle == JsxAttributeCompletionStyleBraces + useBraces := preferences.JsxAttributeCompletionStyle == lsutil.JsxAttributeCompletionStyleBraces t := typeChecker.GetTypeOfSymbolAtLocation(symbol, data.location) // If is boolean like or undefined, don't return a snippet, we want to return just the completion. - if preferences.JsxAttributeCompletionStyle == JsxAttributeCompletionStyleAuto && + if preferences.JsxAttributeCompletionStyle == lsutil.JsxAttributeCompletionStyleAuto && !t.IsBooleanLike() && !(t.IsUnion() && core.Some(t.Types(), (*checker.Type).IsBooleanLike)) { if t.IsStringLike() || @@ -2294,7 +2262,7 @@ func (l *LanguageService) createCompletionItem( } } - var autoImportData *completionEntryData + var autoImportData *lsproto.AutoImportData if originIsExport(origin) { autoImportData = origin.toCompletionEntryData() hasAction = data.importStatementCompletion == nil @@ -2328,10 +2296,10 @@ func (l *LanguageService) createCompletionItem( elementKind := getSymbolKind(typeChecker, symbol, data.location) var commitCharacters *[]string - if clientSupportsItemCommitCharacters(clientOptions) { + if clientSupportsItemCommitCharacters(ctx) { if elementKind == ScriptElementKindWarning || elementKind == ScriptElementKindString { commitCharacters = &[]string{} - } else if !clientSupportsDefaultCommitCharacters(clientOptions) { + } else if !clientSupportsDefaultCommitCharacters(ctx) { commitCharacters = ptrTo(data.defaultCommitCharacters) } // Otherwise use the completion list default. @@ -2341,6 +2309,7 @@ func (l *LanguageService) createCompletionItem( kindModifiers := getSymbolModifiers(typeChecker, symbol) return l.createLSPCompletionItem( + ctx, name, insertText, filterText, @@ -2352,7 +2321,6 @@ func (l *LanguageService) createCompletionItem( labelDetails, file, position, - clientOptions, isMemberCompletion, isSnippet, hasAction, @@ -2420,9 +2388,9 @@ func getFilterText( dotAccessor string, ) string { // Private field completion, e.g. label `#bar`. - if strings.HasPrefix(label, "#") { + if after, ok := strings.CutPrefix(label, "#"); ok { if insertText != "" { - if strings.HasPrefix(insertText, "this.#") { + if after, ok := strings.CutPrefix(insertText, "this.#"); ok { if wordStart == '#' { // `method() { this.#| }` // `method() { #| }` @@ -2430,7 +2398,7 @@ func getFilterText( } else { // `method() { this.| }` // `method() { | }` - return strings.TrimPrefix(insertText, "this.#") + return after } } } else { @@ -2440,7 +2408,7 @@ func getFilterText( } else { // `method() { this.| }` // `method() { | }` - return strings.TrimPrefix(label, "#") + return after } } } @@ -2535,7 +2503,7 @@ func boolToPtr(v bool) *bool { } func getLineOfPosition(file *ast.SourceFile, pos int) int { - line, _ := scanner.GetECMALineAndCharacterOfPosition(file, pos) + line := scanner.GetECMALineOfPosition(file, pos) return line } @@ -3163,7 +3131,7 @@ func (l *LanguageService) createRangeFromStringLiteralLikeContent(file *ast.Sour return l.createLspRangeFromBounds(nodeStart+1, replacementEnd, file) } -func quotePropertyName(file *ast.SourceFile, preferences *UserPreferences, name string) string { +func quotePropertyName(file *ast.SourceFile, preferences *lsutil.UserPreferences, name string) string { r, _ := utf8.DecodeRuneInString(name) if unicode.IsDigit(r) { return name @@ -3198,7 +3166,7 @@ func isNamedImportsOrExports(node *ast.Node) bool { func generateIdentifierForArbitraryString(text string) string { needsUnderscore := false - identifier := "" + var identifier strings.Builder var ch rune var size int @@ -3213,9 +3181,9 @@ func generateIdentifierForArbitraryString(text string) string { } if size > 0 && validChar { if needsUnderscore { - identifier += "_" + identifier.WriteRune('_') } - identifier += string(ch) + identifier.WriteRune(ch) needsUnderscore = false } else { needsUnderscore = true @@ -3223,15 +3191,16 @@ func generateIdentifierForArbitraryString(text string) string { } if needsUnderscore { - identifier += "_" + identifier.WriteRune('_') } // Default to "_" if the provided text was empty - if identifier == "" { + id := identifier.String() + if id == "" { return "_" } - return identifier + return id } // Copied from vscode TS extension. @@ -3289,10 +3258,7 @@ func getCompletionsSymbolKind(kind ScriptElementKind) lsproto.CompletionItemKind // Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order. // So, it's important that we sort those ties in the order we want them displayed if it matters. We don't // strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to -// do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned -// by the language service consistent with what TS Server does and what editors typically do. This also makes -// completions tests make more sense. We used to sort only alphabetically and only in the server layer, but -// this made tests really weird, since most fourslash tests don't use the server. +// do the work of comparing them so we can sort those ties appropriately. func compareCompletionEntries(entryInSlice *lsproto.CompletionItem, entryToInsert *lsproto.CompletionItem) int { compareStrings := stringutil.CompareStringsCaseInsensitiveThenSensitive result := compareStrings(*entryInSlice.SortText, *entryToInsert.SortText) @@ -3300,14 +3266,21 @@ func compareCompletionEntries(entryInSlice *lsproto.CompletionItem, entryToInser result = compareStrings(entryInSlice.Label, entryToInsert.Label) } if result == stringutil.ComparisonEqual && entryInSlice.Data != nil && entryToInsert.Data != nil { - sliceEntryData, ok1 := (*entryInSlice.Data).(*completionEntryData) - insertEntryData, ok2 := (*entryToInsert.Data).(*completionEntryData) - if ok1 && ok2 && sliceEntryData.ModuleSpecifier != "" && insertEntryData.ModuleSpecifier != "" { + sliceEntryData := entryInSlice.Data + insertEntryData := entryToInsert.Data + if sliceEntryData.AutoImport != nil && sliceEntryData.AutoImport.ModuleSpecifier != "" && + insertEntryData.AutoImport != nil && insertEntryData.AutoImport.ModuleSpecifier != "" { // Sort same-named auto-imports by module specifier - result = compareNumberOfDirectorySeparators( - sliceEntryData.ModuleSpecifier, - insertEntryData.ModuleSpecifier, + result = tspath.CompareNumberOfDirectorySeparators( + sliceEntryData.AutoImport.ModuleSpecifier, + insertEntryData.AutoImport.ModuleSpecifier, ) + if result == stringutil.ComparisonEqual { + result = compareStrings( + sliceEntryData.AutoImport.ModuleSpecifier, + insertEntryData.AutoImport.ModuleSpecifier, + ) + } } } if result == stringutil.ComparisonEqual { @@ -3526,10 +3499,10 @@ func getContextualKeywords(file *ast.SourceFile, contextToken *ast.Node, positio // Source: https://tc39.es/proposal-import-assertions/ if contextToken != nil { parent := contextToken.Parent - tokenLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, contextToken.End()) - currentLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, position) + tokenLine := scanner.GetECMALineOfPosition(file, contextToken.End()) + currentLine := scanner.GetECMALineOfPosition(file, position) if (ast.IsImportDeclaration(parent) || - ast.IsExportDeclaration(parent) && parent.AsExportDeclaration().ModuleSpecifier != nil) && + ast.IsExportDeclaration(parent) && parent.ModuleSpecifier() != nil) && contextToken == parent.ModuleSpecifier() && tokenLine == currentLine { entries = append(entries, &lsproto.CompletionItem{ @@ -4006,10 +3979,10 @@ func filterObjectMembersList( if ast.IsSpreadAssignment(member) { setMemberDeclaredBySpreadAssignment(member, &membersDeclaredBySpreadAssignment, typeChecker) - } else if ast.IsBindingElement(member) && member.AsBindingElement().PropertyName != nil { + } else if ast.IsBindingElement(member) && member.PropertyName() != nil { // include only identifiers in completion list - if member.AsBindingElement().PropertyName.Kind == ast.KindIdentifier { - existingName = member.AsBindingElement().PropertyName.Text() + if member.PropertyName().Kind == ast.KindIdentifier { + existingName = member.PropertyName().Text() } } else { // TODO: Account for computed property name @@ -4097,7 +4070,7 @@ func tryGetObjectTypeDeclarationCompletionContainer( } return nil case ast.KindEndOfFile: - stmtList := location.Parent.AsSourceFile().Statements + stmtList := location.Parent.StatementList() if stmtList != nil && len(stmtList.Nodes) > 0 && ast.IsObjectTypeDeclaration(stmtList.Nodes[len(stmtList.Nodes)-1]) { cls := stmtList.Nodes[len(stmtList.Nodes)-1] if findChildOfKind(cls, ast.KindCloseBraceToken, file) == nil { @@ -4326,7 +4299,7 @@ func isTypeKeywordTokenOrIdentifier(node *ast.Node) bool { // Returns the item defaults for completion items, if that capability is supported. // Otherwise, if some item default is not supported by client, sets that property on each item. func (l *LanguageService) setItemDefaults( - clientOptions *lsproto.CompletionClientCapabilities, + ctx context.Context, position int, file *ast.SourceFile, items []*lsproto.CompletionItem, @@ -4335,8 +4308,8 @@ func (l *LanguageService) setItemDefaults( ) *lsproto.CompletionItemDefaults { var itemDefaults *lsproto.CompletionItemDefaults if defaultCommitCharacters != nil { - supportsItemCommitCharacters := clientSupportsItemCommitCharacters(clientOptions) - if clientSupportsDefaultCommitCharacters(clientOptions) && supportsItemCommitCharacters { + supportsItemCommitCharacters := clientSupportsItemCommitCharacters(ctx) + if clientSupportsDefaultCommitCharacters(ctx) && supportsItemCommitCharacters { itemDefaults = &lsproto.CompletionItemDefaults{ CommitCharacters: defaultCommitCharacters, } @@ -4354,7 +4327,7 @@ func (l *LanguageService) setItemDefaults( Start: optionalReplacementSpan.Start, End: l.createLspPosition(position, file), } - if clientSupportsDefaultEditRange(clientOptions) { + if clientSupportsDefaultEditRange(ctx) { itemDefaults = core.OrElse(itemDefaults, &lsproto.CompletionItemDefaults{}) itemDefaults.EditRange = &lsproto.RangeOrEditRangeWithInsertReplace{ EditRangeWithInsertReplace: &lsproto.EditRangeWithInsertReplace{ @@ -4376,7 +4349,7 @@ func (l *LanguageService) setItemDefaults( item.InsertText = nil } } - } else if clientSupportsItemInsertReplace(clientOptions) { + } else if clientSupportsItemInsertReplace(ctx) { for _, item := range items { if item.TextEdit == nil { item.TextEdit = &lsproto.TextEditOrInsertReplaceEdit{ @@ -4395,7 +4368,7 @@ func (l *LanguageService) setItemDefaults( } func (l *LanguageService) specificKeywordCompletionInfo( - clientOptions *lsproto.CompletionClientCapabilities, + ctx context.Context, position int, file *ast.SourceFile, items []*lsproto.CompletionItem, @@ -4404,7 +4377,7 @@ func (l *LanguageService) specificKeywordCompletionInfo( ) *lsproto.CompletionList { defaultCommitCharacters := getDefaultCommitCharacters(isNewIdentifierLocation) itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -4419,10 +4392,10 @@ func (l *LanguageService) specificKeywordCompletionInfo( } func (l *LanguageService) getJsxClosingTagCompletion( + ctx context.Context, location *ast.Node, file *ast.SourceFile, position int, - clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { // We wanna walk up the tree till we find a JSX closing element. jsxClosingElement := ast.FindAncestorOrQuit(location, func(node *ast.Node) ast.FindAncestorResult { @@ -4460,6 +4433,7 @@ func (l *LanguageService) getJsxClosingTagCompletion( defaultCommitCharacters := getDefaultCommitCharacters(false /*isNewIdentifierLocation*/) item := l.createLSPCompletionItem( + ctx, fullClosingTag, /*name*/ "", /*insertText*/ "", /*filterText*/ @@ -4471,7 +4445,6 @@ func (l *LanguageService) getJsxClosingTagCompletion( nil, /*labelDetails*/ file, position, - clientOptions, true, /*isMemberCompletion*/ false, /*isSnippet*/ false, /*hasAction*/ @@ -4481,7 +4454,7 @@ func (l *LanguageService) getJsxClosingTagCompletion( ) items := []*lsproto.CompletionItem{item} itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -4497,10 +4470,11 @@ func (l *LanguageService) getJsxClosingTagCompletion( } func (l *LanguageService) createLSPCompletionItem( + ctx context.Context, name string, insertText string, filterText string, - sortText sortText, + sortText SortText, elementKind ScriptElementKind, kindModifiers collections.Set[ScriptElementKindModifier], replacementSpan *lsproto.Range, @@ -4508,18 +4482,17 @@ func (l *LanguageService) createLSPCompletionItem( labelDetails *lsproto.CompletionItemLabelDetails, file *ast.SourceFile, position int, - clientOptions *lsproto.CompletionClientCapabilities, isMemberCompletion bool, isSnippet bool, hasAction bool, preselect bool, source string, - autoImportEntryData *completionEntryData, + autoImportEntryData *lsproto.AutoImportData, ) *lsproto.CompletionItem { kind := getCompletionsSymbolKind(elementKind) - var data any = &itemData{ + data := &lsproto.CompletionItemData{ FileName: file.FileName(), - Position: position, + Position: int32(position), Source: source, Name: name, AutoImport: autoImportEntryData, @@ -4597,24 +4570,24 @@ func (l *LanguageService) createLSPCompletionItem( InsertTextFormat: insertTextFormat, TextEdit: textEdit, CommitCharacters: commitCharacters, - Data: &data, + Data: data, } } func (l *LanguageService) getLabelCompletionsAtPosition( + ctx context.Context, node *ast.BreakOrContinueStatement, - clientOptions *lsproto.CompletionClientCapabilities, file *ast.SourceFile, position int, optionalReplacementSpan *lsproto.Range, ) *lsproto.CompletionList { - items := l.getLabelStatementCompletions(node, clientOptions, file, position) + items := l.getLabelStatementCompletions(ctx, node, file, position) if len(items) == 0 { return nil } defaultCommitCharacters := getDefaultCommitCharacters(false /*isNewIdentifierLocation*/) itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -4629,8 +4602,8 @@ func (l *LanguageService) getLabelCompletionsAtPosition( } func (l *LanguageService) getLabelStatementCompletions( + ctx context.Context, node *ast.BreakOrContinueStatement, - clientOptions *lsproto.CompletionClientCapabilities, file *ast.SourceFile, position int, ) []*lsproto.CompletionItem { @@ -4646,6 +4619,7 @@ func (l *LanguageService) getLabelStatementCompletions( if !uniques.Has(name) { uniques.Add(name) items = append(items, l.createLSPCompletionItem( + ctx, name, "", /*insertText*/ "", /*filterText*/ @@ -4657,7 +4631,6 @@ func (l *LanguageService) getLabelStatementCompletions( nil, /*labelDetails*/ file, position, - clientOptions, false, /*isMemberCompletion*/ false, /*isSnippet*/ false, /*hasAction*/ @@ -4897,38 +4870,28 @@ func isInJsxText(contextToken *ast.Node, location *ast.Node) bool { return false } -func hasCompletionItem(clientOptions *lsproto.CompletionClientCapabilities) bool { - return clientOptions != nil && clientOptions.CompletionItem != nil +func clientSupportsItemLabelDetails(ctx context.Context) bool { + return lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionItem.LabelDetailsSupport } -func clientSupportsItemLabelDetails(clientOptions *lsproto.CompletionClientCapabilities) bool { - return hasCompletionItem(clientOptions) && ptrIsTrue(clientOptions.CompletionItem.LabelDetailsSupport) +func clientSupportsItemSnippet(ctx context.Context) bool { + return lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionItem.SnippetSupport } -func clientSupportsItemSnippet(clientOptions *lsproto.CompletionClientCapabilities) bool { - return hasCompletionItem(clientOptions) && ptrIsTrue(clientOptions.CompletionItem.SnippetSupport) +func clientSupportsItemCommitCharacters(ctx context.Context) bool { + return lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionItem.CommitCharactersSupport } -func clientSupportsItemCommitCharacters(clientOptions *lsproto.CompletionClientCapabilities) bool { - return hasCompletionItem(clientOptions) && ptrIsTrue(clientOptions.CompletionItem.CommitCharactersSupport) +func clientSupportsItemInsertReplace(ctx context.Context) bool { + return lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionItem.InsertReplaceSupport } -func clientSupportsItemInsertReplace(clientOptions *lsproto.CompletionClientCapabilities) bool { - return hasCompletionItem(clientOptions) && ptrIsTrue(clientOptions.CompletionItem.InsertReplaceSupport) -} - -func clientSupportsDefaultCommitCharacters(clientOptions *lsproto.CompletionClientCapabilities) bool { - if clientOptions == nil || clientOptions.CompletionList == nil || clientOptions.CompletionList.ItemDefaults == nil { - return false - } - return slices.Contains(*clientOptions.CompletionList.ItemDefaults, "commitCharacters") +func clientSupportsDefaultCommitCharacters(ctx context.Context) bool { + return slices.Contains(lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionList.ItemDefaults, "commitCharacters") } -func clientSupportsDefaultEditRange(clientOptions *lsproto.CompletionClientCapabilities) bool { - if clientOptions == nil || clientOptions.CompletionList == nil || clientOptions.CompletionList.ItemDefaults == nil { - return false - } - return slices.Contains(*clientOptions.CompletionList.ItemDefaults, "editRange") +func clientSupportsDefaultEditRange(ctx context.Context) bool { + return slices.Contains(lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionList.ItemDefaults, "editRange") } type argumentInfoForCompletions struct { @@ -4949,33 +4912,7 @@ func getArgumentInfoForCompletions(node *ast.Node, position int, file *ast.Sourc } } -type itemData struct { - FileName string `json:"fileName"` - Position int `json:"position"` - Source string `json:"source,omitempty"` - Name string `json:"name,omitempty"` - AutoImport *completionEntryData `json:"autoImport,omitempty"` -} - -type completionEntryData struct { - /** - * The name of the property or export in the module's symbol table. Differs from the completion name - * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. - */ - ExportName string `json:"exportName"` - ExportMapKey ExportInfoMapKey `json:"exportMapKey"` - ModuleSpecifier string `json:"moduleSpecifier"` - - /** The file name declaring the export's module symbol, if it was an external module */ - FileName *string `json:"fileName"` - /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ - AmbientModuleName *string `json:"ambientModuleName"` - - /** True if the export was found in the package.json AutoImportProvider */ - IsPackageJsonImport core.Tristate `json:"isPackageJsonImport"` -} - -func (d *completionEntryData) toSymbolOriginExport(symbolName string, moduleSymbol *ast.Symbol, isDefaultExport bool) *symbolOriginInfoExport { +func autoImportDataToSymbolOriginExport(d *lsproto.AutoImportData, symbolName string, moduleSymbol *ast.Symbol, isDefaultExport bool) *symbolOriginInfoExport { return &symbolOriginInfoExport{ symbolName: symbolName, moduleSymbol: moduleSymbol, @@ -5012,9 +4949,7 @@ const ( func (l *LanguageService) ResolveCompletionItem( ctx context.Context, item *lsproto.CompletionItem, - data *itemData, - clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, + data *lsproto.CompletionItemData, ) (*lsproto.CompletionItem, error) { if data == nil { return nil, errors.New("completion item data is nil") @@ -5025,19 +4960,11 @@ func (l *LanguageService) ResolveCompletionItem( return nil, fmt.Errorf("file not found: %s", data.FileName) } - return l.getCompletionItemDetails(ctx, program, data.Position, file, item, data, clientOptions, preferences), nil + return l.getCompletionItemDetails(ctx, program, int(data.Position), file, item, data), nil } -func GetCompletionItemData(item *lsproto.CompletionItem) (*itemData, error) { - bytes, err := json.Marshal(item.Data) - if err != nil { - return nil, fmt.Errorf("failed to marshal completion item data: %w", err) - } - var itemData itemData - if err := json.Unmarshal(bytes, &itemData); err != nil { - return nil, fmt.Errorf("failed to unmarshal completion item data: %w", err) - } - return &itemData, nil +func getCompletionDocumentationFormat(ctx context.Context) lsproto.MarkupKind { + return lsproto.PreferredMarkupKind(lsproto.GetClientCapabilities(ctx).TextDocument.Completion.CompletionItem.DocumentationFormat) } func (l *LanguageService) getCompletionItemDetails( @@ -5046,23 +4973,22 @@ func (l *LanguageService) getCompletionItemDetails( position int, file *ast.SourceFile, item *lsproto.CompletionItem, - itemData *itemData, - clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, + data *lsproto.CompletionItemData, ) *lsproto.CompletionItem { checker, done := program.GetTypeCheckerForFile(ctx, file) defer done() + docFormat := getCompletionDocumentationFormat(ctx) contextToken, previousToken := getRelevantTokens(position, file) if IsInString(file, position, previousToken) { return l.getStringLiteralCompletionDetails( ctx, checker, item, - itemData.Name, + data.Name, file, position, contextToken, - preferences, + docFormat, ) } @@ -5072,25 +4998,25 @@ func (l *LanguageService) getCompletionItemDetails( checker, file, position, - itemData, - clientOptions, - preferences, + data, ) + preferences := l.UserPreferences() + switch { case symbolCompletion.request != nil: request := *symbolCompletion.request switch request := request.(type) { case *completionDataJSDocTagName: - return createSimpleDetails(item, itemData.Name) + return createSimpleDetails(item, data.Name, docFormat) case *completionDataJSDocTag: - return createSimpleDetails(item, itemData.Name) + return createSimpleDetails(item, data.Name, docFormat) case *completionDataJSDocParameterName: - return createSimpleDetails(item, itemData.Name) + return createSimpleDetails(item, data.Name, docFormat) case *completionDataKeyword: if core.Some(request.keywordCompletions, func(c *lsproto.CompletionItem) bool { - return c.Label == itemData.Name + return c.Label == data.Name }) { - return createSimpleDetails(item, itemData.Name) + return createSimpleDetails(item, data.Name, docFormat) } return item default: @@ -5098,26 +5024,27 @@ func (l *LanguageService) getCompletionItemDetails( } case symbolCompletion.symbol != nil: symbolDetails := symbolCompletion.symbol - actions := l.getCompletionItemActions(ctx, checker, file, position, itemData, symbolDetails, preferences) - return createCompletionDetailsForSymbol( + actions := l.getCompletionItemActions(ctx, checker, file, position, data, symbolDetails) + return l.createCompletionDetailsForSymbol( item, symbolDetails.symbol, checker, symbolDetails.location, actions, + docFormat, ) case symbolCompletion.literal != nil: literal := symbolCompletion.literal - return createSimpleDetails(item, completionNameForLiteral(file, preferences, *literal)) + return createSimpleDetails(item, completionNameForLiteral(file, preferences, *literal), docFormat) case symbolCompletion.cases != nil: // !!! exhaustive case completions return item default: // Didn't find a symbol with this name. See if we can find a keyword instead. if core.Some(allKeywordCompletions(), func(c *lsproto.CompletionItem) bool { - return c.Label == itemData.Name + return c.Label == data.Name }) { - return createSimpleDetails(item, itemData.Name) + return createSimpleDetails(item, data.Name, docFormat) } return item } @@ -5145,9 +5072,7 @@ func (l *LanguageService) getSymbolCompletionFromItemData( ch *checker.Checker, file *ast.SourceFile, position int, - itemData *itemData, - clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, + itemData *lsproto.CompletionItemData, ) detailsData { if itemData.Source == SourceSwitchCases { return detailsData{ @@ -5164,7 +5089,7 @@ func (l *LanguageService) getSymbolCompletionFromItemData( } } - completionData := l.getCompletionData(ctx, ch, file, position, &UserPreferences{IncludeCompletionsForModuleExports: core.TSTrue, IncludeCompletionsForImportStatements: core.TSTrue}) + completionData := l.getCompletionData(ctx, ch, file, position, &lsutil.UserPreferences{IncludeCompletionsForModuleExports: core.TSTrue, IncludeCompletionsForImportStatements: core.TSTrue}) if completionData == nil { return detailsData{} } @@ -5177,6 +5102,7 @@ func (l *LanguageService) getSymbolCompletionFromItemData( data := completionData.(*completionDataData) + preferences := l.UserPreferences() var literal literalValue for _, l := range data.literals { if completionNameForLiteral(file, preferences, l) == itemData.Name { @@ -5194,9 +5120,8 @@ func (l *LanguageService) getSymbolCompletionFromItemData( // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - for _, symbol := range data.symbols { - symbolId := ast.GetSymbolId(symbol) - origin := data.symbolToOriginInfoMap[symbolId] + for index, symbol := range data.symbols { + origin := data.symbolToOriginInfoMap[index] displayName, _ := getCompletionEntryDisplayNameForSymbol(symbol, origin, data.completionKind, data.isJsxIdentifierExpected) if displayName == itemData.Name && (itemData.Source == string(completionSourceClassMemberSnippet) && symbol.Flags&ast.SymbolFlagsClassMember != 0 || @@ -5219,15 +5144,15 @@ func (l *LanguageService) getSymbolCompletionFromItemData( return detailsData{} } -func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker.Checker, name string, autoImportData *completionEntryData) *symbolDetails { +func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker.Checker, name string, autoImportData *lsproto.AutoImportData) *symbolDetails { containingProgram := l.GetProgram() // !!! isPackageJson ? packageJsonAutoimportProvider : program var moduleSymbol *ast.Symbol - if autoImportData.AmbientModuleName != nil { - moduleSymbol = ch.TryFindAmbientModule(*autoImportData.AmbientModuleName) - } else if autoImportData.FileName != nil { - moduleSymbolSourceFile := containingProgram.GetSourceFile(*autoImportData.FileName) + if autoImportData.AmbientModuleName != "" { + moduleSymbol = ch.TryFindAmbientModule(autoImportData.AmbientModuleName) + } else if autoImportData.FileName != "" { + moduleSymbolSourceFile := containingProgram.GetSourceFile(autoImportData.FileName) if moduleSymbolSourceFile == nil { - panic("module sourceFile not found: " + *autoImportData.FileName) + panic("module sourceFile not found: " + autoImportData.FileName) } moduleSymbol = ch.GetMergedSymbol(moduleSymbolSourceFile.Symbol) } @@ -5253,10 +5178,10 @@ func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker } origin := &symbolOriginInfo{ kind: symbolOriginInfoKindExport, - fileName: *autoImportData.FileName, - isFromPackageJson: autoImportData.IsPackageJsonImport.IsTrue(), + fileName: autoImportData.FileName, + isFromPackageJson: autoImportData.IsPackageJsonImport, isDefaultExport: isDefaultExport, - data: autoImportData.toSymbolOriginExport(name, moduleSymbol, isDefaultExport), + data: autoImportDataToSymbolOriginExport(autoImportData, name, moduleSymbol, isDefaultExport), } return &symbolDetails{symbol: symbol, origin: origin} @@ -5265,14 +5190,16 @@ func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker func createSimpleDetails( item *lsproto.CompletionItem, name string, + docFormat lsproto.MarkupKind, ) *lsproto.CompletionItem { - return createCompletionDetails(item, name, "" /*documentation*/) + return createCompletionDetails(item, name, "" /*documentation*/, docFormat) } func createCompletionDetails( item *lsproto.CompletionItem, detail string, documentation string, + docFormat lsproto.MarkupKind, ) *lsproto.CompletionItem { // !!! fill in additionalTextEdits from code actions if item.Detail == nil && detail != "" { @@ -5281,7 +5208,7 @@ func createCompletionDetails( if documentation != "" { item.Documentation = &lsproto.StringOrMarkupContent{ MarkupContent: &lsproto.MarkupContent{ - Kind: lsproto.MarkupKindMarkdown, + Kind: docFormat, Value: documentation, }, } @@ -5296,12 +5223,13 @@ type codeAction struct { changes []*lsproto.TextEdit } -func createCompletionDetailsForSymbol( +func (l *LanguageService) createCompletionDetailsForSymbol( item *lsproto.CompletionItem, symbol *ast.Symbol, checker *checker.Checker, location *ast.Node, actions []codeAction, + docFormat lsproto.MarkupKind, ) *lsproto.CompletionItem { details := make([]string, 0, len(actions)+1) edits := make([]*lsproto.TextEdit, 0, len(actions)) @@ -5309,16 +5237,16 @@ func createCompletionDetailsForSymbol( details = append(details, action.description) edits = append(edits, action.changes...) } - quickInfo, documentation := getQuickInfoAndDocumentationForSymbol(checker, symbol, location) + quickInfo, documentation := l.getQuickInfoAndDocumentationForSymbol(checker, symbol, location, docFormat) details = append(details, quickInfo) if len(edits) != 0 { item.AdditionalTextEdits = &edits } - return createCompletionDetails(item, strings.Join(details, "\n\n"), documentation) + return createCompletionDetails(item, strings.Join(details, "\n\n"), documentation, docFormat) } // !!! snippets -func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *checker.Checker, file *ast.SourceFile, position int, itemData *itemData, symbolDetails *symbolDetails, preferences *UserPreferences) []codeAction { +func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *checker.Checker, file *ast.SourceFile, position int, itemData *lsproto.CompletionItemData, symbolDetails *symbolDetails) []codeAction { if itemData.AutoImport != nil && itemData.AutoImport.ModuleSpecifier != "" && symbolDetails.previousToken != nil { // Import statement completion: 'import c|' if symbolDetails.contextToken != nil && l.getImportStatementCompletionInfo(symbolDetails.contextToken, file).replacementSpan != nil { @@ -5331,7 +5259,7 @@ func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *chec // !!! origin.isTypeOnlyAlias // entryId.source == CompletionSourceObjectLiteralMemberWithComma && contextToken - if symbolDetails.origin == nil { + if symbolDetails.origin == nil || symbolDetails.origin.data == nil { return nil } @@ -5348,7 +5276,7 @@ func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *chec moduleSymbol := symbolDetails.origin.moduleSymbol() - var exportMapkey ExportInfoMapKey + var exportMapkey lsproto.ExportInfoMapKey if itemData.AutoImport != nil { exportMapkey = itemData.AutoImport.ExportMapKey } @@ -5363,7 +5291,6 @@ func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *chec itemData.Name, isJsxOpeningTagName, // formatContext, - preferences, ) if !(moduleSpecifier == itemData.AutoImport.ModuleSpecifier || itemData.AutoImport.ModuleSpecifier == "") { @@ -5435,7 +5362,7 @@ func (l *LanguageService) getImportStatementCompletionInfo(contextToken *ast.Nod result.replacementSpan = l.getSingleLineReplacementSpanForImportCompletionNode(candidate) result.couldBeTypeOnlyImportSpecifier = couldBeTypeOnlyImportSpecifier(candidate, contextToken) if ast.IsImportDeclaration(candidate) { - result.isTopLevelTypeOnly = candidate.AsImportDeclaration().ImportClause.IsTypeOnly() + result.isTopLevelTypeOnly = candidate.ImportClause().IsTypeOnly() } else if candidate.Kind == ast.KindImportEqualsDeclaration { result.isTopLevelTypeOnly = candidate.IsTypeOnly() } @@ -5597,14 +5524,14 @@ func isTagWithTypeExpression(tag *ast.JSDocTag) bool { } func (l *LanguageService) jsDocCompletionInfo( - clientOptions *lsproto.CompletionClientCapabilities, + ctx context.Context, position int, file *ast.SourceFile, items []*lsproto.CompletionItem, ) *lsproto.CompletionList { defaultCommitCharacters := getDefaultCommitCharacters(false /*isNewIdentifierLocation*/) itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -5740,12 +5667,12 @@ func getJSDocTagCompletions() []*lsproto.CompletionItem { } func getJSDocParameterCompletions( - clientOptions *lsproto.CompletionClientCapabilities, + ctx context.Context, file *ast.SourceFile, position int, typeChecker *checker.Checker, options *core.CompilerOptions, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, tagNameOnly bool, ) []*lsproto.CompletionItem { currentToken := astnav.GetTokenAtPosition(file, position) @@ -5887,7 +5814,7 @@ func getJSDocParamAnnotation( isSnippet bool, typeChecker *checker.Checker, options *core.CompilerOptions, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, tabstopCounter *int, ) string { if isSnippet { @@ -5973,7 +5900,7 @@ func generateJSDocParamTagsForDestructuring( isSnippet bool, typeChecker *checker.Checker, options *core.CompilerOptions, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, ) []string { tabstopCounter := 1 if !isJS { @@ -6013,7 +5940,7 @@ func jsDocParamPatternWorker( isSnippet bool, typeChecker *checker.Checker, options *core.CompilerOptions, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, counter *int, ) []string { if ast.IsObjectBindingPattern(pattern) && dotDotDotToken == nil { @@ -6082,7 +6009,7 @@ func jsDocParamElementWorker( isSnippet bool, typeChecker *checker.Checker, options *core.CompilerOptions, - preferences *UserPreferences, + preferences *lsutil.UserPreferences, counter *int, ) []string { if ast.IsIdentifier(element.Name()) { // `{ b }` or `{ b: newB }` diff --git a/internal/ls/converters.go b/internal/ls/converters.go deleted file mode 100644 index b7730f3e5d..0000000000 --- a/internal/ls/converters.go +++ /dev/null @@ -1,199 +0,0 @@ -package ls - -import ( - "fmt" - "net/url" - "slices" - "strings" - "unicode/utf16" - "unicode/utf8" - - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/tspath" -) - -type Converters struct { - getLineMap func(fileName string) *LSPLineMap - positionEncoding lsproto.PositionEncodingKind -} - -type Script interface { - FileName() string - Text() string -} - -func NewConverters(positionEncoding lsproto.PositionEncodingKind, getLineMap func(fileName string) *LSPLineMap) *Converters { - return &Converters{ - getLineMap: getLineMap, - positionEncoding: positionEncoding, - } -} - -func (c *Converters) ToLSPRange(script Script, textRange core.TextRange) lsproto.Range { - return lsproto.Range{ - Start: c.PositionToLineAndCharacter(script, core.TextPos(textRange.Pos())), - End: c.PositionToLineAndCharacter(script, core.TextPos(textRange.End())), - } -} - -func (c *Converters) FromLSPRange(script Script, textRange lsproto.Range) core.TextRange { - return core.NewTextRange( - int(c.LineAndCharacterToPosition(script, textRange.Start)), - int(c.LineAndCharacterToPosition(script, textRange.End)), - ) -} - -func (c *Converters) FromLSPTextChange(script Script, change *lsproto.TextDocumentContentChangePartial) core.TextChange { - return core.TextChange{ - TextRange: c.FromLSPRange(script, change.Range), - NewText: change.Text, - } -} - -func (c *Converters) ToLSPLocation(script Script, rng core.TextRange) lsproto.Location { - return lsproto.Location{ - Uri: FileNameToDocumentURI(script.FileName()), - Range: c.ToLSPRange(script, rng), - } -} - -func LanguageKindToScriptKind(languageID lsproto.LanguageKind) core.ScriptKind { - switch languageID { - case "typescript": - return core.ScriptKindTS - case "typescriptreact": - return core.ScriptKindTSX - case "javascript": - return core.ScriptKindJS - case "javascriptreact": - return core.ScriptKindJSX - case "json": - return core.ScriptKindJSON - default: - return core.ScriptKindUnknown - } -} - -// https://github.com/microsoft/vscode-uri/blob/edfdccd976efaf4bb8fdeca87e97c47257721729/src/uri.ts#L455 -var extraEscapeReplacer = strings.NewReplacer( - ":", "%3A", - "/", "%2F", - "?", "%3F", - "#", "%23", - "[", "%5B", - "]", "%5D", - "@", "%40", - - "!", "%21", - "$", "%24", - "&", "%26", - "'", "%27", - "(", "%28", - ")", "%29", - "*", "%2A", - "+", "%2B", - ",", "%2C", - ";", "%3B", - "=", "%3D", - - " ", "%20", -) - -func FileNameToDocumentURI(fileName string) lsproto.DocumentUri { - if strings.HasPrefix(fileName, "^/") { - scheme, rest, ok := strings.Cut(fileName[2:], "/") - if !ok { - panic("invalid file name: " + fileName) - } - authority, path, ok := strings.Cut(rest, "/") - if !ok { - panic("invalid file name: " + fileName) - } - if authority == "ts-nul-authority" { - return lsproto.DocumentUri(scheme + ":" + path) - } - return lsproto.DocumentUri(scheme + "://" + authority + "/" + path) - } - - volume, fileName, _ := tspath.SplitVolumePath(fileName) - if volume != "" { - volume = "/" + extraEscapeReplacer.Replace(volume) - } - - fileName = strings.TrimPrefix(fileName, "//") - - parts := strings.Split(fileName, "/") - for i, part := range parts { - parts[i] = extraEscapeReplacer.Replace(url.PathEscape(part)) - } - - return lsproto.DocumentUri("file://" + volume + strings.Join(parts, "/")) -} - -func (c *Converters) LineAndCharacterToPosition(script Script, lineAndCharacter lsproto.Position) core.TextPos { - // UTF-8/16 0-indexed line and character to UTF-8 offset - - lineMap := c.getLineMap(script.FileName()) - - line := core.TextPos(lineAndCharacter.Line) - char := core.TextPos(lineAndCharacter.Character) - - if line < 0 || int(line) >= len(lineMap.LineStarts) { - panic(fmt.Sprintf("bad line number. Line: %d, lineMap length: %d", line, len(lineMap.LineStarts))) - } - - start := lineMap.LineStarts[line] - if lineMap.AsciiOnly || c.positionEncoding == lsproto.PositionEncodingKindUTF8 { - return start + char - } - - var utf8Char core.TextPos - var utf16Char core.TextPos - - for i, r := range script.Text()[start:] { - u16Len := core.TextPos(utf16.RuneLen(r)) - if utf16Char+u16Len > char { - break - } - utf16Char += u16Len - utf8Char = core.TextPos(i + utf8.RuneLen(r)) - } - - return start + utf8Char -} - -func (c *Converters) PositionToLineAndCharacter(script Script, position core.TextPos) lsproto.Position { - // UTF-8 offset to UTF-8/16 0-indexed line and character - - lineMap := c.getLineMap(script.FileName()) - - line, isLineStart := slices.BinarySearch(lineMap.LineStarts, position) - if !isLineStart { - line-- - } - line = max(0, line) - - // The current line ranges from lineMap.LineStarts[line] (or 0) to lineMap.LineStarts[line+1] (or len(text)). - - start := lineMap.LineStarts[line] - - var character core.TextPos - if lineMap.AsciiOnly || c.positionEncoding == lsproto.PositionEncodingKindUTF8 { - character = position - start - } else { - // We need to rescan the text as UTF-16 to find the character offset. - for _, r := range script.Text()[start:position] { - character += core.TextPos(utf16.RuneLen(r)) - } - } - - return lsproto.Position{ - Line: uint32(line), - Character: uint32(character), - } -} - -func ptrTo[T any](v T) *T { - return &v -} diff --git a/internal/ls/definition.go b/internal/ls/definition.go index 85ad411aae..d6e69d1f9e 100644 --- a/internal/ls/definition.go +++ b/internal/ls/definition.go @@ -7,30 +7,39 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/scanner" ) -func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.DefinitionResponse, error) { +func (l *LanguageService) ProvideDefinition( + ctx context.Context, + documentURI lsproto.DocumentUri, + position lsproto.Position, +) (lsproto.DefinitionResponse, error) { + caps := lsproto.GetClientCapabilities(ctx) + clientSupportsLink := caps.TextDocument.Definition.LinkSupport + program, file := l.getProgramAndFile(documentURI) node := astnav.GetTouchingPropertyName(file, int(l.converters.LineAndCharacterToPosition(file, position))) if node.Kind == ast.KindSourceFile { return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{}, nil } + originSelectionRange := l.createLspRangeFromNode(node, file) c, done := program.GetTypeCheckerForFile(ctx, file) defer done() if node.Kind == ast.KindOverrideKeyword { if sym := getSymbolForOverriddenMember(c, node); sym != nil { - return l.createLocationsFromDeclarations(sym.Declarations), nil + return l.createLocationsFromDeclarations(originSelectionRange, clientSupportsLink, sym.Declarations), nil } } if ast.IsJumpStatementTarget(node) { if label := getTargetLabel(node.Parent, node.Text()); label != nil { - return l.createLocationsFromDeclarations([]*ast.Node{label}), nil + return l.createLocationsFromDeclarations(originSelectionRange, clientSupportsLink, []*ast.Node{label}), nil } } @@ -43,7 +52,7 @@ func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsp if node.Kind == ast.KindReturnKeyword || node.Kind == ast.KindYieldKeyword || node.Kind == ast.KindAwaitKeyword { if fn := ast.FindAncestor(node, ast.IsFunctionLikeDeclaration); fn != nil { - return l.createLocationsFromDeclarations([]*ast.Node{fn}), nil + return l.createLocationsFromDeclarations(originSelectionRange, clientSupportsLink, []*ast.Node{fn}), nil } } @@ -54,15 +63,23 @@ func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsp nonFunctionDeclarations := core.Filter(slices.Clip(declarations), func(node *ast.Node) bool { return !ast.IsFunctionLike(node) }) declarations = append(nonFunctionDeclarations, calledDeclaration) } - return l.createLocationsFromDeclarations(declarations), nil + return l.createLocationsFromDeclarations(originSelectionRange, clientSupportsLink, declarations), nil } -func (l *LanguageService) ProvideTypeDefinition(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.DefinitionResponse, error) { +func (l *LanguageService) ProvideTypeDefinition( + ctx context.Context, + documentURI lsproto.DocumentUri, + position lsproto.Position, +) (lsproto.TypeDefinitionResponse, error) { + caps := lsproto.GetClientCapabilities(ctx) + clientSupportsLink := caps.TextDocument.TypeDefinition.LinkSupport + program, file := l.getProgramAndFile(documentURI) node := astnav.GetTouchingPropertyName(file, int(l.converters.LineAndCharacterToPosition(file, position))) if node.Kind == ast.KindSourceFile { return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{}, nil } + originSelectionRange := l.createLspRangeFromNode(node, file) c, done := program.GetTypeCheckerForFile(ctx, file) defer done() @@ -76,10 +93,10 @@ func (l *LanguageService) ProvideTypeDefinition(ctx context.Context, documentURI declarations = core.Concatenate(getDeclarationsFromType(typeArgument), declarations) } if len(declarations) != 0 { - return l.createLocationsFromDeclarations(declarations), nil + return l.createLocationsFromDeclarations(originSelectionRange, clientSupportsLink, declarations), nil } if symbol.Flags&ast.SymbolFlagsValue == 0 && symbol.Flags&ast.SymbolFlagsType != 0 { - return l.createLocationsFromDeclarations(symbol.Declarations), nil + return l.createLocationsFromDeclarations(originSelectionRange, clientSupportsLink, symbol.Declarations), nil } } @@ -99,15 +116,49 @@ func getDeclarationNameForKeyword(node *ast.Node) *ast.Node { return node } -func (l *LanguageService) createLocationsFromDeclarations(declarations []*ast.Node) lsproto.DefinitionResponse { - locations := make([]lsproto.Location, 0, len(declarations)) +type fileRange struct { + fileName string + fileRange core.TextRange +} + +func (l *LanguageService) createLocationsFromDeclarations( + originSelectionRange *lsproto.Range, + clientSupportsLink bool, + declarations []*ast.Node, +) lsproto.DefinitionResponse { + locations := make([]*lsproto.LocationLink, 0, len(declarations)) + locationRanges := collections.Set[fileRange]{} for _, decl := range declarations { file := ast.GetSourceFileOfNode(decl) + fileName := file.FileName() name := core.OrElse(ast.GetNameOfDeclaration(decl), decl) - nodeRange := createRangeFromNode(name, file) - mappedLocation := l.getMappedLocation(file.FileName(), nodeRange) - locations = core.AppendIfUnique(locations, mappedLocation) + nameRange := createRangeFromNode(name, file) + if locationRanges.AddIfAbsent(fileRange{fileName, nameRange}) { + contextNode := core.OrElse(getContextNode(decl), decl) + contextRange := core.OrElse(toContextRange(&nameRange, file, contextNode), &nameRange) + targetSelectionLoc := l.getMappedLocation(fileName, nameRange) + targetLoc := l.getMappedLocation(fileName, *contextRange) + locations = append(locations, &lsproto.LocationLink{ + OriginSelectionRange: originSelectionRange, + TargetSelectionRange: targetSelectionLoc.Range, + TargetUri: targetLoc.Uri, + TargetRange: targetLoc.Range, + }) + } } + if !clientSupportsLink { + return createLocationsFromLinks(locations) + } + return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{DefinitionLinks: &locations} +} + +func createLocationsFromLinks(links []*lsproto.LocationLink) lsproto.DefinitionResponse { + locations := core.Map(links, func(link *lsproto.LocationLink) lsproto.Location { + return lsproto.Location{ + Uri: link.TargetUri, + Range: link.TargetSelectionRange, + } + }) return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{Locations: &locations} } @@ -152,7 +203,7 @@ func getDeclarationsFromLocation(c *checker.Checker, node *ast.Node) []*ast.Node // Returns a CallLikeExpression where `node` is the target being invoked. func getAncestorCallLikeExpression(node *ast.Node) *ast.Node { target := ast.FindAncestor(node, func(n *ast.Node) bool { - return !isRightSideOfPropertyAccess(n) + return !ast.IsRightSideOfPropertyAccess(n) }) callLike := target.Parent if callLike != nil && ast.IsCallLikeExpression(callLike) && ast.GetInvokedExpression(callLike) == target { diff --git a/internal/ls/diagnostics.go b/internal/ls/diagnostics.go index 5eeadfa06a..52d65512ea 100644 --- a/internal/ls/diagnostics.go +++ b/internal/ls/diagnostics.go @@ -2,11 +2,9 @@ package ls import ( "context" - "strings" "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/diagnostics" - "github.com/microsoft/typescript-go/internal/diagnosticwriter" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" ) @@ -25,12 +23,12 @@ func (l *LanguageService) ProvideDiagnostics(ctx context.Context, uri lsproto.Do return lsproto.RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{ FullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{ - Items: toLSPDiagnostics(l.converters, diagnostics...), + Items: l.toLSPDiagnostics(ctx, diagnostics...), }, }, nil } -func toLSPDiagnostics(converters *Converters, diagnostics ...[]*ast.Diagnostic) []*lsproto.Diagnostic { +func (l *LanguageService) toLSPDiagnostics(ctx context.Context, diagnostics ...[]*ast.Diagnostic) []*lsproto.Diagnostic { size := 0 for _, diagSlice := range diagnostics { size += len(diagSlice) @@ -38,72 +36,8 @@ func toLSPDiagnostics(converters *Converters, diagnostics ...[]*ast.Diagnostic) lspDiagnostics := make([]*lsproto.Diagnostic, 0, size) for _, diagSlice := range diagnostics { for _, diag := range diagSlice { - lspDiagnostics = append(lspDiagnostics, toLSPDiagnostic(converters, diag)) + lspDiagnostics = append(lspDiagnostics, lsconv.DiagnosticToLSPPull(ctx, l.converters, diag, l.UserPreferences().ReportStyleChecksAsWarnings)) } } return lspDiagnostics } - -func toLSPDiagnostic(converters *Converters, diagnostic *ast.Diagnostic) *lsproto.Diagnostic { - var severity lsproto.DiagnosticSeverity - switch diagnostic.Category() { - case diagnostics.CategorySuggestion: - severity = lsproto.DiagnosticSeverityHint - case diagnostics.CategoryMessage: - severity = lsproto.DiagnosticSeverityInformation - case diagnostics.CategoryWarning: - severity = lsproto.DiagnosticSeverityWarning - default: - severity = lsproto.DiagnosticSeverityError - } - - relatedInformation := make([]*lsproto.DiagnosticRelatedInformation, 0, len(diagnostic.RelatedInformation())) - for _, related := range diagnostic.RelatedInformation() { - relatedInformation = append(relatedInformation, &lsproto.DiagnosticRelatedInformation{ - Location: lsproto.Location{ - Uri: FileNameToDocumentURI(related.File().FileName()), - Range: converters.ToLSPRange(related.File(), related.Loc()), - }, - Message: related.Message(), - }) - } - - var tags []lsproto.DiagnosticTag - if diagnostic.ReportsUnnecessary() || diagnostic.ReportsDeprecated() { - tags = make([]lsproto.DiagnosticTag, 0, 2) - if diagnostic.ReportsUnnecessary() { - tags = append(tags, lsproto.DiagnosticTagUnnecessary) - } - if diagnostic.ReportsDeprecated() { - tags = append(tags, lsproto.DiagnosticTagDeprecated) - } - } - - return &lsproto.Diagnostic{ - Range: converters.ToLSPRange(diagnostic.File(), diagnostic.Loc()), - Code: &lsproto.IntegerOrString{ - Integer: ptrTo(diagnostic.Code()), - }, - Severity: &severity, - Message: messageChainToString(diagnostic), - Source: ptrTo("ts"), - RelatedInformation: ptrToSliceIfNonEmpty(relatedInformation), - Tags: ptrToSliceIfNonEmpty(tags), - } -} - -func messageChainToString(diagnostic *ast.Diagnostic) string { - if len(diagnostic.MessageChain()) == 0 { - return diagnostic.Message() - } - var b strings.Builder - diagnosticwriter.WriteFlattenedDiagnosticMessage(&b, diagnostic, "\n") - return b.String() -} - -func ptrToSliceIfNonEmpty[T any](s []T) *[]T { - if len(s) == 0 { - return nil - } - return &s -} diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index f0ed4ce0e0..192cd502a4 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -7,7 +7,7 @@ import ( "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" - "github.com/microsoft/typescript-go/internal/lsutil" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/stringutil" @@ -51,32 +51,31 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen } func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { - options := refOptions{use: referenceUseReferences} + options := refOptions{use: referenceUseNone} referenceEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, []*ast.SourceFile{sourceFile}, options, &collections.Set[string]{}) if referenceEntries == nil { return nil } + var highlights []*lsproto.DocumentHighlight for _, entry := range referenceEntries { for _, ref := range entry.references { - if ref.node != nil { - fileName, highlight := l.toDocumentHighlight(ref) - if fileName == sourceFile.FileName() { - highlights = append(highlights, highlight) - } + fileName, highlight := l.toDocumentHighlight(ref) + if fileName == sourceFile.FileName() { + highlights = append(highlights, highlight) } } } return highlights } -func (l *LanguageService) toDocumentHighlight(entry *referenceEntry) (string, *lsproto.DocumentHighlight) { +func (l *LanguageService) toDocumentHighlight(entry *ReferenceEntry) (string, *lsproto.DocumentHighlight) { entry = l.resolveEntry(entry) kind := lsproto.DocumentHighlightKindRead if entry.kind == entryKindRange { return entry.fileName, &lsproto.DocumentHighlight{ - Range: *entry.textRange, + Range: *l.getRangeOfEntry(entry), Kind: &kind, } } @@ -87,7 +86,7 @@ func (l *LanguageService) toDocumentHighlight(entry *referenceEntry) (string, *l } dh := &lsproto.DocumentHighlight{ - Range: *entry.textRange, + Range: *l.getRangeOfEntry(entry), Kind: &kind, } @@ -557,12 +556,9 @@ func getAsyncAndAwaitOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []* var keywords []*ast.Node - modifiers := fun.Modifiers() - if modifiers != nil { - for _, modifier := range modifiers.Nodes { - if modifier.Kind == ast.KindAsyncKeyword { - keywords = append(keywords, modifier) - } + for _, modifier := range fun.ModifierNodes() { + if modifier.Kind == ast.KindAsyncKeyword { + keywords = append(keywords, modifier) } } @@ -679,11 +675,9 @@ func getNodesToSearchForModifier(declaration *ast.Node, modifierFlag ast.Modifie } func findModifier(node *ast.Node, kind ast.Kind) *ast.Node { - if modifiers := node.Modifiers(); modifiers != nil { - for _, modifier := range modifiers.Nodes { - if modifier.Kind == kind { - return modifier - } + for _, modifier := range node.ModifierNodes() { + if modifier.Kind == kind { + return modifier } } return nil diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index f97981931f..46194abf40 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -6,6 +6,7 @@ import ( "fmt" "slices" "strings" + "sync" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" @@ -15,6 +16,7 @@ import ( "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/stringutil" @@ -51,10 +53,10 @@ type refInfo struct { type SymbolAndEntries struct { definition *Definition - references []*referenceEntry + references []*ReferenceEntry } -func NewSymbolAndEntries(kind definitionKind, node *ast.Node, symbol *ast.Symbol, references []*referenceEntry) *SymbolAndEntries { +func NewSymbolAndEntries(kind DefinitionKind, node *ast.Node, symbol *ast.Symbol, references []*ReferenceEntry) *SymbolAndEntries { return &SymbolAndEntries{ &Definition{ Kind: kind, @@ -65,19 +67,19 @@ func NewSymbolAndEntries(kind definitionKind, node *ast.Node, symbol *ast.Symbol } } -type definitionKind int +type DefinitionKind int const ( - definitionKindSymbol definitionKind = 0 - definitionKindLabel definitionKind = 1 - definitionKindKeyword definitionKind = 2 - definitionKindThis definitionKind = 3 - definitionKindString definitionKind = 4 - definitionKindTripleSlashReference definitionKind = 5 + definitionKindSymbol DefinitionKind = 0 + definitionKindLabel DefinitionKind = 1 + definitionKindKeyword DefinitionKind = 2 + definitionKindThis DefinitionKind = 3 + definitionKindString DefinitionKind = 4 + definitionKindTripleSlashReference DefinitionKind = 5 ) type Definition struct { - Kind definitionKind + Kind DefinitionKind symbol *ast.Symbol node *ast.Node tripleSlashFileRef *tripleSlashDefinition @@ -98,49 +100,68 @@ const ( entryKindSearchedPropertyFoundLocal entryKind = 5 ) -type referenceEntry struct { +type ReferenceEntry struct { kind entryKind node *ast.Node context *ast.Node // !!! ContextWithStartAndEndNode, optional fileName string - textRange *lsproto.Range + textRange *core.TextRange + lspRange *lsproto.Location } -func (l *LanguageService) getRangeOfEntry(entry *referenceEntry) *lsproto.Range { - return l.resolveEntry(entry).textRange +func (entry *SymbolAndEntries) canUseDefinitionSymbol() bool { + if entry.definition == nil { + return false + } + + switch entry.definition.Kind { + case definitionKindSymbol, definitionKindThis: + return entry.definition.symbol != nil + case definitionKindTripleSlashReference: + // !!! TODO : need to find file reference instead? + // May need to return true to indicate this to be file search instead and might need to do for import stuff as well + // For now + return false + default: + return false + } +} + +func (l *LanguageService) getRangeOfEntry(entry *ReferenceEntry) *lsproto.Range { + return &l.resolveEntry(entry).lspRange.Range } -func (l *LanguageService) getFileNameOfEntry(entry *referenceEntry) string { - return l.resolveEntry(entry).fileName +func (l *LanguageService) getFileNameOfEntry(entry *ReferenceEntry) lsproto.DocumentUri { + return l.resolveEntry(entry).lspRange.Uri } -func (l *LanguageService) resolveEntry(entry *referenceEntry) *referenceEntry { +func (l *LanguageService) getLocationOfEntry(entry *ReferenceEntry) *lsproto.Location { + return l.resolveEntry(entry).lspRange +} + +func (l *LanguageService) resolveEntry(entry *ReferenceEntry) *ReferenceEntry { if entry.textRange == nil { sourceFile := ast.GetSourceFileOfNode(entry.node) - entry.textRange = l.getRangeOfNode(entry.node, sourceFile, nil /*endNode*/) + textRange := getRangeOfNode(entry.node, sourceFile, nil /*endNode*/) + entry.textRange = &textRange entry.fileName = sourceFile.FileName() } - return entry -} - -func (l *LanguageService) newRangeEntry(file *ast.SourceFile, start, end int) *referenceEntry { - // !!! used in not-yet implemented features - return &referenceEntry{ - kind: entryKindRange, - fileName: file.FileName(), - textRange: l.createLspRangeFromBounds(start, end, file), + if entry.lspRange == nil { + location := l.getMappedLocation(entry.fileName, *entry.textRange) + entry.lspRange = &location } + return entry } -func newNodeEntryWithKind(node *ast.Node, kind entryKind) *referenceEntry { +func newNodeEntryWithKind(node *ast.Node, kind entryKind) *ReferenceEntry { e := newNodeEntry(node) e.kind = kind return e } -func newNodeEntry(node *ast.Node) *referenceEntry { +func newNodeEntry(node *ast.Node) *ReferenceEntry { // creates nodeEntry with `kind == entryKindNode` - return &referenceEntry{ + return &ReferenceEntry{ kind: entryKindNode, node: core.OrElse(node.Name(), node), context: getContextNodeForNodeEntry(node), @@ -260,7 +281,15 @@ func getContextNode(node *ast.Node) *ast.Node { } // utils -func (l *LanguageService) getRangeOfNode(node *ast.Node, sourceFile *ast.SourceFile, endNode *ast.Node) *lsproto.Range { +func (l *LanguageService) getLspRangeOfNode(node *ast.Node, sourceFile *ast.SourceFile, endNode *ast.Node) *lsproto.Range { + if sourceFile == nil { + sourceFile = ast.GetSourceFileOfNode(node) + } + textRange := getRangeOfNode(node, sourceFile, endNode) + return l.createLspRangeFromBounds(textRange.Pos(), textRange.End(), sourceFile) +} + +func getRangeOfNode(node *ast.Node, sourceFile *ast.SourceFile, endNode *ast.Node) core.TextRange { if sourceFile == nil { sourceFile = ast.GetSourceFileOfNode(node) } @@ -276,7 +305,7 @@ func (l *LanguageService) getRangeOfNode(node *ast.Node, sourceFile *ast.SourceF if endNode != nil && endNode.Kind == ast.KindCaseBlock { end = endNode.Pos() } - return l.createLspRangeFromBounds(start, end, sourceFile) + return core.NewTextRange(start, end) } func isValidReferencePosition(node *ast.Node, searchSymbolName string) bool { @@ -406,16 +435,170 @@ func getSymbolScope(symbol *ast.Symbol) *ast.Node { // === functions on (*ls) === -func (l *LanguageService) ProvideReferences(ctx context.Context, params *lsproto.ReferenceParams) (lsproto.ReferencesResponse, error) { +type position struct { + uri lsproto.DocumentUri + pos lsproto.Position +} + +var _ lsproto.HasTextDocumentPosition = (*position)(nil) + +func (nld *position) TextDocumentURI() lsproto.DocumentUri { return nld.uri } +func (nld *position) TextDocumentPosition() lsproto.Position { return nld.pos } + +type NonLocalDefinition struct { + position + GetSourcePosition func() lsproto.HasTextDocumentPosition + GetGeneratedPosition func() lsproto.HasTextDocumentPosition +} + +func getFileAndStartPosFromDeclaration(declaration *ast.Node) (*ast.SourceFile, core.TextPos) { + file := ast.GetSourceFileOfNode(declaration) + name := core.OrElse(ast.GetNameOfDeclaration(declaration), declaration) + textRange := getRangeOfNode(name, file, nil /*endNode*/) + + return file, core.TextPos(textRange.Pos()) +} + +func (l *LanguageService) GetNonLocalDefinition(ctx context.Context, entry *SymbolAndEntries) *NonLocalDefinition { + if !entry.canUseDefinitionSymbol() { + return nil + } + + program := l.GetProgram() + checker, done := program.GetTypeChecker(ctx) + defer done() + emitResolver := checker.GetEmitResolver() + for _, d := range entry.definition.symbol.Declarations { + if isDefinitionVisible(emitResolver, d) { + file, startPos := getFileAndStartPosFromDeclaration(d) + fileName := file.FileName() + return &NonLocalDefinition{ + position: position{ + uri: lsconv.FileNameToDocumentURI(fileName), + pos: l.converters.PositionToLineAndCharacter(file, startPos), + }, + GetSourcePosition: sync.OnceValue(func() lsproto.HasTextDocumentPosition { + mapped := l.tryGetSourcePosition(fileName, startPos) + if mapped != nil { + return &position{ + uri: lsconv.FileNameToDocumentURI(mapped.FileName), + pos: l.converters.PositionToLineAndCharacter(l.getScript(mapped.FileName), core.TextPos(mapped.Pos)), + } + } + return nil + }), + GetGeneratedPosition: sync.OnceValue(func() lsproto.HasTextDocumentPosition { + mapped := l.tryGetGeneratedPosition(fileName, startPos) + if mapped != nil { + return &position{ + uri: lsconv.FileNameToDocumentURI(mapped.FileName), + pos: l.converters.PositionToLineAndCharacter(l.getScript(mapped.FileName), core.TextPos(mapped.Pos)), + } + } + return nil + }), + } + } + } + return nil +} + +// This is special handling to determine if we should load up more projects and find location in other projects +// By default arrows (and such other ast kinds) are not visible as declaration emitter doesnt need them +// But we want to handle them specially so that they are visible if their parent is visible +func isDefinitionVisible(emitResolver *checker.EmitResolver, declaration *ast.Node) bool { + if emitResolver.IsDeclarationVisible(declaration) { + return true + } + if declaration.Parent == nil { + return false + } + + // Variable initializers are visible if variable is visible + if ast.HasInitializer(declaration.Parent) && declaration.Parent.Initializer() == declaration { + return isDefinitionVisible(emitResolver, declaration.Parent) + } + + // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent + switch declaration.Kind { + case ast.KindPropertyDeclaration, + ast.KindGetAccessor, + ast.KindSetAccessor, + ast.KindMethodDeclaration: + // Private/protected properties/methods are not visible + if ast.HasModifier(declaration, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifier(declaration.Name()) { + return false + } + // Public properties/methods are visible if its parents are visible, so: + // falls through + fallthrough + case ast.KindConstructor, + ast.KindPropertyAssignment, + ast.KindShorthandPropertyAssignment, + ast.KindObjectLiteralExpression, + ast.KindClassExpression, + ast.KindArrowFunction, + ast.KindFunctionExpression: + return isDefinitionVisible(emitResolver, declaration.Parent) + default: + return false + } +} + +func (l *LanguageService) ForEachOriginalDefinitionLocation( + ctx context.Context, + entry *SymbolAndEntries, + cb func(lsproto.DocumentUri, lsproto.Position), +) { + if !entry.canUseDefinitionSymbol() { + return + } + + program := l.GetProgram() + for _, d := range entry.definition.symbol.Declarations { + file, startPos := getFileAndStartPosFromDeclaration(d) + fileName := file.FileName() + if tspath.IsDeclarationFileName(fileName) { + // Map to ts position + mapped := l.tryGetSourcePosition(file.FileName(), startPos) + if mapped != nil { + cb( + lsconv.FileNameToDocumentURI(mapped.FileName), + l.converters.PositionToLineAndCharacter(l.getScript(mapped.FileName), core.TextPos(mapped.Pos)), + ) + } + } else if program.IsSourceFromProjectReference(l.toPath(fileName)) { + cb( + lsconv.FileNameToDocumentURI(fileName), + l.converters.PositionToLineAndCharacter(file, startPos), + ) + } + } +} + +func (l *LanguageService) ProvideSymbolsAndEntries(ctx context.Context, uri lsproto.DocumentUri, documentPosition lsproto.Position, isRename bool) (*ast.Node, []*SymbolAndEntries, bool) { // `findReferencedSymbols` except only computes the information needed to return reference locations - program, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) - position := int(l.converters.LineAndCharacterToPosition(sourceFile, params.Position)) + program, sourceFile := l.getProgramAndFile(uri) + position := int(l.converters.LineAndCharacterToPosition(sourceFile, documentPosition)) node := astnav.GetTouchingPropertyName(sourceFile, position) - options := refOptions{use: referenceUseReferences} + if isRename && node.Kind != ast.KindIdentifier { + return node, nil, false + } - symbolsAndEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, program.GetSourceFiles(), options, nil) + var options refOptions + if !isRename { + options.use = referenceUseReferences + } else { + options.use = referenceUseRename + options.useAliasesForRename = true + } + return node, l.getReferencedSymbolsForNode(ctx, position, node, program, program.GetSourceFiles(), options, nil), true +} + +func (l *LanguageService) ProvideReferencesFromSymbolAndEntries(ctx context.Context, params *lsproto.ReferenceParams, originalNode *ast.Node, symbolsAndEntries []*SymbolAndEntries) (lsproto.ReferencesResponse, error) { + // `findReferencedSymbols` except only computes the information needed to return reference locations locations := core.FlatMap(symbolsAndEntries, l.convertSymbolAndEntriesToLocations) return lsproto.LocationsOrNull{Locations: &locations}, nil } @@ -426,7 +609,7 @@ func (l *LanguageService) ProvideImplementations(ctx context.Context, params *ls node := astnav.GetTouchingPropertyName(sourceFile, position) var seenNodes collections.Set[*ast.Node] - var entries []*referenceEntry + var entries []*ReferenceEntry queue := l.getImplementationReferenceEntries(ctx, program, node, position) for len(queue) != 0 { if ctx.Err() != nil { @@ -442,34 +625,35 @@ func (l *LanguageService) ProvideImplementations(ctx context.Context, params *ls } } + if lsproto.GetClientCapabilities(ctx).TextDocument.Implementation.LinkSupport { + links := l.convertEntriesToLocationLinks(entries) + return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{DefinitionLinks: &links}, nil + } locations := l.convertEntriesToLocations(entries) return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{Locations: &locations}, nil } -func (l *LanguageService) getImplementationReferenceEntries(ctx context.Context, program *compiler.Program, node *ast.Node, position int) []*referenceEntry { +func (l *LanguageService) getImplementationReferenceEntries(ctx context.Context, program *compiler.Program, node *ast.Node, position int) []*ReferenceEntry { options := refOptions{use: referenceUseReferences, implementations: true} symbolsAndEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, program.GetSourceFiles(), options, nil) - return core.FlatMap(symbolsAndEntries, func(s *SymbolAndEntries) []*referenceEntry { return s.references }) + return core.FlatMap(symbolsAndEntries, func(s *SymbolAndEntries) []*ReferenceEntry { return s.references }) } -func (l *LanguageService) ProvideRename(ctx context.Context, params *lsproto.RenameParams) (lsproto.WorkspaceEditOrNull, error) { - program, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) - position := int(l.converters.LineAndCharacterToPosition(sourceFile, params.Position)) - node := astnav.GetTouchingPropertyName(sourceFile, position) - if node.Kind != ast.KindIdentifier { +func (l *LanguageService) ProvideRenameFromSymbolAndEntries(ctx context.Context, params *lsproto.RenameParams, originalNode *ast.Node, symbolsAndEntries []*SymbolAndEntries) (lsproto.WorkspaceEditOrNull, error) { + if originalNode.Kind != ast.KindIdentifier { return lsproto.WorkspaceEditOrNull{}, nil } - options := refOptions{use: referenceUseRename, useAliasesForRename: true} - symbolsAndEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, program.GetSourceFiles(), options, nil) - entries := core.FlatMap(symbolsAndEntries, func(s *SymbolAndEntries) []*referenceEntry { return s.references }) + + program := l.GetProgram() + entries := core.FlatMap(symbolsAndEntries, func(s *SymbolAndEntries) []*ReferenceEntry { return s.references }) changes := make(map[lsproto.DocumentUri][]*lsproto.TextEdit) checker, done := program.GetTypeChecker(ctx) defer done() for _, entry := range entries { - uri := FileNameToDocumentURI(l.getFileNameOfEntry(entry)) + uri := l.getFileNameOfEntry(entry) textEdit := &lsproto.TextEdit{ Range: *l.getRangeOfEntry(entry), - NewText: l.getTextForRename(node, entry, params.NewName, checker), + NewText: l.getTextForRename(originalNode, entry, params.NewName, checker), } changes[uri] = append(changes[uri], textEdit) } @@ -480,7 +664,7 @@ func (l *LanguageService) ProvideRename(ctx context.Context, params *lsproto.Ren }, nil } -func (l *LanguageService) getTextForRename(originalNode *ast.Node, entry *referenceEntry, newText string, checker *checker.Checker) string { +func (l *LanguageService) getTextForRename(originalNode *ast.Node, entry *ReferenceEntry, newText string, checker *checker.Checker) string { if entry.kind != entryKindRange && (ast.IsIdentifier(originalNode) || ast.IsStringLiteralLike(originalNode)) { node := entry.node kind := entry.kind @@ -533,20 +717,44 @@ func (l *LanguageService) convertSymbolAndEntriesToLocations(s *SymbolAndEntries return l.convertEntriesToLocations(s.references) } -func (l *LanguageService) convertEntriesToLocations(entries []*referenceEntry) []lsproto.Location { +func (l *LanguageService) convertEntriesToLocations(entries []*ReferenceEntry) []lsproto.Location { locations := make([]lsproto.Location, len(entries)) for i, entry := range entries { - locations[i] = lsproto.Location{ - Uri: FileNameToDocumentURI(l.getFileNameOfEntry(entry)), - Range: *l.getRangeOfEntry(entry), - } + locations[i] = *l.getLocationOfEntry(entry) } return locations } +func (l *LanguageService) convertEntriesToLocationLinks(entries []*ReferenceEntry) []*lsproto.LocationLink { + links := make([]*lsproto.LocationLink, len(entries)) + for i, entry := range entries { + + // Get the selection range (the actual reference) + targetSelectionRange := &l.getLocationOfEntry(entry).Range + targetRange := targetSelectionRange + + // For entries with nodes, compute ranges directly from the node + if entry.node != nil { + // Get the context range (broader scope including declaration context) + contextTextRange := toContextRange(entry.textRange, l.program.GetSourceFile(entry.fileName), entry.context) + if contextTextRange != nil { + contextLocation := l.getMappedLocation(entry.fileName, *contextTextRange) + targetRange = &contextLocation.Range + } + } + + links[i] = &lsproto.LocationLink{ + TargetUri: lsconv.FileNameToDocumentURI(entry.fileName), + TargetRange: *targetRange, + TargetSelectionRange: *targetSelectionRange, + } + } + return links +} + func (l *LanguageService) mergeReferences(program *compiler.Program, referencesToMerge ...[]*SymbolAndEntries) []*SymbolAndEntries { result := []*SymbolAndEntries{} - getSourceFileIndexOfEntry := func(program *compiler.Program, entry *referenceEntry) int { + getSourceFileIndexOfEntry := func(program *compiler.Program, entry *ReferenceEntry) int { var sourceFile *ast.SourceFile if entry.kind == entryKindRange { sourceFile = program.GetSourceFile(entry.fileName) @@ -582,14 +790,14 @@ func (l *LanguageService) mergeReferences(program *compiler.Program, referencesT reference := result[refIndex] sortedRefs := append(reference.references, entry.references...) - slices.SortStableFunc(sortedRefs, func(entry1, entry2 *referenceEntry) int { + slices.SortStableFunc(sortedRefs, func(entry1, entry2 *ReferenceEntry) int { entry1File := getSourceFileIndexOfEntry(program, entry1) entry2File := getSourceFileIndexOfEntry(program, entry2) if entry1File != entry2File { return cmp.Compare(entry1File, entry2File) } - return CompareRanges(l.getRangeOfEntry(entry1), l.getRangeOfEntry(entry2)) + return lsproto.CompareRanges(l.getRangeOfEntry(entry1), l.getRangeOfEntry(entry2)) }) result[refIndex] = &SymbolAndEntries{ definition: reference.definition, @@ -611,6 +819,10 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } } + if options.use == referenceUseReferences || options.use == referenceUseRename { + node = getAdjustedLocation(node, options.use == referenceUseRename, ast.GetSourceFileOfNode(node)) + } + checker, done := program.GetTypeChecker(ctx) defer done() @@ -621,7 +833,7 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } if moduleSymbol := checker.GetMergedSymbol(resolvedRef.file.Symbol); moduleSymbol != nil { - return getReferencedSymbolsForModule(ctx, program, moduleSymbol /*excludeImportTypeOfExportEquals*/, false, sourceFiles, sourceFilesSet) + return l.getReferencedSymbolsForModule(ctx, program, moduleSymbol /*excludeImportTypeOfExportEquals*/, false, sourceFiles, sourceFilesSet) } // !!! not implemented @@ -669,7 +881,7 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } if symbol.Name == ast.InternalSymbolNameExportEquals { - return getReferencedSymbolsForModule(ctx, program, symbol.Parent, false /*excludeImportTypeOfExportEquals*/, sourceFiles, sourceFilesSet) + return l.getReferencedSymbolsForModule(ctx, program, symbol.Parent, false /*excludeImportTypeOfExportEquals*/, sourceFiles, sourceFilesSet) } moduleReferences := l.getReferencedSymbolsForModuleIfDeclaredBySourceFile(ctx, symbol, program, sourceFiles, checker, options, sourceFilesSet) // !!! cancellationToken @@ -696,8 +908,8 @@ func (l *LanguageService) getReferencedSymbolsForModuleIfDeclaredBySourceFile(ct } exportEquals := symbol.Exports.Get(ast.InternalSymbolNameExportEquals) // If exportEquals != nil, we're about to add references to `import("mod")` anyway, so don't double-count them. - moduleReferences := getReferencedSymbolsForModule(ctx, program, symbol, exportEquals != nil, sourceFiles, sourceFilesSet) - if exportEquals == nil || !sourceFilesSet.Has(moduleSourceFileName) { + moduleReferences := l.getReferencedSymbolsForModule(ctx, program, symbol, exportEquals != nil, sourceFiles, sourceFilesSet) + if exportEquals == nil || exportEquals.Flags&ast.SymbolFlagsAlias == 0 || !sourceFilesSet.Has(moduleSourceFileName) { return moduleReferences } symbol, _ = checker.ResolveAlias(exportEquals) @@ -731,7 +943,7 @@ func getReferencedSymbolsSpecial(node *ast.Node, sourceFiles []*ast.SourceFile) } if node.Kind == ast.KindStaticKeyword && node.Parent.Kind == ast.KindClassStaticBlockDeclaration { - return []*SymbolAndEntries{{definition: &Definition{Kind: definitionKindKeyword, node: node}, references: []*referenceEntry{newNodeEntry(node)}}} + return []*SymbolAndEntries{{definition: &Definition{Kind: definitionKindKeyword, node: node}, references: []*ReferenceEntry{newNodeEntry(node)}}} } // Labels @@ -763,7 +975,7 @@ func getReferencedSymbolsSpecial(node *ast.Node, sourceFiles []*ast.SourceFile) func getLabelReferencesInNode(container *ast.Node, targetLabel *ast.Node) []*SymbolAndEntries { sourceFile := ast.GetSourceFileOfNode(container) labelName := targetLabel.Text() - references := core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, labelName, container), func(node *ast.Node) *referenceEntry { + references := core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, labelName, container), func(node *ast.Node) *ReferenceEntry { // Only pick labels that are either the target label, or have a target that is the target label if node == targetLabel.AsNode() || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) == targetLabel) { return newNodeEntry(node) @@ -835,10 +1047,10 @@ func getReferencesForThisKeyword(thisOrSuperKeyword *ast.Node, sourceFiles []*as return false }) }), - func(n *ast.Node) *referenceEntry { return newNodeEntry(n) }, + func(n *ast.Node) *ReferenceEntry { return newNodeEntry(n) }, ) - thisParameter := core.FirstNonNil(references, func(ref *referenceEntry) *ast.Node { + thisParameter := core.FirstNonNil(references, func(ref *ReferenceEntry) *ast.Node { if ref.node.Parent.Kind == ast.KindParameter { return ref.node } @@ -847,7 +1059,7 @@ func getReferencesForThisKeyword(thisOrSuperKeyword *ast.Node, sourceFiles []*as if thisParameter == nil { thisParameter = thisOrSuperKeyword } - return []*SymbolAndEntries{NewSymbolAndEntries(definitionKindThis, thisParameter, nil, references)} + return []*SymbolAndEntries{NewSymbolAndEntries(definitionKindThis, thisParameter, searchSpaceNode.Symbol(), references)} } func getReferencesForSuperKeyword(superKeyword *ast.Node) []*SymbolAndEntries { @@ -867,7 +1079,7 @@ func getReferencesForSuperKeyword(superKeyword *ast.Node) []*SymbolAndEntries { } sourceFile := ast.GetSourceFileOfNode(searchSpaceNode) - references := core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), func(node *ast.Node) *referenceEntry { + references := core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), func(node *ast.Node) *ReferenceEntry { if node.Kind != ast.KindSuperKeyword { return nil } @@ -887,8 +1099,8 @@ func getReferencesForSuperKeyword(superKeyword *ast.Node) []*SymbolAndEntries { } func getAllReferencesForImportMeta(sourceFiles []*ast.SourceFile) []*SymbolAndEntries { - references := core.FlatMap(sourceFiles, func(sourceFile *ast.SourceFile) []*referenceEntry { - return core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, "meta", sourceFile.AsNode()), func(node *ast.Node) *referenceEntry { + references := core.FlatMap(sourceFiles, func(sourceFile *ast.SourceFile) []*ReferenceEntry { + return core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, "meta", sourceFile.AsNode()), func(node *ast.Node) *ReferenceEntry { parent := node.Parent if ast.IsImportMeta(parent) { return newNodeEntry(parent) @@ -904,9 +1116,9 @@ func getAllReferencesForImportMeta(sourceFiles []*ast.SourceFile) []*SymbolAndEn func getAllReferencesForKeyword(sourceFiles []*ast.SourceFile, keywordKind ast.Kind, filterReadOnlyTypeOperator bool) []*SymbolAndEntries { // references is a list of NodeEntry - references := core.FlatMap(sourceFiles, func(sourceFile *ast.SourceFile) []*referenceEntry { + references := core.FlatMap(sourceFiles, func(sourceFile *ast.SourceFile) []*ReferenceEntry { // cancellationToken.throwIfCancellationRequested(); - return core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, scanner.TokenToString(keywordKind), sourceFile.AsNode()), func(referenceLocation *ast.Node) *referenceEntry { + return core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, scanner.TokenToString(keywordKind), sourceFile.AsNode()), func(referenceLocation *ast.Node) *ReferenceEntry { if referenceLocation.Kind == keywordKind && (!filterReadOnlyTypeOperator || isReadonlyTypeOperator(referenceLocation)) { return newNodeEntry(referenceLocation) } @@ -1000,9 +1212,9 @@ func findFirstJsxNode(root *ast.Node) *ast.Node { return visit(root) } -func getReferencesForNonModule(referencedFile *ast.SourceFile, program *compiler.Program) []*referenceEntry { +func getReferencesForNonModule(referencedFile *ast.SourceFile, program *compiler.Program) []*ReferenceEntry { // !!! not implemented - return []*referenceEntry{} + return []*ReferenceEntry{} } func getMergedAliasedSymbolOfNamespaceExportDeclaration(node *ast.Node, symbol *ast.Symbol, checker *checker.Checker) *ast.Symbol { @@ -1017,14 +1229,14 @@ func getMergedAliasedSymbolOfNamespaceExportDeclaration(node *ast.Node, symbol * return nil } -func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { +func (l *LanguageService) getReferencedSymbolsForModule(ctx context.Context, program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { debug.Assert(symbol.ValueDeclaration != nil) checker, done := program.GetTypeChecker(ctx) defer done() moduleRefs := findModuleReferences(program, sourceFiles, symbol, checker) - references := core.MapNonNil(moduleRefs, func(reference ModuleReference) *referenceEntry { + references := core.MapNonNil(moduleRefs, func(reference ModuleReference) *ReferenceEntry { switch reference.kind { case ModuleReferenceKindImport: parent := reference.literal.Parent @@ -1058,10 +1270,11 @@ func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Progra } return newNodeEntry(rangeNode) case ModuleReferenceKindReference: - // or - // We can't easily create a proper range entry here without access to LanguageService, - // but we can create a node-based entry pointing to the source file which will be resolved later - return newNodeEntry(reference.referencingFile.AsNode()) + return &ReferenceEntry{ + kind: entryKindRange, + fileName: reference.referencingFile.FileName(), + textRange: &reference.ref.TextRange, + } } return nil }) @@ -1093,7 +1306,7 @@ func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Progra var node *ast.Node // At `module.exports = ...`, reference node is `module` if ast.IsBinaryExpression(decl) && ast.IsPropertyAccessExpression(decl.AsBinaryExpression().Left) { - node = decl.AsBinaryExpression().Left.AsPropertyAccessExpression().Expression + node = decl.AsBinaryExpression().Left.Expression() } else if ast.IsExportAssignment(decl) { // Find the export keyword node = findChildOfKind(decl, ast.KindExportKeyword, sourceFile) @@ -1115,7 +1328,7 @@ func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Progra references: references, }} } - return nil + return []*SymbolAndEntries{} } func getReferenceAtPosition(sourceFile *ast.SourceFile, position int, program *compiler.Program) *refInfo { @@ -1353,7 +1566,7 @@ func getReferenceEntriesForShorthandPropertyAssignment(node *ast.Node, checker * shorthandSymbol := checker.GetShorthandAssignmentValueSymbol(refSymbol.ValueDeclaration) if shorthandSymbol != nil && len(shorthandSymbol.Declarations) > 0 { for _, declaration := range shorthandSymbol.Declarations { - if getMeaningFromDeclaration(declaration)&ast.SemanticMeaningValue != 0 { + if ast.GetMeaningFromDeclaration(declaration)&ast.SemanticMeaningValue != 0 { addReference(declaration) } } @@ -1361,7 +1574,7 @@ func getReferenceEntriesForShorthandPropertyAssignment(node *ast.Node, checker * } func climbPastPropertyAccess(node *ast.Node) *ast.Node { - if isRightSideOfPropertyAccess(node) { + if ast.IsRightSideOfPropertyAccess(node) { return node.Parent } return node @@ -1371,14 +1584,14 @@ func isNewExpressionTarget(node *ast.Node) bool { if node.Parent == nil { return false } - return node.Parent.Kind == ast.KindNewExpression && node.Parent.AsNewExpression().Expression == node + return node.Parent.Kind == ast.KindNewExpression && node.Parent.Expression() == node } func isCallExpressionTarget(node *ast.Node) bool { if node.Parent == nil { return false } - return node.Parent.Kind == ast.KindCallExpression && node.Parent.AsCallExpression().Expression == node + return node.Parent.Kind == ast.KindCallExpression && node.Parent.Expression() == node } func isMethodOrAccessor(node *ast.Node) bool { diff --git a/internal/ls/format.go b/internal/ls/format.go index 548c766741..9e0f55cf19 100644 --- a/internal/ls/format.go +++ b/internal/ls/format.go @@ -113,7 +113,8 @@ func (l *LanguageService) getFormattingEditsAfterKeystroke( ) []core.TextChange { ctx = format.WithFormatCodeSettings(ctx, options, options.NewLineCharacter) - if isInComment(file, position, nil) == nil { + tokenAtPosition := astnav.GetTokenAtPosition(file, position) + if isInComment(file, position, tokenAtPosition) == nil { switch key { case "{": return format.FormatOnOpeningCurly(ctx, file, position) diff --git a/internal/ls/format_test.go b/internal/ls/format_test.go new file mode 100644 index 0000000000..8d84bcb211 --- /dev/null +++ b/internal/ls/format_test.go @@ -0,0 +1,135 @@ +package ls + +import ( + "context" + "testing" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/parser" +) + +// Test for issue: Panic Handling textDocument/onTypeFormatting +// This reproduces the panic when pressing enter in an empty file +func TestGetFormattingEditsAfterKeystroke_EmptyFile(t *testing.T) { + t.Parallel() + // Create an empty file + text := "" + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/index.ts", + Path: "/index.ts", + }, text, core.ScriptKindTS) + + // Create language service with nil program (we're only testing the formatting function) + langService := &LanguageService{} + + // Test formatting after keystroke with newline character at position 0 + ctx := context.Background() + options := format.GetDefaultFormatCodeSettings("\n") + + // This should not panic + edits := langService.getFormattingEditsAfterKeystroke( + ctx, + sourceFile, + options, + 0, // position + "\n", + ) + + // Should return nil or empty edits, not panic + _ = edits +} + +// Test with a simple statement +func TestGetFormattingEditsAfterKeystroke_SimpleStatement(t *testing.T) { + t.Parallel() + // Create a file with a simple statement + text := "const x = 1" + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/index.ts", + Path: "/index.ts", + }, text, core.ScriptKindTS) + + // Create language service with nil program + langService := &LanguageService{} + + // Test formatting after keystroke with newline character at end of statement + ctx := context.Background() + options := format.GetDefaultFormatCodeSettings("\n") + + // This should not panic + edits := langService.getFormattingEditsAfterKeystroke( + ctx, + sourceFile, + options, + len(text), // position at end of file + "\n", + ) + + // Should return nil or empty edits, not panic + _ = edits +} + +// Test for issue: Crash in range formatting when requested on a line that is different from the containing function +// This reproduces the panic when formatting a range inside a function body +func TestGetFormattingEditsForRange_FunctionBody(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + text string + startPos int + endPos int + }{ + { + name: "return statement in function", + text: "function foo() {\n return (1 + 2);\n}", + startPos: 21, // Start of "return" + endPos: 38, // End of ");" + }, + { + name: "function with newline after keyword", + text: "function\nf() {\n}", + startPos: 9, // After "function\n" + endPos: 13, // Inside or after function + }, + { + name: "empty function body", + text: "function f() {\n \n}", + startPos: 15, // Inside body + endPos: 17, // Inside body + }, + { + name: "after function closing brace", + text: "function f() {\n}", + startPos: 15, // After closing brace + endPos: 15, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, tc.text, core.ScriptKindTS) + + langService := &LanguageService{} + ctx := context.Background() + options := format.GetDefaultFormatCodeSettings("\n") + + // This should not panic + edits := langService.getFormattingEditsForRange( + ctx, + sourceFile, + options, + core.NewTextRange(tc.startPos, tc.endPos), + ) + + // Should not panic + _ = edits // Just ensuring no panic + }) + } +} diff --git a/internal/ls/host.go b/internal/ls/host.go index dfeaa02a62..8f517b787c 100644 --- a/internal/ls/host.go +++ b/internal/ls/host.go @@ -1,10 +1,17 @@ package ls -import "github.com/microsoft/typescript-go/internal/sourcemap" +import ( + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/sourcemap" +) type Host interface { UseCaseSensitiveFileNames() bool ReadFile(path string) (contents string, ok bool) - Converters() *Converters + Converters() *lsconv.Converters + UserPreferences() *lsutil.UserPreferences + FormatOptions() *format.FormatCodeSettings GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo } diff --git a/internal/ls/hover.go b/internal/ls/hover.go index fecdff43af..6c8c644adc 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/lsp/lsproto" ) @@ -19,6 +20,9 @@ const ( ) func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.HoverResponse, error) { + caps := lsproto.GetClientCapabilities(ctx) + contentFormat := lsproto.PreferredMarkupKind(caps.TextDocument.Hover.ContentFormat) + program, file := l.getProgramAndFile(documentURI) node := astnav.GetTouchingPropertyName(file, int(l.converters.LineAndCharacterToPosition(file, position))) if node.Kind == ast.KindSourceFile { @@ -27,77 +31,100 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto. } c, done := program.GetTypeCheckerForFile(ctx, file) defer done() - quickInfo, documentation := getQuickInfoAndDocumentation(c, node) + rangeNode := getNodeForQuickInfo(node) + symbol := getSymbolAtLocationForQuickInfo(c, node) + quickInfo, documentation := l.getQuickInfoAndDocumentationForSymbol(c, symbol, rangeNode, contentFormat) if quickInfo == "" { return lsproto.HoverOrNull{}, nil } + hoverRange := l.getLspRangeOfNode(rangeNode, nil, nil) + + var content string + if contentFormat == lsproto.MarkupKindMarkdown { + content = formatQuickInfo(quickInfo) + documentation + } else { + content = quickInfo + documentation + } + return lsproto.HoverOrNull{ Hover: &lsproto.Hover{ Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{ MarkupContent: &lsproto.MarkupContent{ - Kind: lsproto.MarkupKindMarkdown, - Value: formatQuickInfo(quickInfo) + documentation, + Kind: contentFormat, + Value: content, }, }, + Range: hoverRange, }, }, nil } -func getQuickInfoAndDocumentation(c *checker.Checker, node *ast.Node) (string, string) { - return getQuickInfoAndDocumentationForSymbol(c, c.GetSymbolAtLocation(node), getNodeForQuickInfo(node)) -} - -func getQuickInfoAndDocumentationForSymbol(c *checker.Checker, symbol *ast.Symbol, node *ast.Node) (string, string) { +func (l *LanguageService) getQuickInfoAndDocumentationForSymbol(c *checker.Checker, symbol *ast.Symbol, node *ast.Node, contentFormat lsproto.MarkupKind) (string, string) { + if symbol == nil { + return "", "" + } quickInfo, declaration := getQuickInfoAndDeclarationAtLocation(c, symbol, node) if quickInfo == "" { return "", "" } + return quickInfo, l.getDocumentationFromDeclaration(c, declaration, contentFormat) +} + +func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, declaration *ast.Node, contentFormat lsproto.MarkupKind) string { + if declaration == nil { + return "" + } + isMarkdown := contentFormat == lsproto.MarkupKindMarkdown var b strings.Builder - if declaration != nil { - if jsdoc := getJSDocOrTag(declaration); jsdoc != nil && !containsTypedefTag(jsdoc) { - writeComments(&b, jsdoc.Comments()) - if jsdoc.Kind == ast.KindJSDoc { - if tags := jsdoc.AsJSDoc().Tags; tags != nil { - for _, tag := range tags.Nodes { - if tag.Kind == ast.KindJSDocTypeTag { - continue - } - b.WriteString("\n\n*@") + if jsdoc := getJSDocOrTag(c, declaration); jsdoc != nil && !containsTypedefTag(jsdoc) { + l.writeComments(&b, c, jsdoc.Comments(), isMarkdown) + if jsdoc.Kind == ast.KindJSDoc { + if tags := jsdoc.AsJSDoc().Tags; tags != nil { + for _, tag := range tags.Nodes { + if tag.Kind == ast.KindJSDocTypeTag { + continue + } + b.WriteString("\n\n") + if isMarkdown { + b.WriteString("*@") b.WriteString(tag.TagName().Text()) b.WriteString("*") - switch tag.Kind { - case ast.KindJSDocParameterTag, ast.KindJSDocPropertyTag: - writeOptionalEntityName(&b, tag.Name()) - case ast.KindJSDocAugmentsTag: - writeOptionalEntityName(&b, tag.AsJSDocAugmentsTag().ClassName) - case ast.KindJSDocSeeTag: - writeOptionalEntityName(&b, tag.AsJSDocSeeTag().NameExpression) - case ast.KindJSDocTemplateTag: - for i, tp := range tag.TypeParameters() { - if i != 0 { - b.WriteString(",") - } - writeOptionalEntityName(&b, tp.Name()) + } else { + b.WriteString("@") + b.WriteString(tag.TagName().Text()) + } + switch tag.Kind { + case ast.KindJSDocParameterTag, ast.KindJSDocPropertyTag: + writeOptionalEntityName(&b, tag.Name()) + case ast.KindJSDocAugmentsTag: + writeOptionalEntityName(&b, tag.ClassName()) + case ast.KindJSDocSeeTag: + writeOptionalEntityName(&b, tag.AsJSDocSeeTag().NameExpression) + case ast.KindJSDocTemplateTag: + for i, tp := range tag.TypeParameters() { + if i != 0 { + b.WriteString(",") } + writeOptionalEntityName(&b, tp.Name()) } - comments := tag.Comments() - if len(comments) != 0 { - if commentHasPrefix(comments, "```") { - b.WriteString("\n") - } else { - b.WriteString(" ") - if !commentHasPrefix(comments, "-") { - b.WriteString("— ") - } + } + comments := tag.Comments() + if len(comments) != 0 { + if commentHasPrefix(comments, "```") { + b.WriteString("\n") + } else { + b.WriteString(" ") + if !commentHasPrefix(comments, "-") { + b.WriteString("— ") } - writeComments(&b, comments) } + l.writeComments(&b, c, comments, isMarkdown) } } } } } - return quickInfo, b.String() + return b.String() } func formatQuickInfo(quickInfo string) string { @@ -108,126 +135,164 @@ func formatQuickInfo(quickInfo string) string { } func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol, node *ast.Node) (string, *ast.Node) { - isAlias := symbol != nil && symbol.Flags&ast.SymbolFlagsAlias != 0 - if isAlias { - symbol = c.GetAliasedSymbol(symbol) - } - if symbol == nil || symbol == c.GetUnknownSymbol() { - return "", nil - } - declaration := symbol.ValueDeclaration - if symbol.Flags&ast.SymbolFlagsClass != 0 && inConstructorContext(node) { - if s := symbol.Members.Get(ast.InternalSymbolNameConstructor); s != nil { - symbol = s - declaration = core.Find(symbol.Declarations, func(d *ast.Node) bool { - return ast.IsConstructorDeclaration(d) || ast.IsConstructSignatureDeclaration(d) - }) - } - } - flags := symbol.Flags - if flags&ast.SymbolFlagsType != 0 && (ast.IsPartOfTypeNode(node) || ast.IsTypeDeclarationName(node)) { - // If the symbol has a type meaning and we're in a type context, remove value-only meanings - flags &^= ast.SymbolFlagsVariable | ast.SymbolFlagsFunction - } - container := getContainerNode(node) var b strings.Builder - if isAlias { - b.WriteString("(alias) ") + var visitedAliases collections.Set[*ast.Symbol] + container := getContainerNode(node) + if node.Kind == ast.KindThisKeyword && ast.IsInExpressionContext(node) { + return c.TypeToStringEx(c.GetTypeAtLocation(node), container, typeFormatFlags), nil } - switch { - case flags&(ast.SymbolFlagsVariable|ast.SymbolFlagsProperty|ast.SymbolFlagsAccessor) != 0: - switch { - case flags&ast.SymbolFlagsProperty != 0: - b.WriteString("(property) ") - case flags&ast.SymbolFlagsAccessor != 0: - b.WriteString("(accessor) ") - default: - decl := symbol.ValueDeclaration - if decl != nil { - switch { - case ast.IsParameter(decl): - b.WriteString("(parameter) ") - case ast.IsVarLet(decl): - b.WriteString("let ") - case ast.IsVarConst(decl): - b.WriteString("const ") - case ast.IsVarUsing(decl): - b.WriteString("using ") - case ast.IsVarAwaitUsing(decl): - b.WriteString("await using ") - default: - b.WriteString("var ") - } - } + writeSymbolMeaning := func(symbol *ast.Symbol, meaning ast.SymbolFlags, isAlias bool) *ast.Node { + flags := symbol.Flags & meaning + if flags == 0 { + return nil } - b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - b.WriteString(": ") - b.WriteString(c.TypeToStringEx(c.GetTypeOfSymbolAtLocation(symbol, node), container, typeFormatFlags)) - case flags&ast.SymbolFlagsEnumMember != 0: - b.WriteString("(enum member) ") - t := c.GetTypeOfSymbol(symbol) - b.WriteString(c.TypeToStringEx(t, container, typeFormatFlags)) - if t.Flags()&checker.TypeFlagsLiteral != 0 { - b.WriteString(" = ") - b.WriteString(t.AsLiteralType().String()) + declaration := symbol.ValueDeclaration + if flags&ast.SymbolFlagsProperty != 0 && declaration != nil && ast.IsMethodDeclaration(declaration) { + flags = ast.SymbolFlagsMethod } - case flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsMethod) != 0: - signatures := getSignaturesAtLocation(c, symbol, checker.SignatureKindCall, node) - if len(signatures) == 1 && signatures[0].Declaration() != nil { - declaration = signatures[0].Declaration() + if b.Len() != 0 { + b.WriteString("\n") } - prefix := core.IfElse(symbol.Flags&ast.SymbolFlagsMethod != 0, "(method) ", "function ") - writeSignatures(&b, c, signatures, container, prefix, symbol) - case flags&ast.SymbolFlagsConstructor != 0: - signatures := getSignaturesAtLocation(c, symbol.Parent, checker.SignatureKindConstruct, node) - if len(signatures) == 1 && signatures[0].Declaration() != nil { - declaration = signatures[0].Declaration() + if isAlias { + b.WriteString("(alias) ") } - writeSignatures(&b, c, signatures, container, "constructor ", symbol.Parent) - case flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) != 0: - if node.Kind == ast.KindThisKeyword || ast.IsThisInTypeQuery(node) { - b.WriteString("this") - } else { - b.WriteString(core.IfElse(symbol.Flags&ast.SymbolFlagsClass != 0, "class ", "interface ")) + switch { + case flags&(ast.SymbolFlagsVariable|ast.SymbolFlagsProperty|ast.SymbolFlagsAccessor) != 0: + switch { + case flags&ast.SymbolFlagsProperty != 0: + b.WriteString("(property) ") + case flags&ast.SymbolFlagsAccessor != 0: + b.WriteString("(accessor) ") + default: + decl := symbol.ValueDeclaration + if decl != nil { + switch { + case ast.IsParameter(decl): + b.WriteString("(parameter) ") + case ast.IsVarLet(decl): + b.WriteString("let ") + case ast.IsVarConst(decl): + b.WriteString("const ") + case ast.IsVarUsing(decl): + b.WriteString("using ") + case ast.IsVarAwaitUsing(decl): + b.WriteString("await using ") + default: + b.WriteString("var ") + } + } + } + if symbol.Name == ast.InternalSymbolNameExportEquals && symbol.Parent != nil && symbol.Parent.Flags&ast.SymbolFlagsModule != 0 { + b.WriteString("exports") + } else { + b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) + } + b.WriteString(": ") + if callNode := getCallOrNewExpression(node); callNode != nil { + b.WriteString(c.SignatureToStringEx(c.GetResolvedSignature(callNode), container, typeFormatFlags|checker.TypeFormatFlagsWriteCallStyleSignature|checker.TypeFormatFlagsWriteTypeArgumentsOfSignature|checker.TypeFormatFlagsWriteArrowStyleSignature)) + } else { + b.WriteString(c.TypeToStringEx(c.GetTypeOfSymbolAtLocation(symbol, node), container, typeFormatFlags)) + } + case flags&ast.SymbolFlagsEnumMember != 0: + b.WriteString("(enum member) ") + t := c.GetTypeOfSymbol(symbol) + b.WriteString(c.TypeToStringEx(t, container, typeFormatFlags)) + if t.Flags()&checker.TypeFlagsLiteral != 0 { + b.WriteString(" = ") + b.WriteString(t.AsLiteralType().String()) + } + case flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsMethod) != 0: + prefix := core.IfElse(flags&ast.SymbolFlagsMethod != 0, "(method) ", "function ") + if ast.IsIdentifier(node) && ast.IsFunctionLikeDeclaration(node.Parent) && node.Parent.Name() == node { + declaration = node.Parent + signatures := []*checker.Signature{c.GetSignatureFromDeclaration(declaration)} + writeSignatures(&b, c, signatures, container, isAlias, prefix, symbol) + } else { + signatures := getSignaturesAtLocation(c, symbol, checker.SignatureKindCall, node) + if len(signatures) == 1 { + if d := signatures[0].Declaration(); d != nil && d.Flags&ast.NodeFlagsJSDoc == 0 { + declaration = d + } + } + writeSignatures(&b, c, signatures, container, isAlias, prefix, symbol) + } + case flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) != 0: + if node.Kind == ast.KindThisKeyword || ast.IsThisInTypeQuery(node) { + b.WriteString("this") + } else if node.Kind == ast.KindConstructorKeyword && (ast.IsConstructorDeclaration(node.Parent) || ast.IsConstructSignatureDeclaration(node.Parent)) { + declaration = node.Parent + signatures := []*checker.Signature{c.GetSignatureFromDeclaration(declaration)} + writeSignatures(&b, c, signatures, container, isAlias, "constructor ", symbol) + } else { + var signatures []*checker.Signature + if flags&ast.SymbolFlagsClass != 0 && getCallOrNewExpression(node) != nil { + signatures = getSignaturesAtLocation(c, symbol, checker.SignatureKindConstruct, node) + } + if len(signatures) == 1 { + if d := signatures[0].Declaration(); d != nil && d.Flags&ast.NodeFlagsJSDoc == 0 { + declaration = d + } + writeSignatures(&b, c, signatures, container, isAlias, "constructor ", symbol) + } else { + b.WriteString(core.IfElse(flags&ast.SymbolFlagsClass != 0, "class ", "interface ")) + b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) + params := c.GetDeclaredTypeOfSymbol(symbol).AsInterfaceType().LocalTypeParameters() + writeTypeParams(&b, c, params) + } + } + if flags&ast.SymbolFlagsInterface != 0 { + declaration = core.Find(symbol.Declarations, ast.IsInterfaceDeclaration) + } + case flags&ast.SymbolFlagsEnum != 0: + b.WriteString("enum ") b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - params := c.GetDeclaredTypeOfSymbol(symbol).AsInterfaceType().LocalTypeParameters() - writeTypeParams(&b, c, params) - } - if flags&ast.SymbolFlagsInterface != 0 { - declaration = core.Find(symbol.Declarations, ast.IsInterfaceDeclaration) - } - case flags&ast.SymbolFlagsEnum != 0: - b.WriteString("enum ") - b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - case flags&ast.SymbolFlagsModule != 0: - b.WriteString(core.IfElse(symbol.ValueDeclaration != nil && ast.IsSourceFile(symbol.ValueDeclaration), "module ", "namespace ")) - b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - case flags&ast.SymbolFlagsTypeParameter != 0: - b.WriteString("(type parameter) ") - tp := c.GetDeclaredTypeOfSymbol(symbol) - b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - cons := c.GetConstraintOfTypeParameter(tp) - if cons != nil { - b.WriteString(" extends ") - b.WriteString(c.TypeToStringEx(cons, container, typeFormatFlags)) + case flags&ast.SymbolFlagsModule != 0: + b.WriteString(core.IfElse(symbol.ValueDeclaration != nil && ast.IsSourceFile(symbol.ValueDeclaration), "module ", "namespace ")) + b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) + case flags&ast.SymbolFlagsTypeParameter != 0: + b.WriteString("(type parameter) ") + tp := c.GetDeclaredTypeOfSymbol(symbol) + b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) + cons := c.GetConstraintOfTypeParameter(tp) + if cons != nil { + b.WriteString(" extends ") + b.WriteString(c.TypeToStringEx(cons, container, typeFormatFlags)) + } + declaration = core.Find(symbol.Declarations, ast.IsTypeParameterDeclaration) + case flags&ast.SymbolFlagsTypeAlias != 0: + b.WriteString("type ") + b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) + writeTypeParams(&b, c, c.GetTypeAliasTypeParameters(symbol)) + if len(symbol.Declarations) != 0 { + b.WriteString(" = ") + b.WriteString(c.TypeToStringEx(c.GetDeclaredTypeOfSymbol(symbol), container, typeFormatFlags|checker.TypeFormatFlagsInTypeAlias)) + } + declaration = core.Find(symbol.Declarations, ast.IsTypeAliasDeclaration) + default: + b.WriteString(c.TypeToStringEx(c.GetTypeOfSymbol(symbol), container, typeFormatFlags)) } - declaration = core.Find(symbol.Declarations, ast.IsTypeParameterDeclaration) - case flags&ast.SymbolFlagsTypeAlias != 0: - b.WriteString("type ") - b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - writeTypeParams(&b, c, c.GetTypeAliasTypeParameters(symbol)) - if len(symbol.Declarations) != 0 { - b.WriteString(" = ") - b.WriteString(c.TypeToStringEx(c.GetDeclaredTypeOfSymbol(symbol), container, typeFormatFlags|checker.TypeFormatFlagsInTypeAlias)) + return declaration + } + var writeSymbol func(*ast.Symbol, bool) *ast.Node + writeSymbol = func(symbol *ast.Symbol, isAlias bool) *ast.Node { + var declaration *ast.Node + // Recursively write all meanings of alias + if symbol.Flags&ast.SymbolFlagsAlias != 0 && visitedAliases.AddIfAbsent(symbol) { + if aliasedSymbol := c.GetAliasedSymbol(symbol); aliasedSymbol != c.GetUnknownSymbol() { + declaration = writeSymbol(aliasedSymbol, true /*isAlias*/) + } } - declaration = core.Find(symbol.Declarations, ast.IsTypeAliasDeclaration) - case flags&ast.SymbolFlagsAlias != 0: - b.WriteString("import ") - b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) - default: - b.WriteString(c.TypeToStringEx(c.GetTypeOfSymbol(symbol), container, typeFormatFlags)) - } - return b.String(), declaration + // Write the value meaning, if any + declaration = core.OrElse(declaration, writeSymbolMeaning(symbol, ast.SymbolFlagsValue|ast.SymbolFlagsSignature, isAlias)) + // Write the type meaning, if any + declaration = core.OrElse(declaration, writeSymbolMeaning(symbol, ast.SymbolFlagsType&^ast.SymbolFlagsValue, isAlias)) + // Write the namespace meaning, if any + declaration = core.OrElse(declaration, writeSymbolMeaning(symbol, ast.SymbolFlagsNamespace&^ast.SymbolFlagsValue, isAlias)) + // Return the first declaration + return declaration + } + firstDeclaration := writeSymbol(symbol, false /*isAlias*/) + return b.String(), firstDeclaration } func getNodeForQuickInfo(node *ast.Node) *ast.Node { @@ -249,19 +314,15 @@ func getNodeForQuickInfo(node *ast.Node) *ast.Node { return node } -func inConstructorContext(node *ast.Node) bool { - if node.Kind == ast.KindConstructorKeyword { - return true - } - if ast.IsIdentifier(node) { - for ast.IsRightSideOfQualifiedNameOrPropertyAccess(node) { - node = node.Parent - } - if ast.IsNewExpression(node.Parent) { - return true +func getSymbolAtLocationForQuickInfo(c *checker.Checker, node *ast.Node) *ast.Symbol { + if objectElement := getContainingObjectLiteralElement(node); objectElement != nil { + if contextualType := c.GetContextualType(objectElement.Parent, checker.ContextFlagsNone); contextualType != nil { + if properties := c.GetPropertySymbolsFromContextualType(objectElement, contextualType, false /*unionSymbolOk*/); len(properties) == 1 { + return properties[0] + } } } - return false + return c.GetSymbolAtLocation(node) } func getSignaturesAtLocation(c *checker.Checker, symbol *ast.Symbol, kind checker.SignatureKind, node *ast.Node) []*checker.Signature { @@ -285,7 +346,7 @@ func getCallOrNewExpression(node *ast.Node) *ast.Node { if ast.IsPropertyAccessExpression(node.Parent) && node.Parent.Name() == node { node = node.Parent } - if ast.IsCallExpression(node.Parent) || ast.IsNewExpression(node.Parent) { + if (ast.IsCallExpression(node.Parent) || ast.IsNewExpression(node.Parent)) && node.Parent.Expression() == node { return node.Parent } return nil @@ -310,10 +371,13 @@ func writeTypeParams(b *strings.Builder, c *checker.Checker, params []*checker.T } } -func writeSignatures(b *strings.Builder, c *checker.Checker, signatures []*checker.Signature, container *ast.Node, prefix string, symbol *ast.Symbol) { +func writeSignatures(b *strings.Builder, c *checker.Checker, signatures []*checker.Signature, container *ast.Node, isAlias bool, prefix string, symbol *ast.Symbol) { for i, sig := range signatures { if i != 0 { b.WriteString("\n") + if isAlias { + b.WriteString("(alias) ") + } } if i == 3 && len(signatures) >= 5 { b.WriteString(fmt.Sprintf("// +%v more overloads", len(signatures)-3)) @@ -329,7 +393,7 @@ func containsTypedefTag(jsdoc *ast.Node) bool { if jsdoc.Kind == ast.KindJSDoc { if tags := jsdoc.AsJSDoc().Tags; tags != nil { for _, tag := range tags.Nodes { - if tag.Kind == ast.KindJSDocTypedefTag { + if tag.Kind == ast.KindJSDocTypedefTag || tag.Kind == ast.KindJSDocCallbackTag { return true } } @@ -346,26 +410,40 @@ func getJSDoc(node *ast.Node) *ast.Node { return core.LastOrNil(node.JSDoc(nil)) } -func getJSDocOrTag(node *ast.Node) *ast.Node { +func getJSDocOrTag(c *checker.Checker, node *ast.Node) *ast.Node { if jsdoc := getJSDoc(node); jsdoc != nil { return jsdoc } switch { case ast.IsParameter(node): - return getMatchingJSDocTag(node.Parent, node.Name().Text(), isMatchingParameterTag) + return getMatchingJSDocTag(c, node.Parent, node.Name().Text(), isMatchingParameterTag) case ast.IsTypeParameterDeclaration(node): - return getMatchingJSDocTag(node.Parent, node.Name().Text(), isMatchingTemplateTag) + return getMatchingJSDocTag(c, node.Parent, node.Name().Text(), isMatchingTemplateTag) case ast.IsVariableDeclaration(node) && ast.IsVariableDeclarationList(node.Parent) && core.FirstOrNil(node.Parent.AsVariableDeclarationList().Declarations.Nodes) == node: - return getJSDocOrTag(node.Parent.Parent) + return getJSDocOrTag(c, node.Parent.Parent) case (ast.IsFunctionExpressionOrArrowFunction(node) || ast.IsClassExpression(node)) && (ast.IsVariableDeclaration(node.Parent) || ast.IsPropertyDeclaration(node.Parent) || ast.IsPropertyAssignment(node.Parent)) && node.Parent.Initializer() == node: - return getJSDocOrTag(node.Parent) + return getJSDocOrTag(c, node.Parent) + } + if symbol := node.Symbol(); symbol != nil && node.Parent != nil && ast.IsClassOrInterfaceLike(node.Parent) { + isStatic := ast.HasStaticModifier(node) + for _, baseType := range c.GetBaseTypes(c.GetDeclaredTypeOfSymbol(node.Parent.Symbol())) { + t := baseType + if isStatic { + t = c.GetTypeOfSymbol(baseType.Symbol()) + } + if prop := c.GetPropertyOfType(t, symbol.Name); prop != nil && prop.ValueDeclaration != nil { + if jsDoc := getJSDocOrTag(c, prop.ValueDeclaration); jsDoc != nil { + return jsDoc + } + } + } } return nil } -func getMatchingJSDocTag(node *ast.Node, name string, match func(*ast.Node, string) bool) *ast.Node { - if jsdoc := getJSDocOrTag(node); jsdoc != nil && jsdoc.Kind == ast.KindJSDoc { +func getMatchingJSDocTag(c *checker.Checker, node *ast.Node, name string, match func(*ast.Node, string) bool) *ast.Node { + if jsdoc := getJSDocOrTag(c, node); jsdoc != nil && jsdoc.Kind == ast.KindJSDoc { if tags := jsdoc.AsJSDoc().Tags; tags != nil { for _, tag := range tags.Nodes { if match(tag, name) { @@ -411,61 +489,103 @@ func writeCode(b *strings.Builder, lang string, code string) { b.WriteByte('\n') } -func writeComments(b *strings.Builder, comments []*ast.Node) { +func (l *LanguageService) writeComments(b *strings.Builder, c *checker.Checker, comments []*ast.Node, isMarkdown bool) { for _, comment := range comments { switch comment.Kind { case ast.KindJSDocText: b.WriteString(comment.Text()) - case ast.KindJSDocLink: - name := comment.Name() - text := comment.AsJSDocLink().Text() - if name != nil { - if text == "" { - writeEntityName(b, name) - } else { - writeEntityNameParts(b, name) - } - } - b.WriteString(text) + case ast.KindJSDocLink, ast.KindJSDocLinkPlain: + l.writeJSDocLink(b, c, comment, false /*quote*/, isMarkdown) case ast.KindJSDocLinkCode: - // !!! TODO: This is a temporary placeholder implementation that needs to be updated later - name := comment.Name() - text := comment.AsJSDocLinkCode().Text() - if name != nil { - if text == "" { - writeEntityName(b, name) - } else { - writeEntityNameParts(b, name) - } + l.writeJSDocLink(b, c, comment, true /*quote*/, isMarkdown) + } + } +} + +func (l *LanguageService) writeJSDocLink(b *strings.Builder, c *checker.Checker, link *ast.Node, quote bool, isMarkdown bool) { + name := link.Name() + text := strings.Trim(link.Text(), " ") + if name == nil { + writeQuotedString(b, text, quote && isMarkdown) + return + } + if ast.IsIdentifier(name) && (name.Text() == "http" || name.Text() == "https") && strings.HasPrefix(text, "://") { + linkText := name.Text() + text + linkUri := linkText + if commentPos := strings.IndexFunc(linkText, func(ch rune) bool { return ch == ' ' || ch == '|' }); commentPos >= 0 { + linkUri = linkText[:commentPos] + linkText = trimCommentPrefix(linkText[commentPos:]) + if linkText == "" { + linkText = linkUri } - b.WriteString(text) - case ast.KindJSDocLinkPlain: - // !!! TODO: This is a temporary placeholder implementation that needs to be updated later - name := comment.Name() - text := comment.AsJSDocLinkPlain().Text() - if name != nil { - if text == "" { - writeEntityName(b, name) - } else { - writeEntityNameParts(b, name) - } + } + if isMarkdown { + writeMarkdownLink(b, linkText, linkUri, quote) + } else { + writeQuotedString(b, linkText, false) + if linkText != linkUri { + b.WriteString(" (") + b.WriteString(linkUri) + b.WriteString(")") } - b.WriteString(text) } + return } + declarations := getDeclarationsFromLocation(c, name) + if len(declarations) != 0 { + declaration := declarations[0] + file := ast.GetSourceFileOfNode(declaration) + node := core.OrElse(ast.GetNameOfDeclaration(declaration), declaration) + loc := l.getMappedLocation(file.FileName(), createRangeFromNode(node, file)) + prefixLen := core.IfElse(strings.HasPrefix(text, "()"), 2, 0) + linkText := trimCommentPrefix(text[prefixLen:]) + if linkText == "" { + linkText = getEntityNameString(name) + text[:prefixLen] + } + if isMarkdown { + linkUri := fmt.Sprintf("%s#%d,%d-%d,%d", loc.Uri, loc.Range.Start.Line+1, loc.Range.Start.Character+1, loc.Range.End.Line+1, loc.Range.End.Character+1) + writeMarkdownLink(b, linkText, linkUri, quote) + } else { + writeQuotedString(b, linkText, false) + } + return + } + writeQuotedString(b, getEntityNameString(name)+" "+text, quote && isMarkdown) +} + +func trimCommentPrefix(text string) string { + return strings.TrimLeft(strings.TrimPrefix(strings.TrimLeft(text, " "), "|"), " ") +} + +func writeMarkdownLink(b *strings.Builder, text string, uri string, quote bool) { + b.WriteString("[") + writeQuotedString(b, text, quote) + b.WriteString("](") + b.WriteString(uri) + b.WriteString(")") } func writeOptionalEntityName(b *strings.Builder, name *ast.Node) { if name != nil { b.WriteString(" ") - writeEntityName(b, name) + writeQuotedString(b, getEntityNameString(name), true /*quote*/) + } +} + +func writeQuotedString(b *strings.Builder, str string, quote bool) { + if quote && !strings.Contains(str, "`") { + b.WriteString("`") + b.WriteString(str) + b.WriteString("`") + } else { + b.WriteString(str) } } -func writeEntityName(b *strings.Builder, name *ast.Node) { - b.WriteString("`") - writeEntityNameParts(b, name) - b.WriteString("`") +func getEntityNameString(name *ast.Node) string { + var b strings.Builder + writeEntityNameParts(&b, name) + return b.String() } func writeEntityNameParts(b *strings.Builder, node *ast.Node) { diff --git a/internal/ls/importTracker.go b/internal/ls/importTracker.go index e4a70d62d7..88f6febb4c 100644 --- a/internal/ls/importTracker.go +++ b/internal/ls/importTracker.go @@ -304,7 +304,7 @@ func findNamespaceReExports(sourceFileLike *ast.Node, name *ast.Node, checker *c return false } exportClause := statement.AsExportDeclaration().ExportClause - moduleSpecifier := statement.AsExportDeclaration().ModuleSpecifier + moduleSpecifier := statement.ModuleSpecifier() return moduleSpecifier == nil && exportClause != nil && ast.IsNamedExports(exportClause) && core.Some(exportClause.Elements(), func(element *ast.Node) bool { return checker.GetExportSpecifierLocalTargetSymbol(element) == namespaceImportSymbol }) @@ -502,7 +502,7 @@ func getImportOrExportSymbol(node *ast.Node, symbol *ast.Symbol, checker *checke } else { exportNode := getExportNode(parent, node) switch { - case exportNode != nil && ast.HasSyntacticModifier(exportNode, ast.ModifierFlagsExport): + case exportNode != nil && (ast.HasSyntacticModifier(exportNode, ast.ModifierFlagsExport) || ast.IsImplicitlyExportedJSTypeAlias(exportNode)): if ast.IsImportEqualsDeclaration(exportNode) && exportNode.AsImportEqualsDeclaration().ModuleReference == node { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if comingFromExport { diff --git a/internal/ls/inlay_hints.go b/internal/ls/inlay_hints.go new file mode 100644 index 0000000000..215752091e --- /dev/null +++ b/internal/ls/inlay_hints.go @@ -0,0 +1,906 @@ +package ls + +import ( + "context" + "slices" + "strings" + "unicode" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/checker" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/debug" + "github.com/microsoft/typescript-go/internal/evaluator" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/nodebuilder" + "github.com/microsoft/typescript-go/internal/printer" + "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" +) + +func (l *LanguageService) ProvideInlayHint( + ctx context.Context, + params *lsproto.InlayHintParams, +) (lsproto.InlayHintResponse, error) { + if !isAnyInlayHintEnabled(l.UserPreferences()) { + return lsproto.InlayHintsOrNull{InlayHints: nil}, nil + } + program, file := l.getProgramAndFile(params.TextDocument.Uri) + quotePreference := getQuotePreference(file, l.UserPreferences()) + + checker, done := program.GetTypeCheckerForFile(ctx, file) + defer done() + inlayHintState := &inlayHintState{ + ctx: ctx, + span: l.converters.FromLSPRange(file, params.Range), + preferences: l.UserPreferences(), + quotePreference: quotePreference, + file: file, + checker: checker, + converters: l.converters, + } + inlayHintState.visit(file.AsNode()) + return lsproto.InlayHintsOrNull{InlayHints: &inlayHintState.result}, nil +} + +type inlayHintState struct { + ctx context.Context + span core.TextRange + preferences *lsutil.UserPreferences + quotePreference quotePreference + file *ast.SourceFile + checker *checker.Checker + converters *lsconv.Converters + result []*lsproto.InlayHint +} + +func (s *inlayHintState) visit(node *ast.Node) bool { + if node == nil || node.End()-node.Pos() == 0 { + return false + } + + switch node.Kind { + case ast.KindModuleDeclaration, ast.KindClassDeclaration, ast.KindInterfaceDeclaration, + ast.KindFunctionDeclaration, ast.KindClassExpression, ast.KindFunctionExpression, + ast.KindMethodDeclaration, ast.KindArrowFunction: + if s.ctx.Err() != nil { + return true + } + } + + if !s.span.Intersects(node.Loc) { + return false + } + + if ast.IsTypeNode(node) && !ast.IsExpressionWithTypeArguments(node) { + return false + } + + if s.preferences.IncludeInlayVariableTypeHints && ast.IsVariableDeclaration(node) { + s.visitVariableLikeDeclaration(node) + } else if s.preferences.IncludeInlayPropertyDeclarationTypeHints && ast.IsPropertyDeclaration(node) { + s.visitVariableLikeDeclaration(node) + } else if s.preferences.IncludeInlayEnumMemberValueHints && ast.IsEnumMember(node) { + s.visitEnumMember(node) + } else if shouldShowParameterNameHints(s.preferences) && (ast.IsCallExpression(node) || ast.IsNewExpression(node)) { + s.visitCallOrNewExpression(node) + } else { + if s.preferences.IncludeInlayFunctionParameterTypeHints && + ast.IsFunctionLikeDeclaration(node) && + ast.HasContextSensitiveParameters(node) { + s.visitFunctionLikeForParameterType(node) + } + if s.preferences.IncludeInlayFunctionLikeReturnTypeHints && + isSignatureSupportingReturnAnnotation(node) { + s.visitFunctionDeclarationLikeForReturnType(node) + } + } + return node.ForEachChild(s.visit) +} + +// FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | FunctionExpression | ArrowFunction +func (s *inlayHintState) visitFunctionDeclarationLikeForReturnType(decl *ast.FunctionLikeDeclaration) { + if ast.IsArrowFunction(decl) { + if findChildOfKind(decl, ast.KindOpenParenToken, s.file) == nil { + return + } + } + + typeAnnotation := decl.Type() + if typeAnnotation != nil || decl.Body() == nil { + return + } + + signature := s.checker.GetSignatureFromDeclaration(decl) + if signature == nil { + return + } + + typePredicate := s.checker.GetTypePredicateOfSignature(signature) + + if typePredicate != nil && typePredicate.Type() != nil { + hintParts := s.typePredicateToInlayHintParts(typePredicate) + s.addTypeHints(hintParts, s.getTypeAnnotationPosition(decl)) + return + } + + returnType := s.checker.GetReturnTypeOfSignature(signature) + if isModuleReferenceType(returnType) { + return + } + + hintParts := s.typeToInlayHintParts(returnType) + s.addTypeHints(hintParts, s.getTypeAnnotationPosition(decl)) +} + +func (s *inlayHintState) visitCallOrNewExpression(expr *ast.CallOrNewExpression) { + args := expr.Arguments() + if len(args) == 0 { + return + } + + signature := s.checker.GetResolvedSignature(expr) + if signature == nil { + return + } + + signatureParamPos := 0 + for _, originalArg := range args { + arg := ast.SkipParentheses(originalArg) + if shouldShowLiteralParameterNameHintsOnly(s.preferences) && !isHintableLiteral(arg) { + signatureParamPos++ + continue + } + + spreadArgs := 0 + if ast.IsSpreadElement(arg) { + spreadType := s.checker.GetTypeAtLocation(arg.Expression()) + if spreadType.IsTupleType() { + elementFlags := spreadType.Target().AsTupleType().ElementFlags() + fixedLength := spreadType.Target().AsTupleType().FixedLength() + if fixedLength == 0 { + continue + } + firstOptionalIndex := slices.IndexFunc(elementFlags, func(f checker.ElementFlags) bool { + return f&checker.ElementFlagsRequired == 0 + }) + requiredArgs := core.IfElse(firstOptionalIndex < 0, fixedLength, firstOptionalIndex) + if requiredArgs > 0 { + spreadArgs = requiredArgs + } + } + } + + identifierInfo := s.getParameterIdentifierInfoAtPosition(signature, signatureParamPos) + signatureParamPos = signatureParamPos + core.IfElse(spreadArgs > 0, spreadArgs, 1) + if identifierInfo == nil { + return + } + + parameter := identifierInfo.parameter + parameterName := identifierInfo.name + isFirstVariadicArgument := identifierInfo.isRestParameter + parameterNameNotSameAsArgument := s.preferences.IncludeInlayParameterNameHintsWhenArgumentMatchesName || + !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName) + if !parameterNameNotSameAsArgument && !isFirstVariadicArgument { + continue + } + + if s.leadingCommentsContainsParameterName(arg, parameterName) { + continue + } + + s.addParameterHints( + parameterName, + parameter, + astnav.GetStartOfNode(originalArg, s.file, false /*includeJSDoc*/), + isFirstVariadicArgument, + ) + } +} + +func (s *inlayHintState) visitEnumMember(member *ast.EnumMemberNode) { + if member.Initializer() != nil { + return + } + + enumValue := s.checker.GetConstantValue(member) + if enumValue != nil { + s.addEnumMemberValueHints(evaluator.AnyToString(enumValue), member.End()) + } +} + +func (s *inlayHintState) visitVariableLikeDeclaration(decl *ast.VariableOrPropertyDeclaration) { + if decl.Initializer() == nil && + !(ast.IsPropertyDeclaration(decl) && s.checker.GetTypeAtLocation(decl).Flags()&checker.TypeFlagsAny == 0) || + ast.IsBindingPattern(decl.Name()) || (ast.IsVariableDeclaration(decl) && !isHintableDeclaration(decl)) { + return + } + + typeAnnotation := decl.Type() + if typeAnnotation != nil { + return + } + + declarationType := s.checker.GetTypeAtLocation(decl) + if isModuleReferenceType(declarationType) { + return + } + + hintParts := s.typeToInlayHintParts(declarationType) + var hintText string + if hintParts.String != nil { + hintText = *hintParts.String + } else if hintParts.InlayHintLabelParts != nil { + var b strings.Builder + for _, part := range *hintParts.InlayHintLabelParts { + b.WriteString(part.Value) + } + hintText = b.String() + } + if !s.preferences.IncludeInlayVariableTypeHintsWhenTypeMatchesName && + stringutil.EquateStringCaseInsensitive(decl.Name().Text(), hintText) { + return + } + s.addTypeHints(hintParts, decl.Name().End()) +} + +func (s *inlayHintState) visitFunctionLikeForParameterType(node *ast.FunctionLikeDeclaration) { + signature := s.checker.GetSignatureFromDeclaration(node) + if signature == nil { + return + } + + pos := 0 + for _, param := range node.Parameters() { + if isHintableDeclaration(param) { + var symbol *ast.Symbol + if ast.IsThisParameter(param) { + symbol = signature.ThisParameter() + } else { + symbol = signature.Parameters()[pos] + } + s.addParameterTypeHint(param, symbol) + } + if ast.IsThisParameter(param) { + continue + } + pos++ + } +} + +func (s *inlayHintState) addParameterTypeHint(node *ast.ParameterDeclarationNode, symbol *ast.Symbol) { + typeAnnotation := node.Type() + if typeAnnotation != nil || symbol == nil { + return + } + typeHints := s.getParameterDeclarationTypeHints(symbol) + if typeHints == nil { + return + } + var pos int + if node.QuestionToken() != nil { + pos = node.QuestionToken().End() + } else { + pos = node.Name().End() + } + s.addTypeHints(*typeHints, pos) +} + +func (s *inlayHintState) getParameterDeclarationTypeHints(symbol *ast.Symbol) *lsproto.StringOrInlayHintLabelParts { + valueDeclaration := symbol.ValueDeclaration + if valueDeclaration == nil || !ast.IsParameter(valueDeclaration) { + return nil + } + + signatureParamType := s.checker.GetTypeOfSymbolAtLocation(symbol, valueDeclaration) + if isModuleReferenceType(signatureParamType) { + return nil + } + + return ptrTo(s.typeToInlayHintParts(signatureParamType)) +} + +func (s *inlayHintState) typeToInlayHintParts(t *checker.Type) lsproto.StringOrInlayHintLabelParts { + flags := nodebuilder.FlagsIgnoreErrors | nodebuilder.FlagsAllowUniqueESSymbolType | + nodebuilder.FlagsUseAliasDefinedOutsideCurrentScope + typeNode := s.checker.TypeToTypeNode(t, nil /*enclosingDeclaration*/, flags) + debug.AssertIsDefined(typeNode, "should always get typenode") + return lsproto.StringOrInlayHintLabelParts{ + InlayHintLabelParts: ptrTo(s.getInlayHintLabelParts(typeNode)), + } +} + +func (s *inlayHintState) typePredicateToInlayHintParts(typePredicate *checker.TypePredicate) lsproto.StringOrInlayHintLabelParts { + flags := nodebuilder.FlagsIgnoreErrors | nodebuilder.FlagsAllowUniqueESSymbolType | + nodebuilder.FlagsUseAliasDefinedOutsideCurrentScope + typeNode := s.checker.TypePredicateToTypePredicateNode(typePredicate, nil /*enclosingDeclaration*/, flags) + debug.AssertIsDefined(typeNode, "should always get typePredicateNode") + return lsproto.StringOrInlayHintLabelParts{ + InlayHintLabelParts: ptrTo(s.getInlayHintLabelParts(typeNode)), + } +} + +func (s *inlayHintState) addTypeHints(hint lsproto.StringOrInlayHintLabelParts, position int) { + if hint.String != nil { + hint.String = ptrTo(": " + *hint.String) + } else { + hint.InlayHintLabelParts = ptrTo(append([]*lsproto.InlayHintLabelPart{{Value: ": "}}, *hint.InlayHintLabelParts...)) + } + s.result = append(s.result, &lsproto.InlayHint{ + Label: hint, + Position: s.converters.PositionToLineAndCharacter(s.file, core.TextPos(position)), + Kind: ptrTo(lsproto.InlayHintKindType), + PaddingLeft: ptrTo(true), + }) +} + +func (s *inlayHintState) addEnumMemberValueHints(text string, position int) { + s.result = append(s.result, &lsproto.InlayHint{ + Label: lsproto.StringOrInlayHintLabelParts{ + String: ptrTo("= " + text), + }, + Position: s.converters.PositionToLineAndCharacter(s.file, core.TextPos(position)), + PaddingLeft: ptrTo(true), + }) +} + +func (s *inlayHintState) addParameterHints(text string, parameter *ast.IdentifierNode, position int, isFirstVariadicArgument bool) { + hintText := core.IfElse(isFirstVariadicArgument, "...", "") + text + displayParts := []*lsproto.InlayHintLabelPart{ + s.getNodeDisplayPart(hintText, parameter), + { + Value: ":", + }, + } + labelParts := lsproto.StringOrInlayHintLabelParts{InlayHintLabelParts: &displayParts} + + s.result = append(s.result, &lsproto.InlayHint{ + Label: labelParts, + Position: s.converters.PositionToLineAndCharacter(s.file, core.TextPos(position)), + Kind: ptrTo(lsproto.InlayHintKindParameter), + PaddingRight: ptrTo(true), + }) +} + +func shouldShowParameterNameHints(preferences *lsutil.UserPreferences) bool { + return (preferences.IncludeInlayParameterNameHints == lsutil.IncludeInlayParameterNameHintsLiterals || + preferences.IncludeInlayParameterNameHints == lsutil.IncludeInlayParameterNameHintsAll) +} + +func shouldShowLiteralParameterNameHintsOnly(preferences *lsutil.UserPreferences) bool { + return preferences.IncludeInlayParameterNameHints == lsutil.IncludeInlayParameterNameHintsLiterals +} + +// node is FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration +func isSignatureSupportingReturnAnnotation(node *ast.Node) bool { + return ast.IsArrowFunction(node) || ast.IsFunctionExpression(node) || ast.IsFunctionDeclaration(node) || + ast.IsMethodDeclaration(node) || ast.IsGetAccessorDeclaration(node) +} + +func isHintableDeclaration(node *ast.VariableOrParameterDeclaration) bool { + if (ast.IsPartOfParameterDeclaration(node) || ast.IsVariableDeclaration(node) && ast.IsVarConst(node)) && + node.Initializer() != nil { + initializer := ast.SkipParentheses(node.Initializer()) + return !(isHintableLiteral(initializer) || ast.IsNewExpression(initializer) || + ast.IsObjectLiteralExpression(initializer) || ast.IsAssertionExpression(initializer)) + } + return true +} + +func isHintableLiteral(node *ast.Node) bool { + switch node.Kind { + case ast.KindPrefixUnaryExpression: + operand := node.AsPrefixUnaryExpression().Operand + return ast.IsLiteralExpression(operand) || ast.IsIdentifier(operand) && ast.IsInfinityOrNaNString(operand.Text()) + case ast.KindTrueKeyword, ast.KindFalseKeyword, ast.KindNullKeyword, + ast.KindNoSubstitutionTemplateLiteral, ast.KindTemplateExpression: + return true + case ast.KindIdentifier: + name := node.Text() + return name == "undefined" || ast.IsInfinityOrNaNString(name) + } + return ast.IsLiteralExpression(node) +} + +func isModuleReferenceType(t *checker.Type) bool { + symbol := t.Symbol() + return symbol != nil && symbol.Flags&ast.SymbolFlagsModule != 0 +} + +func (s *inlayHintState) getInlayHintLabelParts(node *ast.Node) []*lsproto.InlayHintLabelPart { + var parts []*lsproto.InlayHintLabelPart + + var visitForDisplayParts func(node *ast.Node) + var visitDisplayPartList func(nodes []*ast.Node, separator string) + var visitParametersAndTypeParameters func(node *ast.SignatureDeclaration) + + visitForDisplayParts = func(node *ast.Node) { + if node == nil { + return + } + + tokenString := scanner.TokenToString(node.Kind) + if tokenString != "" { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: tokenString}) + return + } + + if ast.IsLiteralExpression(node) { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: s.getLiteralText(node)}) + return + } + + switch node.Kind { + case ast.KindIdentifier: + identifierText := node.Text() + var name *ast.Node + // !!! This won't work in Corsa since we don't store symbols on identifiers. We need another strategy for it. + if node.Symbol() != nil && len(node.Symbol().Declarations) != 0 { + name = ast.GetNameOfDeclaration(node.Symbol().Declarations[0]) + } + if name != nil { + parts = append(parts, s.getNodeDisplayPart(identifierText, name)) + } else { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: identifierText}) + } + case ast.KindQualifiedName: + visitForDisplayParts(node.AsQualifiedName().Left) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "."}) + visitForDisplayParts(node.AsQualifiedName().Right) + case ast.KindTypePredicate: + if node.AsTypePredicateNode().AssertsModifier != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "asserts "}) + } + visitForDisplayParts(node.AsTypePredicateNode().ParameterName) + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " is "}) + visitForDisplayParts(node.Type()) + } + case ast.KindTypeReference: + visitForDisplayParts(node.AsTypeReferenceNode().TypeName) + if len(node.TypeArguments()) > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "<"}) + visitDisplayPartList(node.TypeArguments(), ",") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ">"}) + } + case ast.KindTypeParameter: + if len(node.ModifierNodes()) > 0 { + visitDisplayPartList(node.ModifierNodes(), "") + } + visitForDisplayParts(node.Name()) + if node.AsTypeParameter().Constraint != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " extends "}) + visitForDisplayParts(node.AsTypeParameter().Constraint) + } + if node.AsTypeParameter().DefaultType != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " = "}) + visitForDisplayParts(node.AsTypeParameter().DefaultType) + } + case ast.KindParameter: + if len(node.ModifierNodes()) > 0 { + visitDisplayPartList(node.ModifierNodes(), " ") + } + if node.AsParameterDeclaration().DotDotDotToken != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "..."}) + } + visitForDisplayParts(node.Name()) + if node.QuestionToken() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "?"}) + } + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + } + case ast.KindConstructorType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "new "}) + visitParametersAndTypeParameters(node) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " => "}) + visitForDisplayParts(node.Type()) + case ast.KindTypeQuery: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "typeof "}) + visitForDisplayParts(node.AsTypeQueryNode().ExprName) + if len(node.TypeArguments()) > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "<"}) + visitDisplayPartList(node.TypeArguments(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ">"}) + } + case ast.KindTypeLiteral: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "{"}) + if len(node.Members()) > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " "}) + visitDisplayPartList(node.Members(), "; ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " "}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "}"}) + case ast.KindArrayType: + visitForDisplayParts(node.AsArrayTypeNode().ElementType) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "[]"}) + case ast.KindTupleType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "["}) + visitDisplayPartList(node.Elements(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "]"}) + case ast.KindNamedTupleMember: + if node.AsNamedTupleMember().DotDotDotToken != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "..."}) + } + visitForDisplayParts(node.Name()) + if node.QuestionToken() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "?"}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + case ast.KindOptionalType: + visitForDisplayParts(node.Type()) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "?"}) + case ast.KindRestType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "..."}) + visitForDisplayParts(node.Type()) + case ast.KindUnionType: + if node.AsUnionTypeNode().Types != nil { + visitDisplayPartList(node.AsUnionTypeNode().Types.Nodes, " | ") + } + case ast.KindIntersectionType: + if node.AsIntersectionTypeNode().Types != nil { + visitDisplayPartList(node.AsIntersectionTypeNode().Types.Nodes, " & ") + } + case ast.KindConditionalType: + visitForDisplayParts(node.AsConditionalTypeNode().CheckType) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " extends "}) + visitForDisplayParts(node.AsConditionalTypeNode().ExtendsType) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " ? "}) + visitForDisplayParts(node.AsConditionalTypeNode().TrueType) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " : "}) + visitForDisplayParts(node.AsConditionalTypeNode().FalseType) + case ast.KindInferType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "infer "}) + visitForDisplayParts(node.AsInferTypeNode().TypeParameter) + case ast.KindParenthesizedType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "("}) + visitForDisplayParts(node.Type()) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ")"}) + case ast.KindTypeOperator: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: scanner.TokenToString(node.AsTypeOperatorNode().Operator)}) + visitForDisplayParts(node.Type()) + case ast.KindIndexedAccessType: + visitForDisplayParts(node.AsIndexedAccessTypeNode().ObjectType) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "["}) + visitForDisplayParts(node.AsIndexedAccessTypeNode().IndexType) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "]"}) + case ast.KindMappedType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "{ "}) + if node.AsMappedTypeNode().ReadonlyToken != nil { + if node.AsMappedTypeNode().ReadonlyToken.Kind == ast.KindPlusToken { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "+"}) + } else if node.AsMappedTypeNode().ReadonlyToken.Kind == ast.KindMinusToken { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "-"}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "readonly "}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "["}) + visitForDisplayParts(node.AsMappedTypeNode().TypeParameter) + if node.AsMappedTypeNode().NameType != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " as "}) + visitForDisplayParts(node.AsMappedTypeNode().NameType) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "]"}) + if node.QuestionToken() != nil { + if node.QuestionToken().Kind == ast.KindPlusToken { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "+"}) + } else if node.QuestionToken().Kind == ast.KindMinusToken { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "-"}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "?"}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + if node.Type() != nil { + visitForDisplayParts(node.Type()) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "; }"}) + case ast.KindLiteralType: + visitForDisplayParts(node.AsLiteralTypeNode().Literal) + case ast.KindFunctionType: + visitParametersAndTypeParameters(node) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " => "}) + visitForDisplayParts(node.Type()) + case ast.KindImportType: + if node.AsImportTypeNode().IsTypeOf { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "typeof "}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "import("}) + visitForDisplayParts(node.AsImportTypeNode().Argument) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ")"}) + if node.AsImportTypeNode().Qualifier != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "."}) + visitForDisplayParts(node.AsImportTypeNode().Qualifier) + } + if len(node.TypeArguments()) > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "<"}) + visitDisplayPartList(node.TypeArguments(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ">"}) + } + case ast.KindPropertySignature: + if len(node.ModifierNodes()) > 0 { + visitDisplayPartList(node.ModifierNodes(), " ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " "}) + } + visitForDisplayParts(node.Name()) + if node.PostfixToken() != nil { + parts = append( + parts, + &lsproto.InlayHintLabelPart{ + Value: scanner.TokenToString(node.PostfixToken().Kind), + }) + } + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + } + case ast.KindIndexSignature: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "["}) + visitDisplayPartList(node.Parameters(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "]"}) + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + } + case ast.KindMethodSignature: + if len(node.ModifierNodes()) > 0 { + visitDisplayPartList(node.ModifierNodes(), " ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " "}) + } + visitForDisplayParts(node.Name()) + if node.PostfixToken() != nil { + parts = append( + parts, + &lsproto.InlayHintLabelPart{ + Value: scanner.TokenToString(node.PostfixToken().Kind), + }) + } + visitParametersAndTypeParameters(node) + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + } + case ast.KindCallSignature: + visitParametersAndTypeParameters(node) + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + } + case ast.KindConstructSignature: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "new "}) + visitParametersAndTypeParameters(node) + if node.Type() != nil { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ": "}) + visitForDisplayParts(node.Type()) + } + case ast.KindArrayBindingPattern: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "["}) + visitDisplayPartList(node.Elements(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "]"}) + case ast.KindObjectBindingPattern: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "{"}) + if len(node.Elements()) > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " "}) + visitDisplayPartList(node.Elements(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: " "}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "}"}) + case ast.KindBindingElement: + visitForDisplayParts(node.Name()) + case ast.KindPrefixUnaryExpression: + parts = append( + parts, + &lsproto.InlayHintLabelPart{ + Value: scanner.TokenToString(node.AsPrefixUnaryExpression().Operator), + }) + visitForDisplayParts(node.AsPrefixUnaryExpression().Operand) + case ast.KindTemplateLiteralType: + visitForDisplayParts(node.AsTemplateLiteralTypeNode().Head) + for _, span := range node.AsTemplateLiteralTypeNode().TemplateSpans.Nodes { + visitForDisplayParts(span) + } + case ast.KindTemplateHead: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: s.getLiteralText(node)}) + case ast.KindTemplateLiteralTypeSpan: + visitForDisplayParts(node.Type()) + visitForDisplayParts(node.AsTemplateLiteralTypeSpan().Literal) + case ast.KindTemplateMiddle, ast.KindTemplateTail: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: s.getLiteralText(node)}) + case ast.KindThisType: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "this"}) + case ast.KindComputedPropertyName: + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "["}) + visitForDisplayParts(node.Expression()) + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "]"}) + default: + debug.FailBadSyntaxKind(node) + } + } + + visitDisplayPartList = func(nodes []*ast.Node, separator string) { + for i, n := range nodes { + if i > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: separator}) + } + visitForDisplayParts(n) + } + } + + visitParametersAndTypeParameters = func(node *ast.SignatureDeclaration) { + if len(node.TypeParameters()) > 0 { + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "<"}) + visitDisplayPartList(node.TypeParameters(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ">"}) + } + parts = append(parts, &lsproto.InlayHintLabelPart{Value: "("}) + visitDisplayPartList(node.Parameters(), ", ") + parts = append(parts, &lsproto.InlayHintLabelPart{Value: ")"}) + } + + visitForDisplayParts(node) + return parts +} + +func (s *inlayHintState) getNodeDisplayPart(text string, node *ast.Node) *lsproto.InlayHintLabelPart { + file := ast.GetSourceFileOfNode(node) + return &lsproto.InlayHintLabelPart{ + Value: text, + Location: &lsproto.Location{ + Uri: lsconv.FileNameToDocumentURI(file.FileName()), + Range: s.converters.ToLSPRange(file, node.Loc), + }, + } +} + +func (s *inlayHintState) getLiteralText(node *ast.LiteralLikeNode) string { + switch node.Kind { + case ast.KindStringLiteral: + if s.quotePreference == quotePreferenceSingle { + return `'` + printer.EscapeString(node.Text(), printer.QuoteCharSingleQuote) + `'` + } + return `"` + printer.EscapeString(node.Text(), printer.QuoteCharDoubleQuote) + `"` + case ast.KindTemplateHead, ast.KindTemplateMiddle, ast.KindTemplateTail: + rawText := node.RawText() + if rawText == "" { + rawText = printer.EscapeString(node.Text(), printer.QuoteCharBacktick) + } + switch node.Kind { + case ast.KindTemplateHead: + return "`" + rawText + "${" + case ast.KindTemplateMiddle: + return "}" + rawText + "${" + case ast.KindTemplateTail: + return "}" + rawText + "`" + } + } + return node.Text() +} + +type parameterInfo struct { + parameter *ast.IdentifierNode + name string + isRestParameter bool +} + +func (s *inlayHintState) getParameterIdentifierInfoAtPosition(signature *checker.Signature, pos int) *parameterInfo { + parameters := signature.Parameters() + paramCount := len(parameters) - core.IfElse(signature.HasRestParameter(), 1, 0) + if pos < paramCount { + param := parameters[pos] + paramId := getParameterDeclarationIdentifier(param) + if paramId == nil { + return nil + } + return ¶meterInfo{ + parameter: paramId, + name: paramId.Text(), + isRestParameter: false, + } + } + + var restParameter *ast.Symbol + var restId *ast.IdentifierNode + if paramCount < len(parameters) { + restParameter = parameters[paramCount] + restId = getParameterDeclarationIdentifier(restParameter) + } + if restId == nil { + return nil + } + + restType := s.checker.GetTypeOfSymbol(restParameter) + if restType.IsTupleType() { + associatedNames := make([]*ast.Node, 0, len(restType.Target().AsTupleType().ElementInfos())) + for _, elementInfo := range restType.Target().AsTupleType().ElementInfos() { + labeledElement := elementInfo.LabeledDeclaration() + associatedNames = append(associatedNames, labeledElement) + } + index := pos - paramCount + if index < len(associatedNames) { + associatedName := associatedNames[index] + if associatedName != nil { + debug.Assert(ast.IsIdentifier(associatedName.Name())) + var isRestTupleElement bool + if ast.IsNamedTupleMember(associatedName) { + isRestTupleElement = associatedName.AsNamedTupleMember().DotDotDotToken != nil + } else { + isRestTupleElement = associatedName.AsParameterDeclaration().DotDotDotToken != nil + } + return ¶meterInfo{ + parameter: associatedName.Name(), + name: associatedName.Name().Text(), + isRestParameter: isRestTupleElement, + } + } + } + + return nil + } + + if pos == paramCount { + return ¶meterInfo{ + parameter: restId, + name: restParameter.Name, + isRestParameter: true, + } + } + return nil +} + +func getParameterDeclarationIdentifier(symbol *ast.Symbol) *ast.IdentifierNode { + if symbol.ValueDeclaration != nil && ast.IsParameter(symbol.ValueDeclaration) && ast.IsIdentifier(symbol.ValueDeclaration.Name()) { + return symbol.ValueDeclaration.Name() + } + return nil +} + +func identifierOrAccessExpressionPostfixMatchesParameterName(expr *ast.Expression, parameterName string) bool { + if ast.IsIdentifier(expr) { + return expr.Text() == parameterName + } + if ast.IsPropertyAccessExpression(expr) { + return expr.Name().Text() == parameterName + } + return false +} + +func (s *inlayHintState) leadingCommentsContainsParameterName(node *ast.Node, name string) bool { + if !scanner.IsIdentifierText(name, s.file.LanguageVariant) { + return false + } + + ranges := getLeadingCommentRangesOfNode(node, s.file) + fileText := s.file.Text() + for r := range ranges { + commentText := strings.TrimFunc(fileText[r.Pos():r.End()], func(r rune) bool { + return unicode.IsSpace(r) || r == '/' || r == '*' + }) + if commentText == name { + return true + } + } + + return false +} + +func (s *inlayHintState) getTypeAnnotationPosition(decl *ast.FunctionLikeDeclaration) int { + closeParenToken := findChildOfKind(decl, ast.KindCloseParenToken, s.file) + if closeParenToken != nil { + return closeParenToken.End() + } + return decl.ParameterList().End() +} + +func isAnyInlayHintEnabled(preferences *lsutil.UserPreferences) bool { + return preferences.IncludeInlayParameterNameHints != lsutil.IncludeInlayParameterNameHintsNone || + preferences.IncludeInlayFunctionParameterTypeHints || + preferences.IncludeInlayVariableTypeHints || + preferences.IncludeInlayPropertyDeclarationTypeHints || + preferences.IncludeInlayFunctionLikeReturnTypeHints || + preferences.IncludeInlayEnumMemberValueHints +} diff --git a/internal/ls/languageservice.go b/internal/ls/languageservice.go index c7c4596dce..2cfe172468 100644 --- a/internal/ls/languageservice.go +++ b/internal/ls/languageservice.go @@ -3,14 +3,18 @@ package ls import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/sourcemap" + "github.com/microsoft/typescript-go/internal/tspath" ) type LanguageService struct { host Host program *compiler.Program - converters *Converters + converters *lsconv.Converters documentPositionMappers map[string]*sourcemap.DocumentPositionMapper } @@ -26,10 +30,25 @@ func NewLanguageService( } } +func (l *LanguageService) toPath(fileName string) tspath.Path { + return tspath.ToPath(fileName, l.program.GetCurrentDirectory(), l.UseCaseSensitiveFileNames()) +} + func (l *LanguageService) GetProgram() *compiler.Program { return l.program } +func (l *LanguageService) UserPreferences() *lsutil.UserPreferences { + return l.host.UserPreferences() +} + +func (l *LanguageService) FormatOptions() *format.FormatCodeSettings { + if formatOptions := l.host.FormatOptions(); formatOptions != nil { + return formatOptions + } + return format.GetDefaultFormatCodeSettings(l.GetProgram().Options().NewLine.GetNewLineCharacter()) +} + func (l *LanguageService) tryGetProgramAndFile(fileName string) (*compiler.Program, *ast.SourceFile) { program := l.GetProgram() file := program.GetSourceFile(fileName) diff --git a/internal/ls/lsconv/converters.go b/internal/ls/lsconv/converters.go new file mode 100644 index 0000000000..3d5019c5ad --- /dev/null +++ b/internal/ls/lsconv/converters.go @@ -0,0 +1,326 @@ +package lsconv + +import ( + "context" + "fmt" + "net/url" + "slices" + "strings" + "unicode/utf16" + "unicode/utf8" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/diagnosticwriter" + "github.com/microsoft/typescript-go/internal/locale" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/tspath" +) + +type Converters struct { + getLineMap func(fileName string) *LSPLineMap + positionEncoding lsproto.PositionEncodingKind +} + +type Script interface { + FileName() string + Text() string +} + +func NewConverters(positionEncoding lsproto.PositionEncodingKind, getLineMap func(fileName string) *LSPLineMap) *Converters { + return &Converters{ + getLineMap: getLineMap, + positionEncoding: positionEncoding, + } +} + +func (c *Converters) GetLineMap(fileName string) *LSPLineMap { + return c.getLineMap(fileName) +} + +func (c *Converters) ToLSPRange(script Script, textRange core.TextRange) lsproto.Range { + return lsproto.Range{ + Start: c.PositionToLineAndCharacter(script, core.TextPos(textRange.Pos())), + End: c.PositionToLineAndCharacter(script, core.TextPos(textRange.End())), + } +} + +func (c *Converters) FromLSPRange(script Script, textRange lsproto.Range) core.TextRange { + return core.NewTextRange( + int(c.LineAndCharacterToPosition(script, textRange.Start)), + int(c.LineAndCharacterToPosition(script, textRange.End)), + ) +} + +func (c *Converters) FromLSPTextChange(script Script, change *lsproto.TextDocumentContentChangePartial) core.TextChange { + return core.TextChange{ + TextRange: c.FromLSPRange(script, change.Range), + NewText: change.Text, + } +} + +func (c *Converters) ToLSPLocation(script Script, rng core.TextRange) lsproto.Location { + return lsproto.Location{ + Uri: FileNameToDocumentURI(script.FileName()), + Range: c.ToLSPRange(script, rng), + } +} + +func LanguageKindToScriptKind(languageID lsproto.LanguageKind) core.ScriptKind { + switch languageID { + case "typescript": + return core.ScriptKindTS + case "typescriptreact": + return core.ScriptKindTSX + case "javascript": + return core.ScriptKindJS + case "javascriptreact": + return core.ScriptKindJSX + case "json": + return core.ScriptKindJSON + default: + return core.ScriptKindUnknown + } +} + +// https://github.com/microsoft/vscode-uri/blob/edfdccd976efaf4bb8fdeca87e97c47257721729/src/uri.ts#L455 +var extraEscapeReplacer = strings.NewReplacer( + ":", "%3A", + "/", "%2F", + "?", "%3F", + "#", "%23", + "[", "%5B", + "]", "%5D", + "@", "%40", + + "!", "%21", + "$", "%24", + "&", "%26", + "'", "%27", + "(", "%28", + ")", "%29", + "*", "%2A", + "+", "%2B", + ",", "%2C", + ";", "%3B", + "=", "%3D", + + " ", "%20", +) + +func FileNameToDocumentURI(fileName string) lsproto.DocumentUri { + if strings.HasPrefix(fileName, "^/") { + scheme, rest, ok := strings.Cut(fileName[2:], "/") + if !ok { + panic("invalid file name: " + fileName) + } + authority, path, ok := strings.Cut(rest, "/") + if !ok { + panic("invalid file name: " + fileName) + } + if authority == "ts-nul-authority" { + return lsproto.DocumentUri(scheme + ":" + path) + } + return lsproto.DocumentUri(scheme + "://" + authority + "/" + path) + } + + volume, fileName, _ := tspath.SplitVolumePath(fileName) + if volume != "" { + volume = "/" + extraEscapeReplacer.Replace(volume) + } + + fileName = strings.TrimPrefix(fileName, "//") + + parts := strings.Split(fileName, "/") + for i, part := range parts { + parts[i] = extraEscapeReplacer.Replace(url.PathEscape(part)) + } + + return lsproto.DocumentUri("file://" + volume + strings.Join(parts, "/")) +} + +func (c *Converters) LineAndCharacterToPosition(script Script, lineAndCharacter lsproto.Position) core.TextPos { + // UTF-8/16 0-indexed line and character to UTF-8 offset + + lineMap := c.getLineMap(script.FileName()) + + line := core.TextPos(lineAndCharacter.Line) + char := core.TextPos(lineAndCharacter.Character) + + if line < 0 || int(line) >= len(lineMap.LineStarts) { + panic(fmt.Sprintf("bad line number. Line: %d, lineMap length: %d", line, len(lineMap.LineStarts))) + } + + start := lineMap.LineStarts[line] + if lineMap.AsciiOnly || c.positionEncoding == lsproto.PositionEncodingKindUTF8 { + return start + char + } + + var utf8Char core.TextPos + var utf16Char core.TextPos + + for i, r := range script.Text()[start:] { + u16Len := core.TextPos(utf16.RuneLen(r)) + if utf16Char+u16Len > char { + break + } + utf16Char += u16Len + utf8Char = core.TextPos(i + utf8.RuneLen(r)) + } + + return start + utf8Char +} + +func (c *Converters) PositionToLineAndCharacter(script Script, position core.TextPos) lsproto.Position { + // UTF-8 offset to UTF-8/16 0-indexed line and character + + position = min(position, core.TextPos(len(script.Text()))) + + lineMap := c.getLineMap(script.FileName()) + + line, isLineStart := slices.BinarySearch(lineMap.LineStarts, position) + if !isLineStart { + line-- + } + line = max(0, line) + + // The current line ranges from lineMap.LineStarts[line] (or 0) to lineMap.LineStarts[line+1] (or len(text)). + + start := lineMap.LineStarts[line] + + var character core.TextPos + if lineMap.AsciiOnly || c.positionEncoding == lsproto.PositionEncodingKindUTF8 { + character = position - start + } else { + // We need to rescan the text as UTF-16 to find the character offset. + for _, r := range script.Text()[start:position] { + character += core.TextPos(utf16.RuneLen(r)) + } + } + + return lsproto.Position{ + Line: uint32(line), + Character: uint32(character), + } +} + +func ptrTo[T any](v T) *T { + return &v +} + +type diagnosticOptions struct { + reportStyleChecksAsWarnings bool + relatedInformation bool + tagValueSet []lsproto.DiagnosticTag +} + +// DiagnosticToLSPPull converts a diagnostic for pull diagnostics (textDocument/diagnostic) +func DiagnosticToLSPPull(ctx context.Context, converters *Converters, diagnostic *ast.Diagnostic, reportStyleChecksAsWarnings bool) *lsproto.Diagnostic { + clientCaps := lsproto.GetClientCapabilities(ctx).TextDocument.Diagnostic + return diagnosticToLSP(ctx, converters, diagnostic, diagnosticOptions{ + reportStyleChecksAsWarnings: reportStyleChecksAsWarnings, // !!! get through context UserPreferences + relatedInformation: clientCaps.RelatedInformation, + tagValueSet: clientCaps.TagSupport.ValueSet, + }) +} + +// DiagnosticToLSPPush converts a diagnostic for push diagnostics (textDocument/publishDiagnostics) +func DiagnosticToLSPPush(ctx context.Context, converters *Converters, diagnostic *ast.Diagnostic) *lsproto.Diagnostic { + clientCaps := lsproto.GetClientCapabilities(ctx).TextDocument.PublishDiagnostics + return diagnosticToLSP(ctx, converters, diagnostic, diagnosticOptions{ + relatedInformation: clientCaps.RelatedInformation, + tagValueSet: clientCaps.TagSupport.ValueSet, + }) +} + +// https://github.com/microsoft/vscode/blob/93e08afe0469712706ca4e268f778cfadf1a43ef/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts#L40C7-L40C29 +var styleCheckDiagnostics = collections.NewSetFromItems( + diagnostics.X_0_is_declared_but_never_used.Code(), + diagnostics.X_0_is_declared_but_its_value_is_never_read.Code(), + diagnostics.Property_0_is_declared_but_its_value_is_never_read.Code(), + diagnostics.All_imports_in_import_declaration_are_unused.Code(), + diagnostics.Unreachable_code_detected.Code(), + diagnostics.Unused_label.Code(), + diagnostics.Fallthrough_case_in_switch.Code(), + diagnostics.Not_all_code_paths_return_a_value.Code(), +) + +func diagnosticToLSP(ctx context.Context, converters *Converters, diagnostic *ast.Diagnostic, opts diagnosticOptions) *lsproto.Diagnostic { + locale := locale.FromContext(ctx) + var severity lsproto.DiagnosticSeverity + switch diagnostic.Category() { + case diagnostics.CategorySuggestion: + severity = lsproto.DiagnosticSeverityHint + case diagnostics.CategoryMessage: + severity = lsproto.DiagnosticSeverityInformation + case diagnostics.CategoryWarning: + severity = lsproto.DiagnosticSeverityWarning + default: + severity = lsproto.DiagnosticSeverityError + } + + if opts.reportStyleChecksAsWarnings && severity == lsproto.DiagnosticSeverityError && styleCheckDiagnostics.Has(diagnostic.Code()) { + severity = lsproto.DiagnosticSeverityWarning + } + + var relatedInformation []*lsproto.DiagnosticRelatedInformation + if opts.relatedInformation { + relatedInformation = make([]*lsproto.DiagnosticRelatedInformation, 0, len(diagnostic.RelatedInformation())) + for _, related := range diagnostic.RelatedInformation() { + relatedInformation = append(relatedInformation, &lsproto.DiagnosticRelatedInformation{ + Location: lsproto.Location{ + Uri: FileNameToDocumentURI(related.File().FileName()), + Range: converters.ToLSPRange(related.File(), related.Loc()), + }, + Message: related.Localize(locale), + }) + } + } + + var tags []lsproto.DiagnosticTag + if len(opts.tagValueSet) > 0 && (diagnostic.ReportsUnnecessary() || diagnostic.ReportsDeprecated()) { + tags = make([]lsproto.DiagnosticTag, 0, 2) + if diagnostic.ReportsUnnecessary() && slices.Contains(opts.tagValueSet, lsproto.DiagnosticTagUnnecessary) { + tags = append(tags, lsproto.DiagnosticTagUnnecessary) + } + if diagnostic.ReportsDeprecated() && slices.Contains(opts.tagValueSet, lsproto.DiagnosticTagDeprecated) { + tags = append(tags, lsproto.DiagnosticTagDeprecated) + } + } + + // For diagnostics without a file (e.g., program diagnostics), use a zero range + var lspRange lsproto.Range + if diagnostic.File() != nil { + lspRange = converters.ToLSPRange(diagnostic.File(), diagnostic.Loc()) + } + + return &lsproto.Diagnostic{ + Range: lspRange, + Code: &lsproto.IntegerOrString{ + Integer: ptrTo(diagnostic.Code()), + }, + Severity: &severity, + Message: messageChainToString(diagnostic, locale), + Source: ptrTo("ts"), + RelatedInformation: ptrToSliceIfNonEmpty(relatedInformation), + Tags: ptrToSliceIfNonEmpty(tags), + } +} + +func messageChainToString(diagnostic *ast.Diagnostic, locale locale.Locale) string { + if len(diagnostic.MessageChain()) == 0 { + return diagnostic.Localize(locale) + } + var b strings.Builder + diagnosticwriter.WriteFlattenedASTDiagnosticMessage(&b, diagnostic, "\n", locale) + return b.String() +} + +func ptrToSliceIfNonEmpty[T any](s []T) *[]T { + if len(s) == 0 { + return nil + } + return &s +} diff --git a/internal/ls/converters_test.go b/internal/ls/lsconv/converters_test.go similarity index 96% rename from internal/ls/converters_test.go rename to internal/ls/lsconv/converters_test.go index 25fc94bce2..30babd1df5 100644 --- a/internal/ls/converters_test.go +++ b/internal/ls/lsconv/converters_test.go @@ -1,9 +1,9 @@ -package ls_test +package lsconv_test import ( "testing" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "gotest.tools/v3/assert" ) @@ -77,7 +77,7 @@ func TestFileNameToDocumentURI(t *testing.T) { for _, test := range tests { t.Run(test.fileName, func(t *testing.T) { t.Parallel() - assert.Equal(t, ls.FileNameToDocumentURI(test.fileName), test.uri) + assert.Equal(t, lsconv.FileNameToDocumentURI(test.fileName), test.uri) }) } } diff --git a/internal/ls/linemap.go b/internal/ls/lsconv/linemap.go similarity index 99% rename from internal/ls/linemap.go rename to internal/ls/lsconv/linemap.go index 345f7cd997..8fc8cc0241 100644 --- a/internal/ls/linemap.go +++ b/internal/ls/lsconv/linemap.go @@ -1,4 +1,4 @@ -package ls +package lsconv import ( "cmp" diff --git a/internal/lsutil/asi.go b/internal/ls/lsutil/asi.go similarity index 94% rename from internal/lsutil/asi.go rename to internal/ls/lsutil/asi.go index 0cea3e6d4d..3bde178a8e 100644 --- a/internal/lsutil/asi.go +++ b/internal/ls/lsutil/asi.go @@ -98,7 +98,7 @@ func NodeIsASICandidate(node *ast.Node, file *ast.SourceFile) bool { return true } - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, node.End()) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, astnav.GetStartOfNode(nextToken, file, false /*includeJSDoc*/)) + startLine := scanner.GetECMALineOfPosition(file, node.End()) + endLine := scanner.GetECMALineOfPosition(file, astnav.GetStartOfNode(nextToken, file, false /*includeJSDoc*/)) return startLine != endLine } diff --git a/internal/lsutil/children.go b/internal/ls/lsutil/children.go similarity index 100% rename from internal/lsutil/children.go rename to internal/ls/lsutil/children.go diff --git a/internal/ls/lsutil/userpreferences.go b/internal/ls/lsutil/userpreferences.go new file mode 100644 index 0000000000..43573d4f8f --- /dev/null +++ b/internal/ls/lsutil/userpreferences.go @@ -0,0 +1,659 @@ +package lsutil + +import ( + "slices" + "strings" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/modulespecifiers" + "github.com/microsoft/typescript-go/internal/tsoptions" +) + +func NewDefaultUserPreferences() *UserPreferences { + return &UserPreferences{ + IncludeCompletionsForModuleExports: core.TSTrue, + IncludeCompletionsForImportStatements: core.TSTrue, + + AllowRenameOfImportPath: true, + ProvideRefactorNotApplicableReason: true, + IncludeCompletionsWithSnippetText: core.TSTrue, + DisplayPartsForJSDoc: true, + DisableLineTextInReferences: true, + ReportStyleChecksAsWarnings: true, + + ExcludeLibrarySymbolsInNavTo: true, + } +} + +type UserPreferences struct { + QuotePreference QuotePreference + LazyConfiguredProjectsFromExternalProject bool // !!! + + // A positive integer indicating the maximum length of a hover text before it is truncated. + // + // Default: `500` + MaximumHoverLength int // !!! + + // ------- Completions ------- + + // If enabled, TypeScript will search through all external modules' exports and add them to the completions list. + // This affects lone identifier completions but not completions on the right hand side of `obj.`. + IncludeCompletionsForModuleExports core.Tristate + // Enables auto-import-style completions on partially-typed import statements. E.g., allows + // `import write|` to be completed to `import { writeFile } from "fs"`. + IncludeCompletionsForImportStatements core.Tristate + // Unless this option is `false`, member completion lists triggered with `.` will include entries + // on potentially-null and potentially-undefined values, with insertion text to replace + // preceding `.` tokens with `?.`. + IncludeAutomaticOptionalChainCompletions core.Tristate + // Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. + IncludeCompletionsWithSnippetText core.Tristate // !!! + // If enabled, completions for class members (e.g. methods and properties) will include + // a whole declaration for the member. + // E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of + // `class A { foo }`. + IncludeCompletionsWithClassMemberSnippets core.Tristate // !!! + // If enabled, object literal methods will have a method declaration completion entry in addition + // to the regular completion entry containing just the method name. + // E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, + // in addition to `const objectLiteral: T = { foo }`. + IncludeCompletionsWithObjectLiteralMethodSnippets core.Tristate // !!! + JsxAttributeCompletionStyle JsxAttributeCompletionStyle + + // ------- AutoImports -------- + + ImportModuleSpecifierPreference modulespecifiers.ImportModuleSpecifierPreference // !!! + // Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" + ImportModuleSpecifierEnding modulespecifiers.ImportModuleSpecifierEndingPreference // !!! + IncludePackageJsonAutoImports IncludePackageJsonAutoImports // !!! + AutoImportSpecifierExcludeRegexes []string // !!! + AutoImportFileExcludePatterns []string // !!! + PreferTypeOnlyAutoImports bool // !!! + + // ------- OrganizeImports ------- + + // Indicates whether imports should be organized in a case-insensitive manner. + // + // Default: TSUnknown ("auto" in strada), will perform detection + OrganizeImportsIgnoreCase core.Tristate // !!! + // Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value of their + // code points, or via "unicode" collation (via the Unicode Collation Algorithm (https://unicode.org/reports/tr10/#Scope)) + // + // using rules associated with the locale specified in organizeImportsCollationLocale. + // + // Default: Ordinal + OrganizeImportsCollation OrganizeImportsCollation // !!! + // Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant + // for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. + // + // This preference is ignored if organizeImportsCollation is not `unicode`. + // + // Default: `"en"` + OrganizeImportsLocale string // !!! + // Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate + // strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. + // + // This preference is ignored if organizeImportsCollation is not `unicode`. + // + // Default: `false` + OrganizeImportsNumericCollation bool // !!! + // Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When + // `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified + // in organizeImportsCollationLocale. + // + // This preference is ignored if organizeImportsCollation is not `unicode`. + // + // Default: `true` + OrganizeImportsAccentCollation bool // !!! + // Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale + // specified in organizeImportsCollationLocale is used. + // + // This preference is ignored if: + // - organizeImportsCollation is not `unicode` + // - organizeImportsIgnoreCase is `true` + // - organizeImportsIgnoreCase is `auto` and the auto-detected case sensitivity is case-insensitive. + // + // Default: `false` + OrganizeImportsCaseFirst OrganizeImportsCaseFirst // !!! + // Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is type-only. + // + // Default: `auto`, which defaults to `last` + OrganizeImportsTypeOrder OrganizeImportsTypeOrder // !!! + + // ------- MoveToFile ------- + + AllowTextChangesInNewFiles bool // !!! + + // ------- Rename ------- + + // renamed from `providePrefixAndSuffixTextForRename` + UseAliasesForRename core.Tristate + AllowRenameOfImportPath bool // !!! + + // ------- CodeFixes/Refactors ------- + + ProvideRefactorNotApplicableReason bool // !!! + + // ------- InlayHints ------- + + IncludeInlayParameterNameHints IncludeInlayParameterNameHints + IncludeInlayParameterNameHintsWhenArgumentMatchesName bool + IncludeInlayFunctionParameterTypeHints bool + IncludeInlayVariableTypeHints bool + IncludeInlayVariableTypeHintsWhenTypeMatchesName bool + IncludeInlayPropertyDeclarationTypeHints bool + IncludeInlayFunctionLikeReturnTypeHints bool + IncludeInlayEnumMemberValueHints bool + + // ------- Symbols ------- + + ExcludeLibrarySymbolsInNavTo bool + + // ------- Misc ------- + + DisableSuggestions bool // !!! + DisableLineTextInReferences bool // !!! + DisplayPartsForJSDoc bool // !!! + ReportStyleChecksAsWarnings bool // !!! If this changes, we need to ask the client to recompute diagnostics +} + +type JsxAttributeCompletionStyle string + +const ( + JsxAttributeCompletionStyleUnknown JsxAttributeCompletionStyle = "" // !!! + JsxAttributeCompletionStyleAuto JsxAttributeCompletionStyle = "auto" + JsxAttributeCompletionStyleBraces JsxAttributeCompletionStyle = "braces" + JsxAttributeCompletionStyleNone JsxAttributeCompletionStyle = "none" +) + +func parseJsxAttributeCompletionStyle(val any) JsxAttributeCompletionStyle { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "braces": + return JsxAttributeCompletionStyleBraces + case "none": + return JsxAttributeCompletionStyleNone + } + } + return JsxAttributeCompletionStyleAuto +} + +func parseImportModuleSpecifierPreference(val any) modulespecifiers.ImportModuleSpecifierPreference { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "project-relative": + return modulespecifiers.ImportModuleSpecifierPreferenceProjectRelative + case "relative": + return modulespecifiers.ImportModuleSpecifierPreferenceRelative + case "non-relative": + return modulespecifiers.ImportModuleSpecifierPreferenceNonRelative + } + } + return modulespecifiers.ImportModuleSpecifierPreferenceShortest +} + +func parseImportModuleSpecifierEndingPreference(val any) modulespecifiers.ImportModuleSpecifierEndingPreference { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "minimal": + return modulespecifiers.ImportModuleSpecifierEndingPreferenceMinimal + case "index": + return modulespecifiers.ImportModuleSpecifierEndingPreferenceIndex + case "js": + return modulespecifiers.ImportModuleSpecifierEndingPreferenceJs + } + } + return modulespecifiers.ImportModuleSpecifierEndingPreferenceAuto +} + +type IncludeInlayParameterNameHints string + +const ( + IncludeInlayParameterNameHintsNone IncludeInlayParameterNameHints = "" + IncludeInlayParameterNameHintsAll IncludeInlayParameterNameHints = "all" + IncludeInlayParameterNameHintsLiterals IncludeInlayParameterNameHints = "literals" +) + +func parseInlayParameterNameHints(val any) IncludeInlayParameterNameHints { + if prefStr, ok := val.(string); ok { + switch prefStr { + case "all": + return IncludeInlayParameterNameHintsAll + case "literals": + return IncludeInlayParameterNameHintsLiterals + } + } + return IncludeInlayParameterNameHintsNone +} + +type IncludePackageJsonAutoImports string + +const ( + IncludePackageJsonAutoImportsUnknown IncludePackageJsonAutoImports = "" // !!! + IncludePackageJsonAutoImportsAuto IncludePackageJsonAutoImports = "auto" + IncludePackageJsonAutoImportsOn IncludePackageJsonAutoImports = "on" + IncludePackageJsonAutoImportsOff IncludePackageJsonAutoImports = "off" +) + +func parseIncludePackageJsonAutoImports(val any) IncludePackageJsonAutoImports { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "on": + return IncludePackageJsonAutoImportsOn + case "off": + return IncludePackageJsonAutoImportsOff + default: + return IncludePackageJsonAutoImportsAuto + } + } + return IncludePackageJsonAutoImportsUnknown +} + +type OrganizeImportsCollation bool + +const ( + OrganizeImportsCollationOrdinal OrganizeImportsCollation = false + OrganizeImportsCollationUnicode OrganizeImportsCollation = true +) + +func parseOrganizeImportsCollation(val any) OrganizeImportsCollation { + if b, ok := val.(string); ok && strings.ToLower(b) == "unicode" { + return OrganizeImportsCollationUnicode + } + return OrganizeImportsCollationOrdinal +} + +type OrganizeImportsCaseFirst int + +const ( + OrganizeImportsCaseFirstFalse OrganizeImportsCaseFirst = 0 + OrganizeImportsCaseFirstLower OrganizeImportsCaseFirst = 1 + OrganizeImportsCaseFirstUpper OrganizeImportsCaseFirst = 2 +) + +func parseOrganizeImportsCaseFirst(caseFirst any) OrganizeImportsCaseFirst { + if caseFirstStr, ok := caseFirst.(string); ok { + switch caseFirstStr { + case "lower": + return OrganizeImportsCaseFirstLower + case "upper": + return OrganizeImportsCaseFirstUpper + } + } + return OrganizeImportsCaseFirstFalse +} + +type OrganizeImportsTypeOrder int + +const ( + OrganizeImportsTypeOrderAuto OrganizeImportsTypeOrder = 0 + OrganizeImportsTypeOrderLast OrganizeImportsTypeOrder = 1 + OrganizeImportsTypeOrderInline OrganizeImportsTypeOrder = 2 + OrganizeImportsTypeOrderFirst OrganizeImportsTypeOrder = 3 +) + +func parseOrganizeImportsTypeOrder(typeOrder any) OrganizeImportsTypeOrder { + if typeOrderStr, ok := typeOrder.(string); ok { + switch typeOrderStr { + case "last": + return OrganizeImportsTypeOrderLast + case "inline": + return OrganizeImportsTypeOrderInline + case "first": + return OrganizeImportsTypeOrderFirst + } + } + return OrganizeImportsTypeOrderAuto +} + +type QuotePreference string + +const ( + QuotePreferenceUnknown QuotePreference = "" + QuotePreferenceAuto QuotePreference = "auto" + QuotePreferenceDouble QuotePreference = "double" + QuotePreferenceSingle QuotePreference = "single" +) + +func parseQuotePreference(val any) QuotePreference { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "auto": + return QuotePreferenceAuto + case "double": + return QuotePreferenceDouble + case "single": + return QuotePreferenceSingle + } + } + return QuotePreferenceUnknown +} + +func (p *UserPreferences) Copy() *UserPreferences { + if p == nil { + return nil + } + prefCopy := *p + prefCopy.AutoImportSpecifierExcludeRegexes = slices.Clone(p.AutoImportSpecifierExcludeRegexes) + prefCopy.AutoImportFileExcludePatterns = slices.Clone(p.AutoImportFileExcludePatterns) + return &prefCopy +} + +func (p *UserPreferences) CopyOrDefault() *UserPreferences { + if p == nil { + return NewDefaultUserPreferences() + } + return p.Copy() +} + +func (p *UserPreferences) ModuleSpecifierPreferences() modulespecifiers.UserPreferences { + return modulespecifiers.UserPreferences{ + ImportModuleSpecifierPreference: p.ImportModuleSpecifierPreference, + ImportModuleSpecifierEnding: p.ImportModuleSpecifierEnding, + AutoImportSpecifierExcludeRegexes: p.AutoImportSpecifierExcludeRegexes, + } +} + +// ------ Parsing Config Response ------- + +// returns non-nil if should break loop +func (p *UserPreferences) Parse(item any) *UserPreferences { + if item == nil { + // continue + } else if config, ok := item.(map[string]any); ok { + p.parseWorker(config) + } else if item, ok := item.(*UserPreferences); ok { + // case for fourslash + return item.CopyOrDefault() + } + return nil +} + +func (p *UserPreferences) parseWorker(config map[string]any) { + // Process unstable preferences first so that they do not overwrite stable properties + if unstable, ok := config["unstable"]; ok { + // unstable properties must be named the same as userPreferences + p.parseAll(unstable) + } + for name, values := range config { + switch name { + case "unstable": + continue + case "inlayHints": + p.parseInlayHints(values) + case "suggest": + p.parseSuggest(values) + case "preferences": + p.parsePreferences(values) + case "workspaceSymbols": + p.parseWorkspaceSymbols(values) + case "format": + // !!! + case "tsserver": + // !!! + case "tsc": + // !!! + case "experimental": + // !!! + default: + p.set(name, values) + } + } +} + +func (p *UserPreferences) parseAll(prefs any) { + prefsMap, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range prefsMap { + p.set(name, value) + } +} + +func (p *UserPreferences) parseInlayHints(prefs any) { + inlayHintsPreferences, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range inlayHintsPreferences { + if v, ok := value.(map[string]any); ok { + // vscode's inlay hints settings are nested objects with "enabled" and other properties + switch name { + case "parameterNames": + if enabled, ok := v["enabled"]; ok { + p.set("includeInlayParameterNameHints", enabled) + } + p.IncludeInlayParameterNameHintsWhenArgumentMatchesName = parseSupress(v, "supressWhenArgumentMatchesName") + case "parameterTypes": + p.IncludeInlayFunctionParameterTypeHints = parseEnabledBool(v) + case "variableTypes": + p.IncludeInlayVariableTypeHints = parseEnabledBool(v) + p.IncludeInlayVariableTypeHintsWhenTypeMatchesName = parseSupress(v, "supressWhenTypeMatchesName") + case "propertyDeclarationTypes": + p.IncludeInlayPropertyDeclarationTypeHints = parseEnabledBool(v) + case "functionLikeReturnTypes": + p.IncludeInlayFunctionLikeReturnTypeHints = parseEnabledBool(v) + case "enumMemberValues": + p.IncludeInlayEnumMemberValueHints = parseEnabledBool(v) + } + } else { + // non-vscode case + p.set(name, v) + } + } +} + +func (p *UserPreferences) parseSuggest(prefs any) { + completionsPreferences, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range completionsPreferences { + switch name { + case "autoImports": + p.set("includeCompletionsForModuleExports", value) + case "objectLiteralMethodSnippets": + if v, ok := value.(map[string]any); ok { + p.set("includeCompletionsWithObjectLiteralMethodSnippets", parseEnabledBool(v)) + } + case "classMemberSnippets": + if v, ok := value.(map[string]any); ok { + p.set("includeCompletionsWithClassMemberSnippets", parseEnabledBool(v)) + } + case "includeAutomaticOptionalChainCompletions": + p.set("includeAutomaticOptionalChainCompletions", value) + case "includeCompletionsForImportStatements": + p.set("includeCompletionsForImportStatements", value) + } + } +} + +func (p *UserPreferences) parsePreferences(prefs any) { + prefsMap, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range prefsMap { + if name == "organizeImports" { + p.parseOrganizeImportsPreferences(value) + } else { + p.set(name, value) + } + } +} + +func (p *UserPreferences) parseOrganizeImportsPreferences(prefs any) { + // !!! this used to be in the typescript-language-features extension + prefsMap, ok := prefs.(map[string]any) + if !ok { + return + } + if typeOrder, ok := prefsMap["typeOrder"]; ok { + p.set("organizeimportstypeorder", parseOrganizeImportsTypeOrder(typeOrder)) + } + if caseSensitivity, ok := prefsMap["caseSensitivity"]; ok { + if caseSensitivityStr, ok := caseSensitivity.(string); ok { + // default is already "auto" + switch caseSensitivityStr { + case "caseInsensitive": + p.OrganizeImportsIgnoreCase = core.TSTrue + case "caseSensitive": + p.OrganizeImportsIgnoreCase = core.TSFalse + } + } + } + if collation, ok := prefsMap["unicodeCollation"]; ok { + // The rest of the settings are only applicable when using unicode collation + if collationStr, ok := collation.(string); ok && collationStr == "unicode" { + p.set("organizeimportscollation", OrganizeImportsCollationUnicode) + if locale, ok := prefsMap["locale"]; ok { + p.set("organizeimportslocale", locale) + } + if numeric, ok := prefsMap["numericCollation"]; ok { + p.set("organizeimportsnumericcollation", numeric) + } + if accent, ok := prefsMap["accentCollation"]; ok { + p.set("organizeimportsaccentcollation", accent) + } + if caseFirst, ok := prefsMap["caseFirst"]; ok && !p.OrganizeImportsIgnoreCase.IsTrue() { + p.set("organizeimportscasefirst", caseFirst) + } + } + } +} + +func (p *UserPreferences) parseWorkspaceSymbols(prefs any) { + symbolPreferences, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range symbolPreferences { + switch name { + // !!! scope + case "excludeLibrarySymbols": + p.ExcludeLibrarySymbolsInNavTo = parseBoolWithDefault(value, true) + default: + p.set(name, value) + } + } +} + +func parseEnabledBool(v map[string]any) bool { + // vscode nested option + if enabled, ok := v["enabled"]; ok { + if e, ok := enabled.(bool); ok { + return e + } + } + return false +} + +func parseSupress(v map[string]any, name string) bool { + // vscode nested option + if val, ok := v[name]; ok { + if suppress, ok := val.(bool); ok { + return !suppress + } + } + return false +} + +func parseBoolWithDefault(val any, defaultV bool) bool { + if v, ok := val.(bool); ok { + return v + } + return defaultV +} + +func parseIntWithDefault(val any, defaultV int) int { + if v, ok := val.(int); ok { + return v + } + return defaultV +} + +func (p *UserPreferences) set(name string, value any) { + switch strings.ToLower(name) { + case "quotePreference": + p.QuotePreference = parseQuotePreference(value) + case "lazyconfiguredprojectsfromexternalproject": + p.LazyConfiguredProjectsFromExternalProject = parseBoolWithDefault(value, false) + case "maximumhoverlength": + p.MaximumHoverLength = parseIntWithDefault(value, 500) + case "includecompletionsformoduleexports": + p.IncludeCompletionsForModuleExports = tsoptions.ParseTristate(value) + case "includecompletionsforimportstatements": + p.IncludeCompletionsForImportStatements = tsoptions.ParseTristate(value) + case "includeautomaticoptionalchaincompletions": + p.IncludeAutomaticOptionalChainCompletions = tsoptions.ParseTristate(value) + case "includecompletionswithsnippettext": + p.IncludeCompletionsWithSnippetText = tsoptions.ParseTristate(value) + case "includecompletionswithclassmembersnippets": + p.IncludeCompletionsWithClassMemberSnippets = tsoptions.ParseTristate(value) + case "includecompletionswithobjectliteralmethodsnippets": + p.IncludeCompletionsWithObjectLiteralMethodSnippets = tsoptions.ParseTristate(value) + case "jsxattributecompletionstyle": + p.JsxAttributeCompletionStyle = parseJsxAttributeCompletionStyle(value) + case "importmodulespecifierpreference": + p.ImportModuleSpecifierPreference = parseImportModuleSpecifierPreference(value) + case "importmodulespecifierending": + p.ImportModuleSpecifierEnding = parseImportModuleSpecifierEndingPreference(value) + case "includepackagejsonautoimports": + p.IncludePackageJsonAutoImports = parseIncludePackageJsonAutoImports(value) + case "autoimportspecifierexcluderegexes": + p.AutoImportSpecifierExcludeRegexes = tsoptions.ParseStringArray(value) + case "autoimportfileexcludepatterns": + p.AutoImportFileExcludePatterns = tsoptions.ParseStringArray(value) + case "prefertypeonlyautoimports": + p.PreferTypeOnlyAutoImports = parseBoolWithDefault(value, false) + case "organizeimportsignorecase": + p.OrganizeImportsIgnoreCase = tsoptions.ParseTristate(value) + case "organizeimportscollation": + p.OrganizeImportsCollation = parseOrganizeImportsCollation(value) + case "organizeimportslocale": + p.OrganizeImportsLocale = tsoptions.ParseString(value) + case "organizeimportsnumericcollation": + p.OrganizeImportsNumericCollation = parseBoolWithDefault(value, false) + case "organizeimportsaccentcollation": + p.OrganizeImportsAccentCollation = parseBoolWithDefault(value, true) + case "organizeimportscasefirst": + p.OrganizeImportsCaseFirst = parseOrganizeImportsCaseFirst(value) + case "organizeimportstypeorder": + p.OrganizeImportsTypeOrder = parseOrganizeImportsTypeOrder(value) + case "allowtextchangesinnewfiles": + p.AllowTextChangesInNewFiles = parseBoolWithDefault(value, true) // !!! + case "usealiasesforrename", "provideprefixandsuffixtextforrename": + p.UseAliasesForRename = tsoptions.ParseTristate(value) + case "allowrenameofimportpath": + p.AllowRenameOfImportPath = parseBoolWithDefault(value, true) + case "providerefactornotapplicablereason": + p.ProvideRefactorNotApplicableReason = parseBoolWithDefault(value, true) + case "includeinlayparameternamehints": + p.IncludeInlayParameterNameHints = parseInlayParameterNameHints(value) + case "includeinlayparameternamehintswhenargumentmatchesname": + p.IncludeInlayParameterNameHintsWhenArgumentMatchesName = parseBoolWithDefault(value, false) + case "includeinlayfunctionparametertypeHints": + p.IncludeInlayFunctionParameterTypeHints = parseBoolWithDefault(value, false) + case "includeinlayvariabletypehints": + p.IncludeInlayVariableTypeHints = parseBoolWithDefault(value, false) + case "includeinlayvariabletypehintswhentypematchesname": + p.IncludeInlayVariableTypeHintsWhenTypeMatchesName = parseBoolWithDefault(value, false) + case "includeinlaypropertydeclarationtypehints": + p.IncludeInlayPropertyDeclarationTypeHints = parseBoolWithDefault(value, false) + case "includeinlayfunctionlikereturntypehints": + p.IncludeInlayFunctionLikeReturnTypeHints = parseBoolWithDefault(value, false) + case "includeinlayenummembervaluehints": + p.IncludeInlayEnumMemberValueHints = parseBoolWithDefault(value, false) + case "excludelibrarysymbolsinnavto": + p.ExcludeLibrarySymbolsInNavTo = parseBoolWithDefault(value, true) + case "disablesuggestions": + p.DisableSuggestions = parseBoolWithDefault(value, false) + case "disablelinetextinreferences": + p.DisableLineTextInReferences = parseBoolWithDefault(value, true) + case "displaypartsforjsdoc": + p.DisplayPartsForJSDoc = parseBoolWithDefault(value, true) + case "reportstylechecksaswarnings": + p.ReportStyleChecksAsWarnings = parseBoolWithDefault(value, true) + } +} diff --git a/internal/ls/lsutil/utilities.go b/internal/ls/lsutil/utilities.go new file mode 100644 index 0000000000..b5c6972bcc --- /dev/null +++ b/internal/ls/lsutil/utilities.go @@ -0,0 +1,83 @@ +package lsutil + +import ( + "strings" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/scanner" +) + +func ProbablyUsesSemicolons(file *ast.SourceFile) bool { + withSemicolon := 0 + withoutSemicolon := 0 + nStatementsToObserve := 5 + + var visit func(node *ast.Node) bool + visit = func(node *ast.Node) bool { + if node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + if SyntaxRequiresTrailingSemicolonOrASI(node.Kind) { + lastToken := GetLastToken(node, file) + if lastToken != nil && lastToken.Kind == ast.KindSemicolonToken { + withSemicolon++ + } else { + withoutSemicolon++ + } + } else if SyntaxRequiresTrailingCommaOrSemicolonOrASI(node.Kind) { + lastToken := GetLastToken(node, file) + if lastToken != nil && lastToken.Kind == ast.KindSemicolonToken { + withSemicolon++ + } else if lastToken != nil && lastToken.Kind != ast.KindCommaToken { + lastTokenLine := scanner.GetECMALineOfPosition( + file, + astnav.GetStartOfNode(lastToken, file, false /*includeJSDoc*/)) + nextTokenLine := scanner.GetECMALineOfPosition( + file, + scanner.SkipTrivia(file.Text(), lastToken.End())) + // Avoid counting missing semicolon in single-line objects: + // `function f(p: { x: string /*no semicolon here is insignificant*/ }) {` + if lastTokenLine != nextTokenLine { + withoutSemicolon++ + } + } + } + + if withSemicolon+withoutSemicolon >= nStatementsToObserve { + return true + } + + return node.ForEachChild(visit) + } + + file.ForEachChild(visit) + + // One statement missing a semicolon isn't sufficient evidence to say the user + // doesn't want semicolons, because they may not even be done writing that statement. + if withSemicolon == 0 && withoutSemicolon <= 1 { + return true + } + + // If even 2/5 places have a semicolon, the user probably wants semicolons + if withoutSemicolon == 0 { + return true + } + return withSemicolon/withoutSemicolon > 1/nStatementsToObserve +} + +func ShouldUseUriStyleNodeCoreModules(file *ast.SourceFile, program *compiler.Program) bool { + for _, node := range file.Imports() { + if core.NodeCoreModules()[node.Text()] && !core.ExclusivelyPrefixedNodeCoreModules[node.Text()] { + if strings.HasPrefix(node.Text(), "node:") { + return true + } else { + return false + } + } + } + + return program.UsesUriStyleNodeCoreModules() +} diff --git a/internal/ls/organizeimports.go b/internal/ls/organizeimports.go deleted file mode 100644 index 8cdeddab5d..0000000000 --- a/internal/ls/organizeimports.go +++ /dev/null @@ -1,128 +0,0 @@ -package ls - -import ( - "cmp" - "strings" - - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/compiler" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/modulespecifiers" - "github.com/microsoft/typescript-go/internal/tspath" -) - -// statement = anyImportOrRequireStatement -func getImportDeclarationInsertIndex(sortedImports []*ast.Statement, newImport *ast.Statement, comparer func(a, b *ast.Statement) int) int { - // !!! - return len(sortedImports) -} - -// returns `-1` if `a` is better than `b` -// -// note: this sorts in descending order of preference; different than convention in other cmp-like functions -func compareModuleSpecifiers( - a *ImportFix, // !!! ImportFixWithModuleSpecifier - b *ImportFix, // !!! ImportFixWithModuleSpecifier - importingFile *ast.SourceFile, // | FutureSourceFile, - program *compiler.Program, - preferences UserPreferences, - allowsImportingSpecifier func(specifier string) bool, - toPath func(fileName string) tspath.Path, -) int { - if a.kind == ImportFixKindUseNamespace || b.kind == ImportFixKindUseNamespace { - return 0 - } - if comparison := compareBooleans( - b.moduleSpecifierKind != modulespecifiers.ResultKindNodeModules || allowsImportingSpecifier(b.moduleSpecifier), - a.moduleSpecifierKind != modulespecifiers.ResultKindNodeModules || allowsImportingSpecifier(a.moduleSpecifier), - ); comparison != 0 { - return comparison - } - if comparison := compareModuleSpecifierRelativity(a, b, preferences); comparison != 0 { - return comparison - } - if comparison := compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program); comparison != 0 { - return comparison - } - if comparison := compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile.Path(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile.Path(), toPath)); comparison != 0 { - return comparison - } - if comparison := compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); comparison != 0 { - return comparison - } - return 0 -} - -// True > False -func compareBooleans(a, b bool) int { - if a && !b { - return -1 - } else if !a && b { - return 1 - } - return 0 -} - -// returns `-1` if `a` is better than `b` -func compareModuleSpecifierRelativity(a *ImportFix, b *ImportFix, preferences UserPreferences) int { - switch preferences.ImportModuleSpecifierPreference { - case modulespecifiers.ImportModuleSpecifierPreferenceNonRelative, modulespecifiers.ImportModuleSpecifierPreferenceProjectRelative: - return compareBooleans(a.moduleSpecifierKind == modulespecifiers.ResultKindRelative, b.moduleSpecifierKind == modulespecifiers.ResultKindRelative) - } - return 0 -} - -func compareNodeCoreModuleSpecifiers(a, b string, importingFile *ast.SourceFile, program *compiler.Program) int { - if strings.HasPrefix(a, "node:") && !strings.HasPrefix(b, "node:") { - if shouldUseUriStyleNodeCoreModules(importingFile, program) { - return -1 - } - return 1 - } - if strings.HasPrefix(b, "node:") && !strings.HasPrefix(a, "node:") { - if shouldUseUriStyleNodeCoreModules(importingFile, program) { - return 1 - } - return -1 - } - return 0 -} - -func shouldUseUriStyleNodeCoreModules(file *ast.SourceFile, program *compiler.Program) bool { - for _, node := range file.Imports() { - if core.NodeCoreModules()[node.Text()] && !core.ExclusivelyPrefixedNodeCoreModules[node.Text()] { - if strings.HasPrefix(node.Text(), "node:") { - return true - } else { - return false - } - } - } - - return program.UsesUriStyleNodeCoreModules() -} - -// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. -// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. -// This can produce false positives or negatives if re-exports cross into sibling directories -// (e.g. `export * from "../whatever"`) or are not named "index". -func isFixPossiblyReExportingImportingFile(fix *ImportFix, importingFilePath tspath.Path, toPath func(fileName string) tspath.Path) bool { - if fix.isReExport != nil && *(fix.isReExport) && - fix.exportInfo != nil && fix.exportInfo.moduleFileName != "" && isIndexFileName(fix.exportInfo.moduleFileName) { - reExportDir := toPath(tspath.GetDirectoryPath(fix.exportInfo.moduleFileName)) - return strings.HasPrefix(string(importingFilePath), string(reExportDir)) - } - return false -} - -func compareNumberOfDirectorySeparators(path1, path2 string) int { - return cmp.Compare(strings.Count(path1, "/"), strings.Count(path2, "/")) -} - -func isIndexFileName(fileName string) bool { - fileName = tspath.GetBaseFileName(fileName) - if tspath.FileExtensionIsOneOf(fileName, []string{".js", ".jsx", ".d.ts", ".ts", ".tsx"}) { - fileName = tspath.RemoveFileExtension(fileName) - } - return fileName == "index" -} diff --git a/internal/ls/organizeimports/organizeimports.go b/internal/ls/organizeimports/organizeimports.go new file mode 100644 index 0000000000..57ac06331d --- /dev/null +++ b/internal/ls/organizeimports/organizeimports.go @@ -0,0 +1,275 @@ +package organizeimports + +import ( + "cmp" + "math" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/stringutil" + "github.com/microsoft/typescript-go/internal/tspath" +) + +var ( + caseInsensitiveOrganizeImportsComparer = []func(a, b string) int{getOrganizeImportsOrdinalStringComparer(true)} + caseSensitiveOrganizeImportsComparer = []func(a, b string) int{getOrganizeImportsOrdinalStringComparer(false)} + organizeImportsComparers = []func(a, b string) int{ + caseInsensitiveOrganizeImportsComparer[0], + caseSensitiveOrganizeImportsComparer[0], + } +) + +// statement = anyImportOrRequireStatement +func GetImportDeclarationInsertIndex(sortedImports []*ast.Statement, newImport *ast.Statement, comparer func(a, b *ast.Statement) int) int { + // !!! + return len(sortedImports) +} + +func getOrganizeImportsOrdinalStringComparer(ignoreCase bool) func(a, b string) int { + if ignoreCase { + return stringutil.CompareStringsCaseInsensitiveEslintCompatible + } + return stringutil.CompareStringsCaseSensitive +} + +// getModuleSpecifierExpression returns the module specifier expression from an import/require statement +func getModuleSpecifierExpression(declaration *ast.Statement) *ast.Expression { + switch declaration.Kind { + case ast.KindImportEqualsDeclaration: + importEquals := declaration.AsImportEqualsDeclaration() + if importEquals.ModuleReference.Kind == ast.KindExternalModuleReference { + return importEquals.ModuleReference.Expression() + } + return nil + case ast.KindImportDeclaration: + return declaration.ModuleSpecifier() + case ast.KindVariableStatement: + // For require statements: const x = require('...') + variableStatement := declaration.AsVariableStatement() + declarations := variableStatement.DeclarationList.AsVariableDeclarationList().Declarations.Nodes + if len(declarations) > 0 { + decl := declarations[0] + initializer := decl.Initializer() + if initializer != nil && initializer.Kind == ast.KindCallExpression { + callExpr := initializer.AsCallExpression() + if len(callExpr.Arguments.Nodes) > 0 { + return callExpr.Arguments.Nodes[0] + } + } + } + return nil + default: + return nil + } +} + +func getExternalModuleName(specifier *ast.Expression) string { + if specifier != nil && ast.IsStringLiteralLike(specifier.AsNode()) { + return specifier.Text() + } + return "" +} + +// compareModuleSpecifiersWorker compares two module specifiers +func compareModuleSpecifiersWorker(m1 *ast.Expression, m2 *ast.Expression, comparer func(a, b string) int) int { + name1 := getExternalModuleName(m1) + name2 := getExternalModuleName(m2) + if cmp := core.CompareBooleans(name1 == "", name2 == ""); cmp != 0 { + return cmp + } + if cmp := core.CompareBooleans(tspath.IsExternalModuleNameRelative(name1), tspath.IsExternalModuleNameRelative(name2)); cmp != 0 { + return cmp + } + return comparer(name1, name2) +} + +// compareImportKind returns comparison order based on import kind +func compareImportKind(s1 *ast.Statement, s2 *ast.Statement) int { + return cmp.Compare(getImportKindOrder(s1), getImportKindOrder(s2)) +} + +// getImportKindOrder returns the sort order for different import kinds: +// 1. Side-effect imports +// 2. Type-only imports +// 3. Namespace imports +// 4. Default imports +// 5. Named imports +// 6. ImportEqualsDeclarations +// 7. Require variable statements +func getImportKindOrder(s1 *ast.Statement) int { + switch s1.Kind { + case ast.KindImportDeclaration: + importDecl := s1.AsImportDeclaration() + if importDecl.ImportClause == nil { + return 0 // Side-effect import + } + importClause := importDecl.ImportClause.AsImportClause() + if importClause.IsTypeOnly() { + return 1 // Type-only import + } + if importClause.NamedBindings != nil && importClause.NamedBindings.Kind == ast.KindNamespaceImport { + return 2 // Namespace import + } + if importClause.Name() != nil { + return 3 // Default import + } + return 4 // Named imports + case ast.KindImportEqualsDeclaration: + return 5 + case ast.KindVariableStatement: + return 6 // Require statement + default: + return 7 + } +} + +// compareImportsOrRequireStatements compares two import or require statements for sorting +func CompareImportsOrRequireStatements(s1 *ast.Statement, s2 *ast.Statement, comparer func(a, b string) int) int { + if cmp := compareModuleSpecifiersWorker(getModuleSpecifierExpression(s1), getModuleSpecifierExpression(s2), comparer); cmp != 0 { + return cmp + } + return compareImportKind(s1, s2) +} + +// compareImportOrExportSpecifiers compares two import or export specifiers +func compareImportOrExportSpecifiers(s1 *ast.Node, s2 *ast.Node, comparer func(a, b string) int, preferences *lsutil.UserPreferences) int { + typeOrder := lsutil.OrganizeImportsTypeOrderLast + if preferences != nil { + typeOrder = preferences.OrganizeImportsTypeOrder + } + + s1Name := s1.Name().Text() + s2Name := s2.Name().Text() + + switch typeOrder { + case lsutil.OrganizeImportsTypeOrderFirst: + if cmp := core.CompareBooleans(s2.IsTypeOnly(), s1.IsTypeOnly()); cmp != 0 { + return cmp + } + return comparer(s1Name, s2Name) + case lsutil.OrganizeImportsTypeOrderInline: + return comparer(s1Name, s2Name) + default: // OrganizeImportsTypeOrderLast + if cmp := core.CompareBooleans(s1.IsTypeOnly(), s2.IsTypeOnly()); cmp != 0 { + return cmp + } + return comparer(s1Name, s2Name) + } +} + +// GetNamedImportSpecifierComparer returns a comparer function for import/export specifiers +func GetNamedImportSpecifierComparer(preferences *lsutil.UserPreferences, comparer func(a, b string) int) func(s1, s2 *ast.Node) int { + if comparer == nil { + ignoreCase := false + if preferences != nil && !preferences.OrganizeImportsIgnoreCase.IsUnknown() { + ignoreCase = preferences.OrganizeImportsIgnoreCase.IsTrue() + } + comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase) + } + return func(s1, s2 *ast.Node) int { + return compareImportOrExportSpecifiers(s1, s2, comparer, preferences) + } +} + +// getImportSpecifierInsertionIndex finds the insertion index for a new import specifier +func GetImportSpecifierInsertionIndex(sortedImports []*ast.Node, newImport *ast.Node, comparer func(s1, s2 *ast.Node) int) int { + return core.FirstResult(core.BinarySearchUniqueFunc(sortedImports, func(mid int, value *ast.Node) int { + return comparer(value, newImport) + })) +} + +// getOrganizeImportsStringComparerWithDetection detects the string comparer to use based on existing imports +func GetOrganizeImportsStringComparerWithDetection(originalImportDecls []*ast.Statement, preferences *lsutil.UserPreferences) (comparer func(a, b string) int, isSorted bool) { + result := detectModuleSpecifierCaseBySort([][]*ast.Statement{originalImportDecls}, getComparers(preferences)) + return result.comparer, result.isSorted +} + +func getComparers(preferences *lsutil.UserPreferences) []func(a string, b string) int { + if preferences != nil { + switch preferences.OrganizeImportsIgnoreCase { + case core.TSTrue: + return caseInsensitiveOrganizeImportsComparer + case core.TSFalse: + return caseSensitiveOrganizeImportsComparer + } + } + + return organizeImportsComparers +} + +type caseSensitivityDetectionResult struct { + comparer func(a, b string) int + isSorted bool +} + +func detectModuleSpecifierCaseBySort(importDeclsByGroup [][]*ast.Statement, comparersToTest []func(a, b string) int) caseSensitivityDetectionResult { + moduleSpecifiersByGroup := make([][]string, 0, len(importDeclsByGroup)) + for _, importGroup := range importDeclsByGroup { + moduleNames := make([]string, 0, len(importGroup)) + for _, decl := range importGroup { + if expr := getModuleSpecifierExpression(decl); expr != nil { + moduleNames = append(moduleNames, getExternalModuleName(expr)) + } else { + moduleNames = append(moduleNames, "") + } + } + moduleSpecifiersByGroup = append(moduleSpecifiersByGroup, moduleNames) + } + return detectCaseSensitivityBySort(moduleSpecifiersByGroup, comparersToTest) +} + +func detectCaseSensitivityBySort(originalGroups [][]string, comparersToTest []func(a, b string) int) caseSensitivityDetectionResult { + var bestComparer func(a, b string) int + bestDiff := math.MaxInt + + for _, curComparer := range comparersToTest { + diffOfCurrentComparer := 0 + + for _, listToSort := range originalGroups { + if len(listToSort) <= 1 { + continue + } + diff := measureSortedness(listToSort, curComparer) + diffOfCurrentComparer += diff + } + + if diffOfCurrentComparer < bestDiff { + bestDiff = diffOfCurrentComparer + bestComparer = curComparer + } + } + + if bestComparer == nil && len(comparersToTest) > 0 { + bestComparer = comparersToTest[0] + } + + return caseSensitivityDetectionResult{ + comparer: bestComparer, + isSorted: bestDiff == 0, + } +} + +func measureSortedness[T any](arr []T, comparer func(a, b T) int) int { + i := 0 + for j := range len(arr) - 1 { + if comparer(arr[j], arr[j+1]) > 0 { + i++ + } + } + return i +} + +// GetNamedImportSpecifierComparerWithDetection detects the appropriate comparer for named imports +func GetNamedImportSpecifierComparerWithDetection(importDecl *ast.Node, sourceFile *ast.SourceFile, preferences *lsutil.UserPreferences) (specifierComparer func(s1, s2 *ast.Node) int, isSorted core.Tristate) { + specifierComparer = GetNamedImportSpecifierComparer(preferences, getComparers(preferences)[0]) + // Try to detect from the current import declaration + if (preferences == nil || preferences.OrganizeImportsIgnoreCase.IsUnknown() || preferences.OrganizeImportsTypeOrder == lsutil.OrganizeImportsTypeOrderLast) && + importDecl.Kind == ast.KindImportDeclaration { + // For now, just return the default comparer + // Full detection logic would require porting detectNamedImportOrganizationBySort + return specifierComparer, core.TSUnknown + } + + return specifierComparer, core.TSUnknown +} diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go new file mode 100644 index 0000000000..823730282d --- /dev/null +++ b/internal/ls/selectionranges.go @@ -0,0 +1,188 @@ +package ls + +import ( + "context" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/scanner" +) + +func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { + _, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) + if sourceFile == nil { + return lsproto.SelectionRangesOrNull{}, nil + } + + var results []*lsproto.SelectionRange + for _, position := range params.Positions { + pos := l.converters.LineAndCharacterToPosition(sourceFile, position) + selectionRange := getSmartSelectionRange(l, sourceFile, int(pos)) + if selectionRange != nil { + results = append(results, selectionRange) + } + } + + return lsproto.SelectionRangesOrNull{SelectionRanges: &results}, nil +} + +func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos int) *lsproto.SelectionRange { + factory := &ast.NodeFactory{} + + nodeContainsPosition := func(node *ast.Node) bool { + if node == nil { + return false + } + start := scanner.GetTokenPosOfNode(node, sourceFile, true /*includeJSDoc*/) + end := node.End() + return start <= pos && pos < end + } + + pushSelectionRange := func(current *lsproto.SelectionRange, start, end int) *lsproto.SelectionRange { + if start == end { + return current + } + + if !(start <= pos && pos <= end) { + return current + } + + lspRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(start, end)) + + if current != nil && current.Range == lspRange { + return current + } + + return &lsproto.SelectionRange{ + Range: lspRange, + Parent: current, + } + } + + pushSelectionCommentRange := func(current *lsproto.SelectionRange, start, end int) *lsproto.SelectionRange { + current = pushSelectionRange(current, start, end) + + commentPos := start + text := sourceFile.Text() + for commentPos < end && commentPos < len(text) && text[commentPos] == '/' { + commentPos++ + } + current = pushSelectionRange(current, commentPos, end) + + return current + } + + positionsAreOnSameLine := func(pos1, pos2 int) bool { + if pos1 == pos2 { + return true + } + lspPos1 := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos1)) + lspPos2 := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos2)) + return lspPos1.Line == lspPos2.Line + } + + shouldSkipNode := func(node *ast.Node, parent *ast.Node) bool { + if ast.IsBlock(node) { + return true + } + + if ast.IsTemplateSpan(node) || ast.IsTemplateHead(node) || ast.IsTemplateTail(node) { + return true + } + + if parent != nil && ast.IsVariableDeclarationList(node) && ast.IsVariableStatement(parent) { + return true + } + + // Skip lone variable declarations + if parent != nil && ast.IsVariableDeclaration(node) && ast.IsVariableDeclarationList(parent) { + decl := parent.AsVariableDeclarationList() + if decl != nil && len(decl.Declarations.Nodes) == 1 { + return true + } + } + + if ast.IsJSDocTypeExpression(node) || ast.IsJSDocSignature(node) || ast.IsJSDocTypeLiteral(node) { + return true + } + + return false + } + + fullRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(sourceFile.Pos(), sourceFile.End())) + result := &lsproto.SelectionRange{ + Range: fullRange, + } + + var current *ast.Node + for current = sourceFile.AsNode(); current != nil; { + var next *ast.Node + parent := current + + visit := func(node *ast.Node) *ast.Node { + if node != nil && next == nil { + var foundComment *ast.CommentRange + for comment := range scanner.GetTrailingCommentRanges(factory, sourceFile.Text(), node.End()) { + foundComment = &comment + break + } + if foundComment != nil && foundComment.Kind == ast.KindSingleLineCommentTrivia { + result = pushSelectionCommentRange(result, foundComment.Pos(), foundComment.End()) + } + + if nodeContainsPosition(node) { + // Add range for multi-line function bodies before skipping the block + if ast.IsBlock(node) && ast.IsFunctionLikeDeclaration(parent) { + if !positionsAreOnSameLine(astnav.GetStartOfNode(node, sourceFile, false), node.End()) { + start := astnav.GetStartOfNode(node, sourceFile, false) + end := node.End() + result = pushSelectionRange(result, start, end) + } + } + + if !shouldSkipNode(node, parent) { + start := astnav.GetStartOfNode(node, sourceFile, false) + end := node.End() + result = pushSelectionRange(result, start, end) + } + + next = node + } + } + return node + } + + visitNodes := func(nodes *ast.NodeList, v *ast.NodeVisitor) *ast.NodeList { + if nodes != nil && len(nodes.Nodes) > 0 { + shouldSkipList := parent != nil && ast.IsVariableDeclarationList(parent) + + if !shouldSkipList { + start := astnav.GetStartOfNode(nodes.Nodes[0], sourceFile, false) + end := nodes.Nodes[len(nodes.Nodes)-1].End() + + if start <= pos && pos < end { + result = pushSelectionRange(result, start, end) + } + } + } + return v.VisitNodes(nodes) + } + + // Visit JSDoc nodes first if they exist + if current.Flags&ast.NodeFlagsHasJSDoc != 0 { + for _, jsdoc := range current.JSDoc(sourceFile) { + visit(jsdoc) + } + } + + tempVisitor := ast.NewNodeVisitor(visit, nil, ast.NodeVisitorHooks{ + VisitNodes: visitNodes, + }) + + current.VisitEachChild(tempVisitor) + current = next + } + return result +} diff --git a/internal/ls/signaturehelp.go b/internal/ls/signaturehelp.go index 09284f9594..4369ef0bc8 100644 --- a/internal/ls/signaturehelp.go +++ b/internal/ls/signaturehelp.go @@ -3,6 +3,7 @@ package ls import ( "context" "fmt" + "slices" "strings" "github.com/microsoft/typescript-go/internal/ast" @@ -42,8 +43,6 @@ func (l *LanguageService) ProvideSignatureHelp( documentURI lsproto.DocumentUri, position lsproto.Position, context *lsproto.SignatureHelpContext, - clientOptions *lsproto.SignatureHelpClientCapabilities, - preferences *UserPreferences, ) (lsproto.SignatureHelpResponse, error) { program, sourceFile := l.getProgramAndFile(documentURI) items := l.GetSignatureHelpItems( @@ -51,9 +50,7 @@ func (l *LanguageService) ProvideSignatureHelp( int(l.converters.LineAndCharacterToPosition(sourceFile, position)), program, sourceFile, - context, - clientOptions, - preferences) + context) return lsproto.SignatureHelpOrNull{SignatureHelp: items}, nil } @@ -63,8 +60,6 @@ func (l *LanguageService) GetSignatureHelpItems( program *compiler.Program, sourceFile *ast.SourceFile, context *lsproto.SignatureHelpContext, - clientOptions *lsproto.SignatureHelpClientCapabilities, - preferences *UserPreferences, ) *lsproto.SignatureHelp { typeChecker, done := program.GetTypeCheckerForFile(ctx, sourceFile) defer done() @@ -142,12 +137,12 @@ func (l *LanguageService) GetSignatureHelpItems( // return typeChecker.runWithCancellationToken(cancellationToken, typeChecker => if candidateInfo.candidateInfo != nil { - return createSignatureHelpItems(candidateInfo.candidateInfo.candidates, candidateInfo.candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker, onlyUseSyntacticOwners, clientOptions) + return l.createSignatureHelpItems(ctx, candidateInfo.candidateInfo.candidates, candidateInfo.candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker, onlyUseSyntacticOwners) } - return createTypeHelpItems(candidateInfo.typeInfo, argumentInfo, sourceFile, clientOptions, typeChecker) + return createTypeHelpItems(candidateInfo.typeInfo, argumentInfo, sourceFile, typeChecker) } -func createTypeHelpItems(symbol *ast.Symbol, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, clientOptions *lsproto.SignatureHelpClientCapabilities, c *checker.Checker) *lsproto.SignatureHelp { +func createTypeHelpItems(symbol *ast.Symbol, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, c *checker.Checker) *lsproto.SignatureHelp { typeParameters := c.GetLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) if typeParameters == nil { return nil @@ -204,7 +199,10 @@ func getTypeHelpItem(symbol *ast.Symbol, typeParameter []*checker.Type, enclosin } } -func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature *checker.Signature, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, c *checker.Checker, useFullPrefix bool, clientOptions *lsproto.SignatureHelpClientCapabilities) *lsproto.SignatureHelp { +func (l *LanguageService) createSignatureHelpItems(ctx context.Context, candidates []*checker.Signature, resolvedSignature *checker.Signature, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, c *checker.Checker, useFullPrefix bool) *lsproto.SignatureHelp { + caps := lsproto.GetClientCapabilities(ctx) + docFormat := lsproto.PreferredMarkupKind(caps.TextDocument.SignatureHelp.SignatureInformation.DocumentationFormat) + enclosingDeclaration := getEnclosingDeclarationFromInvocation(argumentInfo.invocation) if enclosingDeclaration == nil { return nil @@ -225,7 +223,7 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature } items := make([][]signatureInformation, len(candidates)) for i, candidateSignature := range candidates { - items[i] = getSignatureHelpItem(candidateSignature, argumentInfo.isTypeParameterList, callTargetDisplayParts.String(), enclosingDeclaration, sourceFile, c) + items[i] = l.getSignatureHelpItem(candidateSignature, argumentInfo.isTypeParameterList, callTargetDisplayParts.String(), enclosingDeclaration, sourceFile, c, docFormat) } selectedItemIndex := 0 @@ -264,9 +262,18 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature for j, param := range item.Parameters { parameters[j] = param.parameterInfo } + var documentation *lsproto.StringOrMarkupContent + if item.Documentation != nil { + documentation = &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: docFormat, + Value: *item.Documentation, + }, + } + } signatureInformation[i] = &lsproto.SignatureInformation{ Label: item.Label, - Documentation: nil, + Documentation: documentation, Parameters: ¶meters, } } @@ -293,7 +300,7 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature return help } -func getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool, callTargetSymbol string, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile, c *checker.Checker) []signatureInformation { +func (l *LanguageService) getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool, callTargetSymbol string, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile, c *checker.Checker, docFormat lsproto.MarkupKind) []signatureInformation { var infos []*signatureHelpItemInfo if isTypeParameterList { infos = itemInfoForTypeParameters(candidate, c, enclosingDeclaration, sourceFile) @@ -303,6 +310,15 @@ func getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool suffixDisplayParts := returnTypeToDisplayParts(candidate, c) + // Generate documentation from the signature's declaration + var documentation *string + if declaration := candidate.Declaration(); declaration != nil { + doc := l.getDocumentationFromDeclaration(c, declaration, docFormat) + if doc != "" { + documentation = &doc + } + } + result := make([]signatureInformation, len(infos)) for i, info := range infos { var display strings.Builder @@ -311,7 +327,7 @@ func getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool display.WriteString(suffixDisplayParts) result[i] = signatureInformation{ Label: display.String(), - Documentation: nil, + Documentation: documentation, Parameters: info.parameters, IsVariadic: info.isVariadic, } @@ -589,9 +605,9 @@ func isSyntacticOwner(startingToken *ast.Node, node *ast.CallLikeExpression, sou invocationChildren := getChildrenFromNonJSDocNode(node, sourceFile) switch startingToken.Kind { case ast.KindOpenParenToken, ast.KindCommaToken: - return containsNode(invocationChildren, startingToken) + return slices.Contains(invocationChildren, startingToken) case ast.KindLessThanToken: - return containsPrecedingToken(startingToken, sourceFile, node.AsCallExpression().Expression) + return containsPrecedingToken(startingToken, sourceFile, node.Expression()) default: return false } @@ -1105,15 +1121,6 @@ func getTokenFromNodeList(nodeList *ast.NodeList, nodeListParent *ast.Node, sour return tokens } -func containsNode(nodes []*ast.Node, node *ast.Node) bool { - for i := range nodes { - if nodes[i] == node { - return true - } - } - return false -} - func getArgumentListInfoForTemplate(tagExpression *ast.TaggedTemplateExpression, argumentIndex int, sourceFile *ast.SourceFile) *argumentListInfo { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. argumentCount := 1 diff --git a/internal/ls/source_map.go b/internal/ls/source_map.go index 62eafda161..dee315cf45 100644 --- a/internal/ls/source_map.go +++ b/internal/ls/source_map.go @@ -3,7 +3,9 @@ package ls import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/sourcemap" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -13,16 +15,22 @@ func (l *LanguageService) getMappedLocation(fileName string, fileRange core.Text if startPos == nil { lspRange := l.createLspRangeFromRange(fileRange, l.getScript(fileName)) return lsproto.Location{ - Uri: FileNameToDocumentURI(fileName), + Uri: lsconv.FileNameToDocumentURI(fileName), Range: *lspRange, } } endPos := l.tryGetSourcePosition(fileName, core.TextPos(fileRange.End())) + if endPos == nil { + endPos = &sourcemap.DocumentPosition{ + FileName: startPos.FileName, + Pos: startPos.Pos + fileRange.Len(), + } + } debug.Assert(endPos.FileName == startPos.FileName, "start and end should be in same file") newRange := core.NewTextRange(startPos.Pos, endPos.Pos) lspRange := l.createLspRangeFromRange(newRange, l.getScript(startPos.FileName)) return lsproto.Location{ - Uri: FileNameToDocumentURI(startPos.FileName), + Uri: lsconv.FileNameToDocumentURI(startPos.FileName), Range: *lspRange, } } @@ -79,3 +87,47 @@ func (l *LanguageService) tryGetSourcePositionWorker( } return documentPos } + +func (l *LanguageService) tryGetGeneratedPosition( + fileName string, + position core.TextPos, +) *sourcemap.DocumentPosition { + newPos := l.tryGetGeneratedPositionWorker(fileName, position) + if newPos != nil { + if _, ok := l.ReadFile(newPos.FileName); !ok { // File doesn't exist + return nil + } + } + return newPos +} + +func (l *LanguageService) tryGetGeneratedPositionWorker( + fileName string, + position core.TextPos, +) *sourcemap.DocumentPosition { + if tspath.IsDeclarationFileName(fileName) { + return nil + } + + program := l.GetProgram() + if program == nil || program.GetSourceFile(fileName) == nil { + return nil + } + + path := l.toPath(fileName) + // If this is source file of project reference source (instead of redirect) there is no generated position + if program.IsSourceFromProjectReference(path) { + return nil + } + + declarationFileName := outputpaths.GetOutputDeclarationFileNameWorker(fileName, program.Options(), program) + positionMapper := l.GetDocumentPositionMapper(declarationFileName) + documentPos := positionMapper.GetGeneratedPosition(&sourcemap.DocumentPosition{FileName: fileName, Pos: int(position)}) + if documentPos == nil { + return nil + } + if newPos := l.tryGetGeneratedPositionWorker(documentPos.FileName, core.TextPos(documentPos.Pos)); newPos != nil { + return newPos + } + return documentPos +} diff --git a/internal/ls/string_completions.go b/internal/ls/string_completions.go index a1a3e6d7f8..a27b3768ef 100644 --- a/internal/ls/string_completions.go +++ b/internal/ls/string_completions.go @@ -46,8 +46,6 @@ func (l *LanguageService) getStringLiteralCompletions( position int, contextToken *ast.Node, compilerOptions *core.CompilerOptions, - preferences *UserPreferences, - clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { // !!! reference comment if IsInString(file, position, contextToken) { @@ -58,8 +56,7 @@ func (l *LanguageService) getStringLiteralCompletions( ctx, file, contextToken, - position, - preferences) + position) return l.convertStringLiteralCompletions( ctx, entries, @@ -67,8 +64,6 @@ func (l *LanguageService) getStringLiteralCompletions( file, position, compilerOptions, - preferences, - clientOptions, ) } return nil @@ -81,8 +76,6 @@ func (l *LanguageService) convertStringLiteralCompletions( file *ast.SourceFile, position int, options *core.CompilerOptions, - preferences *UserPreferences, - clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { if completion == nil { return nil @@ -92,7 +85,7 @@ func (l *LanguageService) convertStringLiteralCompletions( switch { case completion.fromPaths != nil: completion := completion.fromPaths - return l.convertPathCompletions(completion, file, position, clientOptions) + return l.convertPathCompletions(ctx, completion, file, position) case completion.fromProperties != nil: completion := completion.fromProperties data := &completionDataData{ @@ -108,13 +101,11 @@ func (l *LanguageService) convertStringLiteralCompletions( contextToken, /*replacementToken*/ position, file, - preferences, options, - clientOptions, ) defaultCommitCharacters := getDefaultCommitCharacters(completion.hasIndexSignature) itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -139,6 +130,7 @@ func (l *LanguageService) convertStringLiteralCompletions( items := core.Map(completion.types, func(t *checker.StringLiteralType) *lsproto.CompletionItem { name := printer.EscapeString(t.AsLiteralType().Value().(string), quoteChar) return l.createLSPCompletionItem( + ctx, name, "", /*insertText*/ "", /*filterText*/ @@ -150,7 +142,6 @@ func (l *LanguageService) convertStringLiteralCompletions( nil, /*labelDetails*/ file, position, - clientOptions, false, /*isMemberCompletion*/ false, /*isSnippet*/ false, /*hasAction*/ @@ -161,7 +152,7 @@ func (l *LanguageService) convertStringLiteralCompletions( }) defaultCommitCharacters := getDefaultCommitCharacters(completion.isNewIdentifier) itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -179,16 +170,17 @@ func (l *LanguageService) convertStringLiteralCompletions( } func (l *LanguageService) convertPathCompletions( + ctx context.Context, pathCompletions []*pathCompletion, file *ast.SourceFile, position int, - clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { isNewIdentifierLocation := true // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. defaultCommitCharacters := getDefaultCommitCharacters(isNewIdentifierLocation) items := core.Map(pathCompletions, func(pathCompletion *pathCompletion) *lsproto.CompletionItem { replacementSpan := l.createLspRangeFromBounds(pathCompletion.textRange.Pos(), pathCompletion.textRange.End(), file) return l.createLSPCompletionItem( + ctx, pathCompletion.name, "", /*insertText*/ "", /*filterText*/ @@ -200,7 +192,6 @@ func (l *LanguageService) convertPathCompletions( nil, /*labelDetails*/ file, position, - clientOptions, false, /*isMemberCompletion*/ false, /*isSnippet*/ false, /*hasAction*/ @@ -210,7 +201,7 @@ func (l *LanguageService) convertPathCompletions( ) }) itemDefaults := l.setItemDefaults( - clientOptions, + ctx, position, file, items, @@ -229,7 +220,6 @@ func (l *LanguageService) getStringLiteralCompletionEntries( file *ast.SourceFile, node *ast.StringLiteralLike, position int, - preferences *UserPreferences, ) *stringLiteralCompletions { typeChecker, done := l.GetProgram().GetTypeCheckerForFile(ctx, file) defer done() @@ -242,7 +232,6 @@ func (l *LanguageService) getStringLiteralCompletionEntries( file, node, l.GetProgram(), - preferences, ) } return fromUnionableLiteralType(grandparent, parent, position, typeChecker) @@ -323,7 +312,7 @@ func (l *LanguageService) getStringLiteralCompletionEntries( // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return getStringLiteralCompletionsFromModuleNames(file, node, l.GetProgram(), preferences) + return getStringLiteralCompletionsFromModuleNames(file, node, l.GetProgram()) case ast.KindCaseClause: tracker := newCaseClauseTracker(typeChecker, parent.Parent.AsCaseBlock().Clauses.Nodes) contextualTypes := fromContextualType(checker.ContextFlagsCompletions, node, typeChecker) @@ -361,10 +350,7 @@ func (l *LanguageService) getStringLiteralCompletionEntries( } exports := typeChecker.GetExportsAndPropertiesOfModule(moduleSpecifierSymbol) existing := collections.NewSetFromItems(core.Map(namedImportsOrExports.Elements(), func(n *ast.Node) string { - if n.PropertyName() != nil { - return n.PropertyName().Text() - } - return n.Name().Text() + return n.PropertyNameOrName().Text() })...) uniques := core.Filter(exports, func(e *ast.Symbol) bool { return e.Name != ast.InternalSymbolNameDefault && !existing.Has(e.Name) @@ -527,7 +513,6 @@ func getStringLiteralCompletionsFromModuleNames( file *ast.SourceFile, node *ast.LiteralExpression, program *compiler.Program, - preferences *UserPreferences, ) *stringLiteralCompletions { // !!! needs `getModeForUsageLocationWorker` return nil @@ -678,7 +663,7 @@ func (l *LanguageService) getStringLiteralCompletionDetails( file *ast.SourceFile, position int, contextToken *ast.Node, - preferences *UserPreferences, + docFormat lsproto.MarkupKind, ) *lsproto.CompletionItem { if contextToken == nil || !ast.IsStringLiteralLike(contextToken) { return item @@ -688,42 +673,42 @@ func (l *LanguageService) getStringLiteralCompletionDetails( file, contextToken, position, - preferences, ) if completions == nil { return item } - return stringLiteralCompletionDetails(item, name, contextToken, completions, file, checker) + return l.stringLiteralCompletionDetails(item, name, contextToken, completions, file, checker, docFormat) } -func stringLiteralCompletionDetails( +func (l *LanguageService) stringLiteralCompletionDetails( item *lsproto.CompletionItem, name string, location *ast.Node, completion *stringLiteralCompletions, file *ast.SourceFile, checker *checker.Checker, + docFormat lsproto.MarkupKind, ) *lsproto.CompletionItem { switch { case completion.fromPaths != nil: pathCompletions := completion.fromPaths for _, pathCompletion := range pathCompletions { if pathCompletion.name == name { - return createCompletionDetails(item, name, "" /*documentation*/) + return createCompletionDetails(item, name, "" /*documentation*/, docFormat) } } case completion.fromProperties != nil: properties := completion.fromProperties for _, symbol := range properties.symbols { if symbol.Name == name { - return createCompletionDetailsForSymbol(item, symbol, checker, location, nil /*actions*/) + return l.createCompletionDetailsForSymbol(item, symbol, checker, location, nil /*actions*/, docFormat) } } case completion.fromTypes != nil: types := completion.fromTypes for _, t := range types.types { if t.AsLiteralType().Value().(string) == name { - return createCompletionDetails(item, name, "" /*documentation*/) + return createCompletionDetails(item, name, "" /*documentation*/, docFormat) } } } diff --git a/internal/ls/symbols.go b/internal/ls/symbols.go index eb4726d246..b45695e703 100644 --- a/internal/ls/symbols.go +++ b/internal/ls/symbols.go @@ -8,19 +8,64 @@ import ( "unicode/utf8" "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/printer" "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/stringutil" + "github.com/microsoft/typescript-go/internal/tspath" ) func (l *LanguageService) ProvideDocumentSymbols(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.DocumentSymbolResponse, error) { _, file := l.getProgramAndFile(documentURI) - symbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode()) - return lsproto.SymbolInformationsOrDocumentSymbolsOrNull{DocumentSymbols: &symbols}, nil + if lsproto.GetClientCapabilities(ctx).TextDocument.DocumentSymbol.HierarchicalDocumentSymbolSupport { + symbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode()) + return lsproto.SymbolInformationsOrDocumentSymbolsOrNull{DocumentSymbols: &symbols}, nil + } + // Client doesn't support hierarchical document symbols, return flat SymbolInformation array + symbolInfos := l.getDocumentSymbolInformations(ctx, file, documentURI) + symbolInfoPtrs := make([]*lsproto.SymbolInformation, len(symbolInfos)) + for i := range symbolInfos { + symbolInfoPtrs[i] = &symbolInfos[i] + } + return lsproto.SymbolInformationsOrDocumentSymbolsOrNull{SymbolInformations: &symbolInfoPtrs}, nil +} + +// getDocumentSymbolInformations converts hierarchical DocumentSymbols to a flat SymbolInformation array +func (l *LanguageService) getDocumentSymbolInformations(ctx context.Context, file *ast.SourceFile, documentURI lsproto.DocumentUri) []lsproto.SymbolInformation { + // First get hierarchical symbols + docSymbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode()) + + // Flatten the hierarchy + var result []lsproto.SymbolInformation + var flatten func(symbols []*lsproto.DocumentSymbol, containerName *string) + flatten = func(symbols []*lsproto.DocumentSymbol, containerName *string) { + for _, symbol := range symbols { + info := lsproto.SymbolInformation{ + Name: symbol.Name, + Kind: symbol.Kind, + Location: lsproto.Location{ + Uri: documentURI, + Range: symbol.Range, + }, + ContainerName: containerName, + Tags: symbol.Tags, + Deprecated: symbol.Deprecated, + } + result = append(result, info) + + // Recursively flatten children with this symbol as container + if symbol.Children != nil && len(*symbol.Children) > 0 { + flatten(*symbol.Children, &symbol.Name) + } + } + } + flatten(docSymbols, nil) + return result } func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, node *ast.Node) []*lsproto.DocumentSymbol { @@ -195,19 +240,27 @@ type DeclarationInfo struct { matchScore int } -func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, converters *Converters, query string) (lsproto.WorkspaceSymbolResponse, error) { +func ProvideWorkspaceSymbols( + ctx context.Context, + programs []*compiler.Program, + converters *lsconv.Converters, + preferences *lsutil.UserPreferences, + query string, +) (lsproto.WorkspaceSymbolResponse, error) { + excludeLibrarySymbols := preferences.ExcludeLibrarySymbolsInNavTo // Obtain set of non-declaration source files from all active programs. - var sourceFiles collections.Set[*ast.SourceFile] + sourceFiles := map[tspath.Path]*ast.SourceFile{} for _, program := range programs { for _, sourceFile := range program.SourceFiles() { - if !sourceFile.IsDeclarationFile { - sourceFiles.Add(sourceFile) + if (program.HasTSFile() || !sourceFile.IsDeclarationFile) && + !shouldExcludeFile(sourceFile, program, excludeLibrarySymbols) { + sourceFiles[sourceFile.Path()] = sourceFile } } } // Create DeclarationInfos for all declarations in the source files. var infos []DeclarationInfo - for sourceFile := range sourceFiles.Keys() { + for _, sourceFile := range sourceFiles { if ctx.Err() != nil { return lsproto.SymbolInformationsOrWorkspaceSymbolsOrNull{}, nil } @@ -226,18 +279,33 @@ func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, count := min(len(infos), 256) symbols := make([]*lsproto.SymbolInformation, count) for i, info := range infos[0:count] { - node := core.OrElse(ast.GetNameOfDeclaration(info.declaration), info.declaration) + node := info.declaration sourceFile := ast.GetSourceFileOfNode(node) - pos := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) + pos := astnav.GetStartOfNode(node, sourceFile, false /*includeJsDoc*/) + container := getContainerNode(info.declaration) + var containerName *string + if container != nil { + containerName = strPtrTo(ast.GetDeclarationName(container)) + } var symbol lsproto.SymbolInformation symbol.Name = info.name symbol.Kind = getSymbolKindFromNode(info.declaration) symbol.Location = converters.ToLSPLocation(sourceFile, core.NewTextRange(pos, node.End())) + symbol.ContainerName = containerName symbols[i] = &symbol } + return lsproto.SymbolInformationsOrWorkspaceSymbolsOrNull{SymbolInformations: &symbols}, nil } +func shouldExcludeFile(file *ast.SourceFile, program *compiler.Program, excludeLibrarySymbols bool) bool { + return excludeLibrarySymbols && (isInsideNodeModules(file.FileName()) || program.IsLibFile(file)) +} + +func isInsideNodeModules(fileName string) bool { + return strings.Contains(fileName, "/node_modules/") +} + // Return a score for matching `s` against `pattern`. In order to match, `s` must contain each of the characters in // `pattern` in the same order. Upper case characters in `pattern` must match exactly, whereas lower case characters // in `pattern` match either case in `s`. If `s` doesn't match, -1 is returned. Otherwise, the returned score is the @@ -304,6 +372,16 @@ func getSymbolKindFromNode(node *ast.Node) lsproto.SymbolKind { return lsproto.SymbolKindEnumMember case ast.KindTypeParameter: return lsproto.SymbolKindTypeParameter + case ast.KindParameter: + if ast.HasSyntacticModifier(node, ast.ModifierFlagsParameterPropertyModifier) { + return lsproto.SymbolKindProperty + } + return lsproto.SymbolKindVariable + case ast.KindBinaryExpression: + switch ast.GetAssignmentDeclarationKind(node.AsBinaryExpression()) { + case ast.JSDeclarationKindThisProperty, ast.JSDeclarationKindProperty: + return lsproto.SymbolKindProperty + } } return lsproto.SymbolKindVariable } diff --git a/internal/ls/userpreferences.go b/internal/ls/userpreferences.go deleted file mode 100644 index 11be04d64a..0000000000 --- a/internal/ls/userpreferences.go +++ /dev/null @@ -1,211 +0,0 @@ -package ls - -import ( - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/modulespecifiers" -) - -type UserPreferences struct { - QuotePreference QuotePreference - LazyConfiguredProjectsFromExternalProject bool // !!! - - // A positive integer indicating the maximum length of a hover text before it is truncated. - // - // Default: `500` - MaximumHoverLength int // !!! - - // ------- Completions ------- - - // If enabled, TypeScript will search through all external modules' exports and add them to the completions list. - // This affects lone identifier completions but not completions on the right hand side of `obj.`. - IncludeCompletionsForModuleExports core.Tristate - // Enables auto-import-style completions on partially-typed import statements. E.g., allows - // `import write|` to be completed to `import { writeFile } from "fs"`. - IncludeCompletionsForImportStatements core.Tristate - // Unless this option is `false`, member completion lists triggered with `.` will include entries - // on potentially-null and potentially-undefined values, with insertion text to replace - // preceding `.` tokens with `?.`. - IncludeAutomaticOptionalChainCompletions core.Tristate - // Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. - IncludeCompletionsWithSnippetText core.Tristate // !!! - // If enabled, completions for class members (e.g. methods and properties) will include - // a whole declaration for the member. - // E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of - // `class A { foo }`. - IncludeCompletionsWithClassMemberSnippets core.Tristate // !!! - // If enabled, object literal methods will have a method declaration completion entry in addition - // to the regular completion entry containing just the method name. - // E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, - // in addition to `const objectLiteral: T = { foo }`. - IncludeCompletionsWithObjectLiteralMethodSnippets core.Tristate // !!! - JsxAttributeCompletionStyle JsxAttributeCompletionStyle - - // ------- AutoImports -------- - - ImportModuleSpecifierPreference modulespecifiers.ImportModuleSpecifierPreference // !!! - // Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" - ImportModuleSpecifierEnding modulespecifiers.ImportModuleSpecifierEndingPreference // !!! - IncludePackageJsonAutoImports IncludePackageJsonAutoImports // !!! - AutoImportSpecifierExcludeRegexes []string // !!! - AutoImportFileExcludePatterns []string // !!! - PreferTypeOnlyAutoImports bool // !!! - - // ------- OrganizeImports ------- - - // Indicates whether imports should be organized in a case-insensitive manner. - // - // Default: TSUnknown ("auto" in strada), will perform detection - OrganizeImportsIgnoreCase core.Tristate // !!! - // Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value of their - // code points, or via "unicode" collation (via the Unicode Collation Algorithm (https://unicode.org/reports/tr10/#Scope)) - // - // using rules associated with the locale specified in organizeImportsCollationLocale. - // - // Default: Ordinal - OrganizeImportsCollation OrganizeImportsCollation // !!! - // Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant - // for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. - // - // This preference is ignored if organizeImportsCollation is not `unicode`. - // - // Default: `"en"` - OrganizeImportsLocale string // !!! - // Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate - // strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. - // - // This preference is ignored if organizeImportsCollation is not `unicode`. - // - // Default: `false` - OrganizeImportsNumericCollation bool // !!! - // Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When - // `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified - // in organizeImportsCollationLocale. - // - // This preference is ignored if organizeImportsCollation is not `unicode`. - // - // Default: `true` - OrganizeImportsAccentCollation OrganizeImportsAccentCollation // !!! - // Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale - // specified in organizeImportsCollationLocale is used. - // - // This preference is ignored if: - // - organizeImportsCollation is not `unicode` - // - organizeImportsIgnoreCase is `true` - // - organizeImportsIgnoreCase is `auto` and the auto-detected case sensitivity is case-insensitive. - // - // Default: `false` - OrganizeImportsCaseFirst OrganizeImportsCaseFirst // !!! - // Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is type-only. - // - // Default: `last` - OrganizeImportsTypeOrder OrganizeImportsTypeOrder // !!! - - // ------- MoveToFile ------- - - AllowTextChangesInNewFiles bool // !!! - - // ------- Rename ------- - - // renamed from `providePrefixAndSuffixTextForRename` - UseAliasesForRename core.Tristate - AllowRenameOfImportPath bool // !!! - - // ------- CodeFixes/Refactors ------- - - ProvideRefactorNotApplicableReason bool // !!! - - // ------- InlayHints ------- - - IncludeInlayParameterNameHints IncludeInlayParameterNameHints - IncludeInlayParameterNameHintsWhenArgumentMatchesName bool - IncludeInlayFunctionParameterTypeHints bool - IncludeInlayVariableTypeHints bool - IncludeInlayVariableTypeHintsWhenTypeMatchesName bool - IncludeInlayPropertyDeclarationTypeHints bool - IncludeInlayFunctionLikeReturnTypeHints bool - IncludeInlayEnumMemberValueHints bool - InteractiveInlayHints bool - - // ------- Misc ------- - - ExcludeLibrarySymbolsInNavTo bool // !!! - DisableSuggestions bool // !!! - DisableLineTextInReferences bool // !!! - DisplayPartsForJSDoc bool // !!! -} - -type JsxAttributeCompletionStyle string - -const ( - JsxAttributeCompletionStyleUnknown JsxAttributeCompletionStyle = "" - JsxAttributeCompletionStyleAuto JsxAttributeCompletionStyle = "auto" - JsxAttributeCompletionStyleBraces JsxAttributeCompletionStyle = "braces" - JsxAttributeCompletionStyleNone JsxAttributeCompletionStyle = "none" -) - -type IncludeInlayParameterNameHints string - -const ( - IncludeInlayParameterNameHintsNone IncludeInlayParameterNameHints = "" - IncludeInlayParameterNameHintsAll IncludeInlayParameterNameHints = "all" - IncludeInlayParameterNameHintsLiterals IncludeInlayParameterNameHints = "literals" -) - -type IncludePackageJsonAutoImports string - -const ( - IncludePackageJsonAutoImportsUnknown IncludePackageJsonAutoImports = "" - IncludePackageJsonAutoImportsAuto IncludePackageJsonAutoImports = "auto" - IncludePackageJsonAutoImportsOn IncludePackageJsonAutoImports = "on" - IncludePackageJsonAutoImportsOff IncludePackageJsonAutoImports = "off" -) - -type OrganizeImportsCollation bool - -const ( - OrganizeImportsCollationOrdinal OrganizeImportsCollation = false - OrganizeImportsCollationUnicode OrganizeImportsCollation = true -) - -type OrganizeImportsAccentCollation int - -const ( - OrganizeImportsAccentCollationTrue OrganizeImportsAccentCollation = 0 - OrganizeImportsAccentCollationFalse OrganizeImportsAccentCollation = 1 -) - -type OrganizeImportsCaseFirst int - -const ( - OrganizeImportsCaseFirstFalse OrganizeImportsCaseFirst = 0 - OrganizeImportsCaseFirstLower OrganizeImportsCaseFirst = 1 - OrganizeImportsCaseFirstUpper OrganizeImportsCaseFirst = 2 -) - -type OrganizeImportsTypeOrder int - -const ( - OrganizeImportsTypeOrderLast OrganizeImportsTypeOrder = 0 - OrganizeImportsTypeOrderInline OrganizeImportsTypeOrder = 1 - OrganizeImportsTypeOrderFirst OrganizeImportsTypeOrder = 2 -) - -type QuotePreference string - -const ( - QuotePreferenceUnknown QuotePreference = "" - QuotePreferenceAuto QuotePreference = "auto" - QuotePreferenceDouble QuotePreference = "double" - QuotePreferenceSingle QuotePreference = "single" -) - -func (p *UserPreferences) Parse(config map[string]interface{}) { -} - -func (p *UserPreferences) ModuleSpecifierPreferences() modulespecifiers.UserPreferences { - return modulespecifiers.UserPreferences{ - ImportModuleSpecifierPreference: p.ImportModuleSpecifierPreference, - ImportModuleSpecifierEnding: p.ImportModuleSpecifierEnding, - AutoImportSpecifierExcludeRegexes: p.AutoImportSpecifierExcludeRegexes, - } -} diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 86e27a9fb7..c2554cb1db 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -1,7 +1,6 @@ package ls import ( - "cmp" "fmt" "iter" "slices" @@ -15,33 +14,14 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/jsnum" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/lsutil" "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/tspath" ) -// Implements a cmp.Compare like function for two lsproto.Position -// ComparePositions(pos, other) == cmp.Compare(pos, other) -func ComparePositions(pos, other lsproto.Position) int { - if lineComp := cmp.Compare(pos.Line, other.Line); lineComp != 0 { - return lineComp - } - return cmp.Compare(pos.Character, other.Character) -} - -// Implements a cmp.Compare like function for two *lsproto.Range -// CompareRanges(lsRange, other) == cmp.Compare(lsrange, other) -// -// Range.Start is compared before Range.End -func CompareRanges(lsRange, other *lsproto.Range) int { - if startComp := ComparePositions(lsRange.Start, other.Start); startComp != 0 { - return startComp - } - return ComparePositions(lsRange.End, other.End) -} - var quoteReplacer = strings.NewReplacer("'", `\'`, `\"`, `"`) func IsInString(sourceFile *ast.SourceFile, position int, previousToken *ast.Node) bool { @@ -101,7 +81,7 @@ func isModuleSpecifierLike(node *ast.Node) bool { } if ast.IsRequireCall(node.Parent, false /*requireStringLiteralLikeArgument*/) || ast.IsImportCall(node.Parent) { - return node.Parent.AsCallExpression().Arguments.Nodes[0] == node + return node.Parent.Arguments()[0] == node } return node.Parent.Kind == ast.KindExternalModuleReference || @@ -177,7 +157,7 @@ func isExportSpecifierAlias(referenceLocation *ast.Identifier, exportSpecifier * } else { // `export { foo } from "foo"` is a re-export. // `export { foo };` is not a re-export, it creates an alias for the local variable `foo`. - return exportSpecifier.Parent.Parent.AsExportDeclaration().ModuleSpecifier == nil + return exportSpecifier.Parent.Parent.ModuleSpecifier() == nil } } @@ -388,7 +368,7 @@ func isThis(node *ast.Node) bool { return true case ast.KindIdentifier: // 'this' as a parameter - return node.AsIdentifier().Text == "this" && node.Parent.Kind == ast.KindParameter + return node.Text() == "this" && node.Parent.Kind == ast.KindParameter default: return false } @@ -442,7 +422,7 @@ func (l *LanguageService) createLspRangeFromBounds(start, end int, file *ast.Sou return &lspRange } -func (l *LanguageService) createLspRangeFromRange(textRange core.TextRange, script Script) *lsproto.Range { +func (l *LanguageService) createLspRangeFromRange(textRange core.TextRange, script lsconv.Script) *lsproto.Range { lspRange := l.converters.ToLSPRange(script, textRange) return &lspRange } @@ -451,7 +431,7 @@ func (l *LanguageService) createLspPosition(position int, file *ast.SourceFile) return l.converters.PositionToLineAndCharacter(file, core.TextPos(position)) } -func quote(file *ast.SourceFile, preferences *UserPreferences, text string) string { +func quote(file *ast.SourceFile, preferences *lsutil.UserPreferences, text string) string { // Editors can pass in undefined or empty string - we want to infer the preference in those cases. quotePreference := getQuotePreference(file, preferences) quoted, _ := core.StringifyJson(text, "" /*prefix*/, "" /*indent*/) @@ -468,71 +448,32 @@ const ( quotePreferenceDouble ) -// !!! -func getQuotePreference(file *ast.SourceFile, preferences *UserPreferences) quotePreference { +func quotePreferenceFromString(str *ast.StringLiteral) quotePreference { + if str.TokenFlags&ast.TokenFlagsSingleQuote != 0 { + return quotePreferenceSingle + } return quotePreferenceDouble } -func isNonContextualKeyword(token ast.Kind) bool { - return ast.IsKeywordKind(token) && !ast.IsContextualKeyword(token) -} - -func probablyUsesSemicolons(file *ast.SourceFile) bool { - withSemicolon := 0 - withoutSemicolon := 0 - nStatementsToObserve := 5 - - var visit func(node *ast.Node) bool - visit = func(node *ast.Node) bool { - if node.Flags&ast.NodeFlagsReparsed != 0 { - return false - } - if lsutil.SyntaxRequiresTrailingSemicolonOrASI(node.Kind) { - lastToken := lsutil.GetLastToken(node, file) - if lastToken != nil && lastToken.Kind == ast.KindSemicolonToken { - withSemicolon++ - } else { - withoutSemicolon++ - } - } else if lsutil.SyntaxRequiresTrailingCommaOrSemicolonOrASI(node.Kind) { - lastToken := lsutil.GetLastToken(node, file) - if lastToken != nil && lastToken.Kind == ast.KindSemicolonToken { - withSemicolon++ - } else if lastToken != nil && lastToken.Kind != ast.KindCommaToken { - lastTokenLine, _ := scanner.GetECMALineAndCharacterOfPosition( - file, - astnav.GetStartOfNode(lastToken, file, false /*includeJSDoc*/)) - nextTokenLine, _ := scanner.GetECMALineAndCharacterOfPosition( - file, - scanner.GetRangeOfTokenAtPosition(file, lastToken.End()).Pos()) - // Avoid counting missing semicolon in single-line objects: - // `function f(p: { x: string /*no semicolon here is insignificant*/ }) {` - if lastTokenLine != nextTokenLine { - withoutSemicolon++ - } - } - } - - if withSemicolon+withoutSemicolon >= nStatementsToObserve { - return true +func getQuotePreference(sourceFile *ast.SourceFile, preferences *lsutil.UserPreferences) quotePreference { + if preferences.QuotePreference != "" && preferences.QuotePreference != "auto" { + if preferences.QuotePreference == "single" { + return quotePreferenceSingle } - - return node.ForEachChild(visit) + return quotePreferenceDouble } - - file.ForEachChild(visit) - - // One statement missing a semicolon isn't sufficient evidence to say the user - // doesn't want semicolons, because they may not even be done writing that statement. - if withSemicolon == 0 && withoutSemicolon <= 1 { - return true + // ignore synthetic import added when importHelpers: true + firstModuleSpecifier := core.Find(sourceFile.Imports(), func(n *ast.Node) bool { + return ast.IsStringLiteral(n) && !ast.NodeIsSynthesized(n.Parent) + }) + if firstModuleSpecifier != nil { + return quotePreferenceFromString(firstModuleSpecifier.AsStringLiteral()) } + return quotePreferenceDouble +} - // If even 2/5 places have a semicolon, the user probably wants semicolons - if withoutSemicolon == 0 { - return true - } - return withSemicolon/withoutSemicolon > 1/nStatementsToObserve +func isNonContextualKeyword(token ast.Kind) bool { + return ast.IsKeywordKind(token) && !ast.IsContextualKeyword(token) } var typeKeywords *collections.Set[ast.Kind] = collections.NewSetFromItems( @@ -731,7 +672,7 @@ func isCompletedNode(n *ast.Node, sourceFile *ast.SourceFile) bool { return isCompletedNode(n.AsCatchClause().Block, sourceFile) case ast.KindNewExpression: - if n.AsNewExpression().Arguments == nil { + if n.ArgumentList() == nil { return true } fallthrough @@ -766,7 +707,7 @@ func isCompletedNode(n *ast.Node, sourceFile *ast.SourceFile) bool { return hasChildOfKind(n, ast.KindCloseParenToken, sourceFile) case ast.KindModuleDeclaration: - return n.AsModuleDeclaration().Body != nil && isCompletedNode(n.AsModuleDeclaration().Body, sourceFile) + return n.Body() != nil && isCompletedNode(n.Body(), sourceFile) case ast.KindIfStatement: if n.AsIfStatement().ElseStatement != nil { @@ -775,7 +716,7 @@ func isCompletedNode(n *ast.Node, sourceFile *ast.SourceFile) bool { return isCompletedNode(n.AsIfStatement().ThenStatement, sourceFile) case ast.KindExpressionStatement: - return isCompletedNode(n.AsExpressionStatement().Expression, sourceFile) || + return isCompletedNode(n.Expression(), sourceFile) || hasChildOfKind(n, ast.KindSemicolonToken, sourceFile) case ast.KindArrayLiteralExpression, @@ -806,7 +747,7 @@ func isCompletedNode(n *ast.Node, sourceFile *ast.SourceFile) bool { if hasChildOfKind(n, ast.KindWhileKeyword, sourceFile) { return nodeEndsWith(n, ast.KindCloseParenToken, sourceFile) } - return isCompletedNode(n.AsDoStatement().Statement, sourceFile) + return isCompletedNode(n.Statement(), sourceFile) case ast.KindTypeQuery: return isCompletedNode(n.AsTypeQueryNode().ExprName, sourceFile) @@ -917,7 +858,7 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // specially by `getSymbolAtLocation`. isModifier := func(node *ast.Node) bool { if ast.IsModifier(node) && (forRename || node.Kind != ast.KindDefaultKeyword) { - return ast.CanHaveModifiers(parent) && slices.Contains(parent.Modifiers().NodeList.Nodes, node) + return ast.CanHaveModifiers(parent) && slices.Contains(parent.ModifierNodes(), node) } switch node.Kind { case ast.KindClassKeyword: @@ -973,7 +914,7 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // export /**/type * from "[|module|]"; // export /**/type * as ... from "[|module|]"; if ast.IsExportDeclaration(parent) && parent.IsTypeOnly() { - if location := getAdjustedLocationForExportDeclaration(parent.Parent.AsExportDeclaration(), forRename); location != nil { + if location := getAdjustedLocationForExportDeclaration(parent.AsExportDeclaration(), forRename); location != nil { return location } } @@ -984,8 +925,8 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... if node.Kind == ast.KindAsKeyword { - if parent.Kind == ast.KindImportSpecifier && parent.AsImportSpecifier().PropertyName != nil || - parent.Kind == ast.KindExportSpecifier && parent.AsExportSpecifier().PropertyName != nil || + if parent.Kind == ast.KindImportSpecifier && parent.PropertyName() != nil || + parent.Kind == ast.KindExportSpecifier && parent.PropertyName() != nil || parent.Kind == ast.KindNamespaceImport || parent.Kind == ast.KindNamespaceExport { return parent.Name() @@ -1022,21 +963,18 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // /**/export default [|name|]; // /**/export = [|name|]; if parent.Kind == ast.KindExportAssignment { - return ast.SkipOuterExpressions(parent.AsExportAssignment().Expression, ast.OEKAll) + return ast.SkipOuterExpressions(parent.Expression(), ast.OEKAll) } } // import name = /**/require("[|module|]"); if node.Kind == ast.KindRequireKeyword && parent.Kind == ast.KindExternalModuleReference { - return parent.AsExternalModuleReference().Expression + return parent.Expression() } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; if node.Kind == ast.KindFromKeyword { - if parent.Kind == ast.KindImportDeclaration && parent.AsImportDeclaration().ModuleSpecifier != nil { - return parent.AsImportDeclaration().ModuleSpecifier - } - if parent.Kind == ast.KindImportDeclaration && parent.AsExportDeclaration().ModuleSpecifier != nil { - return parent.AsExportDeclaration().ModuleSpecifier + if (parent.Kind == ast.KindImportDeclaration || parent.Kind == ast.KindExportDeclaration) && parent.ModuleSpecifier() != nil { + return parent.ModuleSpecifier() } } // class ... /**/extends [|name|] ... @@ -1136,7 +1074,7 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // for (... /**/of [|name|]) if node.Kind == ast.KindInKeyword && parent.Kind == ast.KindForInStatement || node.Kind == ast.KindOfKeyword && parent.Kind == ast.KindForOfStatement { - return ast.SkipOuterExpressions(parent.AsForInOrOfStatement().Expression, ast.OEKAll) + return ast.SkipOuterExpressions(parent.Expression(), ast.OEKAll) } } @@ -1154,9 +1092,7 @@ func getAdjustedLocationForDeclaration(node *ast.Node, forRename bool, sourceFil case ast.KindClassDeclaration, ast.KindFunctionDeclaration: // for class and function declarations, use the `default` modifier // when the declaration is unnamed. - if node.Modifiers() != nil { - return core.Find(node.Modifiers().NodeList.Nodes, func(*ast.Node) bool { return node.Kind == ast.KindDefaultKeyword }) - } + return core.Find(node.ModifierNodes(), func(*ast.Node) bool { return node.Kind == ast.KindDefaultKeyword }) case ast.KindClassExpression: // for class expressions, use the `class` keyword when the class is unnamed return findChildOfKind(node, ast.KindClassKeyword, sourceFile) @@ -1191,11 +1127,11 @@ func getAdjustedLocationForImportDeclaration(node *ast.ImportDeclaration, forRen switch namedBindings.Kind { case ast.KindNamedImports: // do nothing if there is more than one binding - elements := namedBindings.AsNamedImports().Elements - if len(elements.Nodes) != 1 { + elements := namedBindings.Elements() + if len(elements) != 1 { return nil } - return elements.Nodes[0].Name() + return elements[0].Name() case ast.KindNamespaceImport: return namedBindings.Name() @@ -1223,11 +1159,11 @@ func getAdjustedLocationForExportDeclaration(node *ast.ExportDeclaration, forRen switch node.ExportClause.Kind { case ast.KindNamedExports: // do nothing if there is more than one binding - elements := node.ExportClause.AsNamedExports().Elements - if len(elements.Nodes) != 1 { + elements := node.ExportClause.Elements() + if len(elements) != 1 { return nil } - return elements.Nodes[0].Name() + return elements[0].Name() case ast.KindNamespaceExport: return node.ExportClause.Name() } @@ -1240,6 +1176,22 @@ func getAdjustedLocationForExportDeclaration(node *ast.ExportDeclaration, forRen return nil } +func symbolFlagsHaveMeaning(flags ast.SymbolFlags, meaning ast.SemanticMeaning) bool { + if meaning == ast.SemanticMeaningAll { + return true + } + if meaning&ast.SemanticMeaningValue != 0 { + return flags&ast.SymbolFlagsValue != 0 + } + if meaning&ast.SemanticMeaningType != 0 { + return flags&ast.SymbolFlagsType != 0 + } + if meaning&ast.SemanticMeaningNamespace != 0 { + return flags&ast.SymbolFlagsNamespace != 0 + } + return false +} + func getMeaningFromLocation(node *ast.Node) ast.SemanticMeaning { // todo: check if this function needs to be changed for jsdoc updates node = getAdjustedLocation(node, false /*forRename*/, nil) @@ -1447,8 +1399,8 @@ func getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol *ast.Symb func getTargetLabel(referenceNode *ast.Node, labelName string) *ast.Node { // todo: rewrite as `ast.FindAncestor` for referenceNode != nil { - if referenceNode.Kind == ast.KindLabeledStatement && referenceNode.AsLabeledStatement().Label.Text() == labelName { - return referenceNode.AsLabeledStatement().Label + if referenceNode.Kind == ast.KindLabeledStatement && referenceNode.Label().Text() == labelName { + return referenceNode.Label() } referenceNode = referenceNode.Parent } @@ -1659,6 +1611,13 @@ func getChildrenFromNonJSDocNode(node *ast.Node, sourceFile *ast.SourceFile) []* childNodes = append(childNodes, child) return false }) + + // If the node has no children, don't scan for tokens. + // This prevents creating tokens for leaf nodes' own text. + if len(childNodes) == 0 { + return nil + } + var children []*ast.Node pos := node.Pos() for _, child := range childNodes { @@ -1699,20 +1658,24 @@ func getContainingObjectLiteralElementWorker(node *ast.Node) *ast.Node { switch node.Kind { case ast.KindStringLiteral, ast.KindNoSubstitutionTemplateLiteral, ast.KindNumericLiteral: if node.Parent.Kind == ast.KindComputedPropertyName { - if ast.IsObjectLiteralElement(node.Parent.Parent) { + if isObjectLiteralOrJsxElement(node.Parent.Parent) { return node.Parent.Parent } return nil } fallthrough case ast.KindIdentifier: - if ast.IsObjectLiteralElement(node.Parent) && (node.Parent.Parent.Kind == ast.KindObjectLiteralExpression || node.Parent.Parent.Kind == ast.KindJsxAttributes) && node.Parent.Name() == node { + if isObjectLiteralOrJsxElement(node.Parent) && (node.Parent.Parent.Kind == ast.KindObjectLiteralExpression || node.Parent.Parent.Kind == ast.KindJsxAttributes) && node.Parent.Name() == node { return node.Parent } } return nil } +func isObjectLiteralOrJsxElement(node *ast.Node) bool { + return ast.IsObjectLiteralElement(node) || ast.IsJsxAttribute(node) || ast.IsJsxSpreadAttribute(node) +} + // Return a function that returns true if the given node has not been seen func nodeSeenTracker() func(*ast.Node) bool { var seen collections.Set[*ast.Node] @@ -1720,3 +1683,16 @@ func nodeSeenTracker() func(*ast.Node) bool { return seen.AddIfAbsent(node) } } + +// FindAllReferences.toContextSpan +func toContextRange(textRange *core.TextRange, contextFile *ast.SourceFile, context *ast.Node) *core.TextRange { + if context == nil { + return textRange + } + // !!! isContextWithStartAndEndNode + contextRange := getRangeOfNode(context, contextFile, nil /*endNode*/) + if contextRange.Pos() != textRange.Pos() || contextRange.End() != textRange.End() { + return &contextRange + } + return nil +} diff --git a/internal/lsp/lsproto/_generate/fetchModel.mts b/internal/lsp/lsproto/_generate/fetchModel.mts index cc31a5a41f..f37b224857 100644 --- a/internal/lsp/lsproto/_generate/fetchModel.mts +++ b/internal/lsp/lsproto/_generate/fetchModel.mts @@ -14,10 +14,16 @@ const metaModelURL = `https://raw.githubusercontent.com/microsoft/vscode-languag const metaModelSchemaURL = `https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/${hash}/tools/src/metaModel.ts`; const metaModelResponse = await fetch(metaModelURL); -let metaModel = await metaModelResponse.text(); -metaModel = metaModel.replaceAll('"_InitializeParams"', '"InitializeParamsBase"'); +const metaModel = await metaModelResponse.text(); fs.writeFileSync(metaModelPath, metaModel); const metaModelSchemaResponse = await fetch(metaModelSchemaURL); -const metaModelSchema = await metaModelSchemaResponse.text(); +let metaModelSchema = await metaModelSchemaResponse.text(); + +// Patch the schema to add omitzeroValue property to Property type +metaModelSchema = metaModelSchema.replace( + /(\t \* Whether the property is deprecated or not\. If deprecated\n\t \* the property contains the deprecation message\.\n\t \*\/\n\tdeprecated\?: string;)\n}/m, + `$1\n\n\t/**\n\t * Whether this property uses omitzero without being a pointer.\n\t * Custom extension for special value types.\n\t */\n\tomitzeroValue?: boolean;\n}`, +); + fs.writeFileSync(metaModelSchemaPath, metaModelSchema); diff --git a/internal/lsp/lsproto/_generate/generate.mts b/internal/lsp/lsproto/_generate/generate.mts index 1828abd62f..43a78e3a29 100644 --- a/internal/lsp/lsproto/_generate/generate.mts +++ b/internal/lsp/lsproto/_generate/generate.mts @@ -10,6 +10,7 @@ import type { Notification, OrType, Property, + ReferenceType, Request, Structure, Type, @@ -28,8 +29,232 @@ if (!fs.existsSync(metaModelPath)) { const model: MetaModel = JSON.parse(fs.readFileSync(metaModelPath, "utf-8")); -// Preprocess the model to inline extends/mixins contents -function preprocessModel() { +// Custom structures to add to the model +const customStructures: Structure[] = [ + { + name: "InitializationOptions", + properties: [ + { + name: "disablePushDiagnostics", + type: { kind: "base", name: "boolean" }, + optional: true, + documentation: "DisablePushDiagnostics disables automatic pushing of diagnostics to the client.", + }, + ], + documentation: "InitializationOptions contains user-provided initialization options.", + }, + { + name: "ExportInfoMapKey", + properties: [ + { + name: "symbolName", + type: { kind: "base", name: "string" }, + documentation: "The symbol name.", + omitzeroValue: true, + }, + { + name: "symbolId", + type: { kind: "reference", name: "uint64" }, + documentation: "The symbol ID.", + omitzeroValue: true, + }, + { + name: "ambientModuleName", + type: { kind: "base", name: "string" }, + documentation: "The ambient module name.", + omitzeroValue: true, + }, + { + name: "moduleFile", + type: { kind: "base", name: "string" }, + documentation: "The module file path.", + omitzeroValue: true, + }, + ], + documentation: "ExportInfoMapKey uniquely identifies an export for auto-import purposes.", + }, + { + name: "AutoImportData", + properties: [ + { + name: "exportName", + type: { kind: "base", name: "string" }, + documentation: "The name of the property or export in the module's symbol table. Differs from the completion name in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default.", + omitzeroValue: true, + }, + { + name: "exportMapKey", + type: { kind: "reference", name: "ExportInfoMapKey" }, + documentation: "The export map key for this auto-import.", + omitzeroValue: true, + }, + { + name: "moduleSpecifier", + type: { kind: "base", name: "string" }, + documentation: "The module specifier for this auto-import.", + omitzeroValue: true, + }, + { + name: "fileName", + type: { kind: "base", name: "string" }, + documentation: "The file name declaring the export's module symbol, if it was an external module.", + omitzeroValue: true, + }, + { + name: "ambientModuleName", + type: { kind: "base", name: "string" }, + documentation: "The module name (with quotes stripped) of the export's module symbol, if it was an ambient module.", + omitzeroValue: true, + }, + { + name: "isPackageJsonImport", + type: { kind: "base", name: "boolean" }, + documentation: "True if the export was found in the package.json AutoImportProvider.", + omitzeroValue: true, + }, + ], + documentation: "AutoImportData contains information about an auto-import suggestion.", + }, + { + name: "CompletionItemData", + properties: [ + { + name: "fileName", + type: { kind: "base", name: "string" }, + documentation: "The file name where the completion was requested.", + omitzeroValue: true, + }, + { + name: "position", + type: { kind: "base", name: "integer" }, + documentation: "The position where the completion was requested.", + omitzeroValue: true, + }, + { + name: "source", + type: { kind: "base", name: "string" }, + documentation: "Special source value for disambiguation.", + omitzeroValue: true, + }, + { + name: "name", + type: { kind: "base", name: "string" }, + documentation: "The name of the completion item.", + omitzeroValue: true, + }, + { + name: "autoImport", + type: { kind: "reference", name: "AutoImportData" }, + optional: true, + documentation: "Auto-import data for this completion item.", + }, + ], + documentation: "CompletionItemData is preserved on a CompletionItem between CompletionRequest and CompletionResolveRequest.", + }, +]; + +// Track which custom Data structures were declared explicitly +const explicitDataStructures = new Set(customStructures.map(s => s.name)); + +// Global variable to track the RegisterOptions union type for special naming +let registerOptionsUnionType: OrType | undefined; + +// Patch and preprocess the model +function patchAndPreprocessModel() { + // Track which Data types we need to create as placeholders + const neededDataStructures = new Set(); + + // Collect all registration option types from requests and notifications + const registrationOptionTypes: Type[] = []; + for (const request of [...model.requests, ...model.notifications]) { + if (request.registrationOptions) { + registrationOptionTypes.push(request.registrationOptions); + } + } + + // Create synthetic structures for "and" types in registration options + const syntheticStructures: Structure[] = []; + for (let i = 0; i < registrationOptionTypes.length; i++) { + const regOptType = registrationOptionTypes[i]; + if (regOptType.kind === "and") { + // Find which request/notification this registration option belongs to + const owner = [...model.requests, ...model.notifications].find(r => r.registrationOptions === regOptType); + if (!owner) { + throw new Error("Could not find owner for 'and' type registration option"); + } + + // Determine the proper name based on the typeName or method + let structureName: string; + if (owner.typeName) { + // Use typeName as base: "ColorPresentationRequest" -> "ColorPresentationRegistrationOptions" + structureName = owner.typeName.replace(/Request$/, "").replace(/Notification$/, "") + "RegistrationOptions"; + } + else { + // Fall back to method: "textDocument/colorPresentation" -> "ColorPresentationRegistrationOptions" + const methodParts = owner.method.split("/"); + const lastPart = methodParts[methodParts.length - 1]; + structureName = titleCase(lastPart) + "RegistrationOptions"; + } + + // Extract all reference types from the "and" + const refTypes = regOptType.items.filter((item): item is ReferenceType => item.kind === "reference"); + + // Create a synthetic structure that combines all the referenced structures + syntheticStructures.push({ + name: structureName, + properties: [], + extends: refTypes, + documentation: `Registration options for ${owner.method}.`, + }); + + // Replace the "and" type with a reference to the synthetic structure + registrationOptionTypes[i] = { kind: "reference", name: structureName }; + } + } + + for (const structure of model.structures) { + for (const prop of structure.properties) { + // Replace initializationOptions type with custom InitializationOptions + if (prop.name === "initializationOptions" && prop.type.kind === "reference" && prop.type.name === "LSPAny") { + prop.type = { kind: "reference", name: "InitializationOptions" }; + } + + // Replace Data *any fields with custom typed Data fields + if (prop.name === "data" && prop.type.kind === "reference" && prop.type.name === "LSPAny") { + const customDataType = `${structure.name}Data`; + prop.type = { kind: "reference", name: customDataType }; + + // If we haven't explicitly declared this Data structure, we'll need a placeholder + if (!explicitDataStructures.has(customDataType)) { + neededDataStructures.add(customDataType); + } + } + + // Replace registerOptions type with a custom RegisterOptions type + if (prop.name === "registerOptions" && prop.type.kind === "reference" && prop.type.name === "LSPAny") { + // Create a union type and save it for special naming + if (registrationOptionTypes.length > 0) { + registerOptionsUnionType = { kind: "or", items: registrationOptionTypes }; + prop.type = registerOptionsUnionType; + } + } + } + } + + // Create placeholder structures for Data types that weren't explicitly declared + for (const dataTypeName of neededDataStructures) { + const baseName = dataTypeName.replace(/Data$/, ""); + customStructures.push({ + name: dataTypeName, + properties: [], + documentation: `${dataTypeName} is a placeholder for custom data preserved on a ${baseName}.`, + }); + } + + // Add custom structures and synthetic structures to the model + model.structures.push(...customStructures, ...syntheticStructures); + + // Build structure map for preprocessing const structureMap = new Map(); for (const structure of model.structures) { structureMap.set(structure.name, structure); @@ -72,11 +297,18 @@ function preprocessModel() { structure.properties = Array.from(propertyMap.values()); structure.extends = undefined; structure.mixins = undefined; + + // Remove experimental properties from ServerCapabilities and ClientCapabilities + if (structure.name === "ServerCapabilities" || structure.name === "ClientCapabilities") { + structure.properties = structure.properties.filter(p => p.name !== "experimental"); + } } + + // Remove _InitializeParams structure after flattening (it was only needed for inheritance) + model.structures = model.structures.filter(s => s.name !== "_InitializeParams"); } -// Preprocess the model before proceeding -preprocessModel(); +patchAndPreprocessModel(); interface GoType { name: string; @@ -239,6 +471,20 @@ function flattenOrTypes(types: Type[]): Type[] { return Array.from(flattened); } +function pluralize(name: string): string { + // Handle common irregular plurals and special cases + if ( + name.endsWith("s") || name.endsWith("x") || name.endsWith("z") || + name.endsWith("ch") || name.endsWith("sh") + ) { + return name + "es"; + } + if (name.endsWith("y") && name.length > 1 && !"aeiou".includes(name[name.length - 2])) { + return name.slice(0, -1) + "ies"; + } + return name + "s"; +} + function handleOrType(orType: OrType): GoType { // First, flatten any nested OR types const types = flattenOrTypes(orType.items); @@ -272,7 +518,7 @@ function handleOrType(orType: OrType): GoType { type.kind === "array" && (type.element.kind === "reference" || type.element.kind === "base") ) { - return `${titleCase(type.element.name)}s`; + return pluralize(titleCase(type.element.name)); } else if (type.kind === "array") { // Handle more complex array types @@ -355,6 +601,20 @@ function handleOrType(orType: OrType): GoType { unionTypeName = memberNames.join("Or"); } + // Special case: if this is the RegisterOptions union, use a custom name + // and slice off the common suffix "RegistrationOptions" from member names + if (orType === registerOptionsUnionType) { + unionTypeName = "RegisterOptions"; + + // Remove the common suffix "RegistrationOptions" from all member names + memberNames = memberNames.map(name => { + if (name.endsWith("RegistrationOptions")) { + return name.slice(0, -"RegistrationOptions".length); + } + return name; + }); + } + if (containedNull) { unionTypeName += "OrNull"; } @@ -376,6 +636,7 @@ const typeAliasOverrides = new Map([ ["LSPAny", { name: "any", needsPointer: false }], ["LSPArray", { name: "[]any", needsPointer: false }], ["LSPObject", { name: "map[string]any", needsPointer: false }], + ["uint64", { name: "uint64", needsPointer: false }], ]); /** @@ -401,6 +662,7 @@ function collectTypeDefinitions() { "VersionedNotebookDocumentIdentifier", "VersionedTextDocumentIdentifier", "OptionalVersionedTextDocumentIdentifier", + "ExportInfoMapKey", ]); // Process all structures @@ -471,6 +733,141 @@ function generateCode() { parts.push(s + "\n"); } + function generateResolvedStruct(structure: Structure, indent: string = "\t"): string[] { + const lines: string[] = []; + + for (const prop of structure.properties) { + // Add property documentation if it exists + if (prop.documentation) { + const propDoc = formatDocumentation(prop.documentation); + if (propDoc) { + // Add the documentation with proper indentation + for (const line of propDoc.split("\n").filter(l => l)) { + lines.push(`${indent}${line}`); + } + } + } + + const type = resolveType(prop.type); + + // For reference types that are structures, use a named resolved type + if (prop.type.kind === "reference") { + const refStructure = model.structures.find(s => s.name === type.name); + if (refStructure) { + // Use a named type for the resolved version + lines.push(`${indent}${titleCase(prop.name)} Resolved${type.name} \`json:"${prop.name},omitzero"\``); + continue; + } + } + + // For other types (primitives, enums, arrays, etc.), use the type directly (no pointer) + const goType = type.name; + lines.push(`${indent}${titleCase(prop.name)} ${goType} \`json:"${prop.name},omitzero"\``); + } + + return lines; + } + + function generateResolveConversion(structure: Structure, varName: string, indent: string): string[] { + const lines: string[] = []; + + for (const prop of structure.properties) { + const type = resolveType(prop.type); + const fieldName = titleCase(prop.name); + const accessPath = `${varName}.${fieldName}`; + + // For reference types that are structures, call the resolve function + if (prop.type.kind === "reference") { + const refStructure = model.structures.find(s => s.name === type.name); + if (refStructure) { + // Use lowercase (unexported) function name for helper functions + lines.push(`${indent}${fieldName}: resolve${type.name}(${accessPath}),`); + continue; + } + } + + // For other types, dereference if pointer + if (prop.optional || type.needsPointer) { + lines.push(`${indent}${fieldName}: derefOr(${accessPath}),`); + } + else { + lines.push(`${indent}${fieldName}: ${accessPath},`); + } + } + + return lines; + } + + function collectStructureDependencies(structure: Structure, visited = new Set()): Structure[] { + if (visited.has(structure.name)) { + return []; + } + visited.add(structure.name); + + const deps: Structure[] = []; + + for (const prop of structure.properties) { + if (prop.type.kind === "reference") { + const refStructure = model.structures.find(s => s.name === (prop.type as ReferenceType).name); + if (refStructure) { + deps.push(...collectStructureDependencies(refStructure, new Set(visited))); + deps.push(refStructure); + } + } + } + + return deps; + } + + function generateResolvedTypeAndHelper(structure: Structure, isMain: boolean = false): string[] { + const lines: string[] = []; + const typeName = `Resolved${structure.name}`; + // Main function is exported, helpers are unexported + const funcName = isMain ? `Resolve${structure.name}` : `resolve${structure.name}`; + + // Generate the resolved type with documentation + if (!isMain) { + // For non-main types, add standard documentation header + if (structure.documentation) { + const typeDoc = formatDocumentation(structure.documentation); + if (typeDoc) { + // Prepend comment explaining this is the resolved version + lines.push(`// ${typeName} is a resolved version of ${structure.name} with all optional fields`); + lines.push(`// converted to non-pointer values for easier access.`); + lines.push(`//`); + // Add the original structure documentation + for (const line of typeDoc.split("\n").filter(l => l)) { + lines.push(line); + } + } + } + else { + // If no documentation, just add a basic comment + lines.push(`// ${typeName} is a resolved version of ${structure.name} with all optional fields`); + lines.push(`// converted to non-pointer values for easier access.`); + } + } + // For main type, documentation is added separately before calling this function + + lines.push(`type ${typeName} struct {`); + lines.push(...generateResolvedStruct(structure, "\t")); + lines.push(`}`); + lines.push(``); + + // Generate the conversion function + lines.push(`func ${funcName}(v *${structure.name}) ${typeName} {`); + lines.push(`\tif v == nil {`); + lines.push(`\t\treturn ${typeName}{}`); + lines.push(`\t}`); + lines.push(`\treturn ${typeName}{`); + lines.push(...generateResolveConversion(structure, "v", "\t\t")); + lines.push(`\t}`); + lines.push(`}`); + lines.push(``); + + return lines; + } + // File header writeLine("// Code generated by generate.mts; DO NOT EDIT."); writeLine(""); @@ -478,6 +875,7 @@ function generateCode() { writeLine(""); writeLine(`import (`); writeLine(`\t"fmt"`); + writeLine(`\t"strings"`); writeLine(""); writeLine(`\t"github.com/go-json-experiment/json"`); writeLine(`\t"github.com/go-json-experiment/json/jsontext"`); @@ -504,9 +902,12 @@ function generateCode() { } const type = resolveType(prop.type); - const goType = prop.optional || type.needsPointer ? `*${type.name}` : type.name; - writeLine(`\t${titleCase(prop.name)} ${goType} \`json:"${prop.name}${prop.optional ? ",omitzero" : ""}"\``); + // For properties marked with omitzeroValue, use value type with omitzero instead of pointer + const useOmitzero = prop.optional || prop.omitzeroValue; + const goType = (prop.optional || type.needsPointer) && !prop.omitzeroValue ? `*${type.name}` : type.name; + + writeLine(`\t${titleCase(prop.name)} ${goType} \`json:"${prop.name}${useOmitzero ? ",omitzero" : ""}"\``); if (includeDocumentation) { writeLine(""); @@ -526,20 +927,37 @@ function generateCode() { writeLine(`\treturn s.TextDocument.Uri`); writeLine(`}`); writeLine(""); + + if (hasTextDocumentPosition(structure)) { + // Generate TextDocumentPosition method + writeLine(`func (s *${structure.name}) TextDocumentPosition() Position {`); + writeLine(`\treturn s.Position`); + writeLine(`}`); + writeLine(""); + } } // Generate UnmarshalJSONFrom method for structure validation - const requiredProps = structure.properties?.filter(p => !p.optional) || []; + // Skip properties marked with omitzeroValue since they're optional by nature + const requiredProps = structure.properties?.filter(p => { + if (p.optional) return false; + if (p.omitzeroValue) return false; + return true; + }) || []; if (requiredProps.length > 0) { writeLine(`\tvar _ json.UnmarshalerFrom = (*${structure.name})(nil)`); writeLine(""); writeLine(`func (s *${structure.name}) UnmarshalJSONFrom(dec *jsontext.Decoder) error {`); - writeLine(`\tvar (`); - for (const prop of requiredProps) { - writeLine(`\t\tseen${titleCase(prop.name)} bool`); + writeLine(`\tconst (`); + for (let i = 0; i < requiredProps.length; i++) { + const prop = requiredProps[i]; + const iotaPrefix = i === 0 ? " uint = 1 << iota" : ""; + writeLine(`\t\tmissing${titleCase(prop.name)}${iotaPrefix}`); } + writeLine(`\t\t_missingLast`); writeLine(`\t)`); + writeLine(`\tmissing := _missingLast - 1`); writeLine(""); writeLine(`\tif k := dec.PeekKind(); k != '{' {`); @@ -559,8 +977,8 @@ function generateCode() { for (const prop of structure.properties) { writeLine(`\t\tcase \`"${prop.name}"\`:`); - if (!prop.optional) { - writeLine(`\t\t\tseen${titleCase(prop.name)} = true`); + if (!prop.optional && !prop.omitzeroValue) { + writeLine(`\t\t\tmissing &^= missing${titleCase(prop.name)}`); } writeLine(`\t\t\tif err := json.UnmarshalDecode(dec, &s.${titleCase(prop.name)}); err != nil {`); writeLine(`\t\t\t\treturn err`); @@ -578,11 +996,15 @@ function generateCode() { writeLine(`\t}`); writeLine(""); + writeLine(`\tif missing != 0 {`); + writeLine(`\t\tvar missingProps []string`); for (const prop of requiredProps) { - writeLine(`\tif !seen${titleCase(prop.name)} {`); - writeLine(`\t\treturn fmt.Errorf("required property '${prop.name}' is missing")`); - writeLine(`\t}`); + writeLine(`\t\tif missing&missing${titleCase(prop.name)} != 0 {`); + writeLine(`\t\t\tmissingProps = append(missingProps, "${prop.name}")`); + writeLine(`\t\t}`); } + writeLine(`\t\treturn fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", "))`); + writeLine(`\t}`); writeLine(""); writeLine(`\treturn nil`); @@ -591,6 +1013,14 @@ function generateCode() { } } + // Helper function to detect if an enum is a bitflag enum + // Hardcoded list of bitflag enums + const bitflagEnums = new Set(["WatchKind"]); + + function isBitflagEnum(enumeration: any): boolean { + return bitflagEnums.has(enumeration.name); + } + // Generate enumerations writeLine("// Enumerations\n"); @@ -619,6 +1049,8 @@ function generateCode() { const enumValues = enumeration.values.map(value => ({ value: String(value.value), + numericValue: Number(value.value), + name: value.name, identifier: `${enumeration.name}${value.name}`, documentation: value.documentation, deprecated: value.deprecated, @@ -644,6 +1076,194 @@ function generateCode() { writeLine(")"); writeLine(""); + + // Generate String() method for non-string enums + if (enumeration.type.name !== "string") { + const isBitflag = isBitflagEnum(enumeration); + + if (isBitflag) { + // Generate bitflag-aware String() method using stringer-style efficiency + const sortedValues = [...enumValues].sort((a, b) => a.numericValue - b.numericValue); + const names = sortedValues.map(v => v.name); + const values = sortedValues.map(v => v.numericValue); + + const nameConst = `_${enumeration.name}_name`; + const indexVar = `_${enumeration.name}_index`; + const combinedNames = names.join(""); + + writeLine(`const ${nameConst} = "${combinedNames}"`); + write(`var ${indexVar} = [...]uint16{0`); + let offset = 0; + for (const name of names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\tif e == 0 {`); + writeLine(`\t\treturn "0"`); + writeLine(`\t}`); + writeLine(`\tvar parts []string`); + for (let i = 0; i < values.length; i++) { + writeLine(`\tif e&${values[i]} != 0 {`); + writeLine(`\t\tparts = append(parts, ${nameConst}[${indexVar}[${i}]:${indexVar}[${i + 1}]])`); + writeLine(`\t}`); + } + writeLine(`\tif len(parts) == 0 {`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`\treturn strings.Join(parts, "|")`); + writeLine(`}`); + writeLine(""); + } + else { + // Generate regular String() method using stringer-style approach + // Split values into runs of contiguous values + const sortedValues = [...enumValues].sort((a, b) => a.numericValue - b.numericValue); + + // Split into runs + const runs: Array<{ names: string[]; values: number[]; }> = []; + let currentRun = { names: [sortedValues[0].name], values: [sortedValues[0].numericValue] }; + + for (let i = 1; i < sortedValues.length; i++) { + if (sortedValues[i].numericValue === sortedValues[i - 1].numericValue + 1) { + currentRun.names.push(sortedValues[i].name); + currentRun.values.push(sortedValues[i].numericValue); + } + else { + runs.push(currentRun); + currentRun = { names: [sortedValues[i].name], values: [sortedValues[i].numericValue] }; + } + } + runs.push(currentRun); + + const nameConst = `_${enumeration.name}_name`; + const indexVar = `_${enumeration.name}_index`; + + if (runs.length === 1) { + // Single contiguous run - simple case + const combinedNames = runs[0].names.join(""); + writeLine(`const ${nameConst} = "${combinedNames}"`); + write(`var ${indexVar} = [...]uint16{0`); + let offset = 0; + for (const name of runs[0].names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + writeLine(""); + + const minVal = runs[0].values[0]; + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\ti := int(e) - ${minVal}`); + // For unsigned types, i can still be negative if e < minVal (due to underflow in conversion) + // So we always need to check both bounds + writeLine(`\tif i < 0 || i >= len(${indexVar})-1 {`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`\treturn ${nameConst}[${indexVar}[i]:${indexVar}[i+1]]`); + writeLine(`}`); + writeLine(""); + } + else if (runs.length <= 10) { + // Multiple runs - use switch statement + let allNames = ""; + const runInfo: Array<{ startOffset: number; endOffset: number; minVal: number; maxVal: number; }> = []; + + for (const run of runs) { + const startOffset = allNames.length; + allNames += run.names.join(""); + const endOffset = allNames.length; + runInfo.push({ + startOffset, + endOffset, + minVal: run.values[0], + maxVal: run.values[run.values.length - 1], + }); + } + + writeLine(`const ${nameConst} = "${allNames}"`); + writeLine(""); + + // Generate index variables for each run + for (let i = 0; i < runs.length; i++) { + write(`var ${indexVar}_${i} = [...]uint16{0`); + let offset = 0; + for (const name of runs[i].names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + } + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\tswitch {`); + + for (let i = 0; i < runs.length; i++) { + const run = runs[i]; + const info = runInfo[i]; + + if (run.values.length === 1) { + writeLine(`\tcase e == ${run.values[0]}:`); + writeLine(`\t\treturn ${nameConst}[${info.startOffset}:${info.endOffset}]`); + } + else { + if (info.minVal === 0 && baseType.startsWith("uint")) { + writeLine(`\tcase e <= ${info.maxVal}:`); + } + else if (info.minVal === 0) { + writeLine(`\tcase 0 <= e && e <= ${info.maxVal}:`); + } + else { + writeLine(`\tcase ${info.minVal} <= e && e <= ${info.maxVal}:`); + } + writeLine(`\t\ti := int(e) - ${info.minVal}`); + writeLine(`\t\treturn ${nameConst}[${info.startOffset}+${indexVar}_${i}[i]:${info.startOffset}+${indexVar}_${i}[i+1]]`); + } + } + + writeLine(`\tdefault:`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`}`); + writeLine(""); + } + else { + // Too many runs - use a map + let allNames = ""; + const valueMap: Array<{ value: number; startOffset: number; endOffset: number; }> = []; + + for (const run of runs) { + for (let i = 0; i < run.names.length; i++) { + const startOffset = allNames.length; + allNames += run.names[i]; + const endOffset = allNames.length; + valueMap.push({ value: run.values[i], startOffset, endOffset }); + } + } + + writeLine(`const ${nameConst} = "${allNames}"`); + writeLine(""); + writeLine(`var ${enumeration.name}_map = map[${enumeration.name}]string{`); + for (const entry of valueMap) { + writeLine(`\t${entry.value}: ${nameConst}[${entry.startOffset}:${entry.endOffset}],`); + } + writeLine(`}`); + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\tif str, ok := ${enumeration.name}_map[e]; ok {`); + writeLine(`\t\treturn str`); + writeLine(`\t}`); + writeLine(`\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`}`); + writeLine(""); + } + } + } } const requestsAndNotifications: (Request | Notification)[] = [...model.requests, ...model.notifications]; @@ -682,6 +1302,36 @@ function generateCode() { writeLine("}"); writeLine(""); + // Generate unmarshalResult function + writeLine("func unmarshalResult(method Method, data []byte) (any, error) {"); + writeLine("\tswitch method {"); + + // Only requests have results, not notifications + for (const request of model.requests) { + const methodName = methodNameIdentifier(request.method); + + if (!("result" in request)) { + continue; + } + + let responseTypeName: string; + if (request.typeName && request.typeName.endsWith("Request")) { + responseTypeName = request.typeName.replace(/Request$/, "Response"); + } + else { + responseTypeName = `${methodName}Response`; + } + + writeLine(`\tcase Method${methodName}:`); + writeLine(`\t\treturn unmarshalValue[${responseTypeName}](data)`); + } + + writeLine("\tdefault:"); + writeLine(`\t\treturn unmarshalAny(data)`); + writeLine("\t}"); + writeLine("}"); + writeLine(""); + writeLine("// Methods"); writeLine("const ("); for (const request of requestsAndNotifications) { @@ -877,18 +1527,67 @@ function generateCode() { writeLine(""); } + // Generate resolved capabilities + const clientCapsStructure = model.structures.find(s => s.name === "ClientCapabilities"); + if (clientCapsStructure) { + writeLine("// Helper function for dereferencing pointers with zero value fallback"); + writeLine("func derefOr[T any](v *T) T {"); + writeLine("\tif v != nil {"); + writeLine("\t\treturn *v"); + writeLine("\t}"); + writeLine("\tvar zero T"); + writeLine("\treturn zero"); + writeLine("}"); + writeLine(""); + + // Collect all dependent structures and generate their resolved types + const deps = collectStructureDependencies(clientCapsStructure); + const uniqueDeps = Array.from(new Map(deps.map(d => [d.name, d])).values()); + + for (const dep of uniqueDeps) { + const depLines = generateResolvedTypeAndHelper(dep, false); + for (const line of depLines) { + writeLine(line); + } + } + + // Generate the main ResolvedClientCapabilities type and function + writeLine("// ResolvedClientCapabilities is a version of ClientCapabilities where all nested"); + writeLine("// fields are values (not pointers), making it easier to access deeply nested capabilities."); + writeLine("// Use ResolveClientCapabilities to convert from ClientCapabilities."); + if (clientCapsStructure.documentation) { + writeLine("//"); + const typeDoc = formatDocumentation(clientCapsStructure.documentation); + for (const line of typeDoc.split("\n").filter(l => l)) { + writeLine(line); + } + } + const mainLines = generateResolvedTypeAndHelper(clientCapsStructure, true); + for (const line of mainLines) { + writeLine(line); + } + } + return parts.join(""); } -function hasTextDocumentURI(structure: Structure) { +function hasSomeProp(structure: Structure, propName: string, propTypeName: string) { return structure.properties?.some(p => !p.optional && - p.name === "textDocument" && + p.name === propName && p.type.kind === "reference" && - p.type.name === "TextDocumentIdentifier" + p.type.name === propTypeName ); } +function hasTextDocumentURI(structure: Structure) { + return hasSomeProp(structure, "textDocument", "TextDocumentIdentifier"); +} + +function hasTextDocumentPosition(structure: Structure) { + return hasSomeProp(structure, "position", "Position"); +} + /** * Main function */ diff --git a/internal/lsp/lsproto/_generate/metaModelSchema.mts b/internal/lsp/lsproto/_generate/metaModelSchema.mts index 3b4091e54c..89f964bfba 100644 --- a/internal/lsp/lsproto/_generate/metaModelSchema.mts +++ b/internal/lsp/lsproto/_generate/metaModelSchema.mts @@ -319,6 +319,12 @@ export type Property = { * the property contains the deprecation message. */ deprecated?: string; + + /** + * Whether this property uses omitzero without being a pointer. + * Custom extension for special value types. + */ + omitzeroValue?: boolean; }; /** diff --git a/internal/lsp/lsproto/jsonrpc.go b/internal/lsp/lsproto/jsonrpc.go index d78894e824..19d75ac8ad 100644 --- a/internal/lsp/lsproto/jsonrpc.go +++ b/internal/lsp/lsproto/jsonrpc.go @@ -105,8 +105,10 @@ func (m *Message) UnmarshalJSON(data []byte) error { Method Method `json:"method"` ID *ID `json:"id,omitzero"` Params jsontext.Value `json:"params"` - Result any `json:"result,omitzero"` - Error *ResponseError `json:"error,omitzero"` + // We don't have a method in the response, so we have no idea what to decode. + // Store the raw text and let the caller decode it. + Result jsontext.Value `json:"result,omitzero"` + Error *ResponseError `json:"error,omitzero"` } if err := json.Unmarshal(data, &raw); err != nil { return fmt.Errorf("%w: %w", ErrInvalidRequest, err) @@ -114,10 +116,9 @@ func (m *Message) UnmarshalJSON(data []byte) error { if raw.ID != nil && raw.Method == "" { m.Kind = MessageKindResponse m.msg = &ResponseMessage{ - JSONRPC: raw.JSONRPC, - ID: raw.ID, - Result: raw.Result, - Error: raw.Error, + ID: raw.ID, + Result: raw.Result, + Error: raw.Error, } return nil } @@ -138,10 +139,9 @@ func (m *Message) UnmarshalJSON(data []byte) error { } m.msg = &RequestMessage{ - JSONRPC: raw.JSONRPC, - ID: raw.ID, - Method: raw.Method, - Params: params, + ID: raw.ID, + Method: raw.Method, + Params: params, } return nil @@ -151,14 +151,6 @@ func (m *Message) MarshalJSON() ([]byte, error) { return json.Marshal(m.msg) } -func NewNotificationMessage(method Method, params any) *RequestMessage { - return &RequestMessage{ - JSONRPC: JSONRPCVersion{}, - Method: method, - Params: params, - } -} - type RequestMessage struct { JSONRPC JSONRPCVersion `json:"jsonrpc"` ID *ID `json:"id,omitzero"` @@ -166,14 +158,6 @@ type RequestMessage struct { Params any `json:"params,omitzero"` } -func NewRequestMessage(method Method, id *ID, params any) *RequestMessage { - return &RequestMessage{ - ID: id, - Method: method, - Params: params, - } -} - func (r *RequestMessage) Message() *Message { return &Message{ Kind: MessageKindRequest, diff --git a/internal/lsp/lsproto/lsp.go b/internal/lsp/lsproto/lsp.go index dd172077c2..0484e88e97 100644 --- a/internal/lsp/lsproto/lsp.go +++ b/internal/lsp/lsproto/lsp.go @@ -1,13 +1,13 @@ package lsproto import ( + "context" "fmt" "net/url" "strings" "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" - "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -15,7 +15,10 @@ type DocumentUri string // !!! func (uri DocumentUri) FileName() string { if strings.HasPrefix(string(uri), "file://") { - parsed := core.Must(url.Parse(string(uri))) + parsed, err := url.Parse(string(uri)) + if err != nil { + panic(fmt.Sprintf("invalid file URI: %s", uri)) + } if parsed.Host != "" { return "//" + parsed.Host + parsed.Path } @@ -58,6 +61,11 @@ type HasTextDocumentURI interface { TextDocumentURI() DocumentUri } +type HasTextDocumentPosition interface { + HasTextDocumentURI + TextDocumentPosition() Position +} + type URI string // !!! type Method string @@ -70,6 +78,14 @@ func unmarshalPtrTo[T any](data []byte) (*T, error) { return &v, nil } +func unmarshalValue[T any](data []byte) (T, error) { + var v T + if err := json.Unmarshal(data, &v); err != nil { + return *new(T), fmt.Errorf("failed to unmarshal %T: %w", (*T)(nil), err) + } + return v, nil +} + func unmarshalAny(data []byte) (any, error) { var v any if err := json.Unmarshal(data, &v); err != nil { @@ -128,11 +144,43 @@ type RequestInfo[Params, Resp any] struct { Method Method } +func (info RequestInfo[Params, Resp]) UnmarshalResult(result any) (Resp, error) { + if r, ok := result.(Resp); ok { + return r, nil + } + + raw, ok := result.(jsontext.Value) + if !ok { + return *new(Resp), fmt.Errorf("expected jsontext.Value, got %T", result) + } + + r, err := unmarshalResult(info.Method, raw) + if err != nil { + return *new(Resp), err + } + return r.(Resp), nil +} + +func (info RequestInfo[Params, Resp]) NewRequestMessage(id *ID, params Params) *RequestMessage { + return &RequestMessage{ + ID: id, + Method: info.Method, + Params: params, + } +} + type NotificationInfo[Params any] struct { _ [0]Params Method Method } +func (info NotificationInfo[Params]) NewNotificationMessage(params Params) *RequestMessage { + return &RequestMessage{ + Method: info.Method, + Params: params, + } +} + type Null struct{} func (Null) UnmarshalJSONFrom(dec *jsontext.Decoder) error { @@ -149,3 +197,25 @@ func (Null) UnmarshalJSONFrom(dec *jsontext.Decoder) error { func (Null) MarshalJSONTo(enc *jsontext.Encoder) error { return enc.WriteToken(jsontext.Null) } + +type clientCapabilitiesKey struct{} + +func WithClientCapabilities(ctx context.Context, caps *ResolvedClientCapabilities) context.Context { + return context.WithValue(ctx, clientCapabilitiesKey{}, caps) +} + +func GetClientCapabilities(ctx context.Context) *ResolvedClientCapabilities { + if caps, _ := ctx.Value(clientCapabilitiesKey{}).(*ResolvedClientCapabilities); caps != nil { + return caps + } + return &ResolvedClientCapabilities{} +} + +// PreferredMarkupKind returns the first (most preferred) markup kind from the given formats, +// or MarkupKindPlainText if the slice is empty. +func PreferredMarkupKind(formats []MarkupKind) MarkupKind { + if len(formats) > 0 { + return formats[0] + } + return MarkupKindPlainText +} diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index 04892d51b9..8c5585ee62 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -4,6 +4,7 @@ package lsproto import ( "fmt" + "strings" "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" @@ -32,13 +33,19 @@ func (s *ImplementationParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *ImplementationParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*ImplementationParams)(nil) func (s *ImplementationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -54,12 +61,12 @@ func (s *ImplementationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -80,11 +87,15 @@ func (s *ImplementationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -101,10 +112,12 @@ type Location struct { var _ json.UnmarshalerFrom = (*Location)(nil) func (s *Location) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenRange bool + const ( + missingUri uint = 1 << iota + missingRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -120,12 +133,12 @@ func (s *Location) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -138,11 +151,15 @@ func (s *Location) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -163,7 +180,11 @@ type ImplementationRegistrationOptions struct { var _ json.UnmarshalerFrom = (*ImplementationRegistrationOptions)(nil) func (s *ImplementationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -179,7 +200,7 @@ func (s *ImplementationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -200,8 +221,12 @@ func (s *ImplementationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -226,13 +251,19 @@ func (s *TypeDefinitionParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *TypeDefinitionParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*TypeDefinitionParams)(nil) func (s *TypeDefinitionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -248,12 +279,12 @@ func (s *TypeDefinitionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -274,11 +305,15 @@ func (s *TypeDefinitionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -299,7 +334,11 @@ type TypeDefinitionRegistrationOptions struct { var _ json.UnmarshalerFrom = (*TypeDefinitionRegistrationOptions)(nil) func (s *TypeDefinitionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -315,7 +354,7 @@ func (s *TypeDefinitionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -336,8 +375,12 @@ func (s *TypeDefinitionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -356,10 +399,12 @@ type WorkspaceFolder struct { var _ json.UnmarshalerFrom = (*WorkspaceFolder)(nil) func (s *WorkspaceFolder) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenName bool + const ( + missingUri uint = 1 << iota + missingName + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -375,12 +420,12 @@ func (s *WorkspaceFolder) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } @@ -393,11 +438,15 @@ func (s *WorkspaceFolder) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenName { - return fmt.Errorf("required property 'name' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -412,7 +461,11 @@ type DidChangeWorkspaceFoldersParams struct { var _ json.UnmarshalerFrom = (*DidChangeWorkspaceFoldersParams)(nil) func (s *DidChangeWorkspaceFoldersParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenEvent bool + const ( + missingEvent uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -428,7 +481,7 @@ func (s *DidChangeWorkspaceFoldersParams) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"event"`: - seenEvent = true + missing &^= missingEvent if err := json.UnmarshalDecode(dec, &s.Event); err != nil { return err } @@ -441,8 +494,12 @@ func (s *DidChangeWorkspaceFoldersParams) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenEvent { - return fmt.Errorf("required property 'event' is missing") + if missing != 0 { + var missingProps []string + if missing&missingEvent != 0 { + missingProps = append(missingProps, "event") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -456,7 +513,11 @@ type ConfigurationParams struct { var _ json.UnmarshalerFrom = (*ConfigurationParams)(nil) func (s *ConfigurationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItems bool + const ( + missingItems uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -472,7 +533,7 @@ func (s *ConfigurationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -485,8 +546,12 @@ func (s *ConfigurationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -512,7 +577,11 @@ func (s *DocumentColorParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentColorParams)(nil) func (s *DocumentColorParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -536,7 +605,7 @@ func (s *DocumentColorParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -549,8 +618,12 @@ func (s *DocumentColorParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -568,10 +641,12 @@ type ColorInformation struct { var _ json.UnmarshalerFrom = (*ColorInformation)(nil) func (s *ColorInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenColor bool + const ( + missingRange uint = 1 << iota + missingColor + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -587,12 +662,12 @@ func (s *ColorInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"color"`: - seenColor = true + missing &^= missingColor if err := json.UnmarshalDecode(dec, &s.Color); err != nil { return err } @@ -605,11 +680,15 @@ func (s *ColorInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenColor { - return fmt.Errorf("required property 'color' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingColor != 0 { + missingProps = append(missingProps, "color") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -630,7 +709,11 @@ type DocumentColorRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentColorRegistrationOptions)(nil) func (s *DocumentColorRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -646,7 +729,7 @@ func (s *DocumentColorRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -667,8 +750,12 @@ func (s *DocumentColorRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -700,11 +787,13 @@ func (s *ColorPresentationParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*ColorPresentationParams)(nil) func (s *ColorPresentationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenColor bool - seenRange bool + const ( + missingTextDocument uint = 1 << iota + missingColor + missingRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -728,17 +817,17 @@ func (s *ColorPresentationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"color"`: - seenColor = true + missing &^= missingColor if err := json.UnmarshalDecode(dec, &s.Color); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -751,14 +840,18 @@ func (s *ColorPresentationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenColor { - return fmt.Errorf("required property 'color' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingColor != 0 { + missingProps = append(missingProps, "color") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -783,7 +876,11 @@ type ColorPresentation struct { var _ json.UnmarshalerFrom = (*ColorPresentation)(nil) func (s *ColorPresentation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLabel bool + const ( + missingLabel uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -799,7 +896,7 @@ func (s *ColorPresentation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"label"`: - seenLabel = true + missing &^= missingLabel if err := json.UnmarshalDecode(dec, &s.Label); err != nil { return err } @@ -820,8 +917,12 @@ func (s *ColorPresentation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLabel { - return fmt.Errorf("required property 'label' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLabel != 0 { + missingProps = append(missingProps, "label") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -841,7 +942,11 @@ type TextDocumentRegistrationOptions struct { var _ json.UnmarshalerFrom = (*TextDocumentRegistrationOptions)(nil) func (s *TextDocumentRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -857,7 +962,7 @@ func (s *TextDocumentRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -870,8 +975,12 @@ func (s *TextDocumentRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -897,7 +1006,11 @@ func (s *FoldingRangeParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*FoldingRangeParams)(nil) func (s *FoldingRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -921,7 +1034,7 @@ func (s *FoldingRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -934,8 +1047,12 @@ func (s *FoldingRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -974,10 +1091,12 @@ type FoldingRange struct { var _ json.UnmarshalerFrom = (*FoldingRange)(nil) func (s *FoldingRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenStartLine bool - seenEndLine bool + const ( + missingStartLine uint = 1 << iota + missingEndLine + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -993,7 +1112,7 @@ func (s *FoldingRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"startLine"`: - seenStartLine = true + missing &^= missingStartLine if err := json.UnmarshalDecode(dec, &s.StartLine); err != nil { return err } @@ -1002,7 +1121,7 @@ func (s *FoldingRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"endLine"`: - seenEndLine = true + missing &^= missingEndLine if err := json.UnmarshalDecode(dec, &s.EndLine); err != nil { return err } @@ -1027,11 +1146,15 @@ func (s *FoldingRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenStartLine { - return fmt.Errorf("required property 'startLine' is missing") - } - if !seenEndLine { - return fmt.Errorf("required property 'endLine' is missing") + if missing != 0 { + var missingProps []string + if missing&missingStartLine != 0 { + missingProps = append(missingProps, "startLine") + } + if missing&missingEndLine != 0 { + missingProps = append(missingProps, "endLine") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1052,7 +1175,11 @@ type FoldingRangeRegistrationOptions struct { var _ json.UnmarshalerFrom = (*FoldingRangeRegistrationOptions)(nil) func (s *FoldingRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1068,7 +1195,7 @@ func (s *FoldingRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -1089,8 +1216,12 @@ func (s *FoldingRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1115,13 +1246,19 @@ func (s *DeclarationParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *DeclarationParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*DeclarationParams)(nil) func (s *DeclarationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1137,12 +1274,12 @@ func (s *DeclarationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -1163,11 +1300,15 @@ func (s *DeclarationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1188,7 +1329,11 @@ type DeclarationRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DeclarationRegistrationOptions)(nil) func (s *DeclarationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1208,7 +1353,7 @@ func (s *DeclarationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder return err } case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -1225,8 +1370,12 @@ func (s *DeclarationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1255,10 +1404,12 @@ func (s *SelectionRangeParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*SelectionRangeParams)(nil) func (s *SelectionRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPositions bool + const ( + missingTextDocument uint = 1 << iota + missingPositions + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1282,12 +1433,12 @@ func (s *SelectionRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"positions"`: - seenPositions = true + missing &^= missingPositions if err := json.UnmarshalDecode(dec, &s.Positions); err != nil { return err } @@ -1300,11 +1451,15 @@ func (s *SelectionRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPositions { - return fmt.Errorf("required property 'positions' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPositions != 0 { + missingProps = append(missingProps, "positions") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1323,7 +1478,11 @@ type SelectionRange struct { var _ json.UnmarshalerFrom = (*SelectionRange)(nil) func (s *SelectionRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRange bool + const ( + missingRange uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1339,7 +1498,7 @@ func (s *SelectionRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -1356,8 +1515,12 @@ func (s *SelectionRange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1378,7 +1541,11 @@ type SelectionRangeRegistrationOptions struct { var _ json.UnmarshalerFrom = (*SelectionRangeRegistrationOptions)(nil) func (s *SelectionRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1398,7 +1565,7 @@ func (s *SelectionRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -1415,8 +1582,12 @@ func (s *SelectionRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1430,7 +1601,11 @@ type WorkDoneProgressCreateParams struct { var _ json.UnmarshalerFrom = (*WorkDoneProgressCreateParams)(nil) func (s *WorkDoneProgressCreateParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenToken bool + const ( + missingToken uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1446,7 +1621,7 @@ func (s *WorkDoneProgressCreateParams) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"token"`: - seenToken = true + missing &^= missingToken if err := json.UnmarshalDecode(dec, &s.Token); err != nil { return err } @@ -1459,8 +1634,12 @@ func (s *WorkDoneProgressCreateParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenToken { - return fmt.Errorf("required property 'token' is missing") + if missing != 0 { + var missingProps []string + if missing&missingToken != 0 { + missingProps = append(missingProps, "token") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1474,7 +1653,11 @@ type WorkDoneProgressCancelParams struct { var _ json.UnmarshalerFrom = (*WorkDoneProgressCancelParams)(nil) func (s *WorkDoneProgressCancelParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenToken bool + const ( + missingToken uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1490,7 +1673,7 @@ func (s *WorkDoneProgressCancelParams) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"token"`: - seenToken = true + missing &^= missingToken if err := json.UnmarshalDecode(dec, &s.Token); err != nil { return err } @@ -1503,8 +1686,12 @@ func (s *WorkDoneProgressCancelParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenToken { - return fmt.Errorf("required property 'token' is missing") + if missing != 0 { + var missingProps []string + if missing&missingToken != 0 { + missingProps = append(missingProps, "token") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1528,13 +1715,19 @@ func (s *CallHierarchyPrepareParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *CallHierarchyPrepareParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*CallHierarchyPrepareParams)(nil) func (s *CallHierarchyPrepareParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1550,12 +1743,12 @@ func (s *CallHierarchyPrepareParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -1572,11 +1765,15 @@ func (s *CallHierarchyPrepareParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1611,19 +1808,21 @@ type CallHierarchyItem struct { // A data entry field that is preserved between a call hierarchy prepare and // incoming calls or outgoing calls requests. - Data *any `json:"data,omitzero"` + Data *CallHierarchyItemData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*CallHierarchyItem)(nil) func (s *CallHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenName bool - seenKind bool - seenUri bool - seenRange bool - seenSelectionRange bool + const ( + missingName uint = 1 << iota + missingKind + missingUri + missingRange + missingSelectionRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1639,12 +1838,12 @@ func (s *CallHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -1657,17 +1856,17 @@ func (s *CallHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"selectionRange"`: - seenSelectionRange = true + missing &^= missingSelectionRange if err := json.UnmarshalDecode(dec, &s.SelectionRange); err != nil { return err } @@ -1684,20 +1883,24 @@ func (s *CallHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") - } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenSelectionRange { - return fmt.Errorf("required property 'selectionRange' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingSelectionRange != 0 { + missingProps = append(missingProps, "selectionRange") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1721,7 +1924,11 @@ type CallHierarchyRegistrationOptions struct { var _ json.UnmarshalerFrom = (*CallHierarchyRegistrationOptions)(nil) func (s *CallHierarchyRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1737,7 +1944,7 @@ func (s *CallHierarchyRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -1758,8 +1965,12 @@ func (s *CallHierarchyRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1782,7 +1993,11 @@ type CallHierarchyIncomingCallsParams struct { var _ json.UnmarshalerFrom = (*CallHierarchyIncomingCallsParams)(nil) func (s *CallHierarchyIncomingCallsParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItem bool + const ( + missingItem uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1806,7 +2021,7 @@ func (s *CallHierarchyIncomingCallsParams) UnmarshalJSONFrom(dec *jsontext.Decod return err } case `"item"`: - seenItem = true + missing &^= missingItem if err := json.UnmarshalDecode(dec, &s.Item); err != nil { return err } @@ -1819,8 +2034,12 @@ func (s *CallHierarchyIncomingCallsParams) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenItem { - return fmt.Errorf("required property 'item' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItem != 0 { + missingProps = append(missingProps, "item") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1841,10 +2060,12 @@ type CallHierarchyIncomingCall struct { var _ json.UnmarshalerFrom = (*CallHierarchyIncomingCall)(nil) func (s *CallHierarchyIncomingCall) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenFrom bool - seenFromRanges bool + const ( + missingFrom uint = 1 << iota + missingFromRanges + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1860,12 +2081,12 @@ func (s *CallHierarchyIncomingCall) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"from"`: - seenFrom = true + missing &^= missingFrom if err := json.UnmarshalDecode(dec, &s.From); err != nil { return err } case `"fromRanges"`: - seenFromRanges = true + missing &^= missingFromRanges if err := json.UnmarshalDecode(dec, &s.FromRanges); err != nil { return err } @@ -1878,11 +2099,15 @@ func (s *CallHierarchyIncomingCall) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenFrom { - return fmt.Errorf("required property 'from' is missing") - } - if !seenFromRanges { - return fmt.Errorf("required property 'fromRanges' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFrom != 0 { + missingProps = append(missingProps, "from") + } + if missing&missingFromRanges != 0 { + missingProps = append(missingProps, "fromRanges") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1905,7 +2130,11 @@ type CallHierarchyOutgoingCallsParams struct { var _ json.UnmarshalerFrom = (*CallHierarchyOutgoingCallsParams)(nil) func (s *CallHierarchyOutgoingCallsParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItem bool + const ( + missingItem uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1929,7 +2158,7 @@ func (s *CallHierarchyOutgoingCallsParams) UnmarshalJSONFrom(dec *jsontext.Decod return err } case `"item"`: - seenItem = true + missing &^= missingItem if err := json.UnmarshalDecode(dec, &s.Item); err != nil { return err } @@ -1942,8 +2171,12 @@ func (s *CallHierarchyOutgoingCallsParams) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenItem { - return fmt.Errorf("required property 'item' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItem != 0 { + missingProps = append(missingProps, "item") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -1965,10 +2198,12 @@ type CallHierarchyOutgoingCall struct { var _ json.UnmarshalerFrom = (*CallHierarchyOutgoingCall)(nil) func (s *CallHierarchyOutgoingCall) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTo bool - seenFromRanges bool + const ( + missingTo uint = 1 << iota + missingFromRanges + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -1984,12 +2219,12 @@ func (s *CallHierarchyOutgoingCall) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"to"`: - seenTo = true + missing &^= missingTo if err := json.UnmarshalDecode(dec, &s.To); err != nil { return err } case `"fromRanges"`: - seenFromRanges = true + missing &^= missingFromRanges if err := json.UnmarshalDecode(dec, &s.FromRanges); err != nil { return err } @@ -2002,11 +2237,15 @@ func (s *CallHierarchyOutgoingCall) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenTo { - return fmt.Errorf("required property 'to' is missing") - } - if !seenFromRanges { - return fmt.Errorf("required property 'fromRanges' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTo != 0 { + missingProps = append(missingProps, "to") + } + if missing&missingFromRanges != 0 { + missingProps = append(missingProps, "fromRanges") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2032,7 +2271,11 @@ func (s *SemanticTokensParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*SemanticTokensParams)(nil) func (s *SemanticTokensParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2056,7 +2299,7 @@ func (s *SemanticTokensParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -2069,8 +2312,12 @@ func (s *SemanticTokensParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2091,7 +2338,11 @@ type SemanticTokens struct { var _ json.UnmarshalerFrom = (*SemanticTokens)(nil) func (s *SemanticTokens) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenData bool + const ( + missingData uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2111,7 +2362,7 @@ func (s *SemanticTokens) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"data"`: - seenData = true + missing &^= missingData if err := json.UnmarshalDecode(dec, &s.Data); err != nil { return err } @@ -2124,8 +2375,12 @@ func (s *SemanticTokens) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenData { - return fmt.Errorf("required property 'data' is missing") + if missing != 0 { + var missingProps []string + if missing&missingData != 0 { + missingProps = append(missingProps, "data") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2139,7 +2394,11 @@ type SemanticTokensPartialResult struct { var _ json.UnmarshalerFrom = (*SemanticTokensPartialResult)(nil) func (s *SemanticTokensPartialResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenData bool + const ( + missingData uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2155,7 +2414,7 @@ func (s *SemanticTokensPartialResult) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"data"`: - seenData = true + missing &^= missingData if err := json.UnmarshalDecode(dec, &s.Data); err != nil { return err } @@ -2168,8 +2427,12 @@ func (s *SemanticTokensPartialResult) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenData { - return fmt.Errorf("required property 'data' is missing") + if missing != 0 { + var missingProps []string + if missing&missingData != 0 { + missingProps = append(missingProps, "data") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2201,10 +2464,12 @@ type SemanticTokensRegistrationOptions struct { var _ json.UnmarshalerFrom = (*SemanticTokensRegistrationOptions)(nil) func (s *SemanticTokensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenDocumentSelector bool - seenLegend bool + const ( + missingDocumentSelector uint = 1 << iota + missingLegend + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2220,7 +2485,7 @@ func (s *SemanticTokensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -2229,7 +2494,7 @@ func (s *SemanticTokensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } case `"legend"`: - seenLegend = true + missing &^= missingLegend if err := json.UnmarshalDecode(dec, &s.Legend); err != nil { return err } @@ -2254,11 +2519,15 @@ func (s *SemanticTokensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") - } - if !seenLegend { - return fmt.Errorf("required property 'legend' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + if missing&missingLegend != 0 { + missingProps = append(missingProps, "legend") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2288,10 +2557,12 @@ func (s *SemanticTokensDeltaParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*SemanticTokensDeltaParams)(nil) func (s *SemanticTokensDeltaParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPreviousResultId bool + const ( + missingTextDocument uint = 1 << iota + missingPreviousResultId + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2315,12 +2586,12 @@ func (s *SemanticTokensDeltaParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"previousResultId"`: - seenPreviousResultId = true + missing &^= missingPreviousResultId if err := json.UnmarshalDecode(dec, &s.PreviousResultId); err != nil { return err } @@ -2333,11 +2604,15 @@ func (s *SemanticTokensDeltaParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPreviousResultId { - return fmt.Errorf("required property 'previousResultId' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPreviousResultId != 0 { + missingProps = append(missingProps, "previousResultId") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2354,7 +2629,11 @@ type SemanticTokensDelta struct { var _ json.UnmarshalerFrom = (*SemanticTokensDelta)(nil) func (s *SemanticTokensDelta) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenEdits bool + const ( + missingEdits uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2374,7 +2653,7 @@ func (s *SemanticTokensDelta) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"edits"`: - seenEdits = true + missing &^= missingEdits if err := json.UnmarshalDecode(dec, &s.Edits); err != nil { return err } @@ -2387,8 +2666,12 @@ func (s *SemanticTokensDelta) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenEdits { - return fmt.Errorf("required property 'edits' is missing") + if missing != 0 { + var missingProps []string + if missing&missingEdits != 0 { + missingProps = append(missingProps, "edits") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2402,7 +2685,11 @@ type SemanticTokensDeltaPartialResult struct { var _ json.UnmarshalerFrom = (*SemanticTokensDeltaPartialResult)(nil) func (s *SemanticTokensDeltaPartialResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenEdits bool + const ( + missingEdits uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2418,7 +2705,7 @@ func (s *SemanticTokensDeltaPartialResult) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"edits"`: - seenEdits = true + missing &^= missingEdits if err := json.UnmarshalDecode(dec, &s.Edits); err != nil { return err } @@ -2431,8 +2718,12 @@ func (s *SemanticTokensDeltaPartialResult) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenEdits { - return fmt.Errorf("required property 'edits' is missing") + if missing != 0 { + var missingProps []string + if missing&missingEdits != 0 { + missingProps = append(missingProps, "edits") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2461,10 +2752,12 @@ func (s *SemanticTokensRangeParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*SemanticTokensRangeParams)(nil) func (s *SemanticTokensRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenRange bool + const ( + missingTextDocument uint = 1 << iota + missingRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2488,12 +2781,12 @@ func (s *SemanticTokensRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -2506,11 +2799,15 @@ func (s *SemanticTokensRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2544,7 +2841,11 @@ type ShowDocumentParams struct { var _ json.UnmarshalerFrom = (*ShowDocumentParams)(nil) func (s *ShowDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2560,7 +2861,7 @@ func (s *ShowDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -2585,8 +2886,12 @@ func (s *ShowDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2603,7 +2908,11 @@ type ShowDocumentResult struct { var _ json.UnmarshalerFrom = (*ShowDocumentResult)(nil) func (s *ShowDocumentResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSuccess bool + const ( + missingSuccess uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2619,7 +2928,7 @@ func (s *ShowDocumentResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"success"`: - seenSuccess = true + missing &^= missingSuccess if err := json.UnmarshalDecode(dec, &s.Success); err != nil { return err } @@ -2632,8 +2941,12 @@ func (s *ShowDocumentResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenSuccess { - return fmt.Errorf("required property 'success' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSuccess != 0 { + missingProps = append(missingProps, "success") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2654,13 +2967,19 @@ func (s *LinkedEditingRangeParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *LinkedEditingRangeParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*LinkedEditingRangeParams)(nil) func (s *LinkedEditingRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2676,12 +2995,12 @@ func (s *LinkedEditingRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -2698,11 +3017,15 @@ func (s *LinkedEditingRangeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2725,7 +3048,11 @@ type LinkedEditingRanges struct { var _ json.UnmarshalerFrom = (*LinkedEditingRanges)(nil) func (s *LinkedEditingRanges) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRanges bool + const ( + missingRanges uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2741,7 +3068,7 @@ func (s *LinkedEditingRanges) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"ranges"`: - seenRanges = true + missing &^= missingRanges if err := json.UnmarshalDecode(dec, &s.Ranges); err != nil { return err } @@ -2758,8 +3085,12 @@ func (s *LinkedEditingRanges) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRanges { - return fmt.Errorf("required property 'ranges' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRanges != 0 { + missingProps = append(missingProps, "ranges") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2780,7 +3111,11 @@ type LinkedEditingRangeRegistrationOptions struct { var _ json.UnmarshalerFrom = (*LinkedEditingRangeRegistrationOptions)(nil) func (s *LinkedEditingRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2796,7 +3131,7 @@ func (s *LinkedEditingRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext. } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -2817,8 +3152,12 @@ func (s *LinkedEditingRangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext. return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2836,7 +3175,11 @@ type CreateFilesParams struct { var _ json.UnmarshalerFrom = (*CreateFilesParams)(nil) func (s *CreateFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenFiles bool + const ( + missingFiles uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2852,7 +3195,7 @@ func (s *CreateFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"files"`: - seenFiles = true + missing &^= missingFiles if err := json.UnmarshalDecode(dec, &s.Files); err != nil { return err } @@ -2865,8 +3208,12 @@ func (s *CreateFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenFiles { - return fmt.Errorf("required property 'files' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFiles != 0 { + missingProps = append(missingProps, "files") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2920,7 +3267,11 @@ type FileOperationRegistrationOptions struct { var _ json.UnmarshalerFrom = (*FileOperationRegistrationOptions)(nil) func (s *FileOperationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenFilters bool + const ( + missingFilters uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2936,7 +3287,7 @@ func (s *FileOperationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"filters"`: - seenFilters = true + missing &^= missingFilters if err := json.UnmarshalDecode(dec, &s.Filters); err != nil { return err } @@ -2949,8 +3300,12 @@ func (s *FileOperationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenFilters { - return fmt.Errorf("required property 'filters' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFilters != 0 { + missingProps = append(missingProps, "filters") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -2969,7 +3324,11 @@ type RenameFilesParams struct { var _ json.UnmarshalerFrom = (*RenameFilesParams)(nil) func (s *RenameFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenFiles bool + const ( + missingFiles uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -2985,7 +3344,7 @@ func (s *RenameFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"files"`: - seenFiles = true + missing &^= missingFiles if err := json.UnmarshalDecode(dec, &s.Files); err != nil { return err } @@ -2998,8 +3357,12 @@ func (s *RenameFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenFiles { - return fmt.Errorf("required property 'files' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFiles != 0 { + missingProps = append(missingProps, "files") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3017,7 +3380,11 @@ type DeleteFilesParams struct { var _ json.UnmarshalerFrom = (*DeleteFilesParams)(nil) func (s *DeleteFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenFiles bool + const ( + missingFiles uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3033,7 +3400,7 @@ func (s *DeleteFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"files"`: - seenFiles = true + missing &^= missingFiles if err := json.UnmarshalDecode(dec, &s.Files); err != nil { return err } @@ -3046,8 +3413,12 @@ func (s *DeleteFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenFiles { - return fmt.Errorf("required property 'files' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFiles != 0 { + missingProps = append(missingProps, "files") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3072,13 +3443,19 @@ func (s *MonikerParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *MonikerParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*MonikerParams)(nil) func (s *MonikerParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3094,12 +3471,12 @@ func (s *MonikerParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -3120,11 +3497,15 @@ func (s *MonikerParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3151,11 +3532,13 @@ type Moniker struct { var _ json.UnmarshalerFrom = (*Moniker)(nil) func (s *Moniker) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenScheme bool - seenIdentifier bool - seenUnique bool + const ( + missingScheme uint = 1 << iota + missingIdentifier + missingUnique + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3171,17 +3554,17 @@ func (s *Moniker) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"scheme"`: - seenScheme = true + missing &^= missingScheme if err := json.UnmarshalDecode(dec, &s.Scheme); err != nil { return err } case `"identifier"`: - seenIdentifier = true + missing &^= missingIdentifier if err := json.UnmarshalDecode(dec, &s.Identifier); err != nil { return err } case `"unique"`: - seenUnique = true + missing &^= missingUnique if err := json.UnmarshalDecode(dec, &s.Unique); err != nil { return err } @@ -3198,14 +3581,18 @@ func (s *Moniker) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenScheme { - return fmt.Errorf("required property 'scheme' is missing") - } - if !seenIdentifier { - return fmt.Errorf("required property 'identifier' is missing") - } - if !seenUnique { - return fmt.Errorf("required property 'unique' is missing") + if missing != 0 { + var missingProps []string + if missing&missingScheme != 0 { + missingProps = append(missingProps, "scheme") + } + if missing&missingIdentifier != 0 { + missingProps = append(missingProps, "identifier") + } + if missing&missingUnique != 0 { + missingProps = append(missingProps, "unique") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3222,7 +3609,11 @@ type MonikerRegistrationOptions struct { var _ json.UnmarshalerFrom = (*MonikerRegistrationOptions)(nil) func (s *MonikerRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3238,7 +3629,7 @@ func (s *MonikerRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -3255,8 +3646,12 @@ func (s *MonikerRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3280,13 +3675,19 @@ func (s *TypeHierarchyPrepareParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *TypeHierarchyPrepareParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*TypeHierarchyPrepareParams)(nil) func (s *TypeHierarchyPrepareParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3302,12 +3703,12 @@ func (s *TypeHierarchyPrepareParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -3324,11 +3725,15 @@ func (s *TypeHierarchyPrepareParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3364,19 +3769,21 @@ type TypeHierarchyItem struct { // supertypes or subtypes requests. It could also be used to identify the // type hierarchy in the server, helping improve the performance on // resolving supertypes and subtypes. - Data *any `json:"data,omitzero"` + Data *TypeHierarchyItemData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*TypeHierarchyItem)(nil) func (s *TypeHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenName bool - seenKind bool - seenUri bool - seenRange bool - seenSelectionRange bool + const ( + missingName uint = 1 << iota + missingKind + missingUri + missingRange + missingSelectionRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3392,12 +3799,12 @@ func (s *TypeHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -3410,17 +3817,17 @@ func (s *TypeHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"selectionRange"`: - seenSelectionRange = true + missing &^= missingSelectionRange if err := json.UnmarshalDecode(dec, &s.SelectionRange); err != nil { return err } @@ -3437,20 +3844,24 @@ func (s *TypeHierarchyItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") - } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenSelectionRange { - return fmt.Errorf("required property 'selectionRange' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingSelectionRange != 0 { + missingProps = append(missingProps, "selectionRange") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3474,7 +3885,11 @@ type TypeHierarchyRegistrationOptions struct { var _ json.UnmarshalerFrom = (*TypeHierarchyRegistrationOptions)(nil) func (s *TypeHierarchyRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3490,7 +3905,7 @@ func (s *TypeHierarchyRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -3511,8 +3926,12 @@ func (s *TypeHierarchyRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3535,7 +3954,11 @@ type TypeHierarchySupertypesParams struct { var _ json.UnmarshalerFrom = (*TypeHierarchySupertypesParams)(nil) func (s *TypeHierarchySupertypesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItem bool + const ( + missingItem uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3559,7 +3982,7 @@ func (s *TypeHierarchySupertypesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"item"`: - seenItem = true + missing &^= missingItem if err := json.UnmarshalDecode(dec, &s.Item); err != nil { return err } @@ -3572,8 +3995,12 @@ func (s *TypeHierarchySupertypesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenItem { - return fmt.Errorf("required property 'item' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItem != 0 { + missingProps = append(missingProps, "item") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3596,7 +4023,11 @@ type TypeHierarchySubtypesParams struct { var _ json.UnmarshalerFrom = (*TypeHierarchySubtypesParams)(nil) func (s *TypeHierarchySubtypesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItem bool + const ( + missingItem uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3620,7 +4051,7 @@ func (s *TypeHierarchySubtypesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } case `"item"`: - seenItem = true + missing &^= missingItem if err := json.UnmarshalDecode(dec, &s.Item); err != nil { return err } @@ -3633,8 +4064,12 @@ func (s *TypeHierarchySubtypesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenItem { - return fmt.Errorf("required property 'item' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItem != 0 { + missingProps = append(missingProps, "item") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3665,11 +4100,13 @@ func (s *InlineValueParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*InlineValueParams)(nil) func (s *InlineValueParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenRange bool - seenContext bool + const ( + missingTextDocument uint = 1 << iota + missingRange + missingContext + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3689,17 +4126,17 @@ func (s *InlineValueParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"context"`: - seenContext = true + missing &^= missingContext if err := json.UnmarshalDecode(dec, &s.Context); err != nil { return err } @@ -3712,14 +4149,18 @@ func (s *InlineValueParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenContext { - return fmt.Errorf("required property 'context' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingContext != 0 { + missingProps = append(missingProps, "context") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3743,7 +4184,11 @@ type InlineValueRegistrationOptions struct { var _ json.UnmarshalerFrom = (*InlineValueRegistrationOptions)(nil) func (s *InlineValueRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3763,7 +4208,7 @@ func (s *InlineValueRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder return err } case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -3780,8 +4225,12 @@ func (s *InlineValueRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3808,10 +4257,12 @@ func (s *InlayHintParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*InlayHintParams)(nil) func (s *InlayHintParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenRange bool + const ( + missingTextDocument uint = 1 << iota + missingRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3831,12 +4282,12 @@ func (s *InlayHintParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -3849,11 +4300,15 @@ func (s *InlayHintParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -3905,16 +4360,18 @@ type InlayHint struct { // A data entry field that is preserved on an inlay hint between // a `textDocument/inlayHint` and a `inlayHint/resolve` request. - Data *any `json:"data,omitzero"` + Data *InlayHintData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*InlayHint)(nil) func (s *InlayHint) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenPosition bool - seenLabel bool + const ( + missingPosition uint = 1 << iota + missingLabel + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -3930,12 +4387,12 @@ func (s *InlayHint) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } case `"label"`: - seenLabel = true + missing &^= missingLabel if err := json.UnmarshalDecode(dec, &s.Label); err != nil { return err } @@ -3972,11 +4429,15 @@ func (s *InlayHint) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") - } - if !seenLabel { - return fmt.Errorf("required property 'label' is missing") + if missing != 0 { + var missingProps []string + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + if missing&missingLabel != 0 { + missingProps = append(missingProps, "label") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4004,7 +4465,11 @@ type InlayHintRegistrationOptions struct { var _ json.UnmarshalerFrom = (*InlayHintRegistrationOptions)(nil) func (s *InlayHintRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4028,7 +4493,7 @@ func (s *InlayHintRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -4045,8 +4510,12 @@ func (s *InlayHintRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4080,7 +4549,11 @@ func (s *DocumentDiagnosticParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentDiagnosticParams)(nil) func (s *DocumentDiagnosticParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4104,7 +4577,7 @@ func (s *DocumentDiagnosticParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -4125,8 +4598,12 @@ func (s *DocumentDiagnosticParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4142,7 +4619,11 @@ type DocumentDiagnosticReportPartialResult struct { var _ json.UnmarshalerFrom = (*DocumentDiagnosticReportPartialResult)(nil) func (s *DocumentDiagnosticReportPartialResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRelatedDocuments bool + const ( + missingRelatedDocuments uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4158,7 +4639,7 @@ func (s *DocumentDiagnosticReportPartialResult) UnmarshalJSONFrom(dec *jsontext. } switch string(name) { case `"relatedDocuments"`: - seenRelatedDocuments = true + missing &^= missingRelatedDocuments if err := json.UnmarshalDecode(dec, &s.RelatedDocuments); err != nil { return err } @@ -4171,8 +4652,12 @@ func (s *DocumentDiagnosticReportPartialResult) UnmarshalJSONFrom(dec *jsontext. return err } - if !seenRelatedDocuments { - return fmt.Errorf("required property 'relatedDocuments' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRelatedDocuments != 0 { + missingProps = append(missingProps, "relatedDocuments") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4188,7 +4673,11 @@ type DiagnosticServerCancellationData struct { var _ json.UnmarshalerFrom = (*DiagnosticServerCancellationData)(nil) func (s *DiagnosticServerCancellationData) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRetriggerRequest bool + const ( + missingRetriggerRequest uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4204,7 +4693,7 @@ func (s *DiagnosticServerCancellationData) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"retriggerRequest"`: - seenRetriggerRequest = true + missing &^= missingRetriggerRequest if err := json.UnmarshalDecode(dec, &s.RetriggerRequest); err != nil { return err } @@ -4217,8 +4706,12 @@ func (s *DiagnosticServerCancellationData) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenRetriggerRequest { - return fmt.Errorf("required property 'retriggerRequest' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRetriggerRequest != 0 { + missingProps = append(missingProps, "retriggerRequest") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4255,11 +4748,13 @@ type DiagnosticRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DiagnosticRegistrationOptions)(nil) func (s *DiagnosticRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenDocumentSelector bool - seenInterFileDependencies bool - seenWorkspaceDiagnostics bool + const ( + missingDocumentSelector uint = 1 << iota + missingInterFileDependencies + missingWorkspaceDiagnostics + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4275,7 +4770,7 @@ func (s *DiagnosticRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -4288,12 +4783,12 @@ func (s *DiagnosticRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"interFileDependencies"`: - seenInterFileDependencies = true + missing &^= missingInterFileDependencies if err := json.UnmarshalDecode(dec, &s.InterFileDependencies); err != nil { return err } case `"workspaceDiagnostics"`: - seenWorkspaceDiagnostics = true + missing &^= missingWorkspaceDiagnostics if err := json.UnmarshalDecode(dec, &s.WorkspaceDiagnostics); err != nil { return err } @@ -4310,14 +4805,18 @@ func (s *DiagnosticRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") - } - if !seenInterFileDependencies { - return fmt.Errorf("required property 'interFileDependencies' is missing") - } - if !seenWorkspaceDiagnostics { - return fmt.Errorf("required property 'workspaceDiagnostics' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + if missing&missingInterFileDependencies != 0 { + missingProps = append(missingProps, "interFileDependencies") + } + if missing&missingWorkspaceDiagnostics != 0 { + missingProps = append(missingProps, "workspaceDiagnostics") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4345,7 +4844,11 @@ type WorkspaceDiagnosticParams struct { var _ json.UnmarshalerFrom = (*WorkspaceDiagnosticParams)(nil) func (s *WorkspaceDiagnosticParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenPreviousResultIds bool + const ( + missingPreviousResultIds uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4373,7 +4876,7 @@ func (s *WorkspaceDiagnosticParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } case `"previousResultIds"`: - seenPreviousResultIds = true + missing &^= missingPreviousResultIds if err := json.UnmarshalDecode(dec, &s.PreviousResultIds); err != nil { return err } @@ -4386,8 +4889,12 @@ func (s *WorkspaceDiagnosticParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenPreviousResultIds { - return fmt.Errorf("required property 'previousResultIds' is missing") + if missing != 0 { + var missingProps []string + if missing&missingPreviousResultIds != 0 { + missingProps = append(missingProps, "previousResultIds") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4403,7 +4910,11 @@ type WorkspaceDiagnosticReport struct { var _ json.UnmarshalerFrom = (*WorkspaceDiagnosticReport)(nil) func (s *WorkspaceDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItems bool + const ( + missingItems uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4419,7 +4930,7 @@ func (s *WorkspaceDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -4432,8 +4943,12 @@ func (s *WorkspaceDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4449,7 +4964,11 @@ type WorkspaceDiagnosticReportPartialResult struct { var _ json.UnmarshalerFrom = (*WorkspaceDiagnosticReportPartialResult)(nil) func (s *WorkspaceDiagnosticReportPartialResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItems bool + const ( + missingItems uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4465,7 +4984,7 @@ func (s *WorkspaceDiagnosticReportPartialResult) UnmarshalJSONFrom(dec *jsontext } switch string(name) { case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -4478,8 +4997,12 @@ func (s *WorkspaceDiagnosticReportPartialResult) UnmarshalJSONFrom(dec *jsontext return err } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4500,10 +5023,12 @@ type DidOpenNotebookDocumentParams struct { var _ json.UnmarshalerFrom = (*DidOpenNotebookDocumentParams)(nil) func (s *DidOpenNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenNotebookDocument bool - seenCellTextDocuments bool + const ( + missingNotebookDocument uint = 1 << iota + missingCellTextDocuments + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4519,12 +5044,12 @@ func (s *DidOpenNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"notebookDocument"`: - seenNotebookDocument = true + missing &^= missingNotebookDocument if err := json.UnmarshalDecode(dec, &s.NotebookDocument); err != nil { return err } case `"cellTextDocuments"`: - seenCellTextDocuments = true + missing &^= missingCellTextDocuments if err := json.UnmarshalDecode(dec, &s.CellTextDocuments); err != nil { return err } @@ -4537,11 +5062,15 @@ func (s *DidOpenNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenNotebookDocument { - return fmt.Errorf("required property 'notebookDocument' is missing") - } - if !seenCellTextDocuments { - return fmt.Errorf("required property 'cellTextDocuments' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookDocument != 0 { + missingProps = append(missingProps, "notebookDocument") + } + if missing&missingCellTextDocuments != 0 { + missingProps = append(missingProps, "cellTextDocuments") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4566,7 +5095,11 @@ type NotebookDocumentSyncRegistrationOptions struct { var _ json.UnmarshalerFrom = (*NotebookDocumentSyncRegistrationOptions)(nil) func (s *NotebookDocumentSyncRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenNotebookSelector bool + const ( + missingNotebookSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4582,7 +5115,7 @@ func (s *NotebookDocumentSyncRegistrationOptions) UnmarshalJSONFrom(dec *jsontex } switch string(name) { case `"notebookSelector"`: - seenNotebookSelector = true + missing &^= missingNotebookSelector if err := json.UnmarshalDecode(dec, &s.NotebookSelector); err != nil { return err } @@ -4603,8 +5136,12 @@ func (s *NotebookDocumentSyncRegistrationOptions) UnmarshalJSONFrom(dec *jsontex return err } - if !seenNotebookSelector { - return fmt.Errorf("required property 'notebookSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookSelector != 0 { + missingProps = append(missingProps, "notebookSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4639,10 +5176,12 @@ type DidChangeNotebookDocumentParams struct { var _ json.UnmarshalerFrom = (*DidChangeNotebookDocumentParams)(nil) func (s *DidChangeNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenNotebookDocument bool - seenChange bool + const ( + missingNotebookDocument uint = 1 << iota + missingChange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4658,12 +5197,12 @@ func (s *DidChangeNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"notebookDocument"`: - seenNotebookDocument = true + missing &^= missingNotebookDocument if err := json.UnmarshalDecode(dec, &s.NotebookDocument); err != nil { return err } case `"change"`: - seenChange = true + missing &^= missingChange if err := json.UnmarshalDecode(dec, &s.Change); err != nil { return err } @@ -4676,11 +5215,15 @@ func (s *DidChangeNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenNotebookDocument { - return fmt.Errorf("required property 'notebookDocument' is missing") - } - if !seenChange { - return fmt.Errorf("required property 'change' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookDocument != 0 { + missingProps = append(missingProps, "notebookDocument") + } + if missing&missingChange != 0 { + missingProps = append(missingProps, "change") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4697,7 +5240,11 @@ type DidSaveNotebookDocumentParams struct { var _ json.UnmarshalerFrom = (*DidSaveNotebookDocumentParams)(nil) func (s *DidSaveNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenNotebookDocument bool + const ( + missingNotebookDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4713,7 +5260,7 @@ func (s *DidSaveNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"notebookDocument"`: - seenNotebookDocument = true + missing &^= missingNotebookDocument if err := json.UnmarshalDecode(dec, &s.NotebookDocument); err != nil { return err } @@ -4726,8 +5273,12 @@ func (s *DidSaveNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenNotebookDocument { - return fmt.Errorf("required property 'notebookDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookDocument != 0 { + missingProps = append(missingProps, "notebookDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4748,10 +5299,12 @@ type DidCloseNotebookDocumentParams struct { var _ json.UnmarshalerFrom = (*DidCloseNotebookDocumentParams)(nil) func (s *DidCloseNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenNotebookDocument bool - seenCellTextDocuments bool + const ( + missingNotebookDocument uint = 1 << iota + missingCellTextDocuments + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4767,12 +5320,12 @@ func (s *DidCloseNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder } switch string(name) { case `"notebookDocument"`: - seenNotebookDocument = true + missing &^= missingNotebookDocument if err := json.UnmarshalDecode(dec, &s.NotebookDocument); err != nil { return err } case `"cellTextDocuments"`: - seenCellTextDocuments = true + missing &^= missingCellTextDocuments if err := json.UnmarshalDecode(dec, &s.CellTextDocuments); err != nil { return err } @@ -4785,11 +5338,15 @@ func (s *DidCloseNotebookDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenNotebookDocument { - return fmt.Errorf("required property 'notebookDocument' is missing") - } - if !seenCellTextDocuments { - return fmt.Errorf("required property 'cellTextDocuments' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookDocument != 0 { + missingProps = append(missingProps, "notebookDocument") + } + if missing&missingCellTextDocuments != 0 { + missingProps = append(missingProps, "cellTextDocuments") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4819,14 +5376,20 @@ func (s *InlineCompletionParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *InlineCompletionParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*InlineCompletionParams)(nil) func (s *InlineCompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool - seenContext bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + missingContext + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4842,12 +5405,12 @@ func (s *InlineCompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -4856,7 +5419,7 @@ func (s *InlineCompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } case `"context"`: - seenContext = true + missing &^= missingContext if err := json.UnmarshalDecode(dec, &s.Context); err != nil { return err } @@ -4869,14 +5432,18 @@ func (s *InlineCompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") - } - if !seenContext { - return fmt.Errorf("required property 'context' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + if missing&missingContext != 0 { + missingProps = append(missingProps, "context") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4895,7 +5462,11 @@ type InlineCompletionList struct { var _ json.UnmarshalerFrom = (*InlineCompletionList)(nil) func (s *InlineCompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenItems bool + const ( + missingItems uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4911,7 +5482,7 @@ func (s *InlineCompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -4924,8 +5495,12 @@ func (s *InlineCompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -4953,7 +5528,11 @@ type InlineCompletionItem struct { var _ json.UnmarshalerFrom = (*InlineCompletionItem)(nil) func (s *InlineCompletionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenInsertText bool + const ( + missingInsertText uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -4969,7 +5548,7 @@ func (s *InlineCompletionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"insertText"`: - seenInsertText = true + missing &^= missingInsertText if err := json.UnmarshalDecode(dec, &s.InsertText); err != nil { return err } @@ -4994,8 +5573,12 @@ func (s *InlineCompletionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenInsertText { - return fmt.Errorf("required property 'insertText' is missing") + if missing != 0 { + var missingProps []string + if missing&missingInsertText != 0 { + missingProps = append(missingProps, "insertText") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5021,7 +5604,11 @@ type InlineCompletionRegistrationOptions struct { var _ json.UnmarshalerFrom = (*InlineCompletionRegistrationOptions)(nil) func (s *InlineCompletionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5041,7 +5628,7 @@ func (s *InlineCompletionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.De return err } case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -5058,8 +5645,12 @@ func (s *InlineCompletionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.De return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5078,7 +5669,11 @@ type TextDocumentContentParams struct { var _ json.UnmarshalerFrom = (*TextDocumentContentParams)(nil) func (s *TextDocumentContentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5094,7 +5689,7 @@ func (s *TextDocumentContentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -5107,8 +5702,12 @@ func (s *TextDocumentContentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5130,7 +5729,11 @@ type TextDocumentContentResult struct { var _ json.UnmarshalerFrom = (*TextDocumentContentResult)(nil) func (s *TextDocumentContentResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenText bool + const ( + missingText uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5146,7 +5749,7 @@ func (s *TextDocumentContentResult) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"text"`: - seenText = true + missing &^= missingText if err := json.UnmarshalDecode(dec, &s.Text); err != nil { return err } @@ -5159,8 +5762,12 @@ func (s *TextDocumentContentResult) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenText { - return fmt.Errorf("required property 'text' is missing") + if missing != 0 { + var missingProps []string + if missing&missingText != 0 { + missingProps = append(missingProps, "text") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5183,7 +5790,11 @@ type TextDocumentContentRegistrationOptions struct { var _ json.UnmarshalerFrom = (*TextDocumentContentRegistrationOptions)(nil) func (s *TextDocumentContentRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSchemes bool + const ( + missingSchemes uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5199,7 +5810,7 @@ func (s *TextDocumentContentRegistrationOptions) UnmarshalJSONFrom(dec *jsontext } switch string(name) { case `"schemes"`: - seenSchemes = true + missing &^= missingSchemes if err := json.UnmarshalDecode(dec, &s.Schemes); err != nil { return err } @@ -5216,8 +5827,12 @@ func (s *TextDocumentContentRegistrationOptions) UnmarshalJSONFrom(dec *jsontext return err } - if !seenSchemes { - return fmt.Errorf("required property 'schemes' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSchemes != 0 { + missingProps = append(missingProps, "schemes") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5236,7 +5851,11 @@ type TextDocumentContentRefreshParams struct { var _ json.UnmarshalerFrom = (*TextDocumentContentRefreshParams)(nil) func (s *TextDocumentContentRefreshParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5252,7 +5871,7 @@ func (s *TextDocumentContentRefreshParams) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -5265,8 +5884,12 @@ func (s *TextDocumentContentRefreshParams) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5279,7 +5902,11 @@ type RegistrationParams struct { var _ json.UnmarshalerFrom = (*RegistrationParams)(nil) func (s *RegistrationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRegistrations bool + const ( + missingRegistrations uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5295,7 +5922,7 @@ func (s *RegistrationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"registrations"`: - seenRegistrations = true + missing &^= missingRegistrations if err := json.UnmarshalDecode(dec, &s.Registrations); err != nil { return err } @@ -5308,8 +5935,12 @@ func (s *RegistrationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRegistrations { - return fmt.Errorf("required property 'registrations' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRegistrations != 0 { + missingProps = append(missingProps, "registrations") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5322,7 +5953,11 @@ type UnregistrationParams struct { var _ json.UnmarshalerFrom = (*UnregistrationParams)(nil) func (s *UnregistrationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUnregisterations bool + const ( + missingUnregisterations uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5338,7 +5973,7 @@ func (s *UnregistrationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"unregisterations"`: - seenUnregisterations = true + missing &^= missingUnregisterations if err := json.UnmarshalDecode(dec, &s.Unregisterations); err != nil { return err } @@ -5351,8 +5986,12 @@ func (s *UnregistrationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUnregisterations { - return fmt.Errorf("required property 'unregisterations' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUnregisterations != 0 { + missingProps = append(missingProps, "unregisterations") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5401,7 +6040,7 @@ type InitializeParams struct { Capabilities *ClientCapabilities `json:"capabilities"` // User provided initialization options. - InitializationOptions *any `json:"initializationOptions,omitzero"` + InitializationOptions *InitializationOptions `json:"initializationOptions,omitzero"` // The initial trace setting. If omitted trace is disabled ('off'). Trace *TraceValue `json:"trace,omitzero"` @@ -5419,11 +6058,13 @@ type InitializeParams struct { var _ json.UnmarshalerFrom = (*InitializeParams)(nil) func (s *InitializeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenProcessId bool - seenRootUri bool - seenCapabilities bool + const ( + missingProcessId uint = 1 << iota + missingRootUri + missingCapabilities + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5443,7 +6084,7 @@ func (s *InitializeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"processId"`: - seenProcessId = true + missing &^= missingProcessId if err := json.UnmarshalDecode(dec, &s.ProcessId); err != nil { return err } @@ -5460,12 +6101,12 @@ func (s *InitializeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"rootUri"`: - seenRootUri = true + missing &^= missingRootUri if err := json.UnmarshalDecode(dec, &s.RootUri); err != nil { return err } case `"capabilities"`: - seenCapabilities = true + missing &^= missingCapabilities if err := json.UnmarshalDecode(dec, &s.Capabilities); err != nil { return err } @@ -5490,14 +6131,18 @@ func (s *InitializeParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenProcessId { - return fmt.Errorf("required property 'processId' is missing") - } - if !seenRootUri { - return fmt.Errorf("required property 'rootUri' is missing") - } - if !seenCapabilities { - return fmt.Errorf("required property 'capabilities' is missing") + if missing != 0 { + var missingProps []string + if missing&missingProcessId != 0 { + missingProps = append(missingProps, "processId") + } + if missing&missingRootUri != 0 { + missingProps = append(missingProps, "rootUri") + } + if missing&missingCapabilities != 0 { + missingProps = append(missingProps, "capabilities") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5517,7 +6162,11 @@ type InitializeResult struct { var _ json.UnmarshalerFrom = (*InitializeResult)(nil) func (s *InitializeResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenCapabilities bool + const ( + missingCapabilities uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5533,7 +6182,7 @@ func (s *InitializeResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"capabilities"`: - seenCapabilities = true + missing &^= missingCapabilities if err := json.UnmarshalDecode(dec, &s.Capabilities); err != nil { return err } @@ -5550,8 +6199,12 @@ func (s *InitializeResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenCapabilities { - return fmt.Errorf("required property 'capabilities' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCapabilities != 0 { + missingProps = append(missingProps, "capabilities") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5570,7 +6223,11 @@ type InitializeError struct { var _ json.UnmarshalerFrom = (*InitializeError)(nil) func (s *InitializeError) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRetry bool + const ( + missingRetry uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5586,7 +6243,7 @@ func (s *InitializeError) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"retry"`: - seenRetry = true + missing &^= missingRetry if err := json.UnmarshalDecode(dec, &s.Retry); err != nil { return err } @@ -5599,8 +6256,12 @@ func (s *InitializeError) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRetry { - return fmt.Errorf("required property 'retry' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRetry != 0 { + missingProps = append(missingProps, "retry") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5617,7 +6278,11 @@ type DidChangeConfigurationParams struct { var _ json.UnmarshalerFrom = (*DidChangeConfigurationParams)(nil) func (s *DidChangeConfigurationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSettings bool + const ( + missingSettings uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5633,7 +6298,7 @@ func (s *DidChangeConfigurationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"settings"`: - seenSettings = true + missing &^= missingSettings if err := json.UnmarshalDecode(dec, &s.Settings); err != nil { return err } @@ -5646,8 +6311,12 @@ func (s *DidChangeConfigurationParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenSettings { - return fmt.Errorf("required property 'settings' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSettings != 0 { + missingProps = append(missingProps, "settings") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5669,10 +6338,12 @@ type ShowMessageParams struct { var _ json.UnmarshalerFrom = (*ShowMessageParams)(nil) func (s *ShowMessageParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenType bool - seenMessage bool + const ( + missingType uint = 1 << iota + missingMessage + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5688,12 +6359,12 @@ func (s *ShowMessageParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"type"`: - seenType = true + missing &^= missingType if err := json.UnmarshalDecode(dec, &s.Type); err != nil { return err } case `"message"`: - seenMessage = true + missing &^= missingMessage if err := json.UnmarshalDecode(dec, &s.Message); err != nil { return err } @@ -5706,11 +6377,15 @@ func (s *ShowMessageParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenType { - return fmt.Errorf("required property 'type' is missing") - } - if !seenMessage { - return fmt.Errorf("required property 'message' is missing") + if missing != 0 { + var missingProps []string + if missing&missingType != 0 { + missingProps = append(missingProps, "type") + } + if missing&missingMessage != 0 { + missingProps = append(missingProps, "message") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5730,10 +6405,12 @@ type ShowMessageRequestParams struct { var _ json.UnmarshalerFrom = (*ShowMessageRequestParams)(nil) func (s *ShowMessageRequestParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenType bool - seenMessage bool + const ( + missingType uint = 1 << iota + missingMessage + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5749,12 +6426,12 @@ func (s *ShowMessageRequestParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"type"`: - seenType = true + missing &^= missingType if err := json.UnmarshalDecode(dec, &s.Type); err != nil { return err } case `"message"`: - seenMessage = true + missing &^= missingMessage if err := json.UnmarshalDecode(dec, &s.Message); err != nil { return err } @@ -5771,11 +6448,15 @@ func (s *ShowMessageRequestParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenType { - return fmt.Errorf("required property 'type' is missing") - } - if !seenMessage { - return fmt.Errorf("required property 'message' is missing") + if missing != 0 { + var missingProps []string + if missing&missingType != 0 { + missingProps = append(missingProps, "type") + } + if missing&missingMessage != 0 { + missingProps = append(missingProps, "message") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5789,7 +6470,11 @@ type MessageActionItem struct { var _ json.UnmarshalerFrom = (*MessageActionItem)(nil) func (s *MessageActionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTitle bool + const ( + missingTitle uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5805,7 +6490,7 @@ func (s *MessageActionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"title"`: - seenTitle = true + missing &^= missingTitle if err := json.UnmarshalDecode(dec, &s.Title); err != nil { return err } @@ -5818,8 +6503,12 @@ func (s *MessageActionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTitle { - return fmt.Errorf("required property 'title' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTitle != 0 { + missingProps = append(missingProps, "title") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5837,10 +6526,12 @@ type LogMessageParams struct { var _ json.UnmarshalerFrom = (*LogMessageParams)(nil) func (s *LogMessageParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenType bool - seenMessage bool + const ( + missingType uint = 1 << iota + missingMessage + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5856,12 +6547,12 @@ func (s *LogMessageParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"type"`: - seenType = true + missing &^= missingType if err := json.UnmarshalDecode(dec, &s.Type); err != nil { return err } case `"message"`: - seenMessage = true + missing &^= missingMessage if err := json.UnmarshalDecode(dec, &s.Message); err != nil { return err } @@ -5874,11 +6565,15 @@ func (s *LogMessageParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenType { - return fmt.Errorf("required property 'type' is missing") - } - if !seenMessage { - return fmt.Errorf("required property 'message' is missing") + if missing != 0 { + var missingProps []string + if missing&missingType != 0 { + missingProps = append(missingProps, "type") + } + if missing&missingMessage != 0 { + missingProps = append(missingProps, "message") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5893,7 +6588,11 @@ type DidOpenTextDocumentParams struct { var _ json.UnmarshalerFrom = (*DidOpenTextDocumentParams)(nil) func (s *DidOpenTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5909,7 +6608,7 @@ func (s *DidOpenTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -5922,8 +6621,12 @@ func (s *DidOpenTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -5953,10 +6656,12 @@ type DidChangeTextDocumentParams struct { var _ json.UnmarshalerFrom = (*DidChangeTextDocumentParams)(nil) func (s *DidChangeTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenContentChanges bool + const ( + missingTextDocument uint = 1 << iota + missingContentChanges + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -5972,12 +6677,12 @@ func (s *DidChangeTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"contentChanges"`: - seenContentChanges = true + missing &^= missingContentChanges if err := json.UnmarshalDecode(dec, &s.ContentChanges); err != nil { return err } @@ -5990,11 +6695,15 @@ func (s *DidChangeTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenContentChanges { - return fmt.Errorf("required property 'contentChanges' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingContentChanges != 0 { + missingProps = append(missingProps, "contentChanges") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6013,10 +6722,12 @@ type TextDocumentChangeRegistrationOptions struct { var _ json.UnmarshalerFrom = (*TextDocumentChangeRegistrationOptions)(nil) func (s *TextDocumentChangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenDocumentSelector bool - seenSyncKind bool + const ( + missingDocumentSelector uint = 1 << iota + missingSyncKind + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6032,12 +6743,12 @@ func (s *TextDocumentChangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext. } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } case `"syncKind"`: - seenSyncKind = true + missing &^= missingSyncKind if err := json.UnmarshalDecode(dec, &s.SyncKind); err != nil { return err } @@ -6050,11 +6761,15 @@ func (s *TextDocumentChangeRegistrationOptions) UnmarshalJSONFrom(dec *jsontext. return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") - } - if !seenSyncKind { - return fmt.Errorf("required property 'syncKind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + if missing&missingSyncKind != 0 { + missingProps = append(missingProps, "syncKind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6073,7 +6788,11 @@ func (s *DidCloseTextDocumentParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DidCloseTextDocumentParams)(nil) func (s *DidCloseTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6089,7 +6808,7 @@ func (s *DidCloseTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -6102,8 +6821,12 @@ func (s *DidCloseTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6126,7 +6849,11 @@ func (s *DidSaveTextDocumentParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DidSaveTextDocumentParams)(nil) func (s *DidSaveTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6142,7 +6869,7 @@ func (s *DidSaveTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -6159,8 +6886,12 @@ func (s *DidSaveTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6179,7 +6910,11 @@ type TextDocumentSaveRegistrationOptions struct { var _ json.UnmarshalerFrom = (*TextDocumentSaveRegistrationOptions)(nil) func (s *TextDocumentSaveRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6195,7 +6930,7 @@ func (s *TextDocumentSaveRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.De } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -6212,8 +6947,12 @@ func (s *TextDocumentSaveRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.De return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6235,10 +6974,12 @@ func (s *WillSaveTextDocumentParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*WillSaveTextDocumentParams)(nil) func (s *WillSaveTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenReason bool + const ( + missingTextDocument uint = 1 << iota + missingReason + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6254,12 +6995,12 @@ func (s *WillSaveTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"reason"`: - seenReason = true + missing &^= missingReason if err := json.UnmarshalDecode(dec, &s.Reason); err != nil { return err } @@ -6272,11 +7013,15 @@ func (s *WillSaveTextDocumentParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenReason { - return fmt.Errorf("required property 'reason' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingReason != 0 { + missingProps = append(missingProps, "reason") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6296,10 +7041,12 @@ type TextEdit struct { var _ json.UnmarshalerFrom = (*TextEdit)(nil) func (s *TextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenNewText bool + const ( + missingRange uint = 1 << iota + missingNewText + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6315,12 +7062,12 @@ func (s *TextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"newText"`: - seenNewText = true + missing &^= missingNewText if err := json.UnmarshalDecode(dec, &s.NewText); err != nil { return err } @@ -6333,11 +7080,15 @@ func (s *TextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenNewText { - return fmt.Errorf("required property 'newText' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingNewText != 0 { + missingProps = append(missingProps, "newText") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6352,7 +7103,11 @@ type DidChangeWatchedFilesParams struct { var _ json.UnmarshalerFrom = (*DidChangeWatchedFilesParams)(nil) func (s *DidChangeWatchedFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenChanges bool + const ( + missingChanges uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6368,7 +7123,7 @@ func (s *DidChangeWatchedFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"changes"`: - seenChanges = true + missing &^= missingChanges if err := json.UnmarshalDecode(dec, &s.Changes); err != nil { return err } @@ -6381,8 +7136,12 @@ func (s *DidChangeWatchedFilesParams) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenChanges { - return fmt.Errorf("required property 'changes' is missing") + if missing != 0 { + var missingProps []string + if missing&missingChanges != 0 { + missingProps = append(missingProps, "changes") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6397,7 +7156,11 @@ type DidChangeWatchedFilesRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DidChangeWatchedFilesRegistrationOptions)(nil) func (s *DidChangeWatchedFilesRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenWatchers bool + const ( + missingWatchers uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6413,7 +7176,7 @@ func (s *DidChangeWatchedFilesRegistrationOptions) UnmarshalJSONFrom(dec *jsonte } switch string(name) { case `"watchers"`: - seenWatchers = true + missing &^= missingWatchers if err := json.UnmarshalDecode(dec, &s.Watchers); err != nil { return err } @@ -6426,8 +7189,12 @@ func (s *DidChangeWatchedFilesRegistrationOptions) UnmarshalJSONFrom(dec *jsonte return err } - if !seenWatchers { - return fmt.Errorf("required property 'watchers' is missing") + if missing != 0 { + var missingProps []string + if missing&missingWatchers != 0 { + missingProps = append(missingProps, "watchers") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6450,10 +7217,12 @@ type PublishDiagnosticsParams struct { var _ json.UnmarshalerFrom = (*PublishDiagnosticsParams)(nil) func (s *PublishDiagnosticsParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenDiagnostics bool + const ( + missingUri uint = 1 << iota + missingDiagnostics + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6469,7 +7238,7 @@ func (s *PublishDiagnosticsParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -6478,7 +7247,7 @@ func (s *PublishDiagnosticsParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } case `"diagnostics"`: - seenDiagnostics = true + missing &^= missingDiagnostics if err := json.UnmarshalDecode(dec, &s.Diagnostics); err != nil { return err } @@ -6491,11 +7260,15 @@ func (s *PublishDiagnosticsParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenDiagnostics { - return fmt.Errorf("required property 'diagnostics' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingDiagnostics != 0 { + missingProps = append(missingProps, "diagnostics") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6525,13 +7298,19 @@ func (s *CompletionParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *CompletionParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*CompletionParams)(nil) func (s *CompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6547,12 +7326,12 @@ func (s *CompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -6577,11 +7356,15 @@ func (s *CompletionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6725,13 +7508,17 @@ type CompletionItem struct { // A data entry field that is preserved on a completion item between a // CompletionRequest and a CompletionResolveRequest. - Data *any `json:"data,omitzero"` + Data *CompletionItemData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*CompletionItem)(nil) func (s *CompletionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLabel bool + const ( + missingLabel uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6747,7 +7534,7 @@ func (s *CompletionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"label"`: - seenLabel = true + missing &^= missingLabel if err := json.UnmarshalDecode(dec, &s.Label); err != nil { return err } @@ -6832,8 +7619,12 @@ func (s *CompletionItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLabel { - return fmt.Errorf("required property 'label' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLabel != 0 { + missingProps = append(missingProps, "label") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6891,10 +7682,12 @@ type CompletionList struct { var _ json.UnmarshalerFrom = (*CompletionList)(nil) func (s *CompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenIsIncomplete bool - seenItems bool + const ( + missingIsIncomplete uint = 1 << iota + missingItems + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -6910,7 +7703,7 @@ func (s *CompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"isIncomplete"`: - seenIsIncomplete = true + missing &^= missingIsIncomplete if err := json.UnmarshalDecode(dec, &s.IsIncomplete); err != nil { return err } @@ -6923,7 +7716,7 @@ func (s *CompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -6936,11 +7729,15 @@ func (s *CompletionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenIsIncomplete { - return fmt.Errorf("required property 'isIncomplete' is missing") - } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingIsIncomplete != 0 { + missingProps = append(missingProps, "isIncomplete") + } + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -6988,7 +7785,11 @@ type CompletionRegistrationOptions struct { var _ json.UnmarshalerFrom = (*CompletionRegistrationOptions)(nil) func (s *CompletionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7004,7 +7805,7 @@ func (s *CompletionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -7037,8 +7838,12 @@ func (s *CompletionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7060,13 +7865,19 @@ func (s *HoverParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *HoverParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*HoverParams)(nil) func (s *HoverParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7082,12 +7893,12 @@ func (s *HoverParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -7104,11 +7915,15 @@ func (s *HoverParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7127,7 +7942,11 @@ type Hover struct { var _ json.UnmarshalerFrom = (*Hover)(nil) func (s *Hover) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenContents bool + const ( + missingContents uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7143,7 +7962,7 @@ func (s *Hover) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"contents"`: - seenContents = true + missing &^= missingContents if err := json.UnmarshalDecode(dec, &s.Contents); err != nil { return err } @@ -7160,8 +7979,12 @@ func (s *Hover) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenContents { - return fmt.Errorf("required property 'contents' is missing") + if missing != 0 { + var missingProps []string + if missing&missingContents != 0 { + missingProps = append(missingProps, "contents") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7179,7 +8002,11 @@ type HoverRegistrationOptions struct { var _ json.UnmarshalerFrom = (*HoverRegistrationOptions)(nil) func (s *HoverRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7195,7 +8022,7 @@ func (s *HoverRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -7212,8 +8039,12 @@ func (s *HoverRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7241,13 +8072,19 @@ func (s *SignatureHelpParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *SignatureHelpParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*SignatureHelpParams)(nil) func (s *SignatureHelpParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7263,12 +8100,12 @@ func (s *SignatureHelpParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -7289,11 +8126,15 @@ func (s *SignatureHelpParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7339,7 +8180,11 @@ type SignatureHelp struct { var _ json.UnmarshalerFrom = (*SignatureHelp)(nil) func (s *SignatureHelp) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSignatures bool + const ( + missingSignatures uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7355,7 +8200,7 @@ func (s *SignatureHelp) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"signatures"`: - seenSignatures = true + missing &^= missingSignatures if err := json.UnmarshalDecode(dec, &s.Signatures); err != nil { return err } @@ -7376,8 +8221,12 @@ func (s *SignatureHelp) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenSignatures { - return fmt.Errorf("required property 'signatures' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSignatures != 0 { + missingProps = append(missingProps, "signatures") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7406,7 +8255,11 @@ type SignatureHelpRegistrationOptions struct { var _ json.UnmarshalerFrom = (*SignatureHelpRegistrationOptions)(nil) func (s *SignatureHelpRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7422,7 +8275,7 @@ func (s *SignatureHelpRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -7447,8 +8300,12 @@ func (s *SignatureHelpRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7474,13 +8331,19 @@ func (s *DefinitionParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *DefinitionParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*DefinitionParams)(nil) func (s *DefinitionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7496,12 +8359,12 @@ func (s *DefinitionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -7522,11 +8385,15 @@ func (s *DefinitionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7544,7 +8411,11 @@ type DefinitionRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DefinitionRegistrationOptions)(nil) func (s *DefinitionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7560,7 +8431,7 @@ func (s *DefinitionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -7577,8 +8448,12 @@ func (s *DefinitionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7606,14 +8481,20 @@ func (s *ReferenceParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *ReferenceParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*ReferenceParams)(nil) func (s *ReferenceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool - seenContext bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + missingContext + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7629,12 +8510,12 @@ func (s *ReferenceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -7647,7 +8528,7 @@ func (s *ReferenceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"context"`: - seenContext = true + missing &^= missingContext if err := json.UnmarshalDecode(dec, &s.Context); err != nil { return err } @@ -7660,14 +8541,18 @@ func (s *ReferenceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") - } - if !seenContext { - return fmt.Errorf("required property 'context' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + if missing&missingContext != 0 { + missingProps = append(missingProps, "context") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7685,7 +8570,11 @@ type ReferenceRegistrationOptions struct { var _ json.UnmarshalerFrom = (*ReferenceRegistrationOptions)(nil) func (s *ReferenceRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7701,7 +8590,7 @@ func (s *ReferenceRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -7718,8 +8607,12 @@ func (s *ReferenceRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7745,13 +8638,19 @@ func (s *DocumentHighlightParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *DocumentHighlightParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*DocumentHighlightParams)(nil) func (s *DocumentHighlightParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7767,12 +8666,12 @@ func (s *DocumentHighlightParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -7793,11 +8692,15 @@ func (s *DocumentHighlightParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7817,7 +8720,11 @@ type DocumentHighlight struct { var _ json.UnmarshalerFrom = (*DocumentHighlight)(nil) func (s *DocumentHighlight) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRange bool + const ( + missingRange uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7833,7 +8740,7 @@ func (s *DocumentHighlight) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -7850,8 +8757,12 @@ func (s *DocumentHighlight) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7869,7 +8780,11 @@ type DocumentHighlightRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentHighlightRegistrationOptions)(nil) func (s *DocumentHighlightRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7885,7 +8800,7 @@ func (s *DocumentHighlightRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.D } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -7902,8 +8817,12 @@ func (s *DocumentHighlightRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.D return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -7929,7 +8848,11 @@ func (s *DocumentSymbolParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentSymbolParams)(nil) func (s *DocumentSymbolParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -7953,7 +8876,7 @@ func (s *DocumentSymbolParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -7966,8 +8889,12 @@ func (s *DocumentSymbolParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8013,11 +8940,13 @@ type SymbolInformation struct { var _ json.UnmarshalerFrom = (*SymbolInformation)(nil) func (s *SymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenName bool - seenKind bool - seenLocation bool + const ( + missingName uint = 1 << iota + missingKind + missingLocation + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8033,12 +8962,12 @@ func (s *SymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -8055,7 +8984,7 @@ func (s *SymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"location"`: - seenLocation = true + missing &^= missingLocation if err := json.UnmarshalDecode(dec, &s.Location); err != nil { return err } @@ -8068,14 +8997,18 @@ func (s *SymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") - } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenLocation { - return fmt.Errorf("required property 'location' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingLocation != 0 { + missingProps = append(missingProps, "location") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8122,12 +9055,14 @@ type DocumentSymbol struct { var _ json.UnmarshalerFrom = (*DocumentSymbol)(nil) func (s *DocumentSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenName bool - seenKind bool - seenRange bool - seenSelectionRange bool + const ( + missingName uint = 1 << iota + missingKind + missingRange + missingSelectionRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8143,7 +9078,7 @@ func (s *DocumentSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } @@ -8152,7 +9087,7 @@ func (s *DocumentSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -8165,12 +9100,12 @@ func (s *DocumentSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"selectionRange"`: - seenSelectionRange = true + missing &^= missingSelectionRange if err := json.UnmarshalDecode(dec, &s.SelectionRange); err != nil { return err } @@ -8187,17 +9122,21 @@ func (s *DocumentSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") - } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenSelectionRange { - return fmt.Errorf("required property 'selectionRange' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingSelectionRange != 0 { + missingProps = append(missingProps, "selectionRange") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8221,7 +9160,11 @@ type DocumentSymbolRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentSymbolRegistrationOptions)(nil) func (s *DocumentSymbolRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8237,7 +9180,7 @@ func (s *DocumentSymbolRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -8258,8 +9201,12 @@ func (s *DocumentSymbolRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8291,11 +9238,13 @@ func (s *CodeActionParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*CodeActionParams)(nil) func (s *CodeActionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenRange bool - seenContext bool + const ( + missingTextDocument uint = 1 << iota + missingRange + missingContext + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8319,17 +9268,17 @@ func (s *CodeActionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"context"`: - seenContext = true + missing &^= missingContext if err := json.UnmarshalDecode(dec, &s.Context); err != nil { return err } @@ -8342,14 +9291,18 @@ func (s *CodeActionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenContext { - return fmt.Errorf("required property 'context' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingContext != 0 { + missingProps = append(missingProps, "context") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8381,10 +9334,12 @@ type Command struct { var _ json.UnmarshalerFrom = (*Command)(nil) func (s *Command) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTitle bool - seenCommand bool + const ( + missingTitle uint = 1 << iota + missingCommand + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8400,7 +9355,7 @@ func (s *Command) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"title"`: - seenTitle = true + missing &^= missingTitle if err := json.UnmarshalDecode(dec, &s.Title); err != nil { return err } @@ -8409,7 +9364,7 @@ func (s *Command) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"command"`: - seenCommand = true + missing &^= missingCommand if err := json.UnmarshalDecode(dec, &s.Command); err != nil { return err } @@ -8426,11 +9381,15 @@ func (s *Command) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTitle { - return fmt.Errorf("required property 'title' is missing") - } - if !seenCommand { - return fmt.Errorf("required property 'command' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTitle != 0 { + missingProps = append(missingProps, "title") + } + if missing&missingCommand != 0 { + missingProps = append(missingProps, "command") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8490,7 +9449,7 @@ type CodeAction struct { // a `textDocument/codeAction` and a `codeAction/resolve` request. // // Since: 3.16.0 - Data *any `json:"data,omitzero"` + Data *CodeActionData `json:"data,omitzero"` // Tags for this code action. // @@ -8501,7 +9460,11 @@ type CodeAction struct { var _ json.UnmarshalerFrom = (*CodeAction)(nil) func (s *CodeAction) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTitle bool + const ( + missingTitle uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8517,7 +9480,7 @@ func (s *CodeAction) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"title"`: - seenTitle = true + missing &^= missingTitle if err := json.UnmarshalDecode(dec, &s.Title); err != nil { return err } @@ -8562,8 +9525,12 @@ func (s *CodeAction) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTitle { - return fmt.Errorf("required property 'title' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTitle != 0 { + missingProps = append(missingProps, "title") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8611,7 +9578,11 @@ type CodeActionRegistrationOptions struct { var _ json.UnmarshalerFrom = (*CodeActionRegistrationOptions)(nil) func (s *CodeActionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8627,7 +9598,7 @@ func (s *CodeActionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -8656,8 +9627,12 @@ func (s *CodeActionRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8686,7 +9661,11 @@ type WorkspaceSymbolParams struct { var _ json.UnmarshalerFrom = (*WorkspaceSymbolParams)(nil) func (s *WorkspaceSymbolParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenQuery bool + const ( + missingQuery uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8710,7 +9689,7 @@ func (s *WorkspaceSymbolParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"query"`: - seenQuery = true + missing &^= missingQuery if err := json.UnmarshalDecode(dec, &s.Query); err != nil { return err } @@ -8723,8 +9702,12 @@ func (s *WorkspaceSymbolParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenQuery { - return fmt.Errorf("required property 'query' is missing") + if missing != 0 { + var missingProps []string + if missing&missingQuery != 0 { + missingProps = append(missingProps, "query") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8762,17 +9745,19 @@ type WorkspaceSymbol struct { // A data entry field that is preserved on a workspace symbol between a // workspace symbol request and a workspace symbol resolve request. - Data *any `json:"data,omitzero"` + Data *WorkspaceSymbolData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*WorkspaceSymbol)(nil) func (s *WorkspaceSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenName bool - seenKind bool - seenLocation bool + const ( + missingName uint = 1 << iota + missingKind + missingLocation + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8788,12 +9773,12 @@ func (s *WorkspaceSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -8806,7 +9791,7 @@ func (s *WorkspaceSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"location"`: - seenLocation = true + missing &^= missingLocation if err := json.UnmarshalDecode(dec, &s.Location); err != nil { return err } @@ -8823,14 +9808,18 @@ func (s *WorkspaceSymbol) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") - } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenLocation { - return fmt.Errorf("required property 'location' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingLocation != 0 { + missingProps = append(missingProps, "location") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8867,7 +9856,11 @@ func (s *CodeLensParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*CodeLensParams)(nil) func (s *CodeLensParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8891,7 +9884,7 @@ func (s *CodeLensParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -8904,8 +9897,12 @@ func (s *CodeLensParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8925,13 +9922,17 @@ type CodeLens struct { // A data entry field that is preserved on a code lens item between // a CodeLensRequest and a CodeLensResolveRequest - Data *any `json:"data,omitzero"` + Data *CodeLensData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*CodeLens)(nil) func (s *CodeLens) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRange bool + const ( + missingRange uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -8947,7 +9948,7 @@ func (s *CodeLens) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -8968,8 +9969,12 @@ func (s *CodeLens) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -8990,7 +9995,11 @@ type CodeLensRegistrationOptions struct { var _ json.UnmarshalerFrom = (*CodeLensRegistrationOptions)(nil) func (s *CodeLensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9006,7 +10015,7 @@ func (s *CodeLensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -9027,8 +10036,12 @@ func (s *CodeLensRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9054,7 +10067,11 @@ func (s *DocumentLinkParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentLinkParams)(nil) func (s *DocumentLinkParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTextDocument bool + const ( + missingTextDocument uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9078,7 +10095,7 @@ func (s *DocumentLinkParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } @@ -9091,8 +10108,12 @@ func (s *DocumentLinkParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9118,13 +10139,17 @@ type DocumentLink struct { // A data entry field that is preserved on a document link between a // DocumentLinkRequest and a DocumentLinkResolveRequest. - Data *any `json:"data,omitzero"` + Data *DocumentLinkData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*DocumentLink)(nil) func (s *DocumentLink) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRange bool + const ( + missingRange uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9140,7 +10165,7 @@ func (s *DocumentLink) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -9165,8 +10190,12 @@ func (s *DocumentLink) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9187,7 +10216,11 @@ type DocumentLinkRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentLinkRegistrationOptions)(nil) func (s *DocumentLinkRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9203,7 +10236,7 @@ func (s *DocumentLinkRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -9224,8 +10257,12 @@ func (s *DocumentLinkRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9250,10 +10287,12 @@ func (s *DocumentFormattingParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentFormattingParams)(nil) func (s *DocumentFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenOptions bool + const ( + missingTextDocument uint = 1 << iota + missingOptions + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9273,12 +10312,12 @@ func (s *DocumentFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"options"`: - seenOptions = true + missing &^= missingOptions if err := json.UnmarshalDecode(dec, &s.Options); err != nil { return err } @@ -9291,11 +10330,15 @@ func (s *DocumentFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenOptions { - return fmt.Errorf("required property 'options' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingOptions != 0 { + missingProps = append(missingProps, "options") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9313,7 +10356,11 @@ type DocumentFormattingRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentFormattingRegistrationOptions)(nil) func (s *DocumentFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9329,7 +10376,7 @@ func (s *DocumentFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jsontext. } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -9346,8 +10393,12 @@ func (s *DocumentFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jsontext. return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9375,11 +10426,13 @@ func (s *DocumentRangeFormattingParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentRangeFormattingParams)(nil) func (s *DocumentRangeFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenRange bool - seenOptions bool + const ( + missingTextDocument uint = 1 << iota + missingRange + missingOptions + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9399,17 +10452,17 @@ func (s *DocumentRangeFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"options"`: - seenOptions = true + missing &^= missingOptions if err := json.UnmarshalDecode(dec, &s.Options); err != nil { return err } @@ -9422,14 +10475,18 @@ func (s *DocumentRangeFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenOptions { - return fmt.Errorf("required property 'options' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingOptions != 0 { + missingProps = append(missingProps, "options") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9454,7 +10511,11 @@ type DocumentRangeFormattingRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentRangeFormattingRegistrationOptions)(nil) func (s *DocumentRangeFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9470,7 +10531,7 @@ func (s *DocumentRangeFormattingRegistrationOptions) UnmarshalJSONFrom(dec *json } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -9491,8 +10552,12 @@ func (s *DocumentRangeFormattingRegistrationOptions) UnmarshalJSONFrom(dec *json return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9524,11 +10589,13 @@ func (s *DocumentRangesFormattingParams) TextDocumentURI() DocumentUri { var _ json.UnmarshalerFrom = (*DocumentRangesFormattingParams)(nil) func (s *DocumentRangesFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenRanges bool - seenOptions bool + const ( + missingTextDocument uint = 1 << iota + missingRanges + missingOptions + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9548,17 +10615,17 @@ func (s *DocumentRangesFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"ranges"`: - seenRanges = true + missing &^= missingRanges if err := json.UnmarshalDecode(dec, &s.Ranges); err != nil { return err } case `"options"`: - seenOptions = true + missing &^= missingOptions if err := json.UnmarshalDecode(dec, &s.Options); err != nil { return err } @@ -9571,14 +10638,18 @@ func (s *DocumentRangesFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenRanges { - return fmt.Errorf("required property 'ranges' is missing") - } - if !seenOptions { - return fmt.Errorf("required property 'options' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingRanges != 0 { + missingProps = append(missingProps, "ranges") + } + if missing&missingOptions != 0 { + missingProps = append(missingProps, "options") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9608,15 +10679,21 @@ func (s *DocumentOnTypeFormattingParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *DocumentOnTypeFormattingParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*DocumentOnTypeFormattingParams)(nil) func (s *DocumentOnTypeFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool - seenCh bool - seenOptions bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + missingCh + missingOptions + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9632,22 +10709,22 @@ func (s *DocumentOnTypeFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } case `"ch"`: - seenCh = true + missing &^= missingCh if err := json.UnmarshalDecode(dec, &s.Ch); err != nil { return err } case `"options"`: - seenOptions = true + missing &^= missingOptions if err := json.UnmarshalDecode(dec, &s.Options); err != nil { return err } @@ -9660,17 +10737,21 @@ func (s *DocumentOnTypeFormattingParams) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") - } - if !seenCh { - return fmt.Errorf("required property 'ch' is missing") - } - if !seenOptions { - return fmt.Errorf("required property 'options' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + if missing&missingCh != 0 { + missingProps = append(missingProps, "ch") + } + if missing&missingOptions != 0 { + missingProps = append(missingProps, "options") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9692,10 +10773,12 @@ type DocumentOnTypeFormattingRegistrationOptions struct { var _ json.UnmarshalerFrom = (*DocumentOnTypeFormattingRegistrationOptions)(nil) func (s *DocumentOnTypeFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenDocumentSelector bool - seenFirstTriggerCharacter bool + const ( + missingDocumentSelector uint = 1 << iota + missingFirstTriggerCharacter + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9711,12 +10794,12 @@ func (s *DocumentOnTypeFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jso } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } case `"firstTriggerCharacter"`: - seenFirstTriggerCharacter = true + missing &^= missingFirstTriggerCharacter if err := json.UnmarshalDecode(dec, &s.FirstTriggerCharacter); err != nil { return err } @@ -9733,11 +10816,15 @@ func (s *DocumentOnTypeFormattingRegistrationOptions) UnmarshalJSONFrom(dec *jso return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") - } - if !seenFirstTriggerCharacter { - return fmt.Errorf("required property 'firstTriggerCharacter' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + if missing&missingFirstTriggerCharacter != 0 { + missingProps = append(missingProps, "firstTriggerCharacter") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9764,14 +10851,20 @@ func (s *RenameParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *RenameParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*RenameParams)(nil) func (s *RenameParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool - seenNewName bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + missingNewName + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9791,17 +10884,17 @@ func (s *RenameParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } case `"newName"`: - seenNewName = true + missing &^= missingNewName if err := json.UnmarshalDecode(dec, &s.NewName); err != nil { return err } @@ -9814,14 +10907,18 @@ func (s *RenameParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") - } - if !seenNewName { - return fmt.Errorf("required property 'newName' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + if missing&missingNewName != 0 { + missingProps = append(missingProps, "newName") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9844,7 +10941,11 @@ type RenameRegistrationOptions struct { var _ json.UnmarshalerFrom = (*RenameRegistrationOptions)(nil) func (s *RenameRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDocumentSelector bool + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9860,7 +10961,7 @@ func (s *RenameRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"documentSelector"`: - seenDocumentSelector = true + missing &^= missingDocumentSelector if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { return err } @@ -9881,8 +10982,12 @@ func (s *RenameRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenDocumentSelector { - return fmt.Errorf("required property 'documentSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9903,13 +11008,19 @@ func (s *PrepareRenameParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *PrepareRenameParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*PrepareRenameParams)(nil) func (s *PrepareRenameParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9925,12 +11036,12 @@ func (s *PrepareRenameParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -9947,11 +11058,15 @@ func (s *PrepareRenameParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -9972,7 +11087,11 @@ type ExecuteCommandParams struct { var _ json.UnmarshalerFrom = (*ExecuteCommandParams)(nil) func (s *ExecuteCommandParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenCommand bool + const ( + missingCommand uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -9992,7 +11111,7 @@ func (s *ExecuteCommandParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"command"`: - seenCommand = true + missing &^= missingCommand if err := json.UnmarshalDecode(dec, &s.Command); err != nil { return err } @@ -10009,8 +11128,12 @@ func (s *ExecuteCommandParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenCommand { - return fmt.Errorf("required property 'command' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCommand != 0 { + missingProps = append(missingProps, "command") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10027,7 +11150,11 @@ type ExecuteCommandRegistrationOptions struct { var _ json.UnmarshalerFrom = (*ExecuteCommandRegistrationOptions)(nil) func (s *ExecuteCommandRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenCommands bool + const ( + missingCommands uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10047,7 +11174,7 @@ func (s *ExecuteCommandRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } case `"commands"`: - seenCommands = true + missing &^= missingCommands if err := json.UnmarshalDecode(dec, &s.Commands); err != nil { return err } @@ -10060,8 +11187,12 @@ func (s *ExecuteCommandRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenCommands { - return fmt.Errorf("required property 'commands' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCommands != 0 { + missingProps = append(missingProps, "commands") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10088,7 +11219,11 @@ type ApplyWorkspaceEditParams struct { var _ json.UnmarshalerFrom = (*ApplyWorkspaceEditParams)(nil) func (s *ApplyWorkspaceEditParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenEdit bool + const ( + missingEdit uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10108,7 +11243,7 @@ func (s *ApplyWorkspaceEditParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } case `"edit"`: - seenEdit = true + missing &^= missingEdit if err := json.UnmarshalDecode(dec, &s.Edit); err != nil { return err } @@ -10125,8 +11260,12 @@ func (s *ApplyWorkspaceEditParams) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenEdit { - return fmt.Errorf("required property 'edit' is missing") + if missing != 0 { + var missingProps []string + if missing&missingEdit != 0 { + missingProps = append(missingProps, "edit") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10153,7 +11292,11 @@ type ApplyWorkspaceEditResult struct { var _ json.UnmarshalerFrom = (*ApplyWorkspaceEditResult)(nil) func (s *ApplyWorkspaceEditResult) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenApplied bool + const ( + missingApplied uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10169,7 +11312,7 @@ func (s *ApplyWorkspaceEditResult) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"applied"`: - seenApplied = true + missing &^= missingApplied if err := json.UnmarshalDecode(dec, &s.Applied); err != nil { return err } @@ -10190,8 +11333,12 @@ func (s *ApplyWorkspaceEditResult) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenApplied { - return fmt.Errorf("required property 'applied' is missing") + if missing != 0 { + var missingProps []string + if missing&missingApplied != 0 { + missingProps = append(missingProps, "applied") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10230,10 +11377,12 @@ type WorkDoneProgressBegin struct { var _ json.UnmarshalerFrom = (*WorkDoneProgressBegin)(nil) func (s *WorkDoneProgressBegin) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenTitle bool + const ( + missingKind uint = 1 << iota + missingTitle + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10249,12 +11398,12 @@ func (s *WorkDoneProgressBegin) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"title"`: - seenTitle = true + missing &^= missingTitle if err := json.UnmarshalDecode(dec, &s.Title); err != nil { return err } @@ -10279,11 +11428,15 @@ func (s *WorkDoneProgressBegin) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenTitle { - return fmt.Errorf("required property 'title' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingTitle != 0 { + missingProps = append(missingProps, "title") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10317,7 +11470,11 @@ type WorkDoneProgressReport struct { var _ json.UnmarshalerFrom = (*WorkDoneProgressReport)(nil) func (s *WorkDoneProgressReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenKind bool + const ( + missingKind uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10333,7 +11490,7 @@ func (s *WorkDoneProgressReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -10358,8 +11515,12 @@ func (s *WorkDoneProgressReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10376,7 +11537,11 @@ type WorkDoneProgressEnd struct { var _ json.UnmarshalerFrom = (*WorkDoneProgressEnd)(nil) func (s *WorkDoneProgressEnd) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenKind bool + const ( + missingKind uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10392,7 +11557,7 @@ func (s *WorkDoneProgressEnd) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -10409,8 +11574,12 @@ func (s *WorkDoneProgressEnd) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10423,7 +11592,11 @@ type SetTraceParams struct { var _ json.UnmarshalerFrom = (*SetTraceParams)(nil) func (s *SetTraceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValue bool + const ( + missingValue uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10439,7 +11612,7 @@ func (s *SetTraceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -10452,8 +11625,12 @@ func (s *SetTraceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10468,7 +11645,11 @@ type LogTraceParams struct { var _ json.UnmarshalerFrom = (*LogTraceParams)(nil) func (s *LogTraceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenMessage bool + const ( + missingMessage uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10484,7 +11665,7 @@ func (s *LogTraceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"message"`: - seenMessage = true + missing &^= missingMessage if err := json.UnmarshalDecode(dec, &s.Message); err != nil { return err } @@ -10501,8 +11682,12 @@ func (s *LogTraceParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenMessage { - return fmt.Errorf("required property 'message' is missing") + if missing != 0 { + var missingProps []string + if missing&missingMessage != 0 { + missingProps = append(missingProps, "message") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10516,7 +11701,11 @@ type CancelParams struct { var _ json.UnmarshalerFrom = (*CancelParams)(nil) func (s *CancelParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenId bool + const ( + missingId uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10532,7 +11721,7 @@ func (s *CancelParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"id"`: - seenId = true + missing &^= missingId if err := json.UnmarshalDecode(dec, &s.Id); err != nil { return err } @@ -10545,8 +11734,12 @@ func (s *CancelParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenId { - return fmt.Errorf("required property 'id' is missing") + if missing != 0 { + var missingProps []string + if missing&missingId != 0 { + missingProps = append(missingProps, "id") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10563,10 +11756,12 @@ type ProgressParams struct { var _ json.UnmarshalerFrom = (*ProgressParams)(nil) func (s *ProgressParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenToken bool - seenValue bool + const ( + missingToken uint = 1 << iota + missingValue + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10582,12 +11777,12 @@ func (s *ProgressParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"token"`: - seenToken = true + missing &^= missingToken if err := json.UnmarshalDecode(dec, &s.Token); err != nil { return err } case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -10600,11 +11795,15 @@ func (s *ProgressParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenToken { - return fmt.Errorf("required property 'token' is missing") - } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingToken != 0 { + missingProps = append(missingProps, "token") + } + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10624,13 +11823,19 @@ func (s *TextDocumentPositionParams) TextDocumentURI() DocumentUri { return s.TextDocument.Uri } +func (s *TextDocumentPositionParams) TextDocumentPosition() Position { + return s.Position +} + var _ json.UnmarshalerFrom = (*TextDocumentPositionParams)(nil) func (s *TextDocumentPositionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenPosition bool + const ( + missingTextDocument uint = 1 << iota + missingPosition + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10646,12 +11851,12 @@ func (s *TextDocumentPositionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"position"`: - seenPosition = true + missing &^= missingPosition if err := json.UnmarshalDecode(dec, &s.Position); err != nil { return err } @@ -10664,11 +11869,15 @@ func (s *TextDocumentPositionParams) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenPosition { - return fmt.Errorf("required property 'position' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingPosition != 0 { + missingProps = append(missingProps, "position") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10710,11 +11919,13 @@ type LocationLink struct { var _ json.UnmarshalerFrom = (*LocationLink)(nil) func (s *LocationLink) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTargetUri bool - seenTargetRange bool - seenTargetSelectionRange bool + const ( + missingTargetUri uint = 1 << iota + missingTargetRange + missingTargetSelectionRange + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10734,17 +11945,17 @@ func (s *LocationLink) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"targetUri"`: - seenTargetUri = true + missing &^= missingTargetUri if err := json.UnmarshalDecode(dec, &s.TargetUri); err != nil { return err } case `"targetRange"`: - seenTargetRange = true + missing &^= missingTargetRange if err := json.UnmarshalDecode(dec, &s.TargetRange); err != nil { return err } case `"targetSelectionRange"`: - seenTargetSelectionRange = true + missing &^= missingTargetSelectionRange if err := json.UnmarshalDecode(dec, &s.TargetSelectionRange); err != nil { return err } @@ -10757,14 +11968,18 @@ func (s *LocationLink) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTargetUri { - return fmt.Errorf("required property 'targetUri' is missing") - } - if !seenTargetRange { - return fmt.Errorf("required property 'targetRange' is missing") - } - if !seenTargetSelectionRange { - return fmt.Errorf("required property 'targetSelectionRange' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTargetUri != 0 { + missingProps = append(missingProps, "targetUri") + } + if missing&missingTargetRange != 0 { + missingProps = append(missingProps, "targetRange") + } + if missing&missingTargetSelectionRange != 0 { + missingProps = append(missingProps, "targetSelectionRange") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10794,10 +12009,12 @@ type Range struct { var _ json.UnmarshalerFrom = (*Range)(nil) func (s *Range) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenStart bool - seenEnd bool + const ( + missingStart uint = 1 << iota + missingEnd + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10813,12 +12030,12 @@ func (s *Range) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"start"`: - seenStart = true + missing &^= missingStart if err := json.UnmarshalDecode(dec, &s.Start); err != nil { return err } case `"end"`: - seenEnd = true + missing &^= missingEnd if err := json.UnmarshalDecode(dec, &s.End); err != nil { return err } @@ -10831,11 +12048,15 @@ func (s *Range) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenStart { - return fmt.Errorf("required property 'start' is missing") - } - if !seenEnd { - return fmt.Errorf("required property 'end' is missing") + if missing != 0 { + var missingProps []string + if missing&missingStart != 0 { + missingProps = append(missingProps, "start") + } + if missing&missingEnd != 0 { + missingProps = append(missingProps, "end") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10869,10 +12090,12 @@ type WorkspaceFoldersChangeEvent struct { var _ json.UnmarshalerFrom = (*WorkspaceFoldersChangeEvent)(nil) func (s *WorkspaceFoldersChangeEvent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenAdded bool - seenRemoved bool + const ( + missingAdded uint = 1 << iota + missingRemoved + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10888,12 +12111,12 @@ func (s *WorkspaceFoldersChangeEvent) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"added"`: - seenAdded = true + missing &^= missingAdded if err := json.UnmarshalDecode(dec, &s.Added); err != nil { return err } case `"removed"`: - seenRemoved = true + missing &^= missingRemoved if err := json.UnmarshalDecode(dec, &s.Removed); err != nil { return err } @@ -10906,11 +12129,15 @@ func (s *WorkspaceFoldersChangeEvent) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenAdded { - return fmt.Errorf("required property 'added' is missing") - } - if !seenRemoved { - return fmt.Errorf("required property 'removed' is missing") + if missing != 0 { + var missingProps []string + if missing&missingAdded != 0 { + missingProps = append(missingProps, "added") + } + if missing&missingRemoved != 0 { + missingProps = append(missingProps, "removed") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10933,7 +12160,11 @@ type TextDocumentIdentifier struct { var _ json.UnmarshalerFrom = (*TextDocumentIdentifier)(nil) func (s *TextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -10949,7 +12180,7 @@ func (s *TextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -10962,8 +12193,12 @@ func (s *TextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -10987,12 +12222,14 @@ type Color struct { var _ json.UnmarshalerFrom = (*Color)(nil) func (s *Color) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRed bool - seenGreen bool - seenBlue bool - seenAlpha bool + const ( + missingRed uint = 1 << iota + missingGreen + missingBlue + missingAlpha + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11008,22 +12245,22 @@ func (s *Color) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"red"`: - seenRed = true + missing &^= missingRed if err := json.UnmarshalDecode(dec, &s.Red); err != nil { return err } case `"green"`: - seenGreen = true + missing &^= missingGreen if err := json.UnmarshalDecode(dec, &s.Green); err != nil { return err } case `"blue"`: - seenBlue = true + missing &^= missingBlue if err := json.UnmarshalDecode(dec, &s.Blue); err != nil { return err } case `"alpha"`: - seenAlpha = true + missing &^= missingAlpha if err := json.UnmarshalDecode(dec, &s.Alpha); err != nil { return err } @@ -11036,17 +12273,21 @@ func (s *Color) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRed { - return fmt.Errorf("required property 'red' is missing") - } - if !seenGreen { - return fmt.Errorf("required property 'green' is missing") - } - if !seenBlue { - return fmt.Errorf("required property 'blue' is missing") - } - if !seenAlpha { - return fmt.Errorf("required property 'alpha' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRed != 0 { + missingProps = append(missingProps, "red") + } + if missing&missingGreen != 0 { + missingProps = append(missingProps, "green") + } + if missing&missingBlue != 0 { + missingProps = append(missingProps, "blue") + } + if missing&missingAlpha != 0 { + missingProps = append(missingProps, "alpha") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11105,10 +12346,12 @@ type Position struct { var _ json.UnmarshalerFrom = (*Position)(nil) func (s *Position) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenLine bool - seenCharacter bool + const ( + missingLine uint = 1 << iota + missingCharacter + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11124,12 +12367,12 @@ func (s *Position) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"line"`: - seenLine = true + missing &^= missingLine if err := json.UnmarshalDecode(dec, &s.Line); err != nil { return err } case `"character"`: - seenCharacter = true + missing &^= missingCharacter if err := json.UnmarshalDecode(dec, &s.Character); err != nil { return err } @@ -11142,11 +12385,15 @@ func (s *Position) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLine { - return fmt.Errorf("required property 'line' is missing") - } - if !seenCharacter { - return fmt.Errorf("required property 'character' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLine != 0 { + missingProps = append(missingProps, "line") + } + if missing&missingCharacter != 0 { + missingProps = append(missingProps, "character") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11181,7 +12428,11 @@ type SemanticTokensOptions struct { var _ json.UnmarshalerFrom = (*SemanticTokensOptions)(nil) func (s *SemanticTokensOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLegend bool + const ( + missingLegend uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11201,7 +12452,7 @@ func (s *SemanticTokensOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"legend"`: - seenLegend = true + missing &^= missingLegend if err := json.UnmarshalDecode(dec, &s.Legend); err != nil { return err } @@ -11222,8 +12473,12 @@ func (s *SemanticTokensOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLegend { - return fmt.Errorf("required property 'legend' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLegend != 0 { + missingProps = append(missingProps, "legend") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11244,10 +12499,12 @@ type SemanticTokensEdit struct { var _ json.UnmarshalerFrom = (*SemanticTokensEdit)(nil) func (s *SemanticTokensEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenStart bool - seenDeleteCount bool + const ( + missingStart uint = 1 << iota + missingDeleteCount + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11263,12 +12520,12 @@ func (s *SemanticTokensEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"start"`: - seenStart = true + missing &^= missingStart if err := json.UnmarshalDecode(dec, &s.Start); err != nil { return err } case `"deleteCount"`: - seenDeleteCount = true + missing &^= missingDeleteCount if err := json.UnmarshalDecode(dec, &s.DeleteCount); err != nil { return err } @@ -11285,11 +12542,15 @@ func (s *SemanticTokensEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenStart { - return fmt.Errorf("required property 'start' is missing") - } - if !seenDeleteCount { - return fmt.Errorf("required property 'deleteCount' is missing") + if missing != 0 { + var missingProps []string + if missing&missingStart != 0 { + missingProps = append(missingProps, "start") + } + if missing&missingDeleteCount != 0 { + missingProps = append(missingProps, "deleteCount") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11310,7 +12571,11 @@ type FileCreate struct { var _ json.UnmarshalerFrom = (*FileCreate)(nil) func (s *FileCreate) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11326,7 +12591,7 @@ func (s *FileCreate) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -11339,8 +12604,12 @@ func (s *FileCreate) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11367,10 +12636,12 @@ type TextDocumentEdit struct { var _ json.UnmarshalerFrom = (*TextDocumentEdit)(nil) func (s *TextDocumentEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTextDocument bool - seenEdits bool + const ( + missingTextDocument uint = 1 << iota + missingEdits + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11386,12 +12657,12 @@ func (s *TextDocumentEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"textDocument"`: - seenTextDocument = true + missing &^= missingTextDocument if err := json.UnmarshalDecode(dec, &s.TextDocument); err != nil { return err } case `"edits"`: - seenEdits = true + missing &^= missingEdits if err := json.UnmarshalDecode(dec, &s.Edits); err != nil { return err } @@ -11404,11 +12675,15 @@ func (s *TextDocumentEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTextDocument { - return fmt.Errorf("required property 'textDocument' is missing") - } - if !seenEdits { - return fmt.Errorf("required property 'edits' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTextDocument != 0 { + missingProps = append(missingProps, "textDocument") + } + if missing&missingEdits != 0 { + missingProps = append(missingProps, "edits") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11434,10 +12709,12 @@ type CreateFile struct { var _ json.UnmarshalerFrom = (*CreateFile)(nil) func (s *CreateFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenUri bool + const ( + missingKind uint = 1 << iota + missingUri + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11453,7 +12730,7 @@ func (s *CreateFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -11462,7 +12739,7 @@ func (s *CreateFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -11479,11 +12756,15 @@ func (s *CreateFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11512,11 +12793,13 @@ type RenameFile struct { var _ json.UnmarshalerFrom = (*RenameFile)(nil) func (s *RenameFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenOldUri bool - seenNewUri bool + const ( + missingKind uint = 1 << iota + missingOldUri + missingNewUri + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11532,7 +12815,7 @@ func (s *RenameFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -11541,12 +12824,12 @@ func (s *RenameFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"oldUri"`: - seenOldUri = true + missing &^= missingOldUri if err := json.UnmarshalDecode(dec, &s.OldUri); err != nil { return err } case `"newUri"`: - seenNewUri = true + missing &^= missingNewUri if err := json.UnmarshalDecode(dec, &s.NewUri); err != nil { return err } @@ -11563,14 +12846,18 @@ func (s *RenameFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenOldUri { - return fmt.Errorf("required property 'oldUri' is missing") - } - if !seenNewUri { - return fmt.Errorf("required property 'newUri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingOldUri != 0 { + missingProps = append(missingProps, "oldUri") + } + if missing&missingNewUri != 0 { + missingProps = append(missingProps, "newUri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11596,10 +12883,12 @@ type DeleteFile struct { var _ json.UnmarshalerFrom = (*DeleteFile)(nil) func (s *DeleteFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenUri bool + const ( + missingKind uint = 1 << iota + missingUri + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11615,7 +12904,7 @@ func (s *DeleteFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -11624,7 +12913,7 @@ func (s *DeleteFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -11641,11 +12930,15 @@ func (s *DeleteFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11671,7 +12964,11 @@ type ChangeAnnotation struct { var _ json.UnmarshalerFrom = (*ChangeAnnotation)(nil) func (s *ChangeAnnotation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLabel bool + const ( + missingLabel uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11687,7 +12984,7 @@ func (s *ChangeAnnotation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"label"`: - seenLabel = true + missing &^= missingLabel if err := json.UnmarshalDecode(dec, &s.Label); err != nil { return err } @@ -11708,8 +13005,12 @@ func (s *ChangeAnnotation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLabel { - return fmt.Errorf("required property 'label' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLabel != 0 { + missingProps = append(missingProps, "label") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11730,7 +13031,11 @@ type FileOperationFilter struct { var _ json.UnmarshalerFrom = (*FileOperationFilter)(nil) func (s *FileOperationFilter) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenPattern bool + const ( + missingPattern uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11750,7 +13055,7 @@ func (s *FileOperationFilter) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"pattern"`: - seenPattern = true + missing &^= missingPattern if err := json.UnmarshalDecode(dec, &s.Pattern); err != nil { return err } @@ -11763,8 +13068,12 @@ func (s *FileOperationFilter) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenPattern { - return fmt.Errorf("required property 'pattern' is missing") + if missing != 0 { + var missingProps []string + if missing&missingPattern != 0 { + missingProps = append(missingProps, "pattern") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11784,10 +13093,12 @@ type FileRename struct { var _ json.UnmarshalerFrom = (*FileRename)(nil) func (s *FileRename) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenOldUri bool - seenNewUri bool + const ( + missingOldUri uint = 1 << iota + missingNewUri + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11803,12 +13114,12 @@ func (s *FileRename) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"oldUri"`: - seenOldUri = true + missing &^= missingOldUri if err := json.UnmarshalDecode(dec, &s.OldUri); err != nil { return err } case `"newUri"`: - seenNewUri = true + missing &^= missingNewUri if err := json.UnmarshalDecode(dec, &s.NewUri); err != nil { return err } @@ -11821,11 +13132,15 @@ func (s *FileRename) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenOldUri { - return fmt.Errorf("required property 'oldUri' is missing") - } - if !seenNewUri { - return fmt.Errorf("required property 'newUri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingOldUri != 0 { + missingProps = append(missingProps, "oldUri") + } + if missing&missingNewUri != 0 { + missingProps = append(missingProps, "newUri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11842,7 +13157,11 @@ type FileDelete struct { var _ json.UnmarshalerFrom = (*FileDelete)(nil) func (s *FileDelete) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11858,7 +13177,7 @@ func (s *FileDelete) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -11871,8 +13190,12 @@ func (s *FileDelete) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11902,10 +13225,12 @@ type InlineValueContext struct { var _ json.UnmarshalerFrom = (*InlineValueContext)(nil) func (s *InlineValueContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenFrameId bool - seenStoppedLocation bool + const ( + missingFrameId uint = 1 << iota + missingStoppedLocation + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11921,12 +13246,12 @@ func (s *InlineValueContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"frameId"`: - seenFrameId = true + missing &^= missingFrameId if err := json.UnmarshalDecode(dec, &s.FrameId); err != nil { return err } case `"stoppedLocation"`: - seenStoppedLocation = true + missing &^= missingStoppedLocation if err := json.UnmarshalDecode(dec, &s.StoppedLocation); err != nil { return err } @@ -11939,11 +13264,15 @@ func (s *InlineValueContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenFrameId { - return fmt.Errorf("required property 'frameId' is missing") - } - if !seenStoppedLocation { - return fmt.Errorf("required property 'stoppedLocation' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFrameId != 0 { + missingProps = append(missingProps, "frameId") + } + if missing&missingStoppedLocation != 0 { + missingProps = append(missingProps, "stoppedLocation") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -11963,10 +13292,12 @@ type InlineValueText struct { var _ json.UnmarshalerFrom = (*InlineValueText)(nil) func (s *InlineValueText) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenText bool + const ( + missingRange uint = 1 << iota + missingText + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -11982,12 +13313,12 @@ func (s *InlineValueText) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"text"`: - seenText = true + missing &^= missingText if err := json.UnmarshalDecode(dec, &s.Text); err != nil { return err } @@ -12000,11 +13331,15 @@ func (s *InlineValueText) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenText { - return fmt.Errorf("required property 'text' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingText != 0 { + missingProps = append(missingProps, "text") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12030,10 +13365,12 @@ type InlineValueVariableLookup struct { var _ json.UnmarshalerFrom = (*InlineValueVariableLookup)(nil) func (s *InlineValueVariableLookup) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenCaseSensitiveLookup bool + const ( + missingRange uint = 1 << iota + missingCaseSensitiveLookup + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12049,7 +13386,7 @@ func (s *InlineValueVariableLookup) UnmarshalJSONFrom(dec *jsontext.Decoder) err } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -12058,7 +13395,7 @@ func (s *InlineValueVariableLookup) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } case `"caseSensitiveLookup"`: - seenCaseSensitiveLookup = true + missing &^= missingCaseSensitiveLookup if err := json.UnmarshalDecode(dec, &s.CaseSensitiveLookup); err != nil { return err } @@ -12071,11 +13408,15 @@ func (s *InlineValueVariableLookup) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenCaseSensitiveLookup { - return fmt.Errorf("required property 'caseSensitiveLookup' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingCaseSensitiveLookup != 0 { + missingProps = append(missingProps, "caseSensitiveLookup") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12098,7 +13439,11 @@ type InlineValueEvaluatableExpression struct { var _ json.UnmarshalerFrom = (*InlineValueEvaluatableExpression)(nil) func (s *InlineValueEvaluatableExpression) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenRange bool + const ( + missingRange uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12114,7 +13459,7 @@ func (s *InlineValueEvaluatableExpression) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -12131,8 +13476,12 @@ func (s *InlineValueEvaluatableExpression) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12181,7 +13530,11 @@ type InlayHintLabelPart struct { var _ json.UnmarshalerFrom = (*InlayHintLabelPart)(nil) func (s *InlayHintLabelPart) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValue bool + const ( + missingValue uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12197,7 +13550,7 @@ func (s *InlayHintLabelPart) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -12222,8 +13575,12 @@ func (s *InlayHintLabelPart) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12264,10 +13621,12 @@ type MarkupContent struct { var _ json.UnmarshalerFrom = (*MarkupContent)(nil) func (s *MarkupContent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenValue bool + const ( + missingKind uint = 1 << iota + missingValue + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12283,12 +13642,12 @@ func (s *MarkupContent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -12301,11 +13660,15 @@ func (s *MarkupContent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12350,10 +13713,12 @@ type RelatedFullDocumentDiagnosticReport struct { var _ json.UnmarshalerFrom = (*RelatedFullDocumentDiagnosticReport)(nil) func (s *RelatedFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenItems bool + const ( + missingKind uint = 1 << iota + missingItems + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12369,7 +13734,7 @@ func (s *RelatedFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.De } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -12378,7 +13743,7 @@ func (s *RelatedFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.De return err } case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -12395,11 +13760,15 @@ func (s *RelatedFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.De return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12432,10 +13801,12 @@ type RelatedUnchangedDocumentDiagnosticReport struct { var _ json.UnmarshalerFrom = (*RelatedUnchangedDocumentDiagnosticReport)(nil) func (s *RelatedUnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenResultId bool + const ( + missingKind uint = 1 << iota + missingResultId + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12451,12 +13822,12 @@ func (s *RelatedUnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsonte } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"resultId"`: - seenResultId = true + missing &^= missingResultId if err := json.UnmarshalDecode(dec, &s.ResultId); err != nil { return err } @@ -12473,11 +13844,15 @@ func (s *RelatedUnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsonte return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenResultId { - return fmt.Errorf("required property 'resultId' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingResultId != 0 { + missingProps = append(missingProps, "resultId") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12502,10 +13877,12 @@ type FullDocumentDiagnosticReport struct { var _ json.UnmarshalerFrom = (*FullDocumentDiagnosticReport)(nil) func (s *FullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenItems bool + const ( + missingKind uint = 1 << iota + missingItems + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12521,7 +13898,7 @@ func (s *FullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -12530,7 +13907,7 @@ func (s *FullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } @@ -12543,11 +13920,15 @@ func (s *FullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12572,10 +13953,12 @@ type UnchangedDocumentDiagnosticReport struct { var _ json.UnmarshalerFrom = (*UnchangedDocumentDiagnosticReport)(nil) func (s *UnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenResultId bool + const ( + missingKind uint = 1 << iota + missingResultId + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12591,12 +13974,12 @@ func (s *UnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Deco } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"resultId"`: - seenResultId = true + missing &^= missingResultId if err := json.UnmarshalDecode(dec, &s.ResultId); err != nil { return err } @@ -12609,11 +13992,15 @@ func (s *UnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Deco return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenResultId { - return fmt.Errorf("required property 'resultId' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingResultId != 0 { + missingProps = append(missingProps, "resultId") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12642,10 +14029,12 @@ type DiagnosticOptions struct { var _ json.UnmarshalerFrom = (*DiagnosticOptions)(nil) func (s *DiagnosticOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenInterFileDependencies bool - seenWorkspaceDiagnostics bool + const ( + missingInterFileDependencies uint = 1 << iota + missingWorkspaceDiagnostics + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12669,12 +14058,12 @@ func (s *DiagnosticOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"interFileDependencies"`: - seenInterFileDependencies = true + missing &^= missingInterFileDependencies if err := json.UnmarshalDecode(dec, &s.InterFileDependencies); err != nil { return err } case `"workspaceDiagnostics"`: - seenWorkspaceDiagnostics = true + missing &^= missingWorkspaceDiagnostics if err := json.UnmarshalDecode(dec, &s.WorkspaceDiagnostics); err != nil { return err } @@ -12687,11 +14076,15 @@ func (s *DiagnosticOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenInterFileDependencies { - return fmt.Errorf("required property 'interFileDependencies' is missing") - } - if !seenWorkspaceDiagnostics { - return fmt.Errorf("required property 'workspaceDiagnostics' is missing") + if missing != 0 { + var missingProps []string + if missing&missingInterFileDependencies != 0 { + missingProps = append(missingProps, "interFileDependencies") + } + if missing&missingWorkspaceDiagnostics != 0 { + missingProps = append(missingProps, "workspaceDiagnostics") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12712,10 +14105,12 @@ type PreviousResultId struct { var _ json.UnmarshalerFrom = (*PreviousResultId)(nil) func (s *PreviousResultId) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenValue bool + const ( + missingUri uint = 1 << iota + missingValue + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12731,12 +14126,12 @@ func (s *PreviousResultId) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -12749,11 +14144,15 @@ func (s *PreviousResultId) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12786,12 +14185,14 @@ type NotebookDocument struct { var _ json.UnmarshalerFrom = (*NotebookDocument)(nil) func (s *NotebookDocument) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenNotebookType bool - seenVersion bool - seenCells bool + const ( + missingUri uint = 1 << iota + missingNotebookType + missingVersion + missingCells + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12807,17 +14208,17 @@ func (s *NotebookDocument) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"notebookType"`: - seenNotebookType = true + missing &^= missingNotebookType if err := json.UnmarshalDecode(dec, &s.NotebookType); err != nil { return err } case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } @@ -12826,7 +14227,7 @@ func (s *NotebookDocument) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"cells"`: - seenCells = true + missing &^= missingCells if err := json.UnmarshalDecode(dec, &s.Cells); err != nil { return err } @@ -12839,17 +14240,21 @@ func (s *NotebookDocument) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenNotebookType { - return fmt.Errorf("required property 'notebookType' is missing") - } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") - } - if !seenCells { - return fmt.Errorf("required property 'cells' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingNotebookType != 0 { + missingProps = append(missingProps, "notebookType") + } + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + if missing&missingCells != 0 { + missingProps = append(missingProps, "cells") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12875,12 +14280,14 @@ type TextDocumentItem struct { var _ json.UnmarshalerFrom = (*TextDocumentItem)(nil) func (s *TextDocumentItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenLanguageId bool - seenVersion bool - seenText bool + const ( + missingUri uint = 1 << iota + missingLanguageId + missingVersion + missingText + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12896,22 +14303,22 @@ func (s *TextDocumentItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"languageId"`: - seenLanguageId = true + missing &^= missingLanguageId if err := json.UnmarshalDecode(dec, &s.LanguageId); err != nil { return err } case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } case `"text"`: - seenText = true + missing &^= missingText if err := json.UnmarshalDecode(dec, &s.Text); err != nil { return err } @@ -12924,17 +14331,21 @@ func (s *TextDocumentItem) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenLanguageId { - return fmt.Errorf("required property 'languageId' is missing") - } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") - } - if !seenText { - return fmt.Errorf("required property 'text' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingLanguageId != 0 { + missingProps = append(missingProps, "languageId") + } + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + if missing&missingText != 0 { + missingProps = append(missingProps, "text") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -12965,7 +14376,11 @@ type NotebookDocumentSyncOptions struct { var _ json.UnmarshalerFrom = (*NotebookDocumentSyncOptions)(nil) func (s *NotebookDocumentSyncOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenNotebookSelector bool + const ( + missingNotebookSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -12981,7 +14396,7 @@ func (s *NotebookDocumentSyncOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"notebookSelector"`: - seenNotebookSelector = true + missing &^= missingNotebookSelector if err := json.UnmarshalDecode(dec, &s.NotebookSelector); err != nil { return err } @@ -12998,8 +14413,12 @@ func (s *NotebookDocumentSyncOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenNotebookSelector { - return fmt.Errorf("required property 'notebookSelector' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookSelector != 0 { + missingProps = append(missingProps, "notebookSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13019,10 +14438,12 @@ type VersionedNotebookDocumentIdentifier struct { var _ json.UnmarshalerFrom = (*VersionedNotebookDocumentIdentifier)(nil) func (s *VersionedNotebookDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenVersion bool - seenUri bool + const ( + missingVersion uint = 1 << iota + missingUri + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13038,12 +14459,12 @@ func (s *VersionedNotebookDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.De } switch string(name) { case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -13056,11 +14477,15 @@ func (s *VersionedNotebookDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.De return err } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13090,7 +14515,11 @@ type NotebookDocumentIdentifier struct { var _ json.UnmarshalerFrom = (*NotebookDocumentIdentifier)(nil) func (s *NotebookDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13106,7 +14535,7 @@ func (s *NotebookDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -13119,8 +14548,12 @@ func (s *NotebookDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13142,7 +14575,11 @@ type InlineCompletionContext struct { var _ json.UnmarshalerFrom = (*InlineCompletionContext)(nil) func (s *InlineCompletionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTriggerKind bool + const ( + missingTriggerKind uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13158,7 +14595,7 @@ func (s *InlineCompletionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"triggerKind"`: - seenTriggerKind = true + missing &^= missingTriggerKind if err := json.UnmarshalDecode(dec, &s.TriggerKind); err != nil { return err } @@ -13175,8 +14612,12 @@ func (s *InlineCompletionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenTriggerKind { - return fmt.Errorf("required property 'triggerKind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTriggerKind != 0 { + missingProps = append(missingProps, "triggerKind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13204,10 +14645,12 @@ type StringValue struct { var _ json.UnmarshalerFrom = (*StringValue)(nil) func (s *StringValue) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenValue bool + const ( + missingKind uint = 1 << iota + missingValue + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13223,12 +14666,12 @@ func (s *StringValue) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -13241,11 +14684,15 @@ func (s *StringValue) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13273,7 +14720,11 @@ type TextDocumentContentOptions struct { var _ json.UnmarshalerFrom = (*TextDocumentContentOptions)(nil) func (s *TextDocumentContentOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSchemes bool + const ( + missingSchemes uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13289,7 +14740,7 @@ func (s *TextDocumentContentOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"schemes"`: - seenSchemes = true + missing &^= missingSchemes if err := json.UnmarshalDecode(dec, &s.Schemes); err != nil { return err } @@ -13302,8 +14753,12 @@ func (s *TextDocumentContentOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenSchemes { - return fmt.Errorf("required property 'schemes' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSchemes != 0 { + missingProps = append(missingProps, "schemes") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13319,16 +14774,18 @@ type Registration struct { Method string `json:"method"` // Options necessary for the registration. - RegisterOptions *any `json:"registerOptions,omitzero"` + RegisterOptions *RegisterOptions `json:"registerOptions,omitzero"` } var _ json.UnmarshalerFrom = (*Registration)(nil) func (s *Registration) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenId bool - seenMethod bool + const ( + missingId uint = 1 << iota + missingMethod + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13344,12 +14801,12 @@ func (s *Registration) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"id"`: - seenId = true + missing &^= missingId if err := json.UnmarshalDecode(dec, &s.Id); err != nil { return err } case `"method"`: - seenMethod = true + missing &^= missingMethod if err := json.UnmarshalDecode(dec, &s.Method); err != nil { return err } @@ -13366,11 +14823,15 @@ func (s *Registration) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenId { - return fmt.Errorf("required property 'id' is missing") - } - if !seenMethod { - return fmt.Errorf("required property 'method' is missing") + if missing != 0 { + var missingProps []string + if missing&missingId != 0 { + missingProps = append(missingProps, "id") + } + if missing&missingMethod != 0 { + missingProps = append(missingProps, "method") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13389,10 +14850,12 @@ type Unregistration struct { var _ json.UnmarshalerFrom = (*Unregistration)(nil) func (s *Unregistration) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenId bool - seenMethod bool + const ( + missingId uint = 1 << iota + missingMethod + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13408,12 +14871,12 @@ func (s *Unregistration) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"id"`: - seenId = true + missing &^= missingId if err := json.UnmarshalDecode(dec, &s.Id); err != nil { return err } case `"method"`: - seenMethod = true + missing &^= missingMethod if err := json.UnmarshalDecode(dec, &s.Method); err != nil { return err } @@ -13426,144 +14889,15 @@ func (s *Unregistration) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenId { - return fmt.Errorf("required property 'id' is missing") - } - if !seenMethod { - return fmt.Errorf("required property 'method' is missing") - } - - return nil -} - -// The initialize parameters -type InitializeParamsBase struct { - // An optional token that a server can use to report work done progress. - WorkDoneToken *IntegerOrString `json:"workDoneToken,omitzero"` - - // The process Id of the parent process that started - // the server. - // - // Is `null` if the process has not been started by another process. - // If the parent process is not alive then the server should exit. - ProcessId IntegerOrNull `json:"processId"` - - // Information about the client - // - // Since: 3.15.0 - ClientInfo *ClientInfo `json:"clientInfo,omitzero"` - - // The locale the client is currently showing the user interface - // in. This must not necessarily be the locale of the operating - // system. - // - // Uses IETF language tags as the value's syntax - // (See https://en.wikipedia.org/wiki/IETF_language_tag) - // - // Since: 3.16.0 - Locale *string `json:"locale,omitzero"` - - // The rootPath of the workspace. Is null - // if no folder is open. - // - // Deprecated: in favour of rootUri. - RootPath *StringOrNull `json:"rootPath,omitzero"` - - // The rootUri of the workspace. Is null if no - // folder is open. If both `rootPath` and `rootUri` are set - // `rootUri` wins. - // - // Deprecated: in favour of workspaceFolders. - RootUri DocumentUriOrNull `json:"rootUri"` - - // The capabilities provided by the client (editor or tool) - Capabilities *ClientCapabilities `json:"capabilities"` - - // User provided initialization options. - InitializationOptions *any `json:"initializationOptions,omitzero"` - - // The initial trace setting. If omitted trace is disabled ('off'). - Trace *TraceValue `json:"trace,omitzero"` -} - -var _ json.UnmarshalerFrom = (*InitializeParamsBase)(nil) - -func (s *InitializeParamsBase) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenProcessId bool - seenRootUri bool - seenCapabilities bool - ) - - if k := dec.PeekKind(); k != '{' { - return fmt.Errorf("expected object start, but encountered %v", k) - } - if _, err := dec.ReadToken(); err != nil { - return err - } - - for dec.PeekKind() != '}' { - name, err := dec.ReadValue() - if err != nil { - return err + if missing != 0 { + var missingProps []string + if missing&missingId != 0 { + missingProps = append(missingProps, "id") } - switch string(name) { - case `"workDoneToken"`: - if err := json.UnmarshalDecode(dec, &s.WorkDoneToken); err != nil { - return err - } - case `"processId"`: - seenProcessId = true - if err := json.UnmarshalDecode(dec, &s.ProcessId); err != nil { - return err - } - case `"clientInfo"`: - if err := json.UnmarshalDecode(dec, &s.ClientInfo); err != nil { - return err - } - case `"locale"`: - if err := json.UnmarshalDecode(dec, &s.Locale); err != nil { - return err - } - case `"rootPath"`: - if err := json.UnmarshalDecode(dec, &s.RootPath); err != nil { - return err - } - case `"rootUri"`: - seenRootUri = true - if err := json.UnmarshalDecode(dec, &s.RootUri); err != nil { - return err - } - case `"capabilities"`: - seenCapabilities = true - if err := json.UnmarshalDecode(dec, &s.Capabilities); err != nil { - return err - } - case `"initializationOptions"`: - if err := json.UnmarshalDecode(dec, &s.InitializationOptions); err != nil { - return err - } - case `"trace"`: - if err := json.UnmarshalDecode(dec, &s.Trace); err != nil { - return err - } - default: - // Ignore unknown properties. + if missing&missingMethod != 0 { + missingProps = append(missingProps, "method") } - } - - if _, err := dec.ReadToken(); err != nil { - return err - } - - if !seenProcessId { - return fmt.Errorf("required property 'processId' is missing") - } - if !seenRootUri { - return fmt.Errorf("required property 'rootUri' is missing") - } - if !seenCapabilities { - return fmt.Errorf("required property 'capabilities' is missing") + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13723,9 +15057,6 @@ type ServerCapabilities struct { // Workspace specific server capabilities. Workspace *WorkspaceOptions `json:"workspace,omitzero"` - - // Experimental server capabilities. - Experimental *any `json:"experimental,omitzero"` } // Information about the server @@ -13744,7 +15075,11 @@ type ServerInfo struct { var _ json.UnmarshalerFrom = (*ServerInfo)(nil) func (s *ServerInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenName bool + const ( + missingName uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13760,7 +15095,7 @@ func (s *ServerInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } @@ -13777,8 +15112,12 @@ func (s *ServerInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13796,10 +15135,12 @@ type VersionedTextDocumentIdentifier struct { var _ json.UnmarshalerFrom = (*VersionedTextDocumentIdentifier)(nil) func (s *VersionedTextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenVersion bool + const ( + missingUri uint = 1 << iota + missingVersion + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13815,12 +15156,12 @@ func (s *VersionedTextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } @@ -13833,11 +15174,15 @@ func (s *VersionedTextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13861,10 +15206,12 @@ type FileEvent struct { var _ json.UnmarshalerFrom = (*FileEvent)(nil) func (s *FileEvent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenType bool + const ( + missingUri uint = 1 << iota + missingType + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13880,12 +15227,12 @@ func (s *FileEvent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"type"`: - seenType = true + missing &^= missingType if err := json.UnmarshalDecode(dec, &s.Type); err != nil { return err } @@ -13898,11 +15245,15 @@ func (s *FileEvent) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenType { - return fmt.Errorf("required property 'type' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingType != 0 { + missingProps = append(missingProps, "type") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -13923,7 +15274,11 @@ type FileSystemWatcher struct { var _ json.UnmarshalerFrom = (*FileSystemWatcher)(nil) func (s *FileSystemWatcher) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenGlobPattern bool + const ( + missingGlobPattern uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -13939,7 +15294,7 @@ func (s *FileSystemWatcher) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"globPattern"`: - seenGlobPattern = true + missing &^= missingGlobPattern if err := json.UnmarshalDecode(dec, &s.GlobPattern); err != nil { return err } @@ -13956,8 +15311,12 @@ func (s *FileSystemWatcher) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenGlobPattern { - return fmt.Errorf("required property 'globPattern' is missing") + if missing != 0 { + var missingProps []string + if missing&missingGlobPattern != 0 { + missingProps = append(missingProps, "globPattern") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14004,16 +15363,18 @@ type Diagnostic struct { // notification and `textDocument/codeAction` request. // // Since: 3.16.0 - Data *any `json:"data,omitzero"` + Data *DiagnosticData `json:"data,omitzero"` } var _ json.UnmarshalerFrom = (*Diagnostic)(nil) func (s *Diagnostic) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenMessage bool + const ( + missingRange uint = 1 << iota + missingMessage + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14029,7 +15390,7 @@ func (s *Diagnostic) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -14050,7 +15411,7 @@ func (s *Diagnostic) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"message"`: - seenMessage = true + missing &^= missingMessage if err := json.UnmarshalDecode(dec, &s.Message); err != nil { return err } @@ -14075,11 +15436,15 @@ func (s *Diagnostic) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenMessage { - return fmt.Errorf("required property 'message' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingMessage != 0 { + missingProps = append(missingProps, "message") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14098,7 +15463,11 @@ type CompletionContext struct { var _ json.UnmarshalerFrom = (*CompletionContext)(nil) func (s *CompletionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenTriggerKind bool + const ( + missingTriggerKind uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14114,7 +15483,7 @@ func (s *CompletionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"triggerKind"`: - seenTriggerKind = true + missing &^= missingTriggerKind if err := json.UnmarshalDecode(dec, &s.TriggerKind); err != nil { return err } @@ -14131,8 +15500,12 @@ func (s *CompletionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTriggerKind { - return fmt.Errorf("required property 'triggerKind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTriggerKind != 0 { + missingProps = append(missingProps, "triggerKind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14168,11 +15541,13 @@ type InsertReplaceEdit struct { var _ json.UnmarshalerFrom = (*InsertReplaceEdit)(nil) func (s *InsertReplaceEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenNewText bool - seenInsert bool - seenReplace bool + const ( + missingNewText uint = 1 << iota + missingInsert + missingReplace + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14188,17 +15563,17 @@ func (s *InsertReplaceEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"newText"`: - seenNewText = true + missing &^= missingNewText if err := json.UnmarshalDecode(dec, &s.NewText); err != nil { return err } case `"insert"`: - seenInsert = true + missing &^= missingInsert if err := json.UnmarshalDecode(dec, &s.Insert); err != nil { return err } case `"replace"`: - seenReplace = true + missing &^= missingReplace if err := json.UnmarshalDecode(dec, &s.Replace); err != nil { return err } @@ -14211,14 +15586,18 @@ func (s *InsertReplaceEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenNewText { - return fmt.Errorf("required property 'newText' is missing") - } - if !seenInsert { - return fmt.Errorf("required property 'insert' is missing") - } - if !seenReplace { - return fmt.Errorf("required property 'replace' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNewText != 0 { + missingProps = append(missingProps, "newText") + } + if missing&missingInsert != 0 { + missingProps = append(missingProps, "insert") + } + if missing&missingReplace != 0 { + missingProps = append(missingProps, "replace") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14263,7 +15642,7 @@ type CompletionItemDefaults struct { // A default data value. // // Since: 3.17.0 - Data *any `json:"data,omitzero"` + Data *CompletionItemDefaultsData `json:"data,omitzero"` } // Specifies how fields from a completion item should be combined with those @@ -14394,10 +15773,12 @@ type SignatureHelpContext struct { var _ json.UnmarshalerFrom = (*SignatureHelpContext)(nil) func (s *SignatureHelpContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTriggerKind bool - seenIsRetrigger bool + const ( + missingTriggerKind uint = 1 << iota + missingIsRetrigger + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14413,7 +15794,7 @@ func (s *SignatureHelpContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"triggerKind"`: - seenTriggerKind = true + missing &^= missingTriggerKind if err := json.UnmarshalDecode(dec, &s.TriggerKind); err != nil { return err } @@ -14422,7 +15803,7 @@ func (s *SignatureHelpContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"isRetrigger"`: - seenIsRetrigger = true + missing &^= missingIsRetrigger if err := json.UnmarshalDecode(dec, &s.IsRetrigger); err != nil { return err } @@ -14439,11 +15820,15 @@ func (s *SignatureHelpContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTriggerKind { - return fmt.Errorf("required property 'triggerKind' is missing") - } - if !seenIsRetrigger { - return fmt.Errorf("required property 'isRetrigger' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTriggerKind != 0 { + missingProps = append(missingProps, "triggerKind") + } + if missing&missingIsRetrigger != 0 { + missingProps = append(missingProps, "isRetrigger") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14481,7 +15866,11 @@ type SignatureInformation struct { var _ json.UnmarshalerFrom = (*SignatureInformation)(nil) func (s *SignatureInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLabel bool + const ( + missingLabel uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14497,7 +15886,7 @@ func (s *SignatureInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"label"`: - seenLabel = true + missing &^= missingLabel if err := json.UnmarshalDecode(dec, &s.Label); err != nil { return err } @@ -14522,8 +15911,12 @@ func (s *SignatureInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLabel { - return fmt.Errorf("required property 'label' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLabel != 0 { + missingProps = append(missingProps, "label") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14560,7 +15953,11 @@ type ReferenceContext struct { var _ json.UnmarshalerFrom = (*ReferenceContext)(nil) func (s *ReferenceContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenIncludeDeclaration bool + const ( + missingIncludeDeclaration uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14576,7 +15973,7 @@ func (s *ReferenceContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"includeDeclaration"`: - seenIncludeDeclaration = true + missing &^= missingIncludeDeclaration if err := json.UnmarshalDecode(dec, &s.IncludeDeclaration); err != nil { return err } @@ -14589,8 +15986,12 @@ func (s *ReferenceContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenIncludeDeclaration { - return fmt.Errorf("required property 'includeDeclaration' is missing") + if missing != 0 { + var missingProps []string + if missing&missingIncludeDeclaration != 0 { + missingProps = append(missingProps, "includeDeclaration") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14629,10 +16030,12 @@ type BaseSymbolInformation struct { var _ json.UnmarshalerFrom = (*BaseSymbolInformation)(nil) func (s *BaseSymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenName bool - seenKind bool + const ( + missingName uint = 1 << iota + missingKind + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14648,12 +16051,12 @@ func (s *BaseSymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -14674,11 +16077,15 @@ func (s *BaseSymbolInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") - } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14720,7 +16127,11 @@ type CodeActionContext struct { var _ json.UnmarshalerFrom = (*CodeActionContext)(nil) func (s *CodeActionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDiagnostics bool + const ( + missingDiagnostics uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14736,7 +16147,7 @@ func (s *CodeActionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"diagnostics"`: - seenDiagnostics = true + missing &^= missingDiagnostics if err := json.UnmarshalDecode(dec, &s.Diagnostics); err != nil { return err } @@ -14757,8 +16168,12 @@ func (s *CodeActionContext) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenDiagnostics { - return fmt.Errorf("required property 'diagnostics' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDiagnostics != 0 { + missingProps = append(missingProps, "diagnostics") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14777,7 +16192,11 @@ type CodeActionDisabled struct { var _ json.UnmarshalerFrom = (*CodeActionDisabled)(nil) func (s *CodeActionDisabled) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenReason bool + const ( + missingReason uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14793,7 +16212,7 @@ func (s *CodeActionDisabled) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"reason"`: - seenReason = true + missing &^= missingReason if err := json.UnmarshalDecode(dec, &s.Reason); err != nil { return err } @@ -14806,8 +16225,12 @@ func (s *CodeActionDisabled) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenReason { - return fmt.Errorf("required property 'reason' is missing") + if missing != 0 { + var missingProps []string + if missing&missingReason != 0 { + missingProps = append(missingProps, "reason") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14858,7 +16281,11 @@ type LocationUriOnly struct { var _ json.UnmarshalerFrom = (*LocationUriOnly)(nil) func (s *LocationUriOnly) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenUri bool + const ( + missingUri uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14874,7 +16301,7 @@ func (s *LocationUriOnly) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } @@ -14887,8 +16314,12 @@ func (s *LocationUriOnly) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -14948,10 +16379,12 @@ type FormattingOptions struct { var _ json.UnmarshalerFrom = (*FormattingOptions)(nil) func (s *FormattingOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTabSize bool - seenInsertSpaces bool + const ( + missingTabSize uint = 1 << iota + missingInsertSpaces + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -14967,12 +16400,12 @@ func (s *FormattingOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"tabSize"`: - seenTabSize = true + missing &^= missingTabSize if err := json.UnmarshalDecode(dec, &s.TabSize); err != nil { return err } case `"insertSpaces"`: - seenInsertSpaces = true + missing &^= missingInsertSpaces if err := json.UnmarshalDecode(dec, &s.InsertSpaces); err != nil { return err } @@ -14997,11 +16430,15 @@ func (s *FormattingOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTabSize { - return fmt.Errorf("required property 'tabSize' is missing") - } - if !seenInsertSpaces { - return fmt.Errorf("required property 'insertSpaces' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTabSize != 0 { + missingProps = append(missingProps, "tabSize") + } + if missing&missingInsertSpaces != 0 { + missingProps = append(missingProps, "insertSpaces") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15036,7 +16473,11 @@ type DocumentOnTypeFormattingOptions struct { var _ json.UnmarshalerFrom = (*DocumentOnTypeFormattingOptions)(nil) func (s *DocumentOnTypeFormattingOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenFirstTriggerCharacter bool + const ( + missingFirstTriggerCharacter uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15052,7 +16493,7 @@ func (s *DocumentOnTypeFormattingOptions) UnmarshalJSONFrom(dec *jsontext.Decode } switch string(name) { case `"firstTriggerCharacter"`: - seenFirstTriggerCharacter = true + missing &^= missingFirstTriggerCharacter if err := json.UnmarshalDecode(dec, &s.FirstTriggerCharacter); err != nil { return err } @@ -15069,8 +16510,12 @@ func (s *DocumentOnTypeFormattingOptions) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenFirstTriggerCharacter { - return fmt.Errorf("required property 'firstTriggerCharacter' is missing") + if missing != 0 { + var missingProps []string + if missing&missingFirstTriggerCharacter != 0 { + missingProps = append(missingProps, "firstTriggerCharacter") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15096,10 +16541,12 @@ type PrepareRenamePlaceholder struct { var _ json.UnmarshalerFrom = (*PrepareRenamePlaceholder)(nil) func (s *PrepareRenamePlaceholder) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenPlaceholder bool + const ( + missingRange uint = 1 << iota + missingPlaceholder + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15115,12 +16562,12 @@ func (s *PrepareRenamePlaceholder) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"placeholder"`: - seenPlaceholder = true + missing &^= missingPlaceholder if err := json.UnmarshalDecode(dec, &s.Placeholder); err != nil { return err } @@ -15133,11 +16580,15 @@ func (s *PrepareRenamePlaceholder) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenPlaceholder { - return fmt.Errorf("required property 'placeholder' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingPlaceholder != 0 { + missingProps = append(missingProps, "placeholder") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15151,7 +16602,11 @@ type PrepareRenameDefaultBehavior struct { var _ json.UnmarshalerFrom = (*PrepareRenameDefaultBehavior)(nil) func (s *PrepareRenameDefaultBehavior) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenDefaultBehavior bool + const ( + missingDefaultBehavior uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15167,7 +16622,7 @@ func (s *PrepareRenameDefaultBehavior) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"defaultBehavior"`: - seenDefaultBehavior = true + missing &^= missingDefaultBehavior if err := json.UnmarshalDecode(dec, &s.DefaultBehavior); err != nil { return err } @@ -15180,8 +16635,12 @@ func (s *PrepareRenameDefaultBehavior) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenDefaultBehavior { - return fmt.Errorf("required property 'defaultBehavior' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDefaultBehavior != 0 { + missingProps = append(missingProps, "defaultBehavior") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15198,7 +16657,11 @@ type ExecuteCommandOptions struct { var _ json.UnmarshalerFrom = (*ExecuteCommandOptions)(nil) func (s *ExecuteCommandOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenCommands bool + const ( + missingCommands uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15218,7 +16681,7 @@ func (s *ExecuteCommandOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } case `"commands"`: - seenCommands = true + missing &^= missingCommands if err := json.UnmarshalDecode(dec, &s.Commands); err != nil { return err } @@ -15231,8 +16694,12 @@ func (s *ExecuteCommandOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenCommands { - return fmt.Errorf("required property 'commands' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCommands != 0 { + missingProps = append(missingProps, "commands") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15260,10 +16727,12 @@ type SemanticTokensLegend struct { var _ json.UnmarshalerFrom = (*SemanticTokensLegend)(nil) func (s *SemanticTokensLegend) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenTokenTypes bool - seenTokenModifiers bool + const ( + missingTokenTypes uint = 1 << iota + missingTokenModifiers + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15279,12 +16748,12 @@ func (s *SemanticTokensLegend) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"tokenTypes"`: - seenTokenTypes = true + missing &^= missingTokenTypes if err := json.UnmarshalDecode(dec, &s.TokenTypes); err != nil { return err } case `"tokenModifiers"`: - seenTokenModifiers = true + missing &^= missingTokenModifiers if err := json.UnmarshalDecode(dec, &s.TokenModifiers); err != nil { return err } @@ -15297,11 +16766,15 @@ func (s *SemanticTokensLegend) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenTokenTypes { - return fmt.Errorf("required property 'tokenTypes' is missing") - } - if !seenTokenModifiers { - return fmt.Errorf("required property 'tokenModifiers' is missing") + if missing != 0 { + var missingProps []string + if missing&missingTokenTypes != 0 { + missingProps = append(missingProps, "tokenTypes") + } + if missing&missingTokenModifiers != 0 { + missingProps = append(missingProps, "tokenModifiers") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15331,10 +16804,12 @@ type OptionalVersionedTextDocumentIdentifier struct { var _ json.UnmarshalerFrom = (*OptionalVersionedTextDocumentIdentifier)(nil) func (s *OptionalVersionedTextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenUri bool - seenVersion bool + const ( + missingUri uint = 1 << iota + missingVersion + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15350,12 +16825,12 @@ func (s *OptionalVersionedTextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontex } switch string(name) { case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } @@ -15368,11 +16843,15 @@ func (s *OptionalVersionedTextDocumentIdentifier) UnmarshalJSONFrom(dec *jsontex return err } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") + if missing != 0 { + var missingProps []string + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15397,11 +16876,13 @@ type AnnotatedTextEdit struct { var _ json.UnmarshalerFrom = (*AnnotatedTextEdit)(nil) func (s *AnnotatedTextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenNewText bool - seenAnnotationId bool + const ( + missingRange uint = 1 << iota + missingNewText + missingAnnotationId + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15417,17 +16898,17 @@ func (s *AnnotatedTextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"newText"`: - seenNewText = true + missing &^= missingNewText if err := json.UnmarshalDecode(dec, &s.NewText); err != nil { return err } case `"annotationId"`: - seenAnnotationId = true + missing &^= missingAnnotationId if err := json.UnmarshalDecode(dec, &s.AnnotationId); err != nil { return err } @@ -15440,14 +16921,18 @@ func (s *AnnotatedTextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenNewText { - return fmt.Errorf("required property 'newText' is missing") - } - if !seenAnnotationId { - return fmt.Errorf("required property 'annotationId' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingNewText != 0 { + missingProps = append(missingProps, "newText") + } + if missing&missingAnnotationId != 0 { + missingProps = append(missingProps, "annotationId") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15472,10 +16957,12 @@ type SnippetTextEdit struct { var _ json.UnmarshalerFrom = (*SnippetTextEdit)(nil) func (s *SnippetTextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenSnippet bool + const ( + missingRange uint = 1 << iota + missingSnippet + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15491,12 +16978,12 @@ func (s *SnippetTextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"snippet"`: - seenSnippet = true + missing &^= missingSnippet if err := json.UnmarshalDecode(dec, &s.Snippet); err != nil { return err } @@ -15513,11 +17000,15 @@ func (s *SnippetTextEdit) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenSnippet { - return fmt.Errorf("required property 'snippet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingSnippet != 0 { + missingProps = append(missingProps, "snippet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15537,7 +17028,11 @@ type ResourceOperation struct { var _ json.UnmarshalerFrom = (*ResourceOperation)(nil) func (s *ResourceOperation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenKind bool + const ( + missingKind uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15553,7 +17048,7 @@ func (s *ResourceOperation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -15570,8 +17065,12 @@ func (s *ResourceOperation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15630,7 +17129,11 @@ type FileOperationPattern struct { var _ json.UnmarshalerFrom = (*FileOperationPattern)(nil) func (s *FileOperationPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenGlob bool + const ( + missingGlob uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15646,7 +17149,7 @@ func (s *FileOperationPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"glob"`: - seenGlob = true + missing &^= missingGlob if err := json.UnmarshalDecode(dec, &s.Glob); err != nil { return err } @@ -15667,8 +17170,12 @@ func (s *FileOperationPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenGlob { - return fmt.Errorf("required property 'glob' is missing") + if missing != 0 { + var missingProps []string + if missing&missingGlob != 0 { + missingProps = append(missingProps, "glob") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15700,12 +17207,14 @@ type WorkspaceFullDocumentDiagnosticReport struct { var _ json.UnmarshalerFrom = (*WorkspaceFullDocumentDiagnosticReport)(nil) func (s *WorkspaceFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenItems bool - seenUri bool - seenVersion bool + const ( + missingKind uint = 1 << iota + missingItems + missingUri + missingVersion + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15721,7 +17230,7 @@ func (s *WorkspaceFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext. } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } @@ -15730,17 +17239,17 @@ func (s *WorkspaceFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext. return err } case `"items"`: - seenItems = true + missing &^= missingItems if err := json.UnmarshalDecode(dec, &s.Items); err != nil { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } @@ -15753,17 +17262,21 @@ func (s *WorkspaceFullDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext. return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenItems { - return fmt.Errorf("required property 'items' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingItems != 0 { + missingProps = append(missingProps, "items") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15794,12 +17307,14 @@ type WorkspaceUnchangedDocumentDiagnosticReport struct { var _ json.UnmarshalerFrom = (*WorkspaceUnchangedDocumentDiagnosticReport)(nil) func (s *WorkspaceUnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenResultId bool - seenUri bool - seenVersion bool + const ( + missingKind uint = 1 << iota + missingResultId + missingUri + missingVersion + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15815,22 +17330,22 @@ func (s *WorkspaceUnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *json } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"resultId"`: - seenResultId = true + missing &^= missingResultId if err := json.UnmarshalDecode(dec, &s.ResultId); err != nil { return err } case `"uri"`: - seenUri = true + missing &^= missingUri if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { return err } case `"version"`: - seenVersion = true + missing &^= missingVersion if err := json.UnmarshalDecode(dec, &s.Version); err != nil { return err } @@ -15843,17 +17358,21 @@ func (s *WorkspaceUnchangedDocumentDiagnosticReport) UnmarshalJSONFrom(dec *json return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenResultId { - return fmt.Errorf("required property 'resultId' is missing") - } - if !seenUri { - return fmt.Errorf("required property 'uri' is missing") - } - if !seenVersion { - return fmt.Errorf("required property 'version' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingResultId != 0 { + missingProps = append(missingProps, "resultId") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + if missing&missingVersion != 0 { + missingProps = append(missingProps, "version") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15887,10 +17406,12 @@ type NotebookCell struct { var _ json.UnmarshalerFrom = (*NotebookCell)(nil) func (s *NotebookCell) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenDocument bool + const ( + missingKind uint = 1 << iota + missingDocument + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15906,12 +17427,12 @@ func (s *NotebookCell) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"document"`: - seenDocument = true + missing &^= missingDocument if err := json.UnmarshalDecode(dec, &s.Document); err != nil { return err } @@ -15932,11 +17453,15 @@ func (s *NotebookCell) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenDocument { - return fmt.Errorf("required property 'document' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingDocument != 0 { + missingProps = append(missingProps, "document") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -15956,7 +17481,11 @@ type NotebookDocumentFilterWithNotebook struct { var _ json.UnmarshalerFrom = (*NotebookDocumentFilterWithNotebook)(nil) func (s *NotebookDocumentFilterWithNotebook) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenNotebook bool + const ( + missingNotebook uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -15972,7 +17501,7 @@ func (s *NotebookDocumentFilterWithNotebook) UnmarshalJSONFrom(dec *jsontext.Dec } switch string(name) { case `"notebook"`: - seenNotebook = true + missing &^= missingNotebook if err := json.UnmarshalDecode(dec, &s.Notebook); err != nil { return err } @@ -15989,8 +17518,12 @@ func (s *NotebookDocumentFilterWithNotebook) UnmarshalJSONFrom(dec *jsontext.Dec return err } - if !seenNotebook { - return fmt.Errorf("required property 'notebook' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebook != 0 { + missingProps = append(missingProps, "notebook") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16010,7 +17543,11 @@ type NotebookDocumentFilterWithCells struct { var _ json.UnmarshalerFrom = (*NotebookDocumentFilterWithCells)(nil) func (s *NotebookDocumentFilterWithCells) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenCells bool + const ( + missingCells uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16030,7 +17567,7 @@ func (s *NotebookDocumentFilterWithCells) UnmarshalJSONFrom(dec *jsontext.Decode return err } case `"cells"`: - seenCells = true + missing &^= missingCells if err := json.UnmarshalDecode(dec, &s.Cells); err != nil { return err } @@ -16043,8 +17580,12 @@ func (s *NotebookDocumentFilterWithCells) UnmarshalJSONFrom(dec *jsontext.Decode return err } - if !seenCells { - return fmt.Errorf("required property 'cells' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCells != 0 { + missingProps = append(missingProps, "cells") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16082,10 +17623,12 @@ type SelectedCompletionInfo struct { var _ json.UnmarshalerFrom = (*SelectedCompletionInfo)(nil) func (s *SelectedCompletionInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenText bool + const ( + missingRange uint = 1 << iota + missingText + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16101,12 +17644,12 @@ func (s *SelectedCompletionInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } case `"text"`: - seenText = true + missing &^= missingText if err := json.UnmarshalDecode(dec, &s.Text); err != nil { return err } @@ -16119,11 +17662,15 @@ func (s *SelectedCompletionInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenText { - return fmt.Errorf("required property 'text' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingText != 0 { + missingProps = append(missingProps, "text") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16145,7 +17692,11 @@ type ClientInfo struct { var _ json.UnmarshalerFrom = (*ClientInfo)(nil) func (s *ClientInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenName bool + const ( + missingName uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16161,7 +17712,7 @@ func (s *ClientInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"name"`: - seenName = true + missing &^= missingName if err := json.UnmarshalDecode(dec, &s.Name); err != nil { return err } @@ -16178,8 +17729,12 @@ func (s *ClientInfo) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenName { - return fmt.Errorf("required property 'name' is missing") + if missing != 0 { + var missingProps []string + if missing&missingName != 0 { + missingProps = append(missingProps, "name") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16205,9 +17760,6 @@ type ClientCapabilities struct { // // Since: 3.16.0 General *GeneralClientCapabilities `json:"general,omitzero"` - - // Experimental client capabilities. - Experimental *any `json:"experimental,omitzero"` } type TextDocumentSyncOptions struct { @@ -16271,10 +17823,12 @@ type TextDocumentContentChangePartial struct { var _ json.UnmarshalerFrom = (*TextDocumentContentChangePartial)(nil) func (s *TextDocumentContentChangePartial) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRange bool - seenText bool + const ( + missingRange uint = 1 << iota + missingText + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16290,7 +17844,7 @@ func (s *TextDocumentContentChangePartial) UnmarshalJSONFrom(dec *jsontext.Decod } switch string(name) { case `"range"`: - seenRange = true + missing &^= missingRange if err := json.UnmarshalDecode(dec, &s.Range); err != nil { return err } @@ -16299,7 +17853,7 @@ func (s *TextDocumentContentChangePartial) UnmarshalJSONFrom(dec *jsontext.Decod return err } case `"text"`: - seenText = true + missing &^= missingText if err := json.UnmarshalDecode(dec, &s.Text); err != nil { return err } @@ -16312,11 +17866,15 @@ func (s *TextDocumentContentChangePartial) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenRange { - return fmt.Errorf("required property 'range' is missing") - } - if !seenText { - return fmt.Errorf("required property 'text' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRange != 0 { + missingProps = append(missingProps, "range") + } + if missing&missingText != 0 { + missingProps = append(missingProps, "text") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16331,7 +17889,11 @@ type TextDocumentContentChangeWholeDocument struct { var _ json.UnmarshalerFrom = (*TextDocumentContentChangeWholeDocument)(nil) func (s *TextDocumentContentChangeWholeDocument) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenText bool + const ( + missingText uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16347,7 +17909,7 @@ func (s *TextDocumentContentChangeWholeDocument) UnmarshalJSONFrom(dec *jsontext } switch string(name) { case `"text"`: - seenText = true + missing &^= missingText if err := json.UnmarshalDecode(dec, &s.Text); err != nil { return err } @@ -16360,8 +17922,12 @@ func (s *TextDocumentContentChangeWholeDocument) UnmarshalJSONFrom(dec *jsontext return err } - if !seenText { - return fmt.Errorf("required property 'text' is missing") + if missing != 0 { + var missingProps []string + if missing&missingText != 0 { + missingProps = append(missingProps, "text") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16378,7 +17944,11 @@ type CodeDescription struct { var _ json.UnmarshalerFrom = (*CodeDescription)(nil) func (s *CodeDescription) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenHref bool + const ( + missingHref uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16394,7 +17964,7 @@ func (s *CodeDescription) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"href"`: - seenHref = true + missing &^= missingHref if err := json.UnmarshalDecode(dec, &s.Href); err != nil { return err } @@ -16407,8 +17977,12 @@ func (s *CodeDescription) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenHref { - return fmt.Errorf("required property 'href' is missing") + if missing != 0 { + var missingProps []string + if missing&missingHref != 0 { + missingProps = append(missingProps, "href") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16428,10 +18002,12 @@ type DiagnosticRelatedInformation struct { var _ json.UnmarshalerFrom = (*DiagnosticRelatedInformation)(nil) func (s *DiagnosticRelatedInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenLocation bool - seenMessage bool + const ( + missingLocation uint = 1 << iota + missingMessage + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16447,12 +18023,12 @@ func (s *DiagnosticRelatedInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"location"`: - seenLocation = true + missing &^= missingLocation if err := json.UnmarshalDecode(dec, &s.Location); err != nil { return err } case `"message"`: - seenMessage = true + missing &^= missingMessage if err := json.UnmarshalDecode(dec, &s.Message); err != nil { return err } @@ -16465,11 +18041,15 @@ func (s *DiagnosticRelatedInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenLocation { - return fmt.Errorf("required property 'location' is missing") - } - if !seenMessage { - return fmt.Errorf("required property 'message' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLocation != 0 { + missingProps = append(missingProps, "location") + } + if missing&missingMessage != 0 { + missingProps = append(missingProps, "message") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16487,10 +18067,12 @@ type EditRangeWithInsertReplace struct { var _ json.UnmarshalerFrom = (*EditRangeWithInsertReplace)(nil) func (s *EditRangeWithInsertReplace) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenInsert bool - seenReplace bool + const ( + missingInsert uint = 1 << iota + missingReplace + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16506,12 +18088,12 @@ func (s *EditRangeWithInsertReplace) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"insert"`: - seenInsert = true + missing &^= missingInsert if err := json.UnmarshalDecode(dec, &s.Insert); err != nil { return err } case `"replace"`: - seenReplace = true + missing &^= missingReplace if err := json.UnmarshalDecode(dec, &s.Replace); err != nil { return err } @@ -16524,11 +18106,15 @@ func (s *EditRangeWithInsertReplace) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenInsert { - return fmt.Errorf("required property 'insert' is missing") - } - if !seenReplace { - return fmt.Errorf("required property 'replace' is missing") + if missing != 0 { + var missingProps []string + if missing&missingInsert != 0 { + missingProps = append(missingProps, "insert") + } + if missing&missingReplace != 0 { + missingProps = append(missingProps, "replace") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16556,10 +18142,12 @@ type MarkedStringWithLanguage struct { var _ json.UnmarshalerFrom = (*MarkedStringWithLanguage)(nil) func (s *MarkedStringWithLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenLanguage bool - seenValue bool + const ( + missingLanguage uint = 1 << iota + missingValue + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16575,12 +18163,12 @@ func (s *MarkedStringWithLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"language"`: - seenLanguage = true + missing &^= missingLanguage if err := json.UnmarshalDecode(dec, &s.Language); err != nil { return err } case `"value"`: - seenValue = true + missing &^= missingValue if err := json.UnmarshalDecode(dec, &s.Value); err != nil { return err } @@ -16593,11 +18181,15 @@ func (s *MarkedStringWithLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenLanguage { - return fmt.Errorf("required property 'language' is missing") - } - if !seenValue { - return fmt.Errorf("required property 'value' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLanguage != 0 { + missingProps = append(missingProps, "language") + } + if missing&missingValue != 0 { + missingProps = append(missingProps, "value") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16628,7 +18220,11 @@ type ParameterInformation struct { var _ json.UnmarshalerFrom = (*ParameterInformation)(nil) func (s *ParameterInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLabel bool + const ( + missingLabel uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16644,7 +18240,7 @@ func (s *ParameterInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"label"`: - seenLabel = true + missing &^= missingLabel if err := json.UnmarshalDecode(dec, &s.Label); err != nil { return err } @@ -16661,8 +18257,12 @@ func (s *ParameterInformation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLabel { - return fmt.Errorf("required property 'label' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLabel != 0 { + missingProps = append(missingProps, "label") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16690,10 +18290,12 @@ type CodeActionKindDocumentation struct { var _ json.UnmarshalerFrom = (*CodeActionKindDocumentation)(nil) func (s *CodeActionKindDocumentation) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenKind bool - seenCommand bool + const ( + missingKind uint = 1 << iota + missingCommand + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16709,12 +18311,12 @@ func (s *CodeActionKindDocumentation) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"kind"`: - seenKind = true + missing &^= missingKind if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { return err } case `"command"`: - seenCommand = true + missing &^= missingCommand if err := json.UnmarshalDecode(dec, &s.Command); err != nil { return err } @@ -16727,11 +18329,15 @@ func (s *CodeActionKindDocumentation) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenKind { - return fmt.Errorf("required property 'kind' is missing") - } - if !seenCommand { - return fmt.Errorf("required property 'command' is missing") + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingCommand != 0 { + missingProps = append(missingProps, "command") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16758,7 +18364,11 @@ type NotebookCellTextDocumentFilter struct { var _ json.UnmarshalerFrom = (*NotebookCellTextDocumentFilter)(nil) func (s *NotebookCellTextDocumentFilter) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenNotebook bool + const ( + missingNotebook uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16774,7 +18384,7 @@ func (s *NotebookCellTextDocumentFilter) UnmarshalJSONFrom(dec *jsontext.Decoder } switch string(name) { case `"notebook"`: - seenNotebook = true + missing &^= missingNotebook if err := json.UnmarshalDecode(dec, &s.Notebook); err != nil { return err } @@ -16791,8 +18401,12 @@ func (s *NotebookCellTextDocumentFilter) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenNotebook { - return fmt.Errorf("required property 'notebook' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebook != 0 { + missingProps = append(missingProps, "notebook") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16820,7 +18434,11 @@ type ExecutionSummary struct { var _ json.UnmarshalerFrom = (*ExecutionSummary)(nil) func (s *ExecutionSummary) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenExecutionOrder bool + const ( + missingExecutionOrder uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16836,7 +18454,7 @@ func (s *ExecutionSummary) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"executionOrder"`: - seenExecutionOrder = true + missing &^= missingExecutionOrder if err := json.UnmarshalDecode(dec, &s.ExecutionOrder); err != nil { return err } @@ -16853,8 +18471,12 @@ func (s *ExecutionSummary) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenExecutionOrder { - return fmt.Errorf("required property 'executionOrder' is missing") + if missing != 0 { + var missingProps []string + if missing&missingExecutionOrder != 0 { + missingProps = append(missingProps, "executionOrder") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16868,7 +18490,11 @@ type NotebookCellLanguage struct { var _ json.UnmarshalerFrom = (*NotebookCellLanguage)(nil) func (s *NotebookCellLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLanguage bool + const ( + missingLanguage uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16884,7 +18510,7 @@ func (s *NotebookCellLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"language"`: - seenLanguage = true + missing &^= missingLanguage if err := json.UnmarshalDecode(dec, &s.Language); err != nil { return err } @@ -16897,8 +18523,12 @@ func (s *NotebookCellLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenLanguage { - return fmt.Errorf("required property 'language' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLanguage != 0 { + missingProps = append(missingProps, "language") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16921,7 +18551,11 @@ type NotebookDocumentCellChangeStructure struct { var _ json.UnmarshalerFrom = (*NotebookDocumentCellChangeStructure)(nil) func (s *NotebookDocumentCellChangeStructure) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenArray bool + const ( + missingArray uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16937,7 +18571,7 @@ func (s *NotebookDocumentCellChangeStructure) UnmarshalJSONFrom(dec *jsontext.De } switch string(name) { case `"array"`: - seenArray = true + missing &^= missingArray if err := json.UnmarshalDecode(dec, &s.Array); err != nil { return err } @@ -16958,8 +18592,12 @@ func (s *NotebookDocumentCellChangeStructure) UnmarshalJSONFrom(dec *jsontext.De return err } - if !seenArray { - return fmt.Errorf("required property 'array' is missing") + if missing != 0 { + var missingProps []string + if missing&missingArray != 0 { + missingProps = append(missingProps, "array") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -16977,10 +18615,12 @@ type NotebookDocumentCellContentChanges struct { var _ json.UnmarshalerFrom = (*NotebookDocumentCellContentChanges)(nil) func (s *NotebookDocumentCellContentChanges) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenDocument bool - seenChanges bool + const ( + missingDocument uint = 1 << iota + missingChanges + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -16996,12 +18636,12 @@ func (s *NotebookDocumentCellContentChanges) UnmarshalJSONFrom(dec *jsontext.Dec } switch string(name) { case `"document"`: - seenDocument = true + missing &^= missingDocument if err := json.UnmarshalDecode(dec, &s.Document); err != nil { return err } case `"changes"`: - seenChanges = true + missing &^= missingChanges if err := json.UnmarshalDecode(dec, &s.Changes); err != nil { return err } @@ -17014,11 +18654,15 @@ func (s *NotebookDocumentCellContentChanges) UnmarshalJSONFrom(dec *jsontext.Dec return err } - if !seenDocument { - return fmt.Errorf("required property 'document' is missing") - } - if !seenChanges { - return fmt.Errorf("required property 'changes' is missing") + if missing != 0 { + var missingProps []string + if missing&missingDocument != 0 { + missingProps = append(missingProps, "document") + } + if missing&missingChanges != 0 { + missingProps = append(missingProps, "changes") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17253,7 +18897,11 @@ type NotebookDocumentClientCapabilities struct { var _ json.UnmarshalerFrom = (*NotebookDocumentClientCapabilities)(nil) func (s *NotebookDocumentClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSynchronization bool + const ( + missingSynchronization uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17269,7 +18917,7 @@ func (s *NotebookDocumentClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Dec } switch string(name) { case `"synchronization"`: - seenSynchronization = true + missing &^= missingSynchronization if err := json.UnmarshalDecode(dec, &s.Synchronization); err != nil { return err } @@ -17282,8 +18930,12 @@ func (s *NotebookDocumentClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Dec return err } - if !seenSynchronization { - return fmt.Errorf("required property 'synchronization' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSynchronization != 0 { + missingProps = append(missingProps, "synchronization") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17409,10 +19061,12 @@ type RelativePattern struct { var _ json.UnmarshalerFrom = (*RelativePattern)(nil) func (s *RelativePattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenBaseUri bool - seenPattern bool + const ( + missingBaseUri uint = 1 << iota + missingPattern + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17428,12 +19082,12 @@ func (s *RelativePattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"baseUri"`: - seenBaseUri = true + missing &^= missingBaseUri if err := json.UnmarshalDecode(dec, &s.BaseUri); err != nil { return err } case `"pattern"`: - seenPattern = true + missing &^= missingPattern if err := json.UnmarshalDecode(dec, &s.Pattern); err != nil { return err } @@ -17446,11 +19100,15 @@ func (s *RelativePattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenBaseUri { - return fmt.Errorf("required property 'baseUri' is missing") - } - if !seenPattern { - return fmt.Errorf("required property 'pattern' is missing") + if missing != 0 { + var missingProps []string + if missing&missingBaseUri != 0 { + missingProps = append(missingProps, "baseUri") + } + if missing&missingPattern != 0 { + missingProps = append(missingProps, "pattern") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17477,7 +19135,11 @@ type TextDocumentFilterLanguage struct { var _ json.UnmarshalerFrom = (*TextDocumentFilterLanguage)(nil) func (s *TextDocumentFilterLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenLanguage bool + const ( + missingLanguage uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17493,7 +19155,7 @@ func (s *TextDocumentFilterLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"language"`: - seenLanguage = true + missing &^= missingLanguage if err := json.UnmarshalDecode(dec, &s.Language); err != nil { return err } @@ -17514,8 +19176,12 @@ func (s *TextDocumentFilterLanguage) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenLanguage { - return fmt.Errorf("required property 'language' is missing") + if missing != 0 { + var missingProps []string + if missing&missingLanguage != 0 { + missingProps = append(missingProps, "language") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17542,7 +19208,11 @@ type TextDocumentFilterScheme struct { var _ json.UnmarshalerFrom = (*TextDocumentFilterScheme)(nil) func (s *TextDocumentFilterScheme) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenScheme bool + const ( + missingScheme uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17562,7 +19232,7 @@ func (s *TextDocumentFilterScheme) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } case `"scheme"`: - seenScheme = true + missing &^= missingScheme if err := json.UnmarshalDecode(dec, &s.Scheme); err != nil { return err } @@ -17579,8 +19249,12 @@ func (s *TextDocumentFilterScheme) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenScheme { - return fmt.Errorf("required property 'scheme' is missing") + if missing != 0 { + var missingProps []string + if missing&missingScheme != 0 { + missingProps = append(missingProps, "scheme") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17607,7 +19281,11 @@ type TextDocumentFilterPattern struct { var _ json.UnmarshalerFrom = (*TextDocumentFilterPattern)(nil) func (s *TextDocumentFilterPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenPattern bool + const ( + missingPattern uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17631,7 +19309,7 @@ func (s *TextDocumentFilterPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } case `"pattern"`: - seenPattern = true + missing &^= missingPattern if err := json.UnmarshalDecode(dec, &s.Pattern); err != nil { return err } @@ -17644,8 +19322,12 @@ func (s *TextDocumentFilterPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) err return err } - if !seenPattern { - return fmt.Errorf("required property 'pattern' is missing") + if missing != 0 { + var missingProps []string + if missing&missingPattern != 0 { + missingProps = append(missingProps, "pattern") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17668,7 +19350,11 @@ type NotebookDocumentFilterNotebookType struct { var _ json.UnmarshalerFrom = (*NotebookDocumentFilterNotebookType)(nil) func (s *NotebookDocumentFilterNotebookType) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenNotebookType bool + const ( + missingNotebookType uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17684,7 +19370,7 @@ func (s *NotebookDocumentFilterNotebookType) UnmarshalJSONFrom(dec *jsontext.Dec } switch string(name) { case `"notebookType"`: - seenNotebookType = true + missing &^= missingNotebookType if err := json.UnmarshalDecode(dec, &s.NotebookType); err != nil { return err } @@ -17705,8 +19391,12 @@ func (s *NotebookDocumentFilterNotebookType) UnmarshalJSONFrom(dec *jsontext.Dec return err } - if !seenNotebookType { - return fmt.Errorf("required property 'notebookType' is missing") + if missing != 0 { + var missingProps []string + if missing&missingNotebookType != 0 { + missingProps = append(missingProps, "notebookType") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17729,7 +19419,11 @@ type NotebookDocumentFilterScheme struct { var _ json.UnmarshalerFrom = (*NotebookDocumentFilterScheme)(nil) func (s *NotebookDocumentFilterScheme) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenScheme bool + const ( + missingScheme uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17749,7 +19443,7 @@ func (s *NotebookDocumentFilterScheme) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"scheme"`: - seenScheme = true + missing &^= missingScheme if err := json.UnmarshalDecode(dec, &s.Scheme); err != nil { return err } @@ -17766,8 +19460,12 @@ func (s *NotebookDocumentFilterScheme) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenScheme { - return fmt.Errorf("required property 'scheme' is missing") + if missing != 0 { + var missingProps []string + if missing&missingScheme != 0 { + missingProps = append(missingProps, "scheme") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17790,7 +19488,11 @@ type NotebookDocumentFilterPattern struct { var _ json.UnmarshalerFrom = (*NotebookDocumentFilterPattern)(nil) func (s *NotebookDocumentFilterPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenPattern bool + const ( + missingPattern uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17814,7 +19516,7 @@ func (s *NotebookDocumentFilterPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } case `"pattern"`: - seenPattern = true + missing &^= missingPattern if err := json.UnmarshalDecode(dec, &s.Pattern); err != nil { return err } @@ -17827,8 +19529,12 @@ func (s *NotebookDocumentFilterPattern) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenPattern { - return fmt.Errorf("required property 'pattern' is missing") + if missing != 0 { + var missingProps []string + if missing&missingPattern != 0 { + missingProps = append(missingProps, "pattern") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -17852,10 +19558,12 @@ type NotebookCellArrayChange struct { var _ json.UnmarshalerFrom = (*NotebookCellArrayChange)(nil) func (s *NotebookCellArrayChange) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenStart bool - seenDeleteCount bool + const ( + missingStart uint = 1 << iota + missingDeleteCount + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -17871,12 +19579,12 @@ func (s *NotebookCellArrayChange) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"start"`: - seenStart = true + missing &^= missingStart if err := json.UnmarshalDecode(dec, &s.Start); err != nil { return err } case `"deleteCount"`: - seenDeleteCount = true + missing &^= missingDeleteCount if err := json.UnmarshalDecode(dec, &s.DeleteCount); err != nil { return err } @@ -17893,11 +19601,15 @@ func (s *NotebookCellArrayChange) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenStart { - return fmt.Errorf("required property 'start' is missing") - } - if !seenDeleteCount { - return fmt.Errorf("required property 'deleteCount' is missing") + if missing != 0 { + var missingProps []string + if missing&missingStart != 0 { + missingProps = append(missingProps, "start") + } + if missing&missingDeleteCount != 0 { + missingProps = append(missingProps, "deleteCount") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -18556,12 +20268,14 @@ type SemanticTokensClientCapabilities struct { var _ json.UnmarshalerFrom = (*SemanticTokensClientCapabilities)(nil) func (s *SemanticTokensClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenRequests bool - seenTokenTypes bool - seenTokenModifiers bool - seenFormats bool + const ( + missingRequests uint = 1 << iota + missingTokenTypes + missingTokenModifiers + missingFormats + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -18581,22 +20295,22 @@ func (s *SemanticTokensClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decod return err } case `"requests"`: - seenRequests = true + missing &^= missingRequests if err := json.UnmarshalDecode(dec, &s.Requests); err != nil { return err } case `"tokenTypes"`: - seenTokenTypes = true + missing &^= missingTokenTypes if err := json.UnmarshalDecode(dec, &s.TokenTypes); err != nil { return err } case `"tokenModifiers"`: - seenTokenModifiers = true + missing &^= missingTokenModifiers if err := json.UnmarshalDecode(dec, &s.TokenModifiers); err != nil { return err } case `"formats"`: - seenFormats = true + missing &^= missingFormats if err := json.UnmarshalDecode(dec, &s.Formats); err != nil { return err } @@ -18625,17 +20339,21 @@ func (s *SemanticTokensClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decod return err } - if !seenRequests { - return fmt.Errorf("required property 'requests' is missing") - } - if !seenTokenTypes { - return fmt.Errorf("required property 'tokenTypes' is missing") - } - if !seenTokenModifiers { - return fmt.Errorf("required property 'tokenModifiers' is missing") - } - if !seenFormats { - return fmt.Errorf("required property 'formats' is missing") + if missing != 0 { + var missingProps []string + if missing&missingRequests != 0 { + missingProps = append(missingProps, "requests") + } + if missing&missingTokenTypes != 0 { + missingProps = append(missingProps, "tokenTypes") + } + if missing&missingTokenModifiers != 0 { + missingProps = append(missingProps, "tokenModifiers") + } + if missing&missingFormats != 0 { + missingProps = append(missingProps, "formats") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -18765,7 +20483,11 @@ type ShowDocumentClientCapabilities struct { var _ json.UnmarshalerFrom = (*ShowDocumentClientCapabilities)(nil) func (s *ShowDocumentClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenSupport bool + const ( + missingSupport uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -18781,7 +20503,7 @@ func (s *ShowDocumentClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder } switch string(name) { case `"support"`: - seenSupport = true + missing &^= missingSupport if err := json.UnmarshalDecode(dec, &s.Support); err != nil { return err } @@ -18794,8 +20516,12 @@ func (s *ShowDocumentClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenSupport { - return fmt.Errorf("required property 'support' is missing") + if missing != 0 { + var missingProps []string + if missing&missingSupport != 0 { + missingProps = append(missingProps, "support") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -18815,10 +20541,12 @@ type StaleRequestSupportOptions struct { var _ json.UnmarshalerFrom = (*StaleRequestSupportOptions)(nil) func (s *StaleRequestSupportOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var ( - seenCancel bool - seenRetryOnContentModified bool + const ( + missingCancel uint = 1 << iota + missingRetryOnContentModified + _missingLast ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -18834,12 +20562,12 @@ func (s *StaleRequestSupportOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"cancel"`: - seenCancel = true + missing &^= missingCancel if err := json.UnmarshalDecode(dec, &s.Cancel); err != nil { return err } case `"retryOnContentModified"`: - seenRetryOnContentModified = true + missing &^= missingRetryOnContentModified if err := json.UnmarshalDecode(dec, &s.RetryOnContentModified); err != nil { return err } @@ -18852,11 +20580,15 @@ func (s *StaleRequestSupportOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenCancel { - return fmt.Errorf("required property 'cancel' is missing") - } - if !seenRetryOnContentModified { - return fmt.Errorf("required property 'retryOnContentModified' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCancel != 0 { + missingProps = append(missingProps, "cancel") + } + if missing&missingRetryOnContentModified != 0 { + missingProps = append(missingProps, "retryOnContentModified") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -18876,7 +20608,11 @@ type RegularExpressionsClientCapabilities struct { var _ json.UnmarshalerFrom = (*RegularExpressionsClientCapabilities)(nil) func (s *RegularExpressionsClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenEngine bool + const ( + missingEngine uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -18892,7 +20628,7 @@ func (s *RegularExpressionsClientCapabilities) UnmarshalJSONFrom(dec *jsontext.D } switch string(name) { case `"engine"`: - seenEngine = true + missing &^= missingEngine if err := json.UnmarshalDecode(dec, &s.Engine); err != nil { return err } @@ -18909,8 +20645,12 @@ func (s *RegularExpressionsClientCapabilities) UnmarshalJSONFrom(dec *jsontext.D return err } - if !seenEngine { - return fmt.Errorf("required property 'engine' is missing") + if missing != 0 { + var missingProps []string + if missing&missingEngine != 0 { + missingProps = append(missingProps, "engine") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -18936,7 +20676,11 @@ type MarkdownClientCapabilities struct { var _ json.UnmarshalerFrom = (*MarkdownClientCapabilities)(nil) func (s *MarkdownClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenParser bool + const ( + missingParser uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -18952,7 +20696,7 @@ func (s *MarkdownClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"parser"`: - seenParser = true + missing &^= missingParser if err := json.UnmarshalDecode(dec, &s.Parser); err != nil { return err } @@ -18973,8 +20717,12 @@ func (s *MarkdownClientCapabilities) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenParser { - return fmt.Errorf("required property 'parser' is missing") + if missing != 0 { + var missingProps []string + if missing&missingParser != 0 { + missingProps = append(missingProps, "parser") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19010,7 +20758,11 @@ type ClientSymbolTagOptions struct { var _ json.UnmarshalerFrom = (*ClientSymbolTagOptions)(nil) func (s *ClientSymbolTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValueSet bool + const ( + missingValueSet uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19026,7 +20778,7 @@ func (s *ClientSymbolTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error } switch string(name) { case `"valueSet"`: - seenValueSet = true + missing &^= missingValueSet if err := json.UnmarshalDecode(dec, &s.ValueSet); err != nil { return err } @@ -19039,8 +20791,12 @@ func (s *ClientSymbolTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error return err } - if !seenValueSet { - return fmt.Errorf("required property 'valueSet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValueSet != 0 { + missingProps = append(missingProps, "valueSet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19056,7 +20812,11 @@ type ClientSymbolResolveOptions struct { var _ json.UnmarshalerFrom = (*ClientSymbolResolveOptions)(nil) func (s *ClientSymbolResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenProperties bool + const ( + missingProperties uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19072,7 +20832,7 @@ func (s *ClientSymbolResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er } switch string(name) { case `"properties"`: - seenProperties = true + missing &^= missingProperties if err := json.UnmarshalDecode(dec, &s.Properties); err != nil { return err } @@ -19085,8 +20845,12 @@ func (s *ClientSymbolResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) er return err } - if !seenProperties { - return fmt.Errorf("required property 'properties' is missing") + if missing != 0 { + var missingProps []string + if missing&missingProperties != 0 { + missingProps = append(missingProps, "properties") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19227,7 +20991,11 @@ type ClientCodeActionLiteralOptions struct { var _ json.UnmarshalerFrom = (*ClientCodeActionLiteralOptions)(nil) func (s *ClientCodeActionLiteralOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenCodeActionKind bool + const ( + missingCodeActionKind uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19243,7 +21011,7 @@ func (s *ClientCodeActionLiteralOptions) UnmarshalJSONFrom(dec *jsontext.Decoder } switch string(name) { case `"codeActionKind"`: - seenCodeActionKind = true + missing &^= missingCodeActionKind if err := json.UnmarshalDecode(dec, &s.CodeActionKind); err != nil { return err } @@ -19256,8 +21024,12 @@ func (s *ClientCodeActionLiteralOptions) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenCodeActionKind { - return fmt.Errorf("required property 'codeActionKind' is missing") + if missing != 0 { + var missingProps []string + if missing&missingCodeActionKind != 0 { + missingProps = append(missingProps, "codeActionKind") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19272,7 +21044,11 @@ type ClientCodeActionResolveOptions struct { var _ json.UnmarshalerFrom = (*ClientCodeActionResolveOptions)(nil) func (s *ClientCodeActionResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenProperties bool + const ( + missingProperties uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19288,7 +21064,7 @@ func (s *ClientCodeActionResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder } switch string(name) { case `"properties"`: - seenProperties = true + missing &^= missingProperties if err := json.UnmarshalDecode(dec, &s.Properties); err != nil { return err } @@ -19301,8 +21077,12 @@ func (s *ClientCodeActionResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder return err } - if !seenProperties { - return fmt.Errorf("required property 'properties' is missing") + if missing != 0 { + var missingProps []string + if missing&missingProperties != 0 { + missingProps = append(missingProps, "properties") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19317,7 +21097,11 @@ type CodeActionTagOptions struct { var _ json.UnmarshalerFrom = (*CodeActionTagOptions)(nil) func (s *CodeActionTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValueSet bool + const ( + missingValueSet uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19333,7 +21117,7 @@ func (s *CodeActionTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } switch string(name) { case `"valueSet"`: - seenValueSet = true + missing &^= missingValueSet if err := json.UnmarshalDecode(dec, &s.ValueSet); err != nil { return err } @@ -19346,8 +21130,12 @@ func (s *CodeActionTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return err } - if !seenValueSet { - return fmt.Errorf("required property 'valueSet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValueSet != 0 { + missingProps = append(missingProps, "valueSet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19362,7 +21150,11 @@ type ClientCodeLensResolveOptions struct { var _ json.UnmarshalerFrom = (*ClientCodeLensResolveOptions)(nil) func (s *ClientCodeLensResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenProperties bool + const ( + missingProperties uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19378,7 +21170,7 @@ func (s *ClientCodeLensResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"properties"`: - seenProperties = true + missing &^= missingProperties if err := json.UnmarshalDecode(dec, &s.Properties); err != nil { return err } @@ -19391,8 +21183,12 @@ func (s *ClientCodeLensResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenProperties { - return fmt.Errorf("required property 'properties' is missing") + if missing != 0 { + var missingProps []string + if missing&missingProperties != 0 { + missingProps = append(missingProps, "properties") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19460,7 +21256,11 @@ type ClientInlayHintResolveOptions struct { var _ json.UnmarshalerFrom = (*ClientInlayHintResolveOptions)(nil) func (s *ClientInlayHintResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenProperties bool + const ( + missingProperties uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19476,7 +21276,7 @@ func (s *ClientInlayHintResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) } switch string(name) { case `"properties"`: - seenProperties = true + missing &^= missingProperties if err := json.UnmarshalDecode(dec, &s.Properties); err != nil { return err } @@ -19489,8 +21289,12 @@ func (s *ClientInlayHintResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) return err } - if !seenProperties { - return fmt.Errorf("required property 'properties' is missing") + if missing != 0 { + var missingProps []string + if missing&missingProperties != 0 { + missingProps = append(missingProps, "properties") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19513,7 +21317,11 @@ type CompletionItemTagOptions struct { var _ json.UnmarshalerFrom = (*CompletionItemTagOptions)(nil) func (s *CompletionItemTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValueSet bool + const ( + missingValueSet uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19529,7 +21337,7 @@ func (s *CompletionItemTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) erro } switch string(name) { case `"valueSet"`: - seenValueSet = true + missing &^= missingValueSet if err := json.UnmarshalDecode(dec, &s.ValueSet); err != nil { return err } @@ -19542,8 +21350,12 @@ func (s *CompletionItemTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) erro return err } - if !seenValueSet { - return fmt.Errorf("required property 'valueSet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValueSet != 0 { + missingProps = append(missingProps, "valueSet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19558,7 +21370,11 @@ type ClientCompletionItemResolveOptions struct { var _ json.UnmarshalerFrom = (*ClientCompletionItemResolveOptions)(nil) func (s *ClientCompletionItemResolveOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenProperties bool + const ( + missingProperties uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19574,7 +21390,7 @@ func (s *ClientCompletionItemResolveOptions) UnmarshalJSONFrom(dec *jsontext.Dec } switch string(name) { case `"properties"`: - seenProperties = true + missing &^= missingProperties if err := json.UnmarshalDecode(dec, &s.Properties); err != nil { return err } @@ -19587,8 +21403,12 @@ func (s *ClientCompletionItemResolveOptions) UnmarshalJSONFrom(dec *jsontext.Dec return err } - if !seenProperties { - return fmt.Errorf("required property 'properties' is missing") + if missing != 0 { + var missingProps []string + if missing&missingProperties != 0 { + missingProps = append(missingProps, "properties") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19602,7 +21422,11 @@ type ClientCompletionItemInsertTextModeOptions struct { var _ json.UnmarshalerFrom = (*ClientCompletionItemInsertTextModeOptions)(nil) func (s *ClientCompletionItemInsertTextModeOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValueSet bool + const ( + missingValueSet uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19618,7 +21442,7 @@ func (s *ClientCompletionItemInsertTextModeOptions) UnmarshalJSONFrom(dec *jsont } switch string(name) { case `"valueSet"`: - seenValueSet = true + missing &^= missingValueSet if err := json.UnmarshalDecode(dec, &s.ValueSet); err != nil { return err } @@ -19631,8 +21455,12 @@ func (s *ClientCompletionItemInsertTextModeOptions) UnmarshalJSONFrom(dec *jsont return err } - if !seenValueSet { - return fmt.Errorf("required property 'valueSet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValueSet != 0 { + missingProps = append(missingProps, "valueSet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19659,7 +21487,11 @@ type ClientCodeActionKindOptions struct { var _ json.UnmarshalerFrom = (*ClientCodeActionKindOptions)(nil) func (s *ClientCodeActionKindOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValueSet bool + const ( + missingValueSet uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19675,7 +21507,7 @@ func (s *ClientCodeActionKindOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"valueSet"`: - seenValueSet = true + missing &^= missingValueSet if err := json.UnmarshalDecode(dec, &s.ValueSet); err != nil { return err } @@ -19688,8 +21520,12 @@ func (s *ClientCodeActionKindOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenValueSet { - return fmt.Errorf("required property 'valueSet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValueSet != 0 { + missingProps = append(missingProps, "valueSet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19704,7 +21540,11 @@ type ClientDiagnosticsTagOptions struct { var _ json.UnmarshalerFrom = (*ClientDiagnosticsTagOptions)(nil) func (s *ClientDiagnosticsTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - var seenValueSet bool + const ( + missingValueSet uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 if k := dec.PeekKind(); k != '{' { return fmt.Errorf("expected object start, but encountered %v", k) @@ -19720,7 +21560,7 @@ func (s *ClientDiagnosticsTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e } switch string(name) { case `"valueSet"`: - seenValueSet = true + missing &^= missingValueSet if err := json.UnmarshalDecode(dec, &s.ValueSet); err != nil { return err } @@ -19733,8 +21573,12 @@ func (s *ClientDiagnosticsTagOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) e return err } - if !seenValueSet { - return fmt.Errorf("required property 'valueSet' is missing") + if missing != 0 { + var missingProps []string + if missing&missingValueSet != 0 { + missingProps = append(missingProps, "valueSet") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) } return nil @@ -19747,6 +21591,153 @@ type ClientSemanticTokensRequestFullDelta struct { Delta *bool `json:"delta,omitzero"` } +// InitializationOptions contains user-provided initialization options. +type InitializationOptions struct { + // DisablePushDiagnostics disables automatic pushing of diagnostics to the client. + DisablePushDiagnostics *bool `json:"disablePushDiagnostics,omitzero"` +} + +// ExportInfoMapKey uniquely identifies an export for auto-import purposes. +type ExportInfoMapKey struct { + // The symbol name. + SymbolName string `json:"symbolName,omitzero"` + + // The symbol ID. + SymbolId uint64 `json:"symbolId,omitzero"` + + // The ambient module name. + AmbientModuleName string `json:"ambientModuleName,omitzero"` + + // The module file path. + ModuleFile string `json:"moduleFile,omitzero"` +} + +// AutoImportData contains information about an auto-import suggestion. +type AutoImportData struct { + // The name of the property or export in the module's symbol table. Differs from the completion name in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. + ExportName string `json:"exportName,omitzero"` + + // The export map key for this auto-import. + ExportMapKey ExportInfoMapKey `json:"exportMapKey,omitzero"` + + // The module specifier for this auto-import. + ModuleSpecifier string `json:"moduleSpecifier,omitzero"` + + // The file name declaring the export's module symbol, if it was an external module. + FileName string `json:"fileName,omitzero"` + + // The module name (with quotes stripped) of the export's module symbol, if it was an ambient module. + AmbientModuleName string `json:"ambientModuleName,omitzero"` + + // True if the export was found in the package.json AutoImportProvider. + IsPackageJsonImport bool `json:"isPackageJsonImport,omitzero"` +} + +// CompletionItemData is preserved on a CompletionItem between CompletionRequest and CompletionResolveRequest. +type CompletionItemData struct { + // The file name where the completion was requested. + FileName string `json:"fileName,omitzero"` + + // The position where the completion was requested. + Position int32 `json:"position,omitzero"` + + // Special source value for disambiguation. + Source string `json:"source,omitzero"` + + // The name of the completion item. + Name string `json:"name,omitzero"` + + // Auto-import data for this completion item. + AutoImport *AutoImportData `json:"autoImport,omitzero"` +} + +// CallHierarchyItemData is a placeholder for custom data preserved on a CallHierarchyItem. +type CallHierarchyItemData struct{} + +// TypeHierarchyItemData is a placeholder for custom data preserved on a TypeHierarchyItem. +type TypeHierarchyItemData struct{} + +// InlayHintData is a placeholder for custom data preserved on a InlayHint. +type InlayHintData struct{} + +// CodeActionData is a placeholder for custom data preserved on a CodeAction. +type CodeActionData struct{} + +// WorkspaceSymbolData is a placeholder for custom data preserved on a WorkspaceSymbol. +type WorkspaceSymbolData struct{} + +// CodeLensData is a placeholder for custom data preserved on a CodeLens. +type CodeLensData struct{} + +// DocumentLinkData is a placeholder for custom data preserved on a DocumentLink. +type DocumentLinkData struct{} + +// DiagnosticData is a placeholder for custom data preserved on a Diagnostic. +type DiagnosticData struct{} + +// CompletionItemDefaultsData is a placeholder for custom data preserved on a CompletionItemDefaults. +type CompletionItemDefaultsData struct{} + +// Registration options for textDocument/colorPresentation. +type ColorPresentationRegistrationOptions struct { + WorkDoneProgress *bool `json:"workDoneProgress,omitzero"` + + // A document selector to identify the scope of the registration. If set to null + // the document selector provided on the client side will be used. + DocumentSelector DocumentSelectorOrNull `json:"documentSelector"` +} + +var _ json.UnmarshalerFrom = (*ColorPresentationRegistrationOptions)(nil) + +func (s *ColorPresentationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + const ( + missingDocumentSelector uint = 1 << iota + _missingLast + ) + missing := _missingLast - 1 + + if k := dec.PeekKind(); k != '{' { + return fmt.Errorf("expected object start, but encountered %v", k) + } + if _, err := dec.ReadToken(); err != nil { + return err + } + + for dec.PeekKind() != '}' { + name, err := dec.ReadValue() + if err != nil { + return err + } + switch string(name) { + case `"workDoneProgress"`: + if err := json.UnmarshalDecode(dec, &s.WorkDoneProgress); err != nil { + return err + } + case `"documentSelector"`: + missing &^= missingDocumentSelector + if err := json.UnmarshalDecode(dec, &s.DocumentSelector); err != nil { + return err + } + default: + // Ignore unknown properties. + } + } + + if _, err := dec.ReadToken(); err != nil { + return err + } + + if missing != 0 { + var missingProps []string + if missing&missingDocumentSelector != 0 { + missingProps = append(missingProps, "documentSelector") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) + } + + return nil +} + // Enumerations // A set of predefined token types. This set is not fixed @@ -19836,6 +21827,29 @@ const ( ErrorCodesUnknownErrorCode ErrorCodes = -32001 ) +const _ErrorCodes_name = "ParseErrorInternalErrorInvalidParamsMethodNotFoundInvalidRequestServerNotInitializedUnknownErrorCode" + +var ( + _ErrorCodes_index_0 = [...]uint16{0, 10} + _ErrorCodes_index_1 = [...]uint16{0, 13, 26, 40, 54} + _ErrorCodes_index_2 = [...]uint16{0, 20, 36} +) + +func (e ErrorCodes) String() string { + switch { + case e == -32700: + return _ErrorCodes_name[0:10] + case -32603 <= e && e <= -32600: + i := int(e) - -32603 + return _ErrorCodes_name[10+_ErrorCodes_index_1[i] : 10+_ErrorCodes_index_1[i+1]] + case -32002 <= e && e <= -32001: + i := int(e) - -32002 + return _ErrorCodes_name[64+_ErrorCodes_index_2[i] : 64+_ErrorCodes_index_2[i+1]] + default: + return fmt.Sprintf("ErrorCodes(%d)", e) + } +} + type LSPErrorCodes int32 const ( @@ -19866,6 +21880,18 @@ const ( LSPErrorCodesRequestCancelled LSPErrorCodes = -32800 ) +const _LSPErrorCodes_name = "RequestFailedServerCancelledContentModifiedRequestCancelled" + +var _LSPErrorCodes_index = [...]uint16{0, 13, 28, 43, 59} + +func (e LSPErrorCodes) String() string { + i := int(e) - -32803 + if i < 0 || i >= len(_LSPErrorCodes_index)-1 { + return fmt.Sprintf("LSPErrorCodes(%d)", e) + } + return _LSPErrorCodes_name[_LSPErrorCodes_index[i]:_LSPErrorCodes_index[i+1]] +} + // A set of predefined range kinds. type FoldingRangeKind string @@ -19910,6 +21936,18 @@ const ( SymbolKindTypeParameter SymbolKind = 26 ) +const _SymbolKind_name = "FileModuleNamespacePackageClassMethodPropertyFieldConstructorEnumInterfaceFunctionVariableConstantStringNumberBooleanArrayObjectKeyNullEnumMemberStructEventOperatorTypeParameter" + +var _SymbolKind_index = [...]uint16{0, 4, 10, 19, 26, 31, 37, 45, 50, 61, 65, 74, 82, 90, 98, 104, 110, 117, 122, 128, 131, 135, 145, 151, 156, 164, 177} + +func (e SymbolKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_SymbolKind_index)-1 { + return fmt.Sprintf("SymbolKind(%d)", e) + } + return _SymbolKind_name[_SymbolKind_index[i]:_SymbolKind_index[i+1]] +} + // Symbol tags are extra annotations that tweak the rendering of a symbol. // // Since: 3.16 @@ -19920,6 +21958,18 @@ const ( SymbolTagDeprecated SymbolTag = 1 ) +const _SymbolTag_name = "Deprecated" + +var _SymbolTag_index = [...]uint16{0, 10} + +func (e SymbolTag) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_SymbolTag_index)-1 { + return fmt.Sprintf("SymbolTag(%d)", e) + } + return _SymbolTag_name[_SymbolTag_index[i]:_SymbolTag_index[i+1]] +} + // Moniker uniqueness level to define scope of the moniker. // // Since: 3.16.0 @@ -19965,6 +22015,18 @@ const ( InlayHintKindParameter InlayHintKind = 2 ) +const _InlayHintKind_name = "TypeParameter" + +var _InlayHintKind_index = [...]uint16{0, 4, 13} + +func (e InlayHintKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_InlayHintKind_index)-1 { + return fmt.Sprintf("InlayHintKind(%d)", e) + } + return _InlayHintKind_name[_InlayHintKind_index[i]:_InlayHintKind_index[i+1]] +} + // The message type type MessageType uint32 @@ -19985,6 +22047,18 @@ const ( MessageTypeDebug MessageType = 5 ) +const _MessageType_name = "ErrorWarningInfoLogDebug" + +var _MessageType_index = [...]uint16{0, 5, 12, 16, 19, 24} + +func (e MessageType) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_MessageType_index)-1 { + return fmt.Sprintf("MessageType(%d)", e) + } + return _MessageType_name[_MessageType_index[i]:_MessageType_index[i+1]] +} + // Defines how the host (editor) should sync // document changes to the language server. type TextDocumentSyncKind uint32 @@ -20001,6 +22075,18 @@ const ( TextDocumentSyncKindIncremental TextDocumentSyncKind = 2 ) +const _TextDocumentSyncKind_name = "NoneFullIncremental" + +var _TextDocumentSyncKind_index = [...]uint16{0, 4, 8, 19} + +func (e TextDocumentSyncKind) String() string { + i := int(e) - 0 + if i < 0 || i >= len(_TextDocumentSyncKind_index)-1 { + return fmt.Sprintf("TextDocumentSyncKind(%d)", e) + } + return _TextDocumentSyncKind_name[_TextDocumentSyncKind_index[i]:_TextDocumentSyncKind_index[i+1]] +} + // Represents reasons why a text document is saved. type TextDocumentSaveReason uint32 @@ -20014,6 +22100,18 @@ const ( TextDocumentSaveReasonFocusOut TextDocumentSaveReason = 3 ) +const _TextDocumentSaveReason_name = "ManualAfterDelayFocusOut" + +var _TextDocumentSaveReason_index = [...]uint16{0, 6, 16, 24} + +func (e TextDocumentSaveReason) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_TextDocumentSaveReason_index)-1 { + return fmt.Sprintf("TextDocumentSaveReason(%d)", e) + } + return _TextDocumentSaveReason_name[_TextDocumentSaveReason_index[i]:_TextDocumentSaveReason_index[i+1]] +} + // The kind of a completion entry. type CompletionItemKind uint32 @@ -20045,6 +22143,18 @@ const ( CompletionItemKindTypeParameter CompletionItemKind = 25 ) +const _CompletionItemKind_name = "TextMethodFunctionConstructorFieldVariableClassInterfaceModulePropertyUnitValueEnumKeywordSnippetColorFileReferenceFolderEnumMemberConstantStructEventOperatorTypeParameter" + +var _CompletionItemKind_index = [...]uint16{0, 4, 10, 18, 29, 34, 42, 47, 56, 62, 70, 74, 79, 83, 90, 97, 102, 106, 115, 121, 131, 139, 145, 150, 158, 171} + +func (e CompletionItemKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_CompletionItemKind_index)-1 { + return fmt.Sprintf("CompletionItemKind(%d)", e) + } + return _CompletionItemKind_name[_CompletionItemKind_index[i]:_CompletionItemKind_index[i+1]] +} + // Completion item tags are extra annotations that tweak the rendering of a completion // item. // @@ -20056,6 +22166,18 @@ const ( CompletionItemTagDeprecated CompletionItemTag = 1 ) +const _CompletionItemTag_name = "Deprecated" + +var _CompletionItemTag_index = [...]uint16{0, 10} + +func (e CompletionItemTag) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_CompletionItemTag_index)-1 { + return fmt.Sprintf("CompletionItemTag(%d)", e) + } + return _CompletionItemTag_name[_CompletionItemTag_index[i]:_CompletionItemTag_index[i+1]] +} + // Defines whether the insert text in a completion item should be interpreted as // plain text or a snippet. type InsertTextFormat uint32 @@ -20074,6 +22196,18 @@ const ( InsertTextFormatSnippet InsertTextFormat = 2 ) +const _InsertTextFormat_name = "PlainTextSnippet" + +var _InsertTextFormat_index = [...]uint16{0, 9, 16} + +func (e InsertTextFormat) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_InsertTextFormat_index)-1 { + return fmt.Sprintf("InsertTextFormat(%d)", e) + } + return _InsertTextFormat_name[_InsertTextFormat_index[i]:_InsertTextFormat_index[i+1]] +} + // How whitespace and indentation is handled during completion // item insertion. // @@ -20097,6 +22231,18 @@ const ( InsertTextModeadjustIndentation InsertTextMode = 2 ) +const _InsertTextMode_name = "asIsadjustIndentation" + +var _InsertTextMode_index = [...]uint16{0, 4, 21} + +func (e InsertTextMode) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_InsertTextMode_index)-1 { + return fmt.Sprintf("InsertTextMode(%d)", e) + } + return _InsertTextMode_name[_InsertTextMode_index[i]:_InsertTextMode_index[i+1]] +} + // A document highlight kind. type DocumentHighlightKind uint32 @@ -20109,6 +22255,18 @@ const ( DocumentHighlightKindWrite DocumentHighlightKind = 3 ) +const _DocumentHighlightKind_name = "TextReadWrite" + +var _DocumentHighlightKind_index = [...]uint16{0, 4, 8, 13} + +func (e DocumentHighlightKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_DocumentHighlightKind_index)-1 { + return fmt.Sprintf("DocumentHighlightKind(%d)", e) + } + return _DocumentHighlightKind_name[_DocumentHighlightKind_index[i]:_DocumentHighlightKind_index[i+1]] +} + // A set of predefined code action kinds type CodeActionKind string @@ -20192,6 +22350,18 @@ const ( CodeActionTagLLMGenerated CodeActionTag = 1 ) +const _CodeActionTag_name = "LLMGenerated" + +var _CodeActionTag_index = [...]uint16{0, 12} + +func (e CodeActionTag) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_CodeActionTag_index)-1 { + return fmt.Sprintf("CodeActionTag(%d)", e) + } + return _CodeActionTag_name[_CodeActionTag_index[i]:_CodeActionTag_index[i+1]] +} + type TraceValue string const ( @@ -20309,9 +22479,21 @@ const ( InlineCompletionTriggerKindAutomatic InlineCompletionTriggerKind = 2 ) -// A set of predefined position encoding kinds. -// -// Since: 3.17.0 +const _InlineCompletionTriggerKind_name = "InvokedAutomatic" + +var _InlineCompletionTriggerKind_index = [...]uint16{0, 7, 16} + +func (e InlineCompletionTriggerKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_InlineCompletionTriggerKind_index)-1 { + return fmt.Sprintf("InlineCompletionTriggerKind(%d)", e) + } + return _InlineCompletionTriggerKind_name[_InlineCompletionTriggerKind_index[i]:_InlineCompletionTriggerKind_index[i+1]] +} + +// A set of predefined position encoding kinds. +// +// Since: 3.17.0 type PositionEncodingKind string const ( @@ -20342,6 +22524,18 @@ const ( FileChangeTypeDeleted FileChangeType = 3 ) +const _FileChangeType_name = "CreatedChangedDeleted" + +var _FileChangeType_index = [...]uint16{0, 7, 14, 21} + +func (e FileChangeType) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_FileChangeType_index)-1 { + return fmt.Sprintf("FileChangeType(%d)", e) + } + return _FileChangeType_name[_FileChangeType_index[i]:_FileChangeType_index[i+1]] +} + type WatchKind uint32 const ( @@ -20353,6 +22547,30 @@ const ( WatchKindDelete WatchKind = 4 ) +const _WatchKind_name = "CreateChangeDelete" + +var _WatchKind_index = [...]uint16{0, 6, 12, 18} + +func (e WatchKind) String() string { + if e == 0 { + return "0" + } + var parts []string + if e&1 != 0 { + parts = append(parts, _WatchKind_name[_WatchKind_index[0]:_WatchKind_index[1]]) + } + if e&2 != 0 { + parts = append(parts, _WatchKind_name[_WatchKind_index[1]:_WatchKind_index[2]]) + } + if e&4 != 0 { + parts = append(parts, _WatchKind_name[_WatchKind_index[2]:_WatchKind_index[3]]) + } + if len(parts) == 0 { + return fmt.Sprintf("WatchKind(%d)", e) + } + return strings.Join(parts, "|") +} + // The diagnostic's severity. type DiagnosticSeverity uint32 @@ -20367,6 +22585,18 @@ const ( DiagnosticSeverityHint DiagnosticSeverity = 4 ) +const _DiagnosticSeverity_name = "ErrorWarningInformationHint" + +var _DiagnosticSeverity_index = [...]uint16{0, 5, 12, 23, 27} + +func (e DiagnosticSeverity) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_DiagnosticSeverity_index)-1 { + return fmt.Sprintf("DiagnosticSeverity(%d)", e) + } + return _DiagnosticSeverity_name[_DiagnosticSeverity_index[i]:_DiagnosticSeverity_index[i+1]] +} + // The diagnostic tags. // // Since: 3.15.0 @@ -20384,6 +22614,18 @@ const ( DiagnosticTagDeprecated DiagnosticTag = 2 ) +const _DiagnosticTag_name = "UnnecessaryDeprecated" + +var _DiagnosticTag_index = [...]uint16{0, 11, 21} + +func (e DiagnosticTag) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_DiagnosticTag_index)-1 { + return fmt.Sprintf("DiagnosticTag(%d)", e) + } + return _DiagnosticTag_name[_DiagnosticTag_index[i]:_DiagnosticTag_index[i+1]] +} + // How a completion was triggered type CompletionTriggerKind uint32 @@ -20398,6 +22640,18 @@ const ( CompletionTriggerKindTriggerForIncompleteCompletions CompletionTriggerKind = 3 ) +const _CompletionTriggerKind_name = "InvokedTriggerCharacterTriggerForIncompleteCompletions" + +var _CompletionTriggerKind_index = [...]uint16{0, 7, 23, 54} + +func (e CompletionTriggerKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_CompletionTriggerKind_index)-1 { + return fmt.Sprintf("CompletionTriggerKind(%d)", e) + } + return _CompletionTriggerKind_name[_CompletionTriggerKind_index[i]:_CompletionTriggerKind_index[i+1]] +} + // Defines how values from a set of defaults and an individual item will be // merged. // @@ -20415,6 +22669,18 @@ const ( ApplyKindMerge ApplyKind = 2 ) +const _ApplyKind_name = "ReplaceMerge" + +var _ApplyKind_index = [...]uint16{0, 7, 12} + +func (e ApplyKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_ApplyKind_index)-1 { + return fmt.Sprintf("ApplyKind(%d)", e) + } + return _ApplyKind_name[_ApplyKind_index[i]:_ApplyKind_index[i+1]] +} + // How a signature help was triggered. // // Since: 3.15.0 @@ -20429,6 +22695,18 @@ const ( SignatureHelpTriggerKindContentChange SignatureHelpTriggerKind = 3 ) +const _SignatureHelpTriggerKind_name = "InvokedTriggerCharacterContentChange" + +var _SignatureHelpTriggerKind_index = [...]uint16{0, 7, 23, 36} + +func (e SignatureHelpTriggerKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_SignatureHelpTriggerKind_index)-1 { + return fmt.Sprintf("SignatureHelpTriggerKind(%d)", e) + } + return _SignatureHelpTriggerKind_name[_SignatureHelpTriggerKind_index[i]:_SignatureHelpTriggerKind_index[i+1]] +} + // The reason why code actions were requested. // // Since: 3.17.0 @@ -20444,6 +22722,18 @@ const ( CodeActionTriggerKindAutomatic CodeActionTriggerKind = 2 ) +const _CodeActionTriggerKind_name = "InvokedAutomatic" + +var _CodeActionTriggerKind_index = [...]uint16{0, 7, 16} + +func (e CodeActionTriggerKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_CodeActionTriggerKind_index)-1 { + return fmt.Sprintf("CodeActionTriggerKind(%d)", e) + } + return _CodeActionTriggerKind_name[_CodeActionTriggerKind_index[i]:_CodeActionTriggerKind_index[i+1]] +} + // A pattern kind describing if a glob pattern matches a file a folder or // both. // @@ -20469,6 +22759,18 @@ const ( NotebookCellKindCode NotebookCellKind = 2 ) +const _NotebookCellKind_name = "MarkupCode" + +var _NotebookCellKind_index = [...]uint16{0, 6, 10} + +func (e NotebookCellKind) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_NotebookCellKind_index)-1 { + return fmt.Sprintf("NotebookCellKind(%d)", e) + } + return _NotebookCellKind_name[_NotebookCellKind_index[i]:_NotebookCellKind_index[i+1]] +} + type ResourceOperationKind string const ( @@ -20506,6 +22808,18 @@ const ( PrepareSupportDefaultBehaviorIdentifier PrepareSupportDefaultBehavior = 1 ) +const _PrepareSupportDefaultBehavior_name = "Identifier" + +var _PrepareSupportDefaultBehavior_index = [...]uint16{0, 10} + +func (e PrepareSupportDefaultBehavior) String() string { + i := int(e) - 1 + if i < 0 || i >= len(_PrepareSupportDefaultBehavior_index)-1 { + return fmt.Sprintf("PrepareSupportDefaultBehavior(%d)", e) + } + return _PrepareSupportDefaultBehavior_name[_PrepareSupportDefaultBehavior_index[i]:_PrepareSupportDefaultBehavior_index[i+1]] +} + type TokenFormat string const ( @@ -20709,6 +23023,151 @@ func unmarshalParams(method Method, data []byte) (any, error) { } } +func unmarshalResult(method Method, data []byte) (any, error) { + switch method { + case MethodTextDocumentImplementation: + return unmarshalValue[ImplementationResponse](data) + case MethodTextDocumentTypeDefinition: + return unmarshalValue[TypeDefinitionResponse](data) + case MethodWorkspaceWorkspaceFolders: + return unmarshalValue[WorkspaceFoldersResponse](data) + case MethodWorkspaceConfiguration: + return unmarshalValue[ConfigurationResponse](data) + case MethodTextDocumentDocumentColor: + return unmarshalValue[DocumentColorResponse](data) + case MethodTextDocumentColorPresentation: + return unmarshalValue[ColorPresentationResponse](data) + case MethodTextDocumentFoldingRange: + return unmarshalValue[FoldingRangeResponse](data) + case MethodWorkspaceFoldingRangeRefresh: + return unmarshalValue[FoldingRangeRefreshResponse](data) + case MethodTextDocumentDeclaration: + return unmarshalValue[DeclarationResponse](data) + case MethodTextDocumentSelectionRange: + return unmarshalValue[SelectionRangeResponse](data) + case MethodWindowWorkDoneProgressCreate: + return unmarshalValue[WorkDoneProgressCreateResponse](data) + case MethodTextDocumentPrepareCallHierarchy: + return unmarshalValue[CallHierarchyPrepareResponse](data) + case MethodCallHierarchyIncomingCalls: + return unmarshalValue[CallHierarchyIncomingCallsResponse](data) + case MethodCallHierarchyOutgoingCalls: + return unmarshalValue[CallHierarchyOutgoingCallsResponse](data) + case MethodTextDocumentSemanticTokensFull: + return unmarshalValue[SemanticTokensResponse](data) + case MethodTextDocumentSemanticTokensFullDelta: + return unmarshalValue[SemanticTokensDeltaResponse](data) + case MethodTextDocumentSemanticTokensRange: + return unmarshalValue[SemanticTokensRangeResponse](data) + case MethodWorkspaceSemanticTokensRefresh: + return unmarshalValue[SemanticTokensRefreshResponse](data) + case MethodWindowShowDocument: + return unmarshalValue[ShowDocumentResponse](data) + case MethodTextDocumentLinkedEditingRange: + return unmarshalValue[LinkedEditingRangeResponse](data) + case MethodWorkspaceWillCreateFiles: + return unmarshalValue[WillCreateFilesResponse](data) + case MethodWorkspaceWillRenameFiles: + return unmarshalValue[WillRenameFilesResponse](data) + case MethodWorkspaceWillDeleteFiles: + return unmarshalValue[WillDeleteFilesResponse](data) + case MethodTextDocumentMoniker: + return unmarshalValue[MonikerResponse](data) + case MethodTextDocumentPrepareTypeHierarchy: + return unmarshalValue[TypeHierarchyPrepareResponse](data) + case MethodTypeHierarchySupertypes: + return unmarshalValue[TypeHierarchySupertypesResponse](data) + case MethodTypeHierarchySubtypes: + return unmarshalValue[TypeHierarchySubtypesResponse](data) + case MethodTextDocumentInlineValue: + return unmarshalValue[InlineValueResponse](data) + case MethodWorkspaceInlineValueRefresh: + return unmarshalValue[InlineValueRefreshResponse](data) + case MethodTextDocumentInlayHint: + return unmarshalValue[InlayHintResponse](data) + case MethodInlayHintResolve: + return unmarshalValue[InlayHintResolveResponse](data) + case MethodWorkspaceInlayHintRefresh: + return unmarshalValue[InlayHintRefreshResponse](data) + case MethodTextDocumentDiagnostic: + return unmarshalValue[DocumentDiagnosticResponse](data) + case MethodWorkspaceDiagnostic: + return unmarshalValue[WorkspaceDiagnosticResponse](data) + case MethodWorkspaceDiagnosticRefresh: + return unmarshalValue[DiagnosticRefreshResponse](data) + case MethodTextDocumentInlineCompletion: + return unmarshalValue[InlineCompletionResponse](data) + case MethodWorkspaceTextDocumentContent: + return unmarshalValue[TextDocumentContentResponse](data) + case MethodWorkspaceTextDocumentContentRefresh: + return unmarshalValue[TextDocumentContentRefreshResponse](data) + case MethodClientRegisterCapability: + return unmarshalValue[RegistrationResponse](data) + case MethodClientUnregisterCapability: + return unmarshalValue[UnregistrationResponse](data) + case MethodInitialize: + return unmarshalValue[InitializeResponse](data) + case MethodShutdown: + return unmarshalValue[ShutdownResponse](data) + case MethodWindowShowMessageRequest: + return unmarshalValue[ShowMessageResponse](data) + case MethodTextDocumentWillSaveWaitUntil: + return unmarshalValue[WillSaveTextDocumentWaitUntilResponse](data) + case MethodTextDocumentCompletion: + return unmarshalValue[CompletionResponse](data) + case MethodCompletionItemResolve: + return unmarshalValue[CompletionResolveResponse](data) + case MethodTextDocumentHover: + return unmarshalValue[HoverResponse](data) + case MethodTextDocumentSignatureHelp: + return unmarshalValue[SignatureHelpResponse](data) + case MethodTextDocumentDefinition: + return unmarshalValue[DefinitionResponse](data) + case MethodTextDocumentReferences: + return unmarshalValue[ReferencesResponse](data) + case MethodTextDocumentDocumentHighlight: + return unmarshalValue[DocumentHighlightResponse](data) + case MethodTextDocumentDocumentSymbol: + return unmarshalValue[DocumentSymbolResponse](data) + case MethodTextDocumentCodeAction: + return unmarshalValue[CodeActionResponse](data) + case MethodCodeActionResolve: + return unmarshalValue[CodeActionResolveResponse](data) + case MethodWorkspaceSymbol: + return unmarshalValue[WorkspaceSymbolResponse](data) + case MethodWorkspaceSymbolResolve: + return unmarshalValue[WorkspaceSymbolResolveResponse](data) + case MethodTextDocumentCodeLens: + return unmarshalValue[CodeLensResponse](data) + case MethodCodeLensResolve: + return unmarshalValue[CodeLensResolveResponse](data) + case MethodWorkspaceCodeLensRefresh: + return unmarshalValue[CodeLensRefreshResponse](data) + case MethodTextDocumentDocumentLink: + return unmarshalValue[DocumentLinkResponse](data) + case MethodDocumentLinkResolve: + return unmarshalValue[DocumentLinkResolveResponse](data) + case MethodTextDocumentFormatting: + return unmarshalValue[DocumentFormattingResponse](data) + case MethodTextDocumentRangeFormatting: + return unmarshalValue[DocumentRangeFormattingResponse](data) + case MethodTextDocumentRangesFormatting: + return unmarshalValue[DocumentRangesFormattingResponse](data) + case MethodTextDocumentOnTypeFormatting: + return unmarshalValue[DocumentOnTypeFormattingResponse](data) + case MethodTextDocumentRename: + return unmarshalValue[RenameResponse](data) + case MethodTextDocumentPrepareRename: + return unmarshalValue[PrepareRenameResponse](data) + case MethodWorkspaceExecuteCommand: + return unmarshalValue[ExecuteCommandResponse](data) + case MethodWorkspaceApplyEdit: + return unmarshalValue[ApplyWorkspaceEditResponse](data) + default: + return unmarshalAny(data) + } +} + // Methods const ( // A request to resolve the implementation locations of a symbol at a given text @@ -21439,7 +23898,7 @@ type WorkspaceSymbolResolveResponse = *WorkspaceSymbol var WorkspaceSymbolResolveInfo = RequestInfo[*WorkspaceSymbol, WorkspaceSymbolResolveResponse]{Method: MethodWorkspaceSymbolResolve} // Response type for `textDocument/codeLens` -type CodeLensResponse = CodeLenssOrNull +type CodeLensResponse = CodeLensesOrNull // Type mapping info for `textDocument/codeLens` var TextDocumentCodeLensInfo = RequestInfo[*CodeLensParams, CodeLensResponse]{Method: MethodTextDocumentCodeLens} @@ -22513,105 +24972,488 @@ func (o *TextEditOrAnnotatedTextEditOrSnippetTextEdit) UnmarshalJSONFrom(dec *js return fmt.Errorf("invalid TextEditOrAnnotatedTextEditOrSnippetTextEdit: %s", data) } -type TextDocumentSyncOptionsOrKind struct { - Options *TextDocumentSyncOptions - Kind *TextDocumentSyncKind -} - -var _ json.MarshalerTo = (*TextDocumentSyncOptionsOrKind)(nil) - -func (o *TextDocumentSyncOptionsOrKind) MarshalJSONTo(enc *jsontext.Encoder) error { - assertOnlyOne("exactly one element of TextDocumentSyncOptionsOrKind should be set", o.Options != nil, o.Kind != nil) - - if o.Options != nil { - return json.MarshalEncode(enc, o.Options) +type RegisterOptions struct { + Implementation *ImplementationRegistrationOptions + TypeDefinition *TypeDefinitionRegistrationOptions + DocumentColor *DocumentColorRegistrationOptions + ColorPresentation *ColorPresentationRegistrationOptions + FoldingRange *FoldingRangeRegistrationOptions + Declaration *DeclarationRegistrationOptions + SelectionRange *SelectionRangeRegistrationOptions + CallHierarchy *CallHierarchyRegistrationOptions + SemanticTokens *SemanticTokensRegistrationOptions + LinkedEditingRange *LinkedEditingRangeRegistrationOptions + FileOperation *FileOperationRegistrationOptions + Moniker *MonikerRegistrationOptions + TypeHierarchy *TypeHierarchyRegistrationOptions + InlineValue *InlineValueRegistrationOptions + InlayHint *InlayHintRegistrationOptions + Diagnostic *DiagnosticRegistrationOptions + InlineCompletion *InlineCompletionRegistrationOptions + TextDocumentContent *TextDocumentContentRegistrationOptions + TextDocument *TextDocumentRegistrationOptions + Completion *CompletionRegistrationOptions + Hover *HoverRegistrationOptions + SignatureHelp *SignatureHelpRegistrationOptions + Definition *DefinitionRegistrationOptions + Reference *ReferenceRegistrationOptions + DocumentHighlight *DocumentHighlightRegistrationOptions + DocumentSymbol *DocumentSymbolRegistrationOptions + CodeAction *CodeActionRegistrationOptions + WorkspaceSymbol *WorkspaceSymbolRegistrationOptions + CodeLens *CodeLensRegistrationOptions + DocumentLink *DocumentLinkRegistrationOptions + DocumentFormatting *DocumentFormattingRegistrationOptions + DocumentRangeFormatting *DocumentRangeFormattingRegistrationOptions + DocumentOnTypeFormatting *DocumentOnTypeFormattingRegistrationOptions + Rename *RenameRegistrationOptions + ExecuteCommand *ExecuteCommandRegistrationOptions + NotebookDocumentSync *NotebookDocumentSyncRegistrationOptions + DidChangeConfiguration *DidChangeConfigurationRegistrationOptions + TextDocumentChange *TextDocumentChangeRegistrationOptions + TextDocumentSave *TextDocumentSaveRegistrationOptions + DidChangeWatchedFiles *DidChangeWatchedFilesRegistrationOptions +} + +var _ json.MarshalerTo = (*RegisterOptions)(nil) + +func (o *RegisterOptions) MarshalJSONTo(enc *jsontext.Encoder) error { + assertOnlyOne("exactly one element of RegisterOptions should be set", o.Implementation != nil, o.TypeDefinition != nil, o.DocumentColor != nil, o.ColorPresentation != nil, o.FoldingRange != nil, o.Declaration != nil, o.SelectionRange != nil, o.CallHierarchy != nil, o.SemanticTokens != nil, o.LinkedEditingRange != nil, o.FileOperation != nil, o.Moniker != nil, o.TypeHierarchy != nil, o.InlineValue != nil, o.InlayHint != nil, o.Diagnostic != nil, o.InlineCompletion != nil, o.TextDocumentContent != nil, o.TextDocument != nil, o.Completion != nil, o.Hover != nil, o.SignatureHelp != nil, o.Definition != nil, o.Reference != nil, o.DocumentHighlight != nil, o.DocumentSymbol != nil, o.CodeAction != nil, o.WorkspaceSymbol != nil, o.CodeLens != nil, o.DocumentLink != nil, o.DocumentFormatting != nil, o.DocumentRangeFormatting != nil, o.DocumentOnTypeFormatting != nil, o.Rename != nil, o.ExecuteCommand != nil, o.NotebookDocumentSync != nil, o.DidChangeConfiguration != nil, o.TextDocumentChange != nil, o.TextDocumentSave != nil, o.DidChangeWatchedFiles != nil) + + if o.Implementation != nil { + return json.MarshalEncode(enc, o.Implementation) + } + if o.TypeDefinition != nil { + return json.MarshalEncode(enc, o.TypeDefinition) + } + if o.DocumentColor != nil { + return json.MarshalEncode(enc, o.DocumentColor) + } + if o.ColorPresentation != nil { + return json.MarshalEncode(enc, o.ColorPresentation) + } + if o.FoldingRange != nil { + return json.MarshalEncode(enc, o.FoldingRange) + } + if o.Declaration != nil { + return json.MarshalEncode(enc, o.Declaration) + } + if o.SelectionRange != nil { + return json.MarshalEncode(enc, o.SelectionRange) + } + if o.CallHierarchy != nil { + return json.MarshalEncode(enc, o.CallHierarchy) } - if o.Kind != nil { - return json.MarshalEncode(enc, o.Kind) + if o.SemanticTokens != nil { + return json.MarshalEncode(enc, o.SemanticTokens) + } + if o.LinkedEditingRange != nil { + return json.MarshalEncode(enc, o.LinkedEditingRange) + } + if o.FileOperation != nil { + return json.MarshalEncode(enc, o.FileOperation) + } + if o.Moniker != nil { + return json.MarshalEncode(enc, o.Moniker) + } + if o.TypeHierarchy != nil { + return json.MarshalEncode(enc, o.TypeHierarchy) + } + if o.InlineValue != nil { + return json.MarshalEncode(enc, o.InlineValue) + } + if o.InlayHint != nil { + return json.MarshalEncode(enc, o.InlayHint) + } + if o.Diagnostic != nil { + return json.MarshalEncode(enc, o.Diagnostic) + } + if o.InlineCompletion != nil { + return json.MarshalEncode(enc, o.InlineCompletion) + } + if o.TextDocumentContent != nil { + return json.MarshalEncode(enc, o.TextDocumentContent) + } + if o.TextDocument != nil { + return json.MarshalEncode(enc, o.TextDocument) + } + if o.Completion != nil { + return json.MarshalEncode(enc, o.Completion) + } + if o.Hover != nil { + return json.MarshalEncode(enc, o.Hover) + } + if o.SignatureHelp != nil { + return json.MarshalEncode(enc, o.SignatureHelp) + } + if o.Definition != nil { + return json.MarshalEncode(enc, o.Definition) + } + if o.Reference != nil { + return json.MarshalEncode(enc, o.Reference) + } + if o.DocumentHighlight != nil { + return json.MarshalEncode(enc, o.DocumentHighlight) + } + if o.DocumentSymbol != nil { + return json.MarshalEncode(enc, o.DocumentSymbol) + } + if o.CodeAction != nil { + return json.MarshalEncode(enc, o.CodeAction) + } + if o.WorkspaceSymbol != nil { + return json.MarshalEncode(enc, o.WorkspaceSymbol) + } + if o.CodeLens != nil { + return json.MarshalEncode(enc, o.CodeLens) + } + if o.DocumentLink != nil { + return json.MarshalEncode(enc, o.DocumentLink) + } + if o.DocumentFormatting != nil { + return json.MarshalEncode(enc, o.DocumentFormatting) + } + if o.DocumentRangeFormatting != nil { + return json.MarshalEncode(enc, o.DocumentRangeFormatting) + } + if o.DocumentOnTypeFormatting != nil { + return json.MarshalEncode(enc, o.DocumentOnTypeFormatting) + } + if o.Rename != nil { + return json.MarshalEncode(enc, o.Rename) + } + if o.ExecuteCommand != nil { + return json.MarshalEncode(enc, o.ExecuteCommand) + } + if o.NotebookDocumentSync != nil { + return json.MarshalEncode(enc, o.NotebookDocumentSync) + } + if o.DidChangeConfiguration != nil { + return json.MarshalEncode(enc, o.DidChangeConfiguration) + } + if o.TextDocumentChange != nil { + return json.MarshalEncode(enc, o.TextDocumentChange) + } + if o.TextDocumentSave != nil { + return json.MarshalEncode(enc, o.TextDocumentSave) + } + if o.DidChangeWatchedFiles != nil { + return json.MarshalEncode(enc, o.DidChangeWatchedFiles) } panic("unreachable") } -var _ json.UnmarshalerFrom = (*TextDocumentSyncOptionsOrKind)(nil) +var _ json.UnmarshalerFrom = (*RegisterOptions)(nil) -func (o *TextDocumentSyncOptionsOrKind) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - *o = TextDocumentSyncOptionsOrKind{} +func (o *RegisterOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + *o = RegisterOptions{} data, err := dec.ReadValue() if err != nil { return err } - var vOptions TextDocumentSyncOptions - if err := json.Unmarshal(data, &vOptions); err == nil { - o.Options = &vOptions + var vImplementation ImplementationRegistrationOptions + if err := json.Unmarshal(data, &vImplementation); err == nil { + o.Implementation = &vImplementation return nil } - var vKind TextDocumentSyncKind - if err := json.Unmarshal(data, &vKind); err == nil { - o.Kind = &vKind + var vTypeDefinition TypeDefinitionRegistrationOptions + if err := json.Unmarshal(data, &vTypeDefinition); err == nil { + o.TypeDefinition = &vTypeDefinition return nil } - return fmt.Errorf("invalid TextDocumentSyncOptionsOrKind: %s", data) -} - -type NotebookDocumentSyncOptionsOrRegistrationOptions struct { - Options *NotebookDocumentSyncOptions - RegistrationOptions *NotebookDocumentSyncRegistrationOptions -} - -var _ json.MarshalerTo = (*NotebookDocumentSyncOptionsOrRegistrationOptions)(nil) - -func (o *NotebookDocumentSyncOptionsOrRegistrationOptions) MarshalJSONTo(enc *jsontext.Encoder) error { - assertOnlyOne("exactly one element of NotebookDocumentSyncOptionsOrRegistrationOptions should be set", o.Options != nil, o.RegistrationOptions != nil) - - if o.Options != nil { - return json.MarshalEncode(enc, o.Options) - } - if o.RegistrationOptions != nil { - return json.MarshalEncode(enc, o.RegistrationOptions) + var vDocumentColor DocumentColorRegistrationOptions + if err := json.Unmarshal(data, &vDocumentColor); err == nil { + o.DocumentColor = &vDocumentColor + return nil } - panic("unreachable") -} - -var _ json.UnmarshalerFrom = (*NotebookDocumentSyncOptionsOrRegistrationOptions)(nil) - -func (o *NotebookDocumentSyncOptionsOrRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - *o = NotebookDocumentSyncOptionsOrRegistrationOptions{} - - data, err := dec.ReadValue() - if err != nil { - return err + var vColorPresentation ColorPresentationRegistrationOptions + if err := json.Unmarshal(data, &vColorPresentation); err == nil { + o.ColorPresentation = &vColorPresentation + return nil } - var vOptions NotebookDocumentSyncOptions - if err := json.Unmarshal(data, &vOptions); err == nil { - o.Options = &vOptions + var vFoldingRange FoldingRangeRegistrationOptions + if err := json.Unmarshal(data, &vFoldingRange); err == nil { + o.FoldingRange = &vFoldingRange return nil } - var vRegistrationOptions NotebookDocumentSyncRegistrationOptions - if err := json.Unmarshal(data, &vRegistrationOptions); err == nil { - o.RegistrationOptions = &vRegistrationOptions + var vDeclaration DeclarationRegistrationOptions + if err := json.Unmarshal(data, &vDeclaration); err == nil { + o.Declaration = &vDeclaration return nil } - return fmt.Errorf("invalid NotebookDocumentSyncOptionsOrRegistrationOptions: %s", data) -} - -type BooleanOrHoverOptions struct { - Boolean *bool - HoverOptions *HoverOptions -} - -var _ json.MarshalerTo = (*BooleanOrHoverOptions)(nil) - -func (o *BooleanOrHoverOptions) MarshalJSONTo(enc *jsontext.Encoder) error { - assertOnlyOne("exactly one element of BooleanOrHoverOptions should be set", o.Boolean != nil, o.HoverOptions != nil) - - if o.Boolean != nil { - return json.MarshalEncode(enc, o.Boolean) + var vSelectionRange SelectionRangeRegistrationOptions + if err := json.Unmarshal(data, &vSelectionRange); err == nil { + o.SelectionRange = &vSelectionRange + return nil } - if o.HoverOptions != nil { - return json.MarshalEncode(enc, o.HoverOptions) + var vCallHierarchy CallHierarchyRegistrationOptions + if err := json.Unmarshal(data, &vCallHierarchy); err == nil { + o.CallHierarchy = &vCallHierarchy + return nil } - panic("unreachable") + var vSemanticTokens SemanticTokensRegistrationOptions + if err := json.Unmarshal(data, &vSemanticTokens); err == nil { + o.SemanticTokens = &vSemanticTokens + return nil + } + var vLinkedEditingRange LinkedEditingRangeRegistrationOptions + if err := json.Unmarshal(data, &vLinkedEditingRange); err == nil { + o.LinkedEditingRange = &vLinkedEditingRange + return nil + } + var vFileOperation FileOperationRegistrationOptions + if err := json.Unmarshal(data, &vFileOperation); err == nil { + o.FileOperation = &vFileOperation + return nil + } + var vMoniker MonikerRegistrationOptions + if err := json.Unmarshal(data, &vMoniker); err == nil { + o.Moniker = &vMoniker + return nil + } + var vTypeHierarchy TypeHierarchyRegistrationOptions + if err := json.Unmarshal(data, &vTypeHierarchy); err == nil { + o.TypeHierarchy = &vTypeHierarchy + return nil + } + var vInlineValue InlineValueRegistrationOptions + if err := json.Unmarshal(data, &vInlineValue); err == nil { + o.InlineValue = &vInlineValue + return nil + } + var vInlayHint InlayHintRegistrationOptions + if err := json.Unmarshal(data, &vInlayHint); err == nil { + o.InlayHint = &vInlayHint + return nil + } + var vDiagnostic DiagnosticRegistrationOptions + if err := json.Unmarshal(data, &vDiagnostic); err == nil { + o.Diagnostic = &vDiagnostic + return nil + } + var vInlineCompletion InlineCompletionRegistrationOptions + if err := json.Unmarshal(data, &vInlineCompletion); err == nil { + o.InlineCompletion = &vInlineCompletion + return nil + } + var vTextDocumentContent TextDocumentContentRegistrationOptions + if err := json.Unmarshal(data, &vTextDocumentContent); err == nil { + o.TextDocumentContent = &vTextDocumentContent + return nil + } + var vTextDocument TextDocumentRegistrationOptions + if err := json.Unmarshal(data, &vTextDocument); err == nil { + o.TextDocument = &vTextDocument + return nil + } + var vCompletion CompletionRegistrationOptions + if err := json.Unmarshal(data, &vCompletion); err == nil { + o.Completion = &vCompletion + return nil + } + var vHover HoverRegistrationOptions + if err := json.Unmarshal(data, &vHover); err == nil { + o.Hover = &vHover + return nil + } + var vSignatureHelp SignatureHelpRegistrationOptions + if err := json.Unmarshal(data, &vSignatureHelp); err == nil { + o.SignatureHelp = &vSignatureHelp + return nil + } + var vDefinition DefinitionRegistrationOptions + if err := json.Unmarshal(data, &vDefinition); err == nil { + o.Definition = &vDefinition + return nil + } + var vReference ReferenceRegistrationOptions + if err := json.Unmarshal(data, &vReference); err == nil { + o.Reference = &vReference + return nil + } + var vDocumentHighlight DocumentHighlightRegistrationOptions + if err := json.Unmarshal(data, &vDocumentHighlight); err == nil { + o.DocumentHighlight = &vDocumentHighlight + return nil + } + var vDocumentSymbol DocumentSymbolRegistrationOptions + if err := json.Unmarshal(data, &vDocumentSymbol); err == nil { + o.DocumentSymbol = &vDocumentSymbol + return nil + } + var vCodeAction CodeActionRegistrationOptions + if err := json.Unmarshal(data, &vCodeAction); err == nil { + o.CodeAction = &vCodeAction + return nil + } + var vWorkspaceSymbol WorkspaceSymbolRegistrationOptions + if err := json.Unmarshal(data, &vWorkspaceSymbol); err == nil { + o.WorkspaceSymbol = &vWorkspaceSymbol + return nil + } + var vCodeLens CodeLensRegistrationOptions + if err := json.Unmarshal(data, &vCodeLens); err == nil { + o.CodeLens = &vCodeLens + return nil + } + var vDocumentLink DocumentLinkRegistrationOptions + if err := json.Unmarshal(data, &vDocumentLink); err == nil { + o.DocumentLink = &vDocumentLink + return nil + } + var vDocumentFormatting DocumentFormattingRegistrationOptions + if err := json.Unmarshal(data, &vDocumentFormatting); err == nil { + o.DocumentFormatting = &vDocumentFormatting + return nil + } + var vDocumentRangeFormatting DocumentRangeFormattingRegistrationOptions + if err := json.Unmarshal(data, &vDocumentRangeFormatting); err == nil { + o.DocumentRangeFormatting = &vDocumentRangeFormatting + return nil + } + var vDocumentOnTypeFormatting DocumentOnTypeFormattingRegistrationOptions + if err := json.Unmarshal(data, &vDocumentOnTypeFormatting); err == nil { + o.DocumentOnTypeFormatting = &vDocumentOnTypeFormatting + return nil + } + var vRename RenameRegistrationOptions + if err := json.Unmarshal(data, &vRename); err == nil { + o.Rename = &vRename + return nil + } + var vExecuteCommand ExecuteCommandRegistrationOptions + if err := json.Unmarshal(data, &vExecuteCommand); err == nil { + o.ExecuteCommand = &vExecuteCommand + return nil + } + var vNotebookDocumentSync NotebookDocumentSyncRegistrationOptions + if err := json.Unmarshal(data, &vNotebookDocumentSync); err == nil { + o.NotebookDocumentSync = &vNotebookDocumentSync + return nil + } + var vDidChangeConfiguration DidChangeConfigurationRegistrationOptions + if err := json.Unmarshal(data, &vDidChangeConfiguration); err == nil { + o.DidChangeConfiguration = &vDidChangeConfiguration + return nil + } + var vTextDocumentChange TextDocumentChangeRegistrationOptions + if err := json.Unmarshal(data, &vTextDocumentChange); err == nil { + o.TextDocumentChange = &vTextDocumentChange + return nil + } + var vTextDocumentSave TextDocumentSaveRegistrationOptions + if err := json.Unmarshal(data, &vTextDocumentSave); err == nil { + o.TextDocumentSave = &vTextDocumentSave + return nil + } + var vDidChangeWatchedFiles DidChangeWatchedFilesRegistrationOptions + if err := json.Unmarshal(data, &vDidChangeWatchedFiles); err == nil { + o.DidChangeWatchedFiles = &vDidChangeWatchedFiles + return nil + } + return fmt.Errorf("invalid RegisterOptions: %s", data) +} + +type TextDocumentSyncOptionsOrKind struct { + Options *TextDocumentSyncOptions + Kind *TextDocumentSyncKind +} + +var _ json.MarshalerTo = (*TextDocumentSyncOptionsOrKind)(nil) + +func (o *TextDocumentSyncOptionsOrKind) MarshalJSONTo(enc *jsontext.Encoder) error { + assertOnlyOne("exactly one element of TextDocumentSyncOptionsOrKind should be set", o.Options != nil, o.Kind != nil) + + if o.Options != nil { + return json.MarshalEncode(enc, o.Options) + } + if o.Kind != nil { + return json.MarshalEncode(enc, o.Kind) + } + panic("unreachable") +} + +var _ json.UnmarshalerFrom = (*TextDocumentSyncOptionsOrKind)(nil) + +func (o *TextDocumentSyncOptionsOrKind) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + *o = TextDocumentSyncOptionsOrKind{} + + data, err := dec.ReadValue() + if err != nil { + return err + } + var vOptions TextDocumentSyncOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions + return nil + } + var vKind TextDocumentSyncKind + if err := json.Unmarshal(data, &vKind); err == nil { + o.Kind = &vKind + return nil + } + return fmt.Errorf("invalid TextDocumentSyncOptionsOrKind: %s", data) +} + +type NotebookDocumentSyncOptionsOrRegistrationOptions struct { + Options *NotebookDocumentSyncOptions + RegistrationOptions *NotebookDocumentSyncRegistrationOptions +} + +var _ json.MarshalerTo = (*NotebookDocumentSyncOptionsOrRegistrationOptions)(nil) + +func (o *NotebookDocumentSyncOptionsOrRegistrationOptions) MarshalJSONTo(enc *jsontext.Encoder) error { + assertOnlyOne("exactly one element of NotebookDocumentSyncOptionsOrRegistrationOptions should be set", o.Options != nil, o.RegistrationOptions != nil) + + if o.Options != nil { + return json.MarshalEncode(enc, o.Options) + } + if o.RegistrationOptions != nil { + return json.MarshalEncode(enc, o.RegistrationOptions) + } + panic("unreachable") +} + +var _ json.UnmarshalerFrom = (*NotebookDocumentSyncOptionsOrRegistrationOptions)(nil) + +func (o *NotebookDocumentSyncOptionsOrRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + *o = NotebookDocumentSyncOptionsOrRegistrationOptions{} + + data, err := dec.ReadValue() + if err != nil { + return err + } + var vOptions NotebookDocumentSyncOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions + return nil + } + var vRegistrationOptions NotebookDocumentSyncRegistrationOptions + if err := json.Unmarshal(data, &vRegistrationOptions); err == nil { + o.RegistrationOptions = &vRegistrationOptions + return nil + } + return fmt.Errorf("invalid NotebookDocumentSyncOptionsOrRegistrationOptions: %s", data) +} + +type BooleanOrHoverOptions struct { + Boolean *bool + HoverOptions *HoverOptions +} + +var _ json.MarshalerTo = (*BooleanOrHoverOptions)(nil) + +func (o *BooleanOrHoverOptions) MarshalJSONTo(enc *jsontext.Encoder) error { + assertOnlyOne("exactly one element of BooleanOrHoverOptions should be set", o.Boolean != nil, o.HoverOptions != nil) + + if o.Boolean != nil { + return json.MarshalEncode(enc, o.Boolean) + } + if o.HoverOptions != nil { + return json.MarshalEncode(enc, o.HoverOptions) + } + panic("unreachable") } var _ json.UnmarshalerFrom = (*BooleanOrHoverOptions)(nil) @@ -25214,25 +28056,25 @@ func (o *SymbolInformationsOrWorkspaceSymbolsOrNull) UnmarshalJSONFrom(dec *json return fmt.Errorf("invalid SymbolInformationsOrWorkspaceSymbolsOrNull: %s", data) } -type CodeLenssOrNull struct { - CodeLenss *[]*CodeLens +type CodeLensesOrNull struct { + CodeLenses *[]*CodeLens } -var _ json.MarshalerTo = (*CodeLenssOrNull)(nil) +var _ json.MarshalerTo = (*CodeLensesOrNull)(nil) -func (o *CodeLenssOrNull) MarshalJSONTo(enc *jsontext.Encoder) error { - assertAtMostOne("more than one element of CodeLenssOrNull is set", o.CodeLenss != nil) +func (o *CodeLensesOrNull) MarshalJSONTo(enc *jsontext.Encoder) error { + assertAtMostOne("more than one element of CodeLensesOrNull is set", o.CodeLenses != nil) - if o.CodeLenss != nil { - return json.MarshalEncode(enc, o.CodeLenss) + if o.CodeLenses != nil { + return json.MarshalEncode(enc, o.CodeLenses) } return enc.WriteToken(jsontext.Null) } -var _ json.UnmarshalerFrom = (*CodeLenssOrNull)(nil) +var _ json.UnmarshalerFrom = (*CodeLensesOrNull)(nil) -func (o *CodeLenssOrNull) UnmarshalJSONFrom(dec *jsontext.Decoder) error { - *o = CodeLenssOrNull{} +func (o *CodeLensesOrNull) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + *o = CodeLensesOrNull{} data, err := dec.ReadValue() if err != nil { @@ -25242,12 +28084,12 @@ func (o *CodeLenssOrNull) UnmarshalJSONFrom(dec *jsontext.Decoder) error { return nil } - var vCodeLenss []*CodeLens - if err := json.Unmarshal(data, &vCodeLenss); err == nil { - o.CodeLenss = &vCodeLenss + var vCodeLenses []*CodeLens + if err := json.Unmarshal(data, &vCodeLenses); err == nil { + o.CodeLenses = &vCodeLenses return nil } - return fmt.Errorf("invalid CodeLenssOrNull: %s", data) + return fmt.Errorf("invalid CodeLensesOrNull: %s", data) } type DocumentLinksOrNull struct { @@ -25725,3 +28567,2354 @@ func (o *StringLiteralSnippet) UnmarshalJSONFrom(dec *jsontext.Decoder) error { } return nil } + +// Helper function for dereferencing pointers with zero value fallback +func derefOr[T any](v *T) T { + if v != nil { + return *v + } + var zero T + return zero +} + +// ResolvedChangeAnnotationsSupportOptions is a resolved version of ChangeAnnotationsSupportOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedChangeAnnotationsSupportOptions struct { + // Whether the client groups edits with equal labels into tree nodes, + // for instance all edits labelled with "Changes in Strings" would + // be a tree node. + GroupsOnLabel bool `json:"groupsOnLabel,omitzero"` +} + +func resolveChangeAnnotationsSupportOptions(v *ChangeAnnotationsSupportOptions) ResolvedChangeAnnotationsSupportOptions { + if v == nil { + return ResolvedChangeAnnotationsSupportOptions{} + } + return ResolvedChangeAnnotationsSupportOptions{ + GroupsOnLabel: derefOr(v.GroupsOnLabel), + } +} + +// ResolvedWorkspaceEditClientCapabilities is a resolved version of WorkspaceEditClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedWorkspaceEditClientCapabilities struct { + // The client supports versioned document changes in `WorkspaceEdit`s + DocumentChanges bool `json:"documentChanges,omitzero"` + // The resource operations the client supports. Clients should at least + // support 'create', 'rename' and 'delete' files and folders. + // + // Since: 3.13.0 + ResourceOperations []ResourceOperationKind `json:"resourceOperations,omitzero"` + // The failure handling strategy of a client if applying the workspace edit + // fails. + // + // Since: 3.13.0 + FailureHandling FailureHandlingKind `json:"failureHandling,omitzero"` + // Whether the client normalizes line endings to the client specific + // setting. + // If set to `true` the client will normalize line ending characters + // in a workspace edit to the client-specified new line + // character. + // + // Since: 3.16.0 + NormalizesLineEndings bool `json:"normalizesLineEndings,omitzero"` + // Whether the client in general supports change annotations on text edits, + // create file, rename file and delete file changes. + // + // Since: 3.16.0 + ChangeAnnotationSupport ResolvedChangeAnnotationsSupportOptions `json:"changeAnnotationSupport,omitzero"` + // Whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s. + // + // Since: 3.18.0 + // + // Proposed. + MetadataSupport bool `json:"metadataSupport,omitzero"` + // Whether the client supports snippets as text edits. + // + // Since: 3.18.0 + // + // Proposed. + SnippetEditSupport bool `json:"snippetEditSupport,omitzero"` +} + +func resolveWorkspaceEditClientCapabilities(v *WorkspaceEditClientCapabilities) ResolvedWorkspaceEditClientCapabilities { + if v == nil { + return ResolvedWorkspaceEditClientCapabilities{} + } + return ResolvedWorkspaceEditClientCapabilities{ + DocumentChanges: derefOr(v.DocumentChanges), + ResourceOperations: derefOr(v.ResourceOperations), + FailureHandling: derefOr(v.FailureHandling), + NormalizesLineEndings: derefOr(v.NormalizesLineEndings), + ChangeAnnotationSupport: resolveChangeAnnotationsSupportOptions(v.ChangeAnnotationSupport), + MetadataSupport: derefOr(v.MetadataSupport), + SnippetEditSupport: derefOr(v.SnippetEditSupport), + } +} + +// ResolvedDidChangeConfigurationClientCapabilities is a resolved version of DidChangeConfigurationClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedDidChangeConfigurationClientCapabilities struct { + // Did change configuration notification supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveDidChangeConfigurationClientCapabilities(v *DidChangeConfigurationClientCapabilities) ResolvedDidChangeConfigurationClientCapabilities { + if v == nil { + return ResolvedDidChangeConfigurationClientCapabilities{} + } + return ResolvedDidChangeConfigurationClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedDidChangeWatchedFilesClientCapabilities is a resolved version of DidChangeWatchedFilesClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedDidChangeWatchedFilesClientCapabilities struct { + // Did change watched files notification supports dynamic registration. Please note + // that the current protocol doesn't support static configuration for file changes + // from the server side. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Whether the client has support for pattern + // or not. + // + // Since: 3.17.0 + RelativePatternSupport bool `json:"relativePatternSupport,omitzero"` +} + +func resolveDidChangeWatchedFilesClientCapabilities(v *DidChangeWatchedFilesClientCapabilities) ResolvedDidChangeWatchedFilesClientCapabilities { + if v == nil { + return ResolvedDidChangeWatchedFilesClientCapabilities{} + } + return ResolvedDidChangeWatchedFilesClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + RelativePatternSupport: derefOr(v.RelativePatternSupport), + } +} + +// ResolvedClientSymbolKindOptions is a resolved version of ClientSymbolKindOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientSymbolKindOptions struct { + // The symbol kind values the client supports. When this + // property exists the client also guarantees that it will + // handle values outside its set gracefully and falls back + // to a default value when unknown. + // + // If this property is not present the client only supports + // the symbol kinds from `File` to `Array` as defined in + // the initial version of the protocol. + ValueSet []SymbolKind `json:"valueSet,omitzero"` +} + +func resolveClientSymbolKindOptions(v *ClientSymbolKindOptions) ResolvedClientSymbolKindOptions { + if v == nil { + return ResolvedClientSymbolKindOptions{} + } + return ResolvedClientSymbolKindOptions{ + ValueSet: derefOr(v.ValueSet), + } +} + +// ResolvedClientSymbolTagOptions is a resolved version of ClientSymbolTagOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientSymbolTagOptions struct { + // The tags supported by the client. + ValueSet []SymbolTag `json:"valueSet,omitzero"` +} + +func resolveClientSymbolTagOptions(v *ClientSymbolTagOptions) ResolvedClientSymbolTagOptions { + if v == nil { + return ResolvedClientSymbolTagOptions{} + } + return ResolvedClientSymbolTagOptions{ + ValueSet: v.ValueSet, + } +} + +// ResolvedClientSymbolResolveOptions is a resolved version of ClientSymbolResolveOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientSymbolResolveOptions struct { + // The properties that a client can resolve lazily. Usually + // `location.range` + Properties []string `json:"properties,omitzero"` +} + +func resolveClientSymbolResolveOptions(v *ClientSymbolResolveOptions) ResolvedClientSymbolResolveOptions { + if v == nil { + return ResolvedClientSymbolResolveOptions{} + } + return ResolvedClientSymbolResolveOptions{ + Properties: v.Properties, + } +} + +// ResolvedWorkspaceSymbolClientCapabilities is a resolved version of WorkspaceSymbolClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities for a WorkspaceSymbolRequest. +type ResolvedWorkspaceSymbolClientCapabilities struct { + // Symbol request supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. + SymbolKind ResolvedClientSymbolKindOptions `json:"symbolKind,omitzero"` + // The client supports tags on `SymbolInformation`. + // Clients supporting tags have to handle unknown tags gracefully. + // + // Since: 3.16.0 + TagSupport ResolvedClientSymbolTagOptions `json:"tagSupport,omitzero"` + // The client support partial workspace symbols. The client will send the + // request `workspaceSymbol/resolve` to the server to resolve additional + // properties. + // + // Since: 3.17.0 + ResolveSupport ResolvedClientSymbolResolveOptions `json:"resolveSupport,omitzero"` +} + +func resolveWorkspaceSymbolClientCapabilities(v *WorkspaceSymbolClientCapabilities) ResolvedWorkspaceSymbolClientCapabilities { + if v == nil { + return ResolvedWorkspaceSymbolClientCapabilities{} + } + return ResolvedWorkspaceSymbolClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + SymbolKind: resolveClientSymbolKindOptions(v.SymbolKind), + TagSupport: resolveClientSymbolTagOptions(v.TagSupport), + ResolveSupport: resolveClientSymbolResolveOptions(v.ResolveSupport), + } +} + +// ResolvedExecuteCommandClientCapabilities is a resolved version of ExecuteCommandClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// The client capabilities of a ExecuteCommandRequest. +type ResolvedExecuteCommandClientCapabilities struct { + // Execute command supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveExecuteCommandClientCapabilities(v *ExecuteCommandClientCapabilities) ResolvedExecuteCommandClientCapabilities { + if v == nil { + return ResolvedExecuteCommandClientCapabilities{} + } + return ResolvedExecuteCommandClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedSemanticTokensWorkspaceClientCapabilities is a resolved version of SemanticTokensWorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.16.0 +type ResolvedSemanticTokensWorkspaceClientCapabilities struct { + // Whether the client implementation supports a refresh request sent from + // the server to the client. + // + // Note that this event is global and will force the client to refresh all + // semantic tokens currently shown. It should be used with absolute care + // and is useful for situation where a server for example detects a project + // wide change that requires such a calculation. + RefreshSupport bool `json:"refreshSupport,omitzero"` +} + +func resolveSemanticTokensWorkspaceClientCapabilities(v *SemanticTokensWorkspaceClientCapabilities) ResolvedSemanticTokensWorkspaceClientCapabilities { + if v == nil { + return ResolvedSemanticTokensWorkspaceClientCapabilities{} + } + return ResolvedSemanticTokensWorkspaceClientCapabilities{ + RefreshSupport: derefOr(v.RefreshSupport), + } +} + +// ResolvedCodeLensWorkspaceClientCapabilities is a resolved version of CodeLensWorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.16.0 +type ResolvedCodeLensWorkspaceClientCapabilities struct { + // Whether the client implementation supports a refresh request sent from the + // server to the client. + // + // Note that this event is global and will force the client to refresh all + // code lenses currently shown. It should be used with absolute care and is + // useful for situation where a server for example detect a project wide + // change that requires such a calculation. + RefreshSupport bool `json:"refreshSupport,omitzero"` +} + +func resolveCodeLensWorkspaceClientCapabilities(v *CodeLensWorkspaceClientCapabilities) ResolvedCodeLensWorkspaceClientCapabilities { + if v == nil { + return ResolvedCodeLensWorkspaceClientCapabilities{} + } + return ResolvedCodeLensWorkspaceClientCapabilities{ + RefreshSupport: derefOr(v.RefreshSupport), + } +} + +// ResolvedFileOperationClientCapabilities is a resolved version of FileOperationClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Capabilities relating to events from file operations by the user in the client. +// +// These events do not come from the file system, they come from user operations +// like renaming a file in the UI. +// +// Since: 3.16.0 +type ResolvedFileOperationClientCapabilities struct { + // Whether the client supports dynamic registration for file requests/notifications. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client has support for sending didCreateFiles notifications. + DidCreate bool `json:"didCreate,omitzero"` + // The client has support for sending willCreateFiles requests. + WillCreate bool `json:"willCreate,omitzero"` + // The client has support for sending didRenameFiles notifications. + DidRename bool `json:"didRename,omitzero"` + // The client has support for sending willRenameFiles requests. + WillRename bool `json:"willRename,omitzero"` + // The client has support for sending didDeleteFiles notifications. + DidDelete bool `json:"didDelete,omitzero"` + // The client has support for sending willDeleteFiles requests. + WillDelete bool `json:"willDelete,omitzero"` +} + +func resolveFileOperationClientCapabilities(v *FileOperationClientCapabilities) ResolvedFileOperationClientCapabilities { + if v == nil { + return ResolvedFileOperationClientCapabilities{} + } + return ResolvedFileOperationClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + DidCreate: derefOr(v.DidCreate), + WillCreate: derefOr(v.WillCreate), + DidRename: derefOr(v.DidRename), + WillRename: derefOr(v.WillRename), + DidDelete: derefOr(v.DidDelete), + WillDelete: derefOr(v.WillDelete), + } +} + +// ResolvedInlineValueWorkspaceClientCapabilities is a resolved version of InlineValueWorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client workspace capabilities specific to inline values. +// +// Since: 3.17.0 +type ResolvedInlineValueWorkspaceClientCapabilities struct { + // Whether the client implementation supports a refresh request sent from the + // server to the client. + // + // Note that this event is global and will force the client to refresh all + // inline values currently shown. It should be used with absolute care and is + // useful for situation where a server for example detects a project wide + // change that requires such a calculation. + RefreshSupport bool `json:"refreshSupport,omitzero"` +} + +func resolveInlineValueWorkspaceClientCapabilities(v *InlineValueWorkspaceClientCapabilities) ResolvedInlineValueWorkspaceClientCapabilities { + if v == nil { + return ResolvedInlineValueWorkspaceClientCapabilities{} + } + return ResolvedInlineValueWorkspaceClientCapabilities{ + RefreshSupport: derefOr(v.RefreshSupport), + } +} + +// ResolvedInlayHintWorkspaceClientCapabilities is a resolved version of InlayHintWorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client workspace capabilities specific to inlay hints. +// +// Since: 3.17.0 +type ResolvedInlayHintWorkspaceClientCapabilities struct { + // Whether the client implementation supports a refresh request sent from + // the server to the client. + // + // Note that this event is global and will force the client to refresh all + // inlay hints currently shown. It should be used with absolute care and + // is useful for situation where a server for example detects a project wide + // change that requires such a calculation. + RefreshSupport bool `json:"refreshSupport,omitzero"` +} + +func resolveInlayHintWorkspaceClientCapabilities(v *InlayHintWorkspaceClientCapabilities) ResolvedInlayHintWorkspaceClientCapabilities { + if v == nil { + return ResolvedInlayHintWorkspaceClientCapabilities{} + } + return ResolvedInlayHintWorkspaceClientCapabilities{ + RefreshSupport: derefOr(v.RefreshSupport), + } +} + +// ResolvedDiagnosticWorkspaceClientCapabilities is a resolved version of DiagnosticWorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Workspace client capabilities specific to diagnostic pull requests. +// +// Since: 3.17.0 +type ResolvedDiagnosticWorkspaceClientCapabilities struct { + // Whether the client implementation supports a refresh request sent from + // the server to the client. + // + // Note that this event is global and will force the client to refresh all + // pulled diagnostics currently shown. It should be used with absolute care and + // is useful for situation where a server for example detects a project wide + // change that requires such a calculation. + RefreshSupport bool `json:"refreshSupport,omitzero"` +} + +func resolveDiagnosticWorkspaceClientCapabilities(v *DiagnosticWorkspaceClientCapabilities) ResolvedDiagnosticWorkspaceClientCapabilities { + if v == nil { + return ResolvedDiagnosticWorkspaceClientCapabilities{} + } + return ResolvedDiagnosticWorkspaceClientCapabilities{ + RefreshSupport: derefOr(v.RefreshSupport), + } +} + +// ResolvedFoldingRangeWorkspaceClientCapabilities is a resolved version of FoldingRangeWorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// # Client workspace capabilities specific to folding ranges +// +// Since: 3.18.0 +// +// Proposed. +type ResolvedFoldingRangeWorkspaceClientCapabilities struct { + // Whether the client implementation supports a refresh request sent from the + // server to the client. + // + // Note that this event is global and will force the client to refresh all + // folding ranges currently shown. It should be used with absolute care and is + // useful for situation where a server for example detects a project wide + // change that requires such a calculation. + // + // Since: 3.18.0 + // + // Proposed. + RefreshSupport bool `json:"refreshSupport,omitzero"` +} + +func resolveFoldingRangeWorkspaceClientCapabilities(v *FoldingRangeWorkspaceClientCapabilities) ResolvedFoldingRangeWorkspaceClientCapabilities { + if v == nil { + return ResolvedFoldingRangeWorkspaceClientCapabilities{} + } + return ResolvedFoldingRangeWorkspaceClientCapabilities{ + RefreshSupport: derefOr(v.RefreshSupport), + } +} + +// ResolvedTextDocumentContentClientCapabilities is a resolved version of TextDocumentContentClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities for a text document content provider. +// +// Since: 3.18.0 +// +// Proposed. +type ResolvedTextDocumentContentClientCapabilities struct { + // Text document content provider supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveTextDocumentContentClientCapabilities(v *TextDocumentContentClientCapabilities) ResolvedTextDocumentContentClientCapabilities { + if v == nil { + return ResolvedTextDocumentContentClientCapabilities{} + } + return ResolvedTextDocumentContentClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedWorkspaceClientCapabilities is a resolved version of WorkspaceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Workspace specific client capabilities. +type ResolvedWorkspaceClientCapabilities struct { + // The client supports applying batch edits + // to the workspace by supporting the request + // 'workspace/applyEdit' + ApplyEdit bool `json:"applyEdit,omitzero"` + // Capabilities specific to `WorkspaceEdit`s. + WorkspaceEdit ResolvedWorkspaceEditClientCapabilities `json:"workspaceEdit,omitzero"` + // Capabilities specific to the `workspace/didChangeConfiguration` notification. + DidChangeConfiguration ResolvedDidChangeConfigurationClientCapabilities `json:"didChangeConfiguration,omitzero"` + // Capabilities specific to the `workspace/didChangeWatchedFiles` notification. + DidChangeWatchedFiles ResolvedDidChangeWatchedFilesClientCapabilities `json:"didChangeWatchedFiles,omitzero"` + // Capabilities specific to the `workspace/symbol` request. + Symbol ResolvedWorkspaceSymbolClientCapabilities `json:"symbol,omitzero"` + // Capabilities specific to the `workspace/executeCommand` request. + ExecuteCommand ResolvedExecuteCommandClientCapabilities `json:"executeCommand,omitzero"` + // The client has support for workspace folders. + // + // Since: 3.6.0 + WorkspaceFolders bool `json:"workspaceFolders,omitzero"` + // The client supports `workspace/configuration` requests. + // + // Since: 3.6.0 + Configuration bool `json:"configuration,omitzero"` + // Capabilities specific to the semantic token requests scoped to the + // workspace. + // + // Since: 3.16.0. + SemanticTokens ResolvedSemanticTokensWorkspaceClientCapabilities `json:"semanticTokens,omitzero"` + // Capabilities specific to the code lens requests scoped to the + // workspace. + // + // Since: 3.16.0. + CodeLens ResolvedCodeLensWorkspaceClientCapabilities `json:"codeLens,omitzero"` + // The client has support for file notifications/requests for user operations on files. + // + // Since 3.16.0 + FileOperations ResolvedFileOperationClientCapabilities `json:"fileOperations,omitzero"` + // Capabilities specific to the inline values requests scoped to the + // workspace. + // + // Since: 3.17.0. + InlineValue ResolvedInlineValueWorkspaceClientCapabilities `json:"inlineValue,omitzero"` + // Capabilities specific to the inlay hint requests scoped to the + // workspace. + // + // Since: 3.17.0. + InlayHint ResolvedInlayHintWorkspaceClientCapabilities `json:"inlayHint,omitzero"` + // Capabilities specific to the diagnostic requests scoped to the + // workspace. + // + // Since: 3.17.0. + Diagnostics ResolvedDiagnosticWorkspaceClientCapabilities `json:"diagnostics,omitzero"` + // Capabilities specific to the folding range requests scoped to the workspace. + // + // Since: 3.18.0 + // + // Proposed. + FoldingRange ResolvedFoldingRangeWorkspaceClientCapabilities `json:"foldingRange,omitzero"` + // Capabilities specific to the `workspace/textDocumentContent` request. + // + // Since: 3.18.0 + // + // Proposed. + TextDocumentContent ResolvedTextDocumentContentClientCapabilities `json:"textDocumentContent,omitzero"` +} + +func resolveWorkspaceClientCapabilities(v *WorkspaceClientCapabilities) ResolvedWorkspaceClientCapabilities { + if v == nil { + return ResolvedWorkspaceClientCapabilities{} + } + return ResolvedWorkspaceClientCapabilities{ + ApplyEdit: derefOr(v.ApplyEdit), + WorkspaceEdit: resolveWorkspaceEditClientCapabilities(v.WorkspaceEdit), + DidChangeConfiguration: resolveDidChangeConfigurationClientCapabilities(v.DidChangeConfiguration), + DidChangeWatchedFiles: resolveDidChangeWatchedFilesClientCapabilities(v.DidChangeWatchedFiles), + Symbol: resolveWorkspaceSymbolClientCapabilities(v.Symbol), + ExecuteCommand: resolveExecuteCommandClientCapabilities(v.ExecuteCommand), + WorkspaceFolders: derefOr(v.WorkspaceFolders), + Configuration: derefOr(v.Configuration), + SemanticTokens: resolveSemanticTokensWorkspaceClientCapabilities(v.SemanticTokens), + CodeLens: resolveCodeLensWorkspaceClientCapabilities(v.CodeLens), + FileOperations: resolveFileOperationClientCapabilities(v.FileOperations), + InlineValue: resolveInlineValueWorkspaceClientCapabilities(v.InlineValue), + InlayHint: resolveInlayHintWorkspaceClientCapabilities(v.InlayHint), + Diagnostics: resolveDiagnosticWorkspaceClientCapabilities(v.Diagnostics), + FoldingRange: resolveFoldingRangeWorkspaceClientCapabilities(v.FoldingRange), + TextDocumentContent: resolveTextDocumentContentClientCapabilities(v.TextDocumentContent), + } +} + +// ResolvedTextDocumentSyncClientCapabilities is a resolved version of TextDocumentSyncClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedTextDocumentSyncClientCapabilities struct { + // Whether text document synchronization supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports sending will save notifications. + WillSave bool `json:"willSave,omitzero"` + // The client supports sending a will save request and + // waits for a response providing text edits which will + // be applied to the document before it is saved. + WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitzero"` + // The client supports did save notifications. + DidSave bool `json:"didSave,omitzero"` +} + +func resolveTextDocumentSyncClientCapabilities(v *TextDocumentSyncClientCapabilities) ResolvedTextDocumentSyncClientCapabilities { + if v == nil { + return ResolvedTextDocumentSyncClientCapabilities{} + } + return ResolvedTextDocumentSyncClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + WillSave: derefOr(v.WillSave), + WillSaveWaitUntil: derefOr(v.WillSaveWaitUntil), + DidSave: derefOr(v.DidSave), + } +} + +// ResolvedTextDocumentFilterClientCapabilities is a resolved version of TextDocumentFilterClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedTextDocumentFilterClientCapabilities struct { + // The client supports Relative Patterns. + // + // Since: 3.18.0 + RelativePatternSupport bool `json:"relativePatternSupport,omitzero"` +} + +func resolveTextDocumentFilterClientCapabilities(v *TextDocumentFilterClientCapabilities) ResolvedTextDocumentFilterClientCapabilities { + if v == nil { + return ResolvedTextDocumentFilterClientCapabilities{} + } + return ResolvedTextDocumentFilterClientCapabilities{ + RelativePatternSupport: derefOr(v.RelativePatternSupport), + } +} + +// ResolvedCompletionItemTagOptions is a resolved version of CompletionItemTagOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedCompletionItemTagOptions struct { + // The tags supported by the client. + ValueSet []CompletionItemTag `json:"valueSet,omitzero"` +} + +func resolveCompletionItemTagOptions(v *CompletionItemTagOptions) ResolvedCompletionItemTagOptions { + if v == nil { + return ResolvedCompletionItemTagOptions{} + } + return ResolvedCompletionItemTagOptions{ + ValueSet: v.ValueSet, + } +} + +// ResolvedClientCompletionItemResolveOptions is a resolved version of ClientCompletionItemResolveOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCompletionItemResolveOptions struct { + // The properties that a client can resolve lazily. + Properties []string `json:"properties,omitzero"` +} + +func resolveClientCompletionItemResolveOptions(v *ClientCompletionItemResolveOptions) ResolvedClientCompletionItemResolveOptions { + if v == nil { + return ResolvedClientCompletionItemResolveOptions{} + } + return ResolvedClientCompletionItemResolveOptions{ + Properties: v.Properties, + } +} + +// ResolvedClientCompletionItemInsertTextModeOptions is a resolved version of ClientCompletionItemInsertTextModeOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCompletionItemInsertTextModeOptions struct { + ValueSet []InsertTextMode `json:"valueSet,omitzero"` +} + +func resolveClientCompletionItemInsertTextModeOptions(v *ClientCompletionItemInsertTextModeOptions) ResolvedClientCompletionItemInsertTextModeOptions { + if v == nil { + return ResolvedClientCompletionItemInsertTextModeOptions{} + } + return ResolvedClientCompletionItemInsertTextModeOptions{ + ValueSet: v.ValueSet, + } +} + +// ResolvedClientCompletionItemOptions is a resolved version of ClientCompletionItemOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCompletionItemOptions struct { + // Client supports snippets as insert text. + // + // A snippet can define tab stops and placeholders with `$1`, `$2` + // and `${3:foo}`. `$0` defines the final tab stop, it defaults to + // the end of the snippet. Placeholders with equal identifiers are linked, + // that is typing in one will update others too. + SnippetSupport bool `json:"snippetSupport,omitzero"` + // Client supports commit characters on a completion item. + CommitCharactersSupport bool `json:"commitCharactersSupport,omitzero"` + // Client supports the following content formats for the documentation + // property. The order describes the preferred format of the client. + DocumentationFormat []MarkupKind `json:"documentationFormat,omitzero"` + // Client supports the deprecated property on a completion item. + DeprecatedSupport bool `json:"deprecatedSupport,omitzero"` + // Client supports the preselect property on a completion item. + PreselectSupport bool `json:"preselectSupport,omitzero"` + // Client supports the tag property on a completion item. Clients supporting + // tags have to handle unknown tags gracefully. Clients especially need to + // preserve unknown tags when sending a completion item back to the server in + // a resolve call. + // + // Since: 3.15.0 + TagSupport ResolvedCompletionItemTagOptions `json:"tagSupport,omitzero"` + // Client support insert replace edit to control different behavior if a + // completion item is inserted in the text or should replace text. + // + // Since: 3.16.0 + InsertReplaceSupport bool `json:"insertReplaceSupport,omitzero"` + // Indicates which properties a client can resolve lazily on a completion + // item. Before version 3.16.0 only the predefined properties `documentation` + // and `details` could be resolved lazily. + // + // Since: 3.16.0 + ResolveSupport ResolvedClientCompletionItemResolveOptions `json:"resolveSupport,omitzero"` + // The client supports the `insertTextMode` property on + // a completion item to override the whitespace handling mode + // as defined by the client (see `insertTextMode`). + // + // Since: 3.16.0 + InsertTextModeSupport ResolvedClientCompletionItemInsertTextModeOptions `json:"insertTextModeSupport,omitzero"` + // The client has support for completion item label + // details (see also `CompletionItemLabelDetails`). + // + // Since: 3.17.0 + LabelDetailsSupport bool `json:"labelDetailsSupport,omitzero"` +} + +func resolveClientCompletionItemOptions(v *ClientCompletionItemOptions) ResolvedClientCompletionItemOptions { + if v == nil { + return ResolvedClientCompletionItemOptions{} + } + return ResolvedClientCompletionItemOptions{ + SnippetSupport: derefOr(v.SnippetSupport), + CommitCharactersSupport: derefOr(v.CommitCharactersSupport), + DocumentationFormat: derefOr(v.DocumentationFormat), + DeprecatedSupport: derefOr(v.DeprecatedSupport), + PreselectSupport: derefOr(v.PreselectSupport), + TagSupport: resolveCompletionItemTagOptions(v.TagSupport), + InsertReplaceSupport: derefOr(v.InsertReplaceSupport), + ResolveSupport: resolveClientCompletionItemResolveOptions(v.ResolveSupport), + InsertTextModeSupport: resolveClientCompletionItemInsertTextModeOptions(v.InsertTextModeSupport), + LabelDetailsSupport: derefOr(v.LabelDetailsSupport), + } +} + +// ResolvedClientCompletionItemOptionsKind is a resolved version of ClientCompletionItemOptionsKind with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCompletionItemOptionsKind struct { + // The completion item kind values the client supports. When this + // property exists the client also guarantees that it will + // handle values outside its set gracefully and falls back + // to a default value when unknown. + // + // If this property is not present the client only supports + // the completion items kinds from `Text` to `Reference` as defined in + // the initial version of the protocol. + ValueSet []CompletionItemKind `json:"valueSet,omitzero"` +} + +func resolveClientCompletionItemOptionsKind(v *ClientCompletionItemOptionsKind) ResolvedClientCompletionItemOptionsKind { + if v == nil { + return ResolvedClientCompletionItemOptionsKind{} + } + return ResolvedClientCompletionItemOptionsKind{ + ValueSet: derefOr(v.ValueSet), + } +} + +// ResolvedCompletionListCapabilities is a resolved version of CompletionListCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// The client supports the following `CompletionList` specific +// capabilities. +// +// Since: 3.17.0 +type ResolvedCompletionListCapabilities struct { + // The client supports the following itemDefaults on + // a completion list. + // + // The value lists the supported property names of the + // `CompletionList.itemDefaults` object. If omitted + // no properties are supported. + // + // Since: 3.17.0 + ItemDefaults []string `json:"itemDefaults,omitzero"` + // Specifies whether the client supports `CompletionList.applyKind` to + // indicate how supported values from `completionList.itemDefaults` + // and `completion` will be combined. + // + // If a client supports `applyKind` it must support it for all fields + // that it supports that are listed in `CompletionList.applyKind`. This + // means when clients add support for new/future fields in completion + // items the MUST also support merge for them if those fields are + // defined in `CompletionList.applyKind`. + // + // Since: 3.18.0 + ApplyKindSupport bool `json:"applyKindSupport,omitzero"` +} + +func resolveCompletionListCapabilities(v *CompletionListCapabilities) ResolvedCompletionListCapabilities { + if v == nil { + return ResolvedCompletionListCapabilities{} + } + return ResolvedCompletionListCapabilities{ + ItemDefaults: derefOr(v.ItemDefaults), + ApplyKindSupport: derefOr(v.ApplyKindSupport), + } +} + +// ResolvedCompletionClientCapabilities is a resolved version of CompletionClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Completion client capabilities +type ResolvedCompletionClientCapabilities struct { + // Whether completion supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports the following `CompletionItem` specific + // capabilities. + CompletionItem ResolvedClientCompletionItemOptions `json:"completionItem,omitzero"` + CompletionItemKind ResolvedClientCompletionItemOptionsKind `json:"completionItemKind,omitzero"` + // Defines how the client handles whitespace and indentation + // when accepting a completion item that uses multi line + // text in either `insertText` or `textEdit`. + // + // Since: 3.17.0 + InsertTextMode InsertTextMode `json:"insertTextMode,omitzero"` + // The client supports to send additional context information for a + // `textDocument/completion` request. + ContextSupport bool `json:"contextSupport,omitzero"` + // The client supports the following `CompletionList` specific + // capabilities. + // + // Since: 3.17.0 + CompletionList ResolvedCompletionListCapabilities `json:"completionList,omitzero"` +} + +func resolveCompletionClientCapabilities(v *CompletionClientCapabilities) ResolvedCompletionClientCapabilities { + if v == nil { + return ResolvedCompletionClientCapabilities{} + } + return ResolvedCompletionClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + CompletionItem: resolveClientCompletionItemOptions(v.CompletionItem), + CompletionItemKind: resolveClientCompletionItemOptionsKind(v.CompletionItemKind), + InsertTextMode: derefOr(v.InsertTextMode), + ContextSupport: derefOr(v.ContextSupport), + CompletionList: resolveCompletionListCapabilities(v.CompletionList), + } +} + +// ResolvedHoverClientCapabilities is a resolved version of HoverClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedHoverClientCapabilities struct { + // Whether hover supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Client supports the following content formats for the content + // property. The order describes the preferred format of the client. + ContentFormat []MarkupKind `json:"contentFormat,omitzero"` +} + +func resolveHoverClientCapabilities(v *HoverClientCapabilities) ResolvedHoverClientCapabilities { + if v == nil { + return ResolvedHoverClientCapabilities{} + } + return ResolvedHoverClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + ContentFormat: derefOr(v.ContentFormat), + } +} + +// ResolvedClientSignatureParameterInformationOptions is a resolved version of ClientSignatureParameterInformationOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientSignatureParameterInformationOptions struct { + // The client supports processing label offsets instead of a + // simple label string. + // + // Since: 3.14.0 + LabelOffsetSupport bool `json:"labelOffsetSupport,omitzero"` +} + +func resolveClientSignatureParameterInformationOptions(v *ClientSignatureParameterInformationOptions) ResolvedClientSignatureParameterInformationOptions { + if v == nil { + return ResolvedClientSignatureParameterInformationOptions{} + } + return ResolvedClientSignatureParameterInformationOptions{ + LabelOffsetSupport: derefOr(v.LabelOffsetSupport), + } +} + +// ResolvedClientSignatureInformationOptions is a resolved version of ClientSignatureInformationOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientSignatureInformationOptions struct { + // Client supports the following content formats for the documentation + // property. The order describes the preferred format of the client. + DocumentationFormat []MarkupKind `json:"documentationFormat,omitzero"` + // Client capabilities specific to parameter information. + ParameterInformation ResolvedClientSignatureParameterInformationOptions `json:"parameterInformation,omitzero"` + // The client supports the `activeParameter` property on `SignatureInformation` + // literal. + // + // Since: 3.16.0 + ActiveParameterSupport bool `json:"activeParameterSupport,omitzero"` + // The client supports the `activeParameter` property on + // `SignatureHelp`/`SignatureInformation` being set to `null` to + // indicate that no parameter should be active. + // + // Since: 3.18.0 + // + // Proposed. + NoActiveParameterSupport bool `json:"noActiveParameterSupport,omitzero"` +} + +func resolveClientSignatureInformationOptions(v *ClientSignatureInformationOptions) ResolvedClientSignatureInformationOptions { + if v == nil { + return ResolvedClientSignatureInformationOptions{} + } + return ResolvedClientSignatureInformationOptions{ + DocumentationFormat: derefOr(v.DocumentationFormat), + ParameterInformation: resolveClientSignatureParameterInformationOptions(v.ParameterInformation), + ActiveParameterSupport: derefOr(v.ActiveParameterSupport), + NoActiveParameterSupport: derefOr(v.NoActiveParameterSupport), + } +} + +// ResolvedSignatureHelpClientCapabilities is a resolved version of SignatureHelpClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client Capabilities for a SignatureHelpRequest. +type ResolvedSignatureHelpClientCapabilities struct { + // Whether signature help supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports the following `SignatureInformation` + // specific properties. + SignatureInformation ResolvedClientSignatureInformationOptions `json:"signatureInformation,omitzero"` + // The client supports to send additional context information for a + // `textDocument/signatureHelp` request. A client that opts into + // contextSupport will also support the `retriggerCharacters` on + // `SignatureHelpOptions`. + // + // Since: 3.15.0 + ContextSupport bool `json:"contextSupport,omitzero"` +} + +func resolveSignatureHelpClientCapabilities(v *SignatureHelpClientCapabilities) ResolvedSignatureHelpClientCapabilities { + if v == nil { + return ResolvedSignatureHelpClientCapabilities{} + } + return ResolvedSignatureHelpClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + SignatureInformation: resolveClientSignatureInformationOptions(v.SignatureInformation), + ContextSupport: derefOr(v.ContextSupport), + } +} + +// ResolvedDeclarationClientCapabilities is a resolved version of DeclarationClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.14.0 +type ResolvedDeclarationClientCapabilities struct { + // Whether declaration supports dynamic registration. If this is set to `true` + // the client supports the new `DeclarationRegistrationOptions` return value + // for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports additional metadata in the form of declaration links. + LinkSupport bool `json:"linkSupport,omitzero"` +} + +func resolveDeclarationClientCapabilities(v *DeclarationClientCapabilities) ResolvedDeclarationClientCapabilities { + if v == nil { + return ResolvedDeclarationClientCapabilities{} + } + return ResolvedDeclarationClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + LinkSupport: derefOr(v.LinkSupport), + } +} + +// ResolvedDefinitionClientCapabilities is a resolved version of DefinitionClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client Capabilities for a DefinitionRequest. +type ResolvedDefinitionClientCapabilities struct { + // Whether definition supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports additional metadata in the form of definition links. + // + // Since: 3.14.0 + LinkSupport bool `json:"linkSupport,omitzero"` +} + +func resolveDefinitionClientCapabilities(v *DefinitionClientCapabilities) ResolvedDefinitionClientCapabilities { + if v == nil { + return ResolvedDefinitionClientCapabilities{} + } + return ResolvedDefinitionClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + LinkSupport: derefOr(v.LinkSupport), + } +} + +// ResolvedTypeDefinitionClientCapabilities is a resolved version of TypeDefinitionClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since 3.6.0 +type ResolvedTypeDefinitionClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `TypeDefinitionRegistrationOptions` return value + // for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports additional metadata in the form of definition links. + // + // Since 3.14.0 + LinkSupport bool `json:"linkSupport,omitzero"` +} + +func resolveTypeDefinitionClientCapabilities(v *TypeDefinitionClientCapabilities) ResolvedTypeDefinitionClientCapabilities { + if v == nil { + return ResolvedTypeDefinitionClientCapabilities{} + } + return ResolvedTypeDefinitionClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + LinkSupport: derefOr(v.LinkSupport), + } +} + +// ResolvedImplementationClientCapabilities is a resolved version of ImplementationClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.6.0 +type ResolvedImplementationClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `ImplementationRegistrationOptions` return value + // for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports additional metadata in the form of definition links. + // + // Since: 3.14.0 + LinkSupport bool `json:"linkSupport,omitzero"` +} + +func resolveImplementationClientCapabilities(v *ImplementationClientCapabilities) ResolvedImplementationClientCapabilities { + if v == nil { + return ResolvedImplementationClientCapabilities{} + } + return ResolvedImplementationClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + LinkSupport: derefOr(v.LinkSupport), + } +} + +// ResolvedReferenceClientCapabilities is a resolved version of ReferenceClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client Capabilities for a ReferencesRequest. +type ResolvedReferenceClientCapabilities struct { + // Whether references supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveReferenceClientCapabilities(v *ReferenceClientCapabilities) ResolvedReferenceClientCapabilities { + if v == nil { + return ResolvedReferenceClientCapabilities{} + } + return ResolvedReferenceClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedDocumentHighlightClientCapabilities is a resolved version of DocumentHighlightClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client Capabilities for a DocumentHighlightRequest. +type ResolvedDocumentHighlightClientCapabilities struct { + // Whether document highlight supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveDocumentHighlightClientCapabilities(v *DocumentHighlightClientCapabilities) ResolvedDocumentHighlightClientCapabilities { + if v == nil { + return ResolvedDocumentHighlightClientCapabilities{} + } + return ResolvedDocumentHighlightClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedDocumentSymbolClientCapabilities is a resolved version of DocumentSymbolClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client Capabilities for a DocumentSymbolRequest. +type ResolvedDocumentSymbolClientCapabilities struct { + // Whether document symbol supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Specific capabilities for the `SymbolKind` in the + // `textDocument/documentSymbol` request. + SymbolKind ResolvedClientSymbolKindOptions `json:"symbolKind,omitzero"` + // The client supports hierarchical document symbols. + HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitzero"` + // The client supports tags on `SymbolInformation`. Tags are supported on + // `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true. + // Clients supporting tags have to handle unknown tags gracefully. + // + // Since: 3.16.0 + TagSupport ResolvedClientSymbolTagOptions `json:"tagSupport,omitzero"` + // The client supports an additional label presented in the UI when + // registering a document symbol provider. + // + // Since: 3.16.0 + LabelSupport bool `json:"labelSupport,omitzero"` +} + +func resolveDocumentSymbolClientCapabilities(v *DocumentSymbolClientCapabilities) ResolvedDocumentSymbolClientCapabilities { + if v == nil { + return ResolvedDocumentSymbolClientCapabilities{} + } + return ResolvedDocumentSymbolClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + SymbolKind: resolveClientSymbolKindOptions(v.SymbolKind), + HierarchicalDocumentSymbolSupport: derefOr(v.HierarchicalDocumentSymbolSupport), + TagSupport: resolveClientSymbolTagOptions(v.TagSupport), + LabelSupport: derefOr(v.LabelSupport), + } +} + +// ResolvedClientCodeActionKindOptions is a resolved version of ClientCodeActionKindOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCodeActionKindOptions struct { + // The code action kind values the client supports. When this + // property exists the client also guarantees that it will + // handle values outside its set gracefully and falls back + // to a default value when unknown. + ValueSet []CodeActionKind `json:"valueSet,omitzero"` +} + +func resolveClientCodeActionKindOptions(v *ClientCodeActionKindOptions) ResolvedClientCodeActionKindOptions { + if v == nil { + return ResolvedClientCodeActionKindOptions{} + } + return ResolvedClientCodeActionKindOptions{ + ValueSet: v.ValueSet, + } +} + +// ResolvedClientCodeActionLiteralOptions is a resolved version of ClientCodeActionLiteralOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCodeActionLiteralOptions struct { + // The code action kind is support with the following value + // set. + CodeActionKind ResolvedClientCodeActionKindOptions `json:"codeActionKind,omitzero"` +} + +func resolveClientCodeActionLiteralOptions(v *ClientCodeActionLiteralOptions) ResolvedClientCodeActionLiteralOptions { + if v == nil { + return ResolvedClientCodeActionLiteralOptions{} + } + return ResolvedClientCodeActionLiteralOptions{ + CodeActionKind: resolveClientCodeActionKindOptions(v.CodeActionKind), + } +} + +// ResolvedClientCodeActionResolveOptions is a resolved version of ClientCodeActionResolveOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCodeActionResolveOptions struct { + // The properties that a client can resolve lazily. + Properties []string `json:"properties,omitzero"` +} + +func resolveClientCodeActionResolveOptions(v *ClientCodeActionResolveOptions) ResolvedClientCodeActionResolveOptions { + if v == nil { + return ResolvedClientCodeActionResolveOptions{} + } + return ResolvedClientCodeActionResolveOptions{ + Properties: v.Properties, + } +} + +// ResolvedCodeActionTagOptions is a resolved version of CodeActionTagOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 - proposed +type ResolvedCodeActionTagOptions struct { + // The tags supported by the client. + ValueSet []CodeActionTag `json:"valueSet,omitzero"` +} + +func resolveCodeActionTagOptions(v *CodeActionTagOptions) ResolvedCodeActionTagOptions { + if v == nil { + return ResolvedCodeActionTagOptions{} + } + return ResolvedCodeActionTagOptions{ + ValueSet: v.ValueSet, + } +} + +// ResolvedCodeActionClientCapabilities is a resolved version of CodeActionClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// The Client Capabilities of a CodeActionRequest. +type ResolvedCodeActionClientCapabilities struct { + // Whether code action supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client support code action literals of type `CodeAction` as a valid + // response of the `textDocument/codeAction` request. If the property is not + // set the request can only return `Command` literals. + // + // Since: 3.8.0 + CodeActionLiteralSupport ResolvedClientCodeActionLiteralOptions `json:"codeActionLiteralSupport,omitzero"` + // Whether code action supports the `isPreferred` property. + // + // Since: 3.15.0 + IsPreferredSupport bool `json:"isPreferredSupport,omitzero"` + // Whether code action supports the `disabled` property. + // + // Since: 3.16.0 + DisabledSupport bool `json:"disabledSupport,omitzero"` + // Whether code action supports the `data` property which is + // preserved between a `textDocument/codeAction` and a + // `codeAction/resolve` request. + // + // Since: 3.16.0 + DataSupport bool `json:"dataSupport,omitzero"` + // Whether the client supports resolving additional code action + // properties via a separate `codeAction/resolve` request. + // + // Since: 3.16.0 + ResolveSupport ResolvedClientCodeActionResolveOptions `json:"resolveSupport,omitzero"` + // Whether the client honors the change annotations in + // text edits and resource operations returned via the + // `CodeAction#edit` property by for example presenting + // the workspace edit in the user interface and asking + // for confirmation. + // + // Since: 3.16.0 + HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitzero"` + // Whether the client supports documentation for a class of + // code actions. + // + // Since: 3.18.0 + // + // Proposed. + DocumentationSupport bool `json:"documentationSupport,omitzero"` + // Client supports the tag property on a code action. Clients + // supporting tags have to handle unknown tags gracefully. + // + // Since: 3.18.0 - proposed + TagSupport ResolvedCodeActionTagOptions `json:"tagSupport,omitzero"` +} + +func resolveCodeActionClientCapabilities(v *CodeActionClientCapabilities) ResolvedCodeActionClientCapabilities { + if v == nil { + return ResolvedCodeActionClientCapabilities{} + } + return ResolvedCodeActionClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + CodeActionLiteralSupport: resolveClientCodeActionLiteralOptions(v.CodeActionLiteralSupport), + IsPreferredSupport: derefOr(v.IsPreferredSupport), + DisabledSupport: derefOr(v.DisabledSupport), + DataSupport: derefOr(v.DataSupport), + ResolveSupport: resolveClientCodeActionResolveOptions(v.ResolveSupport), + HonorsChangeAnnotations: derefOr(v.HonorsChangeAnnotations), + DocumentationSupport: derefOr(v.DocumentationSupport), + TagSupport: resolveCodeActionTagOptions(v.TagSupport), + } +} + +// ResolvedClientCodeLensResolveOptions is a resolved version of ClientCodeLensResolveOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientCodeLensResolveOptions struct { + // The properties that a client can resolve lazily. + Properties []string `json:"properties,omitzero"` +} + +func resolveClientCodeLensResolveOptions(v *ClientCodeLensResolveOptions) ResolvedClientCodeLensResolveOptions { + if v == nil { + return ResolvedClientCodeLensResolveOptions{} + } + return ResolvedClientCodeLensResolveOptions{ + Properties: v.Properties, + } +} + +// ResolvedCodeLensClientCapabilities is a resolved version of CodeLensClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// The client capabilities of a CodeLensRequest. +type ResolvedCodeLensClientCapabilities struct { + // Whether code lens supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Whether the client supports resolving additional code lens + // properties via a separate `codeLens/resolve` request. + // + // Since: 3.18.0 + ResolveSupport ResolvedClientCodeLensResolveOptions `json:"resolveSupport,omitzero"` +} + +func resolveCodeLensClientCapabilities(v *CodeLensClientCapabilities) ResolvedCodeLensClientCapabilities { + if v == nil { + return ResolvedCodeLensClientCapabilities{} + } + return ResolvedCodeLensClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + ResolveSupport: resolveClientCodeLensResolveOptions(v.ResolveSupport), + } +} + +// ResolvedDocumentLinkClientCapabilities is a resolved version of DocumentLinkClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// The client capabilities of a DocumentLinkRequest. +type ResolvedDocumentLinkClientCapabilities struct { + // Whether document link supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Whether the client supports the `tooltip` property on `DocumentLink`. + // + // Since: 3.15.0 + TooltipSupport bool `json:"tooltipSupport,omitzero"` +} + +func resolveDocumentLinkClientCapabilities(v *DocumentLinkClientCapabilities) ResolvedDocumentLinkClientCapabilities { + if v == nil { + return ResolvedDocumentLinkClientCapabilities{} + } + return ResolvedDocumentLinkClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + TooltipSupport: derefOr(v.TooltipSupport), + } +} + +// ResolvedDocumentColorClientCapabilities is a resolved version of DocumentColorClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedDocumentColorClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `DocumentColorRegistrationOptions` return value + // for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveDocumentColorClientCapabilities(v *DocumentColorClientCapabilities) ResolvedDocumentColorClientCapabilities { + if v == nil { + return ResolvedDocumentColorClientCapabilities{} + } + return ResolvedDocumentColorClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedDocumentFormattingClientCapabilities is a resolved version of DocumentFormattingClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities of a DocumentFormattingRequest. +type ResolvedDocumentFormattingClientCapabilities struct { + // Whether formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveDocumentFormattingClientCapabilities(v *DocumentFormattingClientCapabilities) ResolvedDocumentFormattingClientCapabilities { + if v == nil { + return ResolvedDocumentFormattingClientCapabilities{} + } + return ResolvedDocumentFormattingClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedDocumentRangeFormattingClientCapabilities is a resolved version of DocumentRangeFormattingClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities of a DocumentRangeFormattingRequest. +type ResolvedDocumentRangeFormattingClientCapabilities struct { + // Whether range formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Whether the client supports formatting multiple ranges at once. + // + // Since: 3.18.0 + // + // Proposed. + RangesSupport bool `json:"rangesSupport,omitzero"` +} + +func resolveDocumentRangeFormattingClientCapabilities(v *DocumentRangeFormattingClientCapabilities) ResolvedDocumentRangeFormattingClientCapabilities { + if v == nil { + return ResolvedDocumentRangeFormattingClientCapabilities{} + } + return ResolvedDocumentRangeFormattingClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + RangesSupport: derefOr(v.RangesSupport), + } +} + +// ResolvedDocumentOnTypeFormattingClientCapabilities is a resolved version of DocumentOnTypeFormattingClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities of a DocumentOnTypeFormattingRequest. +type ResolvedDocumentOnTypeFormattingClientCapabilities struct { + // Whether on type formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveDocumentOnTypeFormattingClientCapabilities(v *DocumentOnTypeFormattingClientCapabilities) ResolvedDocumentOnTypeFormattingClientCapabilities { + if v == nil { + return ResolvedDocumentOnTypeFormattingClientCapabilities{} + } + return ResolvedDocumentOnTypeFormattingClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedRenameClientCapabilities is a resolved version of RenameClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedRenameClientCapabilities struct { + // Whether rename supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Client supports testing for validity of rename operations + // before execution. + // + // Since: 3.12.0 + PrepareSupport bool `json:"prepareSupport,omitzero"` + // Client supports the default behavior result. + // + // The value indicates the default behavior used by the + // client. + // + // Since: 3.16.0 + PrepareSupportDefaultBehavior PrepareSupportDefaultBehavior `json:"prepareSupportDefaultBehavior,omitzero"` + // Whether the client honors the change annotations in + // text edits and resource operations returned via the + // rename request's workspace edit by for example presenting + // the workspace edit in the user interface and asking + // for confirmation. + // + // Since: 3.16.0 + HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitzero"` +} + +func resolveRenameClientCapabilities(v *RenameClientCapabilities) ResolvedRenameClientCapabilities { + if v == nil { + return ResolvedRenameClientCapabilities{} + } + return ResolvedRenameClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + PrepareSupport: derefOr(v.PrepareSupport), + PrepareSupportDefaultBehavior: derefOr(v.PrepareSupportDefaultBehavior), + HonorsChangeAnnotations: derefOr(v.HonorsChangeAnnotations), + } +} + +// ResolvedClientFoldingRangeKindOptions is a resolved version of ClientFoldingRangeKindOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientFoldingRangeKindOptions struct { + // The folding range kind values the client supports. When this + // property exists the client also guarantees that it will + // handle values outside its set gracefully and falls back + // to a default value when unknown. + ValueSet []FoldingRangeKind `json:"valueSet,omitzero"` +} + +func resolveClientFoldingRangeKindOptions(v *ClientFoldingRangeKindOptions) ResolvedClientFoldingRangeKindOptions { + if v == nil { + return ResolvedClientFoldingRangeKindOptions{} + } + return ResolvedClientFoldingRangeKindOptions{ + ValueSet: derefOr(v.ValueSet), + } +} + +// ResolvedClientFoldingRangeOptions is a resolved version of ClientFoldingRangeOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientFoldingRangeOptions struct { + // If set, the client signals that it supports setting collapsedText on + // folding ranges to display custom labels instead of the default text. + // + // Since: 3.17.0 + CollapsedText bool `json:"collapsedText,omitzero"` +} + +func resolveClientFoldingRangeOptions(v *ClientFoldingRangeOptions) ResolvedClientFoldingRangeOptions { + if v == nil { + return ResolvedClientFoldingRangeOptions{} + } + return ResolvedClientFoldingRangeOptions{ + CollapsedText: derefOr(v.CollapsedText), + } +} + +// ResolvedFoldingRangeClientCapabilities is a resolved version of FoldingRangeClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedFoldingRangeClientCapabilities struct { + // Whether implementation supports dynamic registration for folding range + // providers. If this is set to `true` the client supports the new + // `FoldingRangeRegistrationOptions` return value for the corresponding + // server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The maximum number of folding ranges that the client prefers to receive + // per document. The value serves as a hint, servers are free to follow the + // limit. + RangeLimit uint32 `json:"rangeLimit,omitzero"` + // If set, the client signals that it only supports folding complete lines. + // If set, client will ignore specified `startCharacter` and `endCharacter` + // properties in a FoldingRange. + LineFoldingOnly bool `json:"lineFoldingOnly,omitzero"` + // Specific options for the folding range kind. + // + // Since: 3.17.0 + FoldingRangeKind ResolvedClientFoldingRangeKindOptions `json:"foldingRangeKind,omitzero"` + // Specific options for the folding range. + // + // Since: 3.17.0 + FoldingRange ResolvedClientFoldingRangeOptions `json:"foldingRange,omitzero"` +} + +func resolveFoldingRangeClientCapabilities(v *FoldingRangeClientCapabilities) ResolvedFoldingRangeClientCapabilities { + if v == nil { + return ResolvedFoldingRangeClientCapabilities{} + } + return ResolvedFoldingRangeClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + RangeLimit: derefOr(v.RangeLimit), + LineFoldingOnly: derefOr(v.LineFoldingOnly), + FoldingRangeKind: resolveClientFoldingRangeKindOptions(v.FoldingRangeKind), + FoldingRange: resolveClientFoldingRangeOptions(v.FoldingRange), + } +} + +// ResolvedSelectionRangeClientCapabilities is a resolved version of SelectionRangeClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedSelectionRangeClientCapabilities struct { + // Whether implementation supports dynamic registration for selection range providers. If this is set to `true` + // the client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server + // capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveSelectionRangeClientCapabilities(v *SelectionRangeClientCapabilities) ResolvedSelectionRangeClientCapabilities { + if v == nil { + return ResolvedSelectionRangeClientCapabilities{} + } + return ResolvedSelectionRangeClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedClientDiagnosticsTagOptions is a resolved version of ClientDiagnosticsTagOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientDiagnosticsTagOptions struct { + // The tags supported by the client. + ValueSet []DiagnosticTag `json:"valueSet,omitzero"` +} + +func resolveClientDiagnosticsTagOptions(v *ClientDiagnosticsTagOptions) ResolvedClientDiagnosticsTagOptions { + if v == nil { + return ResolvedClientDiagnosticsTagOptions{} + } + return ResolvedClientDiagnosticsTagOptions{ + ValueSet: v.ValueSet, + } +} + +// ResolvedPublishDiagnosticsClientCapabilities is a resolved version of PublishDiagnosticsClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// The publish diagnostic client capabilities. +type ResolvedPublishDiagnosticsClientCapabilities struct { + // Whether the clients accepts diagnostics with related information. + RelatedInformation bool `json:"relatedInformation,omitzero"` + // Client supports the tag property to provide meta data about a diagnostic. + // Clients supporting tags have to handle unknown tags gracefully. + // + // Since: 3.15.0 + TagSupport ResolvedClientDiagnosticsTagOptions `json:"tagSupport,omitzero"` + // Client supports a codeDescription property + // + // Since: 3.16.0 + CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitzero"` + // Whether code action supports the `data` property which is + // preserved between a `textDocument/publishDiagnostics` and + // `textDocument/codeAction` request. + // + // Since: 3.16.0 + DataSupport bool `json:"dataSupport,omitzero"` + // Whether the client interprets the version property of the + // `textDocument/publishDiagnostics` notification's parameter. + // + // Since: 3.15.0 + VersionSupport bool `json:"versionSupport,omitzero"` +} + +func resolvePublishDiagnosticsClientCapabilities(v *PublishDiagnosticsClientCapabilities) ResolvedPublishDiagnosticsClientCapabilities { + if v == nil { + return ResolvedPublishDiagnosticsClientCapabilities{} + } + return ResolvedPublishDiagnosticsClientCapabilities{ + RelatedInformation: derefOr(v.RelatedInformation), + TagSupport: resolveClientDiagnosticsTagOptions(v.TagSupport), + CodeDescriptionSupport: derefOr(v.CodeDescriptionSupport), + DataSupport: derefOr(v.DataSupport), + VersionSupport: derefOr(v.VersionSupport), + } +} + +// ResolvedCallHierarchyClientCapabilities is a resolved version of CallHierarchyClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.16.0 +type ResolvedCallHierarchyClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + // return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveCallHierarchyClientCapabilities(v *CallHierarchyClientCapabilities) ResolvedCallHierarchyClientCapabilities { + if v == nil { + return ResolvedCallHierarchyClientCapabilities{} + } + return ResolvedCallHierarchyClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedClientSemanticTokensRequestOptions is a resolved version of ClientSemanticTokensRequestOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientSemanticTokensRequestOptions struct { + // The client will send the `textDocument/semanticTokens/range` request if + // the server provides a corresponding handler. + Range BooleanOrEmptyObject `json:"range,omitzero"` + // The client will send the `textDocument/semanticTokens/full` request if + // the server provides a corresponding handler. + Full BooleanOrClientSemanticTokensRequestFullDelta `json:"full,omitzero"` +} + +func resolveClientSemanticTokensRequestOptions(v *ClientSemanticTokensRequestOptions) ResolvedClientSemanticTokensRequestOptions { + if v == nil { + return ResolvedClientSemanticTokensRequestOptions{} + } + return ResolvedClientSemanticTokensRequestOptions{ + Range: derefOr(v.Range), + Full: derefOr(v.Full), + } +} + +// ResolvedSemanticTokensClientCapabilities is a resolved version of SemanticTokensClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.16.0 +type ResolvedSemanticTokensClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + // return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Which requests the client supports and might send to the server + // depending on the server's capability. Please note that clients might not + // show semantic tokens or degrade some of the user experience if a range + // or full request is advertised by the client but not provided by the + // server. If for example the client capability `requests.full` and + // `request.range` are both set to true but the server only provides a + // range provider the client might not render a minimap correctly or might + // even decide to not show any semantic tokens at all. + Requests ResolvedClientSemanticTokensRequestOptions `json:"requests,omitzero"` + // The token types that the client supports. + TokenTypes []string `json:"tokenTypes,omitzero"` + // The token modifiers that the client supports. + TokenModifiers []string `json:"tokenModifiers,omitzero"` + // The token formats the clients supports. + Formats []TokenFormat `json:"formats,omitzero"` + // Whether the client supports tokens that can overlap each other. + OverlappingTokenSupport bool `json:"overlappingTokenSupport,omitzero"` + // Whether the client supports tokens that can span multiple lines. + MultilineTokenSupport bool `json:"multilineTokenSupport,omitzero"` + // Whether the client allows the server to actively cancel a + // semantic token request, e.g. supports returning + // LSPErrorCodes.ServerCancelled. If a server does the client + // needs to retrigger the request. + // + // Since: 3.17.0 + ServerCancelSupport bool `json:"serverCancelSupport,omitzero"` + // Whether the client uses semantic tokens to augment existing + // syntax tokens. If set to `true` client side created syntax + // tokens and semantic tokens are both used for colorization. If + // set to `false` the client only uses the returned semantic tokens + // for colorization. + // + // If the value is `undefined` then the client behavior is not + // specified. + // + // Since: 3.17.0 + AugmentsSyntaxTokens bool `json:"augmentsSyntaxTokens,omitzero"` +} + +func resolveSemanticTokensClientCapabilities(v *SemanticTokensClientCapabilities) ResolvedSemanticTokensClientCapabilities { + if v == nil { + return ResolvedSemanticTokensClientCapabilities{} + } + return ResolvedSemanticTokensClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + Requests: resolveClientSemanticTokensRequestOptions(v.Requests), + TokenTypes: v.TokenTypes, + TokenModifiers: v.TokenModifiers, + Formats: v.Formats, + OverlappingTokenSupport: derefOr(v.OverlappingTokenSupport), + MultilineTokenSupport: derefOr(v.MultilineTokenSupport), + ServerCancelSupport: derefOr(v.ServerCancelSupport), + AugmentsSyntaxTokens: derefOr(v.AugmentsSyntaxTokens), + } +} + +// ResolvedLinkedEditingRangeClientCapabilities is a resolved version of LinkedEditingRangeClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities for the linked editing range request. +// +// Since: 3.16.0 +type ResolvedLinkedEditingRangeClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + // return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveLinkedEditingRangeClientCapabilities(v *LinkedEditingRangeClientCapabilities) ResolvedLinkedEditingRangeClientCapabilities { + if v == nil { + return ResolvedLinkedEditingRangeClientCapabilities{} + } + return ResolvedLinkedEditingRangeClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedMonikerClientCapabilities is a resolved version of MonikerClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities specific to the moniker request. +// +// Since: 3.16.0 +type ResolvedMonikerClientCapabilities struct { + // Whether moniker supports dynamic registration. If this is set to `true` + // the client supports the new `MonikerRegistrationOptions` return value + // for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveMonikerClientCapabilities(v *MonikerClientCapabilities) ResolvedMonikerClientCapabilities { + if v == nil { + return ResolvedMonikerClientCapabilities{} + } + return ResolvedMonikerClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedTypeHierarchyClientCapabilities is a resolved version of TypeHierarchyClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.17.0 +type ResolvedTypeHierarchyClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + // return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveTypeHierarchyClientCapabilities(v *TypeHierarchyClientCapabilities) ResolvedTypeHierarchyClientCapabilities { + if v == nil { + return ResolvedTypeHierarchyClientCapabilities{} + } + return ResolvedTypeHierarchyClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedInlineValueClientCapabilities is a resolved version of InlineValueClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities specific to inline values. +// +// Since: 3.17.0 +type ResolvedInlineValueClientCapabilities struct { + // Whether implementation supports dynamic registration for inline value providers. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveInlineValueClientCapabilities(v *InlineValueClientCapabilities) ResolvedInlineValueClientCapabilities { + if v == nil { + return ResolvedInlineValueClientCapabilities{} + } + return ResolvedInlineValueClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedClientInlayHintResolveOptions is a resolved version of ClientInlayHintResolveOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientInlayHintResolveOptions struct { + // The properties that a client can resolve lazily. + Properties []string `json:"properties,omitzero"` +} + +func resolveClientInlayHintResolveOptions(v *ClientInlayHintResolveOptions) ResolvedClientInlayHintResolveOptions { + if v == nil { + return ResolvedClientInlayHintResolveOptions{} + } + return ResolvedClientInlayHintResolveOptions{ + Properties: v.Properties, + } +} + +// ResolvedInlayHintClientCapabilities is a resolved version of InlayHintClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Inlay hint client capabilities. +// +// Since: 3.17.0 +type ResolvedInlayHintClientCapabilities struct { + // Whether inlay hints support dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Indicates which properties a client can resolve lazily on an inlay + // hint. + ResolveSupport ResolvedClientInlayHintResolveOptions `json:"resolveSupport,omitzero"` +} + +func resolveInlayHintClientCapabilities(v *InlayHintClientCapabilities) ResolvedInlayHintClientCapabilities { + if v == nil { + return ResolvedInlayHintClientCapabilities{} + } + return ResolvedInlayHintClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + ResolveSupport: resolveClientInlayHintResolveOptions(v.ResolveSupport), + } +} + +// ResolvedDiagnosticClientCapabilities is a resolved version of DiagnosticClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities specific to diagnostic pull requests. +// +// Since: 3.17.0 +type ResolvedDiagnosticClientCapabilities struct { + // Whether the clients accepts diagnostics with related information. + RelatedInformation bool `json:"relatedInformation,omitzero"` + // Client supports the tag property to provide meta data about a diagnostic. + // Clients supporting tags have to handle unknown tags gracefully. + // + // Since: 3.15.0 + TagSupport ResolvedClientDiagnosticsTagOptions `json:"tagSupport,omitzero"` + // Client supports a codeDescription property + // + // Since: 3.16.0 + CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitzero"` + // Whether code action supports the `data` property which is + // preserved between a `textDocument/publishDiagnostics` and + // `textDocument/codeAction` request. + // + // Since: 3.16.0 + DataSupport bool `json:"dataSupport,omitzero"` + // Whether implementation supports dynamic registration. If this is set to `true` + // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + // return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // Whether the clients supports related documents for document diagnostic pulls. + RelatedDocumentSupport bool `json:"relatedDocumentSupport,omitzero"` +} + +func resolveDiagnosticClientCapabilities(v *DiagnosticClientCapabilities) ResolvedDiagnosticClientCapabilities { + if v == nil { + return ResolvedDiagnosticClientCapabilities{} + } + return ResolvedDiagnosticClientCapabilities{ + RelatedInformation: derefOr(v.RelatedInformation), + TagSupport: resolveClientDiagnosticsTagOptions(v.TagSupport), + CodeDescriptionSupport: derefOr(v.CodeDescriptionSupport), + DataSupport: derefOr(v.DataSupport), + DynamicRegistration: derefOr(v.DynamicRegistration), + RelatedDocumentSupport: derefOr(v.RelatedDocumentSupport), + } +} + +// ResolvedInlineCompletionClientCapabilities is a resolved version of InlineCompletionClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities specific to inline completions. +// +// Since: 3.18.0 +// +// Proposed. +type ResolvedInlineCompletionClientCapabilities struct { + // Whether implementation supports dynamic registration for inline completion providers. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` +} + +func resolveInlineCompletionClientCapabilities(v *InlineCompletionClientCapabilities) ResolvedInlineCompletionClientCapabilities { + if v == nil { + return ResolvedInlineCompletionClientCapabilities{} + } + return ResolvedInlineCompletionClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + } +} + +// ResolvedTextDocumentClientCapabilities is a resolved version of TextDocumentClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Text document specific client capabilities. +type ResolvedTextDocumentClientCapabilities struct { + // Defines which synchronization capabilities the client supports. + Synchronization ResolvedTextDocumentSyncClientCapabilities `json:"synchronization,omitzero"` + // Defines which filters the client supports. + // + // Since: 3.18.0 + Filters ResolvedTextDocumentFilterClientCapabilities `json:"filters,omitzero"` + // Capabilities specific to the `textDocument/completion` request. + Completion ResolvedCompletionClientCapabilities `json:"completion,omitzero"` + // Capabilities specific to the `textDocument/hover` request. + Hover ResolvedHoverClientCapabilities `json:"hover,omitzero"` + // Capabilities specific to the `textDocument/signatureHelp` request. + SignatureHelp ResolvedSignatureHelpClientCapabilities `json:"signatureHelp,omitzero"` + // Capabilities specific to the `textDocument/declaration` request. + // + // Since: 3.14.0 + Declaration ResolvedDeclarationClientCapabilities `json:"declaration,omitzero"` + // Capabilities specific to the `textDocument/definition` request. + Definition ResolvedDefinitionClientCapabilities `json:"definition,omitzero"` + // Capabilities specific to the `textDocument/typeDefinition` request. + // + // Since: 3.6.0 + TypeDefinition ResolvedTypeDefinitionClientCapabilities `json:"typeDefinition,omitzero"` + // Capabilities specific to the `textDocument/implementation` request. + // + // Since: 3.6.0 + Implementation ResolvedImplementationClientCapabilities `json:"implementation,omitzero"` + // Capabilities specific to the `textDocument/references` request. + References ResolvedReferenceClientCapabilities `json:"references,omitzero"` + // Capabilities specific to the `textDocument/documentHighlight` request. + DocumentHighlight ResolvedDocumentHighlightClientCapabilities `json:"documentHighlight,omitzero"` + // Capabilities specific to the `textDocument/documentSymbol` request. + DocumentSymbol ResolvedDocumentSymbolClientCapabilities `json:"documentSymbol,omitzero"` + // Capabilities specific to the `textDocument/codeAction` request. + CodeAction ResolvedCodeActionClientCapabilities `json:"codeAction,omitzero"` + // Capabilities specific to the `textDocument/codeLens` request. + CodeLens ResolvedCodeLensClientCapabilities `json:"codeLens,omitzero"` + // Capabilities specific to the `textDocument/documentLink` request. + DocumentLink ResolvedDocumentLinkClientCapabilities `json:"documentLink,omitzero"` + // Capabilities specific to the `textDocument/documentColor` and the + // `textDocument/colorPresentation` request. + // + // Since: 3.6.0 + ColorProvider ResolvedDocumentColorClientCapabilities `json:"colorProvider,omitzero"` + // Capabilities specific to the `textDocument/formatting` request. + Formatting ResolvedDocumentFormattingClientCapabilities `json:"formatting,omitzero"` + // Capabilities specific to the `textDocument/rangeFormatting` request. + RangeFormatting ResolvedDocumentRangeFormattingClientCapabilities `json:"rangeFormatting,omitzero"` + // Capabilities specific to the `textDocument/onTypeFormatting` request. + OnTypeFormatting ResolvedDocumentOnTypeFormattingClientCapabilities `json:"onTypeFormatting,omitzero"` + // Capabilities specific to the `textDocument/rename` request. + Rename ResolvedRenameClientCapabilities `json:"rename,omitzero"` + // Capabilities specific to the `textDocument/foldingRange` request. + // + // Since: 3.10.0 + FoldingRange ResolvedFoldingRangeClientCapabilities `json:"foldingRange,omitzero"` + // Capabilities specific to the `textDocument/selectionRange` request. + // + // Since: 3.15.0 + SelectionRange ResolvedSelectionRangeClientCapabilities `json:"selectionRange,omitzero"` + // Capabilities specific to the `textDocument/publishDiagnostics` notification. + PublishDiagnostics ResolvedPublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitzero"` + // Capabilities specific to the various call hierarchy requests. + // + // Since: 3.16.0 + CallHierarchy ResolvedCallHierarchyClientCapabilities `json:"callHierarchy,omitzero"` + // Capabilities specific to the various semantic token request. + // + // Since: 3.16.0 + SemanticTokens ResolvedSemanticTokensClientCapabilities `json:"semanticTokens,omitzero"` + // Capabilities specific to the `textDocument/linkedEditingRange` request. + // + // Since: 3.16.0 + LinkedEditingRange ResolvedLinkedEditingRangeClientCapabilities `json:"linkedEditingRange,omitzero"` + // Client capabilities specific to the `textDocument/moniker` request. + // + // Since: 3.16.0 + Moniker ResolvedMonikerClientCapabilities `json:"moniker,omitzero"` + // Capabilities specific to the various type hierarchy requests. + // + // Since: 3.17.0 + TypeHierarchy ResolvedTypeHierarchyClientCapabilities `json:"typeHierarchy,omitzero"` + // Capabilities specific to the `textDocument/inlineValue` request. + // + // Since: 3.17.0 + InlineValue ResolvedInlineValueClientCapabilities `json:"inlineValue,omitzero"` + // Capabilities specific to the `textDocument/inlayHint` request. + // + // Since: 3.17.0 + InlayHint ResolvedInlayHintClientCapabilities `json:"inlayHint,omitzero"` + // Capabilities specific to the diagnostic pull model. + // + // Since: 3.17.0 + Diagnostic ResolvedDiagnosticClientCapabilities `json:"diagnostic,omitzero"` + // Client capabilities specific to inline completions. + // + // Since: 3.18.0 + // + // Proposed. + InlineCompletion ResolvedInlineCompletionClientCapabilities `json:"inlineCompletion,omitzero"` +} + +func resolveTextDocumentClientCapabilities(v *TextDocumentClientCapabilities) ResolvedTextDocumentClientCapabilities { + if v == nil { + return ResolvedTextDocumentClientCapabilities{} + } + return ResolvedTextDocumentClientCapabilities{ + Synchronization: resolveTextDocumentSyncClientCapabilities(v.Synchronization), + Filters: resolveTextDocumentFilterClientCapabilities(v.Filters), + Completion: resolveCompletionClientCapabilities(v.Completion), + Hover: resolveHoverClientCapabilities(v.Hover), + SignatureHelp: resolveSignatureHelpClientCapabilities(v.SignatureHelp), + Declaration: resolveDeclarationClientCapabilities(v.Declaration), + Definition: resolveDefinitionClientCapabilities(v.Definition), + TypeDefinition: resolveTypeDefinitionClientCapabilities(v.TypeDefinition), + Implementation: resolveImplementationClientCapabilities(v.Implementation), + References: resolveReferenceClientCapabilities(v.References), + DocumentHighlight: resolveDocumentHighlightClientCapabilities(v.DocumentHighlight), + DocumentSymbol: resolveDocumentSymbolClientCapabilities(v.DocumentSymbol), + CodeAction: resolveCodeActionClientCapabilities(v.CodeAction), + CodeLens: resolveCodeLensClientCapabilities(v.CodeLens), + DocumentLink: resolveDocumentLinkClientCapabilities(v.DocumentLink), + ColorProvider: resolveDocumentColorClientCapabilities(v.ColorProvider), + Formatting: resolveDocumentFormattingClientCapabilities(v.Formatting), + RangeFormatting: resolveDocumentRangeFormattingClientCapabilities(v.RangeFormatting), + OnTypeFormatting: resolveDocumentOnTypeFormattingClientCapabilities(v.OnTypeFormatting), + Rename: resolveRenameClientCapabilities(v.Rename), + FoldingRange: resolveFoldingRangeClientCapabilities(v.FoldingRange), + SelectionRange: resolveSelectionRangeClientCapabilities(v.SelectionRange), + PublishDiagnostics: resolvePublishDiagnosticsClientCapabilities(v.PublishDiagnostics), + CallHierarchy: resolveCallHierarchyClientCapabilities(v.CallHierarchy), + SemanticTokens: resolveSemanticTokensClientCapabilities(v.SemanticTokens), + LinkedEditingRange: resolveLinkedEditingRangeClientCapabilities(v.LinkedEditingRange), + Moniker: resolveMonikerClientCapabilities(v.Moniker), + TypeHierarchy: resolveTypeHierarchyClientCapabilities(v.TypeHierarchy), + InlineValue: resolveInlineValueClientCapabilities(v.InlineValue), + InlayHint: resolveInlayHintClientCapabilities(v.InlayHint), + Diagnostic: resolveDiagnosticClientCapabilities(v.Diagnostic), + InlineCompletion: resolveInlineCompletionClientCapabilities(v.InlineCompletion), + } +} + +// ResolvedNotebookDocumentSyncClientCapabilities is a resolved version of NotebookDocumentSyncClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Notebook specific client capabilities. +// +// Since: 3.17.0 +type ResolvedNotebookDocumentSyncClientCapabilities struct { + // Whether implementation supports dynamic registration. If this is + // set to `true` the client supports the new + // `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + // return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitzero"` + // The client supports sending execution summary data per cell. + ExecutionSummarySupport bool `json:"executionSummarySupport,omitzero"` +} + +func resolveNotebookDocumentSyncClientCapabilities(v *NotebookDocumentSyncClientCapabilities) ResolvedNotebookDocumentSyncClientCapabilities { + if v == nil { + return ResolvedNotebookDocumentSyncClientCapabilities{} + } + return ResolvedNotebookDocumentSyncClientCapabilities{ + DynamicRegistration: derefOr(v.DynamicRegistration), + ExecutionSummarySupport: derefOr(v.ExecutionSummarySupport), + } +} + +// ResolvedNotebookDocumentClientCapabilities is a resolved version of NotebookDocumentClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Capabilities specific to the notebook document support. +// +// Since: 3.17.0 +type ResolvedNotebookDocumentClientCapabilities struct { + // Capabilities specific to notebook document synchronization + // + // Since: 3.17.0 + Synchronization ResolvedNotebookDocumentSyncClientCapabilities `json:"synchronization,omitzero"` +} + +func resolveNotebookDocumentClientCapabilities(v *NotebookDocumentClientCapabilities) ResolvedNotebookDocumentClientCapabilities { + if v == nil { + return ResolvedNotebookDocumentClientCapabilities{} + } + return ResolvedNotebookDocumentClientCapabilities{ + Synchronization: resolveNotebookDocumentSyncClientCapabilities(v.Synchronization), + } +} + +// ResolvedClientShowMessageActionItemOptions is a resolved version of ClientShowMessageActionItemOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedClientShowMessageActionItemOptions struct { + // Whether the client supports additional attributes which + // are preserved and send back to the server in the + // request's response. + AdditionalPropertiesSupport bool `json:"additionalPropertiesSupport,omitzero"` +} + +func resolveClientShowMessageActionItemOptions(v *ClientShowMessageActionItemOptions) ResolvedClientShowMessageActionItemOptions { + if v == nil { + return ResolvedClientShowMessageActionItemOptions{} + } + return ResolvedClientShowMessageActionItemOptions{ + AdditionalPropertiesSupport: derefOr(v.AdditionalPropertiesSupport), + } +} + +// ResolvedShowMessageRequestClientCapabilities is a resolved version of ShowMessageRequestClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Show message request client capabilities +type ResolvedShowMessageRequestClientCapabilities struct { + // Capabilities specific to the `MessageActionItem` type. + MessageActionItem ResolvedClientShowMessageActionItemOptions `json:"messageActionItem,omitzero"` +} + +func resolveShowMessageRequestClientCapabilities(v *ShowMessageRequestClientCapabilities) ResolvedShowMessageRequestClientCapabilities { + if v == nil { + return ResolvedShowMessageRequestClientCapabilities{} + } + return ResolvedShowMessageRequestClientCapabilities{ + MessageActionItem: resolveClientShowMessageActionItemOptions(v.MessageActionItem), + } +} + +// ResolvedShowDocumentClientCapabilities is a resolved version of ShowDocumentClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities for the showDocument request. +// +// Since: 3.16.0 +type ResolvedShowDocumentClientCapabilities struct { + // The client has support for the showDocument + // request. + Support bool `json:"support,omitzero"` +} + +func resolveShowDocumentClientCapabilities(v *ShowDocumentClientCapabilities) ResolvedShowDocumentClientCapabilities { + if v == nil { + return ResolvedShowDocumentClientCapabilities{} + } + return ResolvedShowDocumentClientCapabilities{ + Support: v.Support, + } +} + +// ResolvedWindowClientCapabilities is a resolved version of WindowClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +type ResolvedWindowClientCapabilities struct { + // It indicates whether the client supports server initiated + // progress using the `window/workDoneProgress/create` request. + // + // The capability also controls Whether client supports handling + // of progress notifications. If set servers are allowed to report a + // `workDoneProgress` property in the request specific server + // capabilities. + // + // Since: 3.15.0 + WorkDoneProgress bool `json:"workDoneProgress,omitzero"` + // Capabilities specific to the showMessage request. + // + // Since: 3.16.0 + ShowMessage ResolvedShowMessageRequestClientCapabilities `json:"showMessage,omitzero"` + // Capabilities specific to the showDocument request. + // + // Since: 3.16.0 + ShowDocument ResolvedShowDocumentClientCapabilities `json:"showDocument,omitzero"` +} + +func resolveWindowClientCapabilities(v *WindowClientCapabilities) ResolvedWindowClientCapabilities { + if v == nil { + return ResolvedWindowClientCapabilities{} + } + return ResolvedWindowClientCapabilities{ + WorkDoneProgress: derefOr(v.WorkDoneProgress), + ShowMessage: resolveShowMessageRequestClientCapabilities(v.ShowMessage), + ShowDocument: resolveShowDocumentClientCapabilities(v.ShowDocument), + } +} + +// ResolvedStaleRequestSupportOptions is a resolved version of StaleRequestSupportOptions with all optional fields +// converted to non-pointer values for easier access. +// +// Since: 3.18.0 +type ResolvedStaleRequestSupportOptions struct { + // The client will actively cancel the request. + Cancel bool `json:"cancel,omitzero"` + // The list of requests for which the client + // will retry the request if it receives a + // response with error code `ContentModified` + RetryOnContentModified []string `json:"retryOnContentModified,omitzero"` +} + +func resolveStaleRequestSupportOptions(v *StaleRequestSupportOptions) ResolvedStaleRequestSupportOptions { + if v == nil { + return ResolvedStaleRequestSupportOptions{} + } + return ResolvedStaleRequestSupportOptions{ + Cancel: v.Cancel, + RetryOnContentModified: v.RetryOnContentModified, + } +} + +// ResolvedRegularExpressionsClientCapabilities is a resolved version of RegularExpressionsClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities specific to regular expressions. +// +// Since: 3.16.0 +type ResolvedRegularExpressionsClientCapabilities struct { + // The engine's name. + Engine string `json:"engine,omitzero"` + // The engine's version. + Version string `json:"version,omitzero"` +} + +func resolveRegularExpressionsClientCapabilities(v *RegularExpressionsClientCapabilities) ResolvedRegularExpressionsClientCapabilities { + if v == nil { + return ResolvedRegularExpressionsClientCapabilities{} + } + return ResolvedRegularExpressionsClientCapabilities{ + Engine: v.Engine, + Version: derefOr(v.Version), + } +} + +// ResolvedMarkdownClientCapabilities is a resolved version of MarkdownClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// Client capabilities specific to the used markdown parser. +// +// Since: 3.16.0 +type ResolvedMarkdownClientCapabilities struct { + // The name of the parser. + Parser string `json:"parser,omitzero"` + // The version of the parser. + Version string `json:"version,omitzero"` + // A list of HTML tags that the client allows / supports in + // Markdown. + // + // Since: 3.17.0 + AllowedTags []string `json:"allowedTags,omitzero"` +} + +func resolveMarkdownClientCapabilities(v *MarkdownClientCapabilities) ResolvedMarkdownClientCapabilities { + if v == nil { + return ResolvedMarkdownClientCapabilities{} + } + return ResolvedMarkdownClientCapabilities{ + Parser: v.Parser, + Version: derefOr(v.Version), + AllowedTags: derefOr(v.AllowedTags), + } +} + +// ResolvedGeneralClientCapabilities is a resolved version of GeneralClientCapabilities with all optional fields +// converted to non-pointer values for easier access. +// +// General client capabilities. +// +// Since: 3.16.0 +type ResolvedGeneralClientCapabilities struct { + // Client capability that signals how the client + // handles stale requests (e.g. a request + // for which the client will not process the response + // anymore since the information is outdated). + // + // Since: 3.17.0 + StaleRequestSupport ResolvedStaleRequestSupportOptions `json:"staleRequestSupport,omitzero"` + // Client capabilities specific to regular expressions. + // + // Since: 3.16.0 + RegularExpressions ResolvedRegularExpressionsClientCapabilities `json:"regularExpressions,omitzero"` + // Client capabilities specific to the client's markdown parser. + // + // Since: 3.16.0 + Markdown ResolvedMarkdownClientCapabilities `json:"markdown,omitzero"` + // The position encodings supported by the client. Client and server + // have to agree on the same position encoding to ensure that offsets + // (e.g. character position in a line) are interpreted the same on both + // sides. + // + // To keep the protocol backwards compatible the following applies: if + // the value 'utf-16' is missing from the array of position encodings + // servers can assume that the client supports UTF-16. UTF-16 is + // therefore a mandatory encoding. + // + // If omitted it defaults to ['utf-16']. + // + // Implementation considerations: since the conversion from one encoding + // into another requires the content of the file / line the conversion + // is best done where the file is read which is usually on the server + // side. + // + // Since: 3.17.0 + PositionEncodings []PositionEncodingKind `json:"positionEncodings,omitzero"` +} + +func resolveGeneralClientCapabilities(v *GeneralClientCapabilities) ResolvedGeneralClientCapabilities { + if v == nil { + return ResolvedGeneralClientCapabilities{} + } + return ResolvedGeneralClientCapabilities{ + StaleRequestSupport: resolveStaleRequestSupportOptions(v.StaleRequestSupport), + RegularExpressions: resolveRegularExpressionsClientCapabilities(v.RegularExpressions), + Markdown: resolveMarkdownClientCapabilities(v.Markdown), + PositionEncodings: derefOr(v.PositionEncodings), + } +} + +// ResolvedClientCapabilities is a version of ClientCapabilities where all nested +// fields are values (not pointers), making it easier to access deeply nested capabilities. +// Use ResolveClientCapabilities to convert from ClientCapabilities. +// +// Defines the capabilities provided by the client. +type ResolvedClientCapabilities struct { + // Workspace specific client capabilities. + Workspace ResolvedWorkspaceClientCapabilities `json:"workspace,omitzero"` + // Text document specific client capabilities. + TextDocument ResolvedTextDocumentClientCapabilities `json:"textDocument,omitzero"` + // Capabilities specific to the notebook document support. + // + // Since: 3.17.0 + NotebookDocument ResolvedNotebookDocumentClientCapabilities `json:"notebookDocument,omitzero"` + // Window specific client capabilities. + Window ResolvedWindowClientCapabilities `json:"window,omitzero"` + // General client capabilities. + // + // Since: 3.16.0 + General ResolvedGeneralClientCapabilities `json:"general,omitzero"` +} + +func ResolveClientCapabilities(v *ClientCapabilities) ResolvedClientCapabilities { + if v == nil { + return ResolvedClientCapabilities{} + } + return ResolvedClientCapabilities{ + Workspace: resolveWorkspaceClientCapabilities(v.Workspace), + TextDocument: resolveTextDocumentClientCapabilities(v.TextDocument), + NotebookDocument: resolveNotebookDocumentClientCapabilities(v.NotebookDocument), + Window: resolveWindowClientCapabilities(v.Window), + General: resolveGeneralClientCapabilities(v.General), + } +} diff --git a/internal/lsp/lsproto/util.go b/internal/lsp/lsproto/util.go new file mode 100644 index 0000000000..917d9e18d7 --- /dev/null +++ b/internal/lsp/lsproto/util.go @@ -0,0 +1,25 @@ +package lsproto + +import ( + "cmp" +) + +// Implements a cmp.Compare like function for two Position +// ComparePositions(pos, other) == cmp.Compare(pos, other) +func ComparePositions(pos, other Position) int { + if lineComp := cmp.Compare(pos.Line, other.Line); lineComp != 0 { + return lineComp + } + return cmp.Compare(pos.Character, other.Character) +} + +// Implements a cmp.Compare like function for two *Range +// CompareRanges(lsRange, other) == cmp.Compare(lsrange, other) +// +// Range.Start is compared before Range.End +func CompareRanges(lsRange, other *Range) int { + if startComp := ComparePositions(lsRange.Start, other.Start); startComp != 0 { + return startComp + } + return ComparePositions(lsRange.End, other.End) +} diff --git a/internal/lsp/server.go b/internal/lsp/server.go index de34bf4194..af6ab02cb6 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -5,20 +5,22 @@ import ( "errors" "fmt" "io" - "os" - "os/exec" - "os/signal" + "iter" "runtime/debug" "slices" "sync" "sync/atomic" - "syscall" "time" "github.com/go-json-experiment/json" + "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/jsonutil" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project" "github.com/microsoft/typescript-go/internal/project/ata" @@ -26,7 +28,6 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" "golang.org/x/sync/errgroup" - "golang.org/x/text/language" ) type ServerOptions struct { @@ -39,17 +40,28 @@ type ServerOptions struct { DefaultLibraryPath string TypingsLocation string ParseCache *project.ParseCache + NpmInstall func(cwd string, args []string) ([]byte, error) + + // Test options + Client project.Client + Logger logging.Logger } func NewServer(opts *ServerOptions) *Server { if opts.Cwd == "" { panic("Cwd is required") } + var logger logging.Logger + if opts.Logger != nil { + logger = opts.Logger + } else { + logger = logging.NewLogger(opts.Err) + } return &Server{ r: opts.In, w: opts.Out, stderr: opts.Err, - logger: logging.NewLogger(opts.Err), + logger: logger, requestQueue: make(chan *lsproto.RequestMessage, 100), outgoingQueue: make(chan *lsproto.Message, 100), pendingClientRequests: make(map[lsproto.ID]pendingClientRequest), @@ -59,6 +71,8 @@ func NewServer(opts *ServerOptions) *Server { defaultLibraryPath: opts.DefaultLibraryPath, typingsLocation: opts.TypingsLocation, parseCache: opts.ParseCache, + npmInstall: opts.NpmInstall, + client: opts.Client, } } @@ -143,9 +157,10 @@ type Server struct { defaultLibraryPath string typingsLocation string - initializeParams *lsproto.InitializeParams - positionEncoding lsproto.PositionEncodingKind - locale language.Tag + initializeParams *lsproto.InitializeParams + clientCapabilities lsproto.ResolvedClientCapabilities + positionEncoding lsproto.PositionEncodingKind + locale locale.Locale watchEnabled bool watcherID atomic.Uint32 @@ -153,22 +168,31 @@ type Server struct { session *project.Session + // Test options for initializing session + client project.Client + // !!! temporary; remove when we have `handleDidChangeConfiguration`/implicit project config support compilerOptionsForInferredProjects *core.CompilerOptions // parseCache can be passed in so separate tests can share ASTs parseCache *project.ParseCache + + npmInstall func(cwd string, args []string) ([]byte, error) } +func (s *Server) Session() *project.Session { return s.session } + // WatchFiles implements project.Client. func (s *Server) WatchFiles(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher) error { - _, err := s.sendRequest(ctx, lsproto.MethodClientRegisterCapability, &lsproto.RegistrationParams{ + _, err := sendClientRequest(ctx, s, lsproto.ClientRegisterCapabilityInfo, &lsproto.RegistrationParams{ Registrations: []*lsproto.Registration{ { Id: string(id), Method: string(lsproto.MethodWorkspaceDidChangeWatchedFiles), - RegisterOptions: ptrTo(any(lsproto.DidChangeWatchedFilesRegistrationOptions{ - Watchers: watchers, - })), + RegisterOptions: &lsproto.RegisterOptions{ + DidChangeWatchedFiles: &lsproto.DidChangeWatchedFilesRegistrationOptions{ + Watchers: watchers, + }, + }, }, }, }) @@ -183,7 +207,7 @@ func (s *Server) WatchFiles(ctx context.Context, id project.WatcherID, watchers // UnwatchFiles implements project.Client. func (s *Server) UnwatchFiles(ctx context.Context, id project.WatcherID) error { if s.watchers.Has(id) { - _, err := s.sendRequest(ctx, lsproto.MethodClientUnregisterCapability, &lsproto.UnregistrationParams{ + _, err := sendClientRequest(ctx, s, lsproto.ClientUnregisterCapabilityInfo, &lsproto.UnregistrationParams{ Unregisterations: []*lsproto.Unregistration{ { Id: string(id), @@ -204,24 +228,51 @@ func (s *Server) UnwatchFiles(ctx context.Context, id project.WatcherID) error { // RefreshDiagnostics implements project.Client. func (s *Server) RefreshDiagnostics(ctx context.Context) error { - if s.initializeParams.Capabilities == nil || - s.initializeParams.Capabilities.Workspace == nil || - s.initializeParams.Capabilities.Workspace.Diagnostics == nil || - !ptrIsTrue(s.initializeParams.Capabilities.Workspace.Diagnostics.RefreshSupport) { + if !s.clientCapabilities.Workspace.Diagnostics.RefreshSupport { return nil } - if _, err := s.sendRequest(ctx, lsproto.MethodWorkspaceDiagnosticRefresh, nil); err != nil { + if _, err := sendClientRequest(ctx, s, lsproto.WorkspaceDiagnosticRefreshInfo, nil); err != nil { return fmt.Errorf("failed to refresh diagnostics: %w", err) } return nil } -func (s *Server) Run() error { - ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - defer stop() +// PublishDiagnostics implements project.Client. +func (s *Server) PublishDiagnostics(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error { + notification := lsproto.TextDocumentPublishDiagnosticsInfo.NewNotificationMessage(params) + s.outgoingQueue <- notification.Message() + return nil +} + +func (s *Server) RequestConfiguration(ctx context.Context) (*lsutil.UserPreferences, error) { + caps := lsproto.GetClientCapabilities(ctx) + if !caps.Workspace.Configuration { + // if no configuration request capapbility, return default preferences + return s.session.NewUserPreferences(), nil + } + configs, err := sendClientRequest(ctx, s, lsproto.WorkspaceConfigurationInfo, &lsproto.ConfigurationParams{ + Items: []*lsproto.ConfigurationItem{ + { + Section: ptrTo("typescript"), + }, + }, + }) + if err != nil { + return nil, fmt.Errorf("configure request failed: %w", err) + } + s.Log(fmt.Sprintf("\n\nconfiguration: %+v, %T\n\n", configs, configs)) + userPreferences := s.session.NewUserPreferences() + for _, item := range configs { + if parsed := userPreferences.Parse(item); parsed != nil { + return parsed, nil + } + } + return userPreferences, nil +} +func (s *Server) Run(ctx context.Context) error { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { return s.dispatchLoop(ctx) }) g.Go(func() error { return s.writeLoop(ctx) }) @@ -314,7 +365,7 @@ func (s *Server) dispatchLoop(ctx context.Context) error { case <-ctx.Done(): return ctx.Err() case req := <-s.requestQueue: - requestCtx := core.WithLocale(ctx, s.locale) + requestCtx := locale.WithLocale(ctx, s.locale) if req.ID != nil { var cancel context.CancelFunc requestCtx, cancel = context.WithCancel(core.WithRequestID(requestCtx, req.ID.String())) @@ -366,9 +417,9 @@ func (s *Server) writeLoop(ctx context.Context) error { } } -func (s *Server) sendRequest(ctx context.Context, method lsproto.Method, params any) (any, error) { +func sendClientRequest[Req, Resp any](ctx context.Context, s *Server, info lsproto.RequestInfo[Req, Resp], params Req) (Resp, error) { id := lsproto.NewIDString(fmt.Sprintf("ts%d", s.clientSeq.Add(1))) - req := lsproto.NewRequestMessage(method, id, params) + req := info.NewRequestMessage(id, params) responseChan := make(chan *lsproto.ResponseMessage, 1) s.pendingServerRequestsMu.Lock() @@ -385,12 +436,12 @@ func (s *Server) sendRequest(ctx context.Context, method lsproto.Method, params close(respChan) delete(s.pendingServerRequests, *id) } - return nil, ctx.Err() + return *new(Resp), ctx.Err() case resp := <-responseChan: if resp.Error != nil { - return nil, fmt.Errorf("request failed: %s", resp.Error.String()) + return *new(Resp), fmt.Errorf("request failed: %s", resp.Error.String()) } - return resp.Result, nil + return info.UnmarshalResult(resp.Result) } } @@ -421,6 +472,8 @@ func (s *Server) sendResponse(resp *lsproto.ResponseMessage) { } func (s *Server) handleRequestOrNotification(ctx context.Context, req *lsproto.RequestMessage) error { + ctx = lsproto.WithClientCapabilities(ctx, &s.clientCapabilities) + if handler := handlers()[req.Method]; handler != nil { return handler(s, ctx, req) } @@ -441,6 +494,7 @@ var handlers = sync.OnceValue(func() handlerMap { registerRequestHandler(handlers, lsproto.ShutdownInfo, (*Server).handleShutdown) registerNotificationHandler(handlers, lsproto.ExitInfo, (*Server).handleExit) + registerNotificationHandler(handlers, lsproto.WorkspaceDidChangeConfigurationInfo, (*Server).handleDidChangeWorkspaceConfiguration) registerNotificationHandler(handlers, lsproto.TextDocumentDidOpenInfo, (*Server).handleDidOpen) registerNotificationHandler(handlers, lsproto.TextDocumentDidChangeInfo, (*Server).handleDidChange) registerNotificationHandler(handlers, lsproto.TextDocumentDidSaveInfo, (*Server).handleDidSave) @@ -453,15 +507,20 @@ var handlers = sync.OnceValue(func() handlerMap { registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDefinitionInfo, (*Server).handleDefinition) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentTypeDefinitionInfo, (*Server).handleTypeDefinition) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentCompletionInfo, (*Server).handleCompletion) - registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentReferencesInfo, (*Server).handleReferences) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentImplementationInfo, (*Server).handleImplementations) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentSignatureHelpInfo, (*Server).handleSignatureHelp) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentFormattingInfo, (*Server).handleDocumentFormat) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentRangeFormattingInfo, (*Server).handleDocumentRangeFormat) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentOnTypeFormattingInfo, (*Server).handleDocumentOnTypeFormat) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentSymbolInfo, (*Server).handleDocumentSymbol) - registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentRenameInfo, (*Server).handleRename) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentHighlightInfo, (*Server).handleDocumentHighlight) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentSelectionRangeInfo, (*Server).handleSelectionRange) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentInlayHintInfo, (*Server).handleInlayHint) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentCodeActionInfo, (*Server).handleCodeAction) + + registerMultiProjectReferenceRequestHandler(handlers, lsproto.TextDocumentReferencesInfo, (*Server).handleReferences, combineReferences) + registerMultiProjectReferenceRequestHandler(handlers, lsproto.TextDocumentRenameInfo, (*Server).handleRename, combineRenameResponse) + registerRequestHandler(handlers, lsproto.WorkspaceSymbolInfo, (*Server).handleWorkspaceSymbol) registerRequestHandler(handlers, lsproto.CompletionItemResolveInfo, (*Server).handleCompletionItemResolve) @@ -537,6 +596,243 @@ func registerLanguageServiceDocumentRequestHandler[Req lsproto.HasTextDocumentUR } } +type projectAndTextDocumentPosition struct { + project *project.Project + ls *ls.LanguageService + Uri lsproto.DocumentUri + Position lsproto.Position + forOriginalLocation bool +} + +type response[Resp any] struct { + complete bool + result Resp + forOriginalLocation bool +} + +func registerMultiProjectReferenceRequestHandler[Req lsproto.HasTextDocumentPosition, Resp any]( + handlers handlerMap, + info lsproto.RequestInfo[Req, Resp], + fn func(*Server, context.Context, *ls.LanguageService, Req, *ast.Node, []*ls.SymbolAndEntries) (Resp, error), + combineResults func(iter.Seq[Resp]) Resp, +) { + handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error { + var params Req + // Ignore empty params. + if req.Params != nil { + params = req.Params.(Req) + } + // !!! sheetal: multiple projects that contain the file through symlinks + defaultProject, defaultLs, allProjects, err := s.session.GetLanguageServiceAndProjectsForFile(ctx, params.TextDocumentURI()) + if err != nil { + return err + } + defer s.recover(req) + + var results collections.SyncMap[tspath.Path, *response[Resp]] + var defaultDefinition *ls.NonLocalDefinition + canSearchProject := func(project *project.Project) bool { + _, searched := results.Load(project.Id()) + return !searched + } + wg := core.NewWorkGroup(false) + var errMu sync.Mutex + var enqueueItem func(item projectAndTextDocumentPosition) + enqueueItem = func(item projectAndTextDocumentPosition) { + var response response[Resp] + if _, loaded := results.LoadOrStore(item.project.Id(), &response); loaded { + return + } + wg.Queue(func() { + if ctx.Err() != nil { + return + } + defer s.recover(req) + // Process the item + ls := item.ls + if ls == nil { + // Get it now + ls = s.session.GetLanguageServiceForProjectWithFile(ctx, item.project, item.Uri) + if ls == nil { + return + } + } + originalNode, symbolsAndEntries, ok := ls.ProvideSymbolsAndEntries(ctx, item.Uri, item.Position, info.Method == lsproto.MethodTextDocumentRename) + if ok { + for _, entry := range symbolsAndEntries { + // Find the default definition that can be in another project + // Later we will use this load ancestor tree that references this location and expand search + if item.project == defaultProject && defaultDefinition == nil { + defaultDefinition = ls.GetNonLocalDefinition(ctx, entry) + } + ls.ForEachOriginalDefinitionLocation(ctx, entry, func(uri lsproto.DocumentUri, position lsproto.Position) { + // Get default configured project for this file + defProjects, errProjects := s.session.GetProjectsForFile(ctx, uri) + if errProjects != nil { + return + } + for _, defProject := range defProjects { + // Optimization: don't enqueue if will be discarded + if canSearchProject(defProject) { + enqueueItem(projectAndTextDocumentPosition{ + project: defProject, + Uri: uri, + Position: position, + forOriginalLocation: true, + }) + } + } + }) + } + } + + if result, errSearch := fn(s, ctx, ls, params, originalNode, symbolsAndEntries); errSearch == nil { + response.complete = true + response.result = result + response.forOriginalLocation = item.forOriginalLocation + } else { + errMu.Lock() + defer errMu.Unlock() + if err != nil { + err = errSearch + } + } + }) + } + + // Initial set of projects and locations in the queue, starting with default project + enqueueItem(projectAndTextDocumentPosition{ + project: defaultProject, + ls: defaultLs, + Uri: params.TextDocumentURI(), + Position: params.TextDocumentPosition(), + }) + for _, project := range allProjects { + if project != defaultProject { + enqueueItem(projectAndTextDocumentPosition{ + project: project, + // TODO!! symlinks need to change the URI + Uri: params.TextDocumentURI(), + Position: params.TextDocumentPosition(), + }) + } + } + + getResultsIterator := func() iter.Seq[Resp] { + return func(yield func(Resp) bool) { + var seenProjects collections.SyncSet[tspath.Path] + if response, loaded := results.Load(defaultProject.Id()); loaded && response.complete { + if !yield(response.result) { + return + } + } + seenProjects.Add(defaultProject.Id()) + for _, project := range allProjects { + if seenProjects.AddIfAbsent(project.Id()) { + if response, loaded := results.Load(project.Id()); loaded && response.complete { + if !yield(response.result) { + return + } + } + } + } + // Prefer the searches from locations for default definition + results.Range(func(key tspath.Path, response *response[Resp]) bool { + if !response.forOriginalLocation && seenProjects.AddIfAbsent(key) && response.complete { + return yield(response.result) + } + return true + }) + // Then the searches from original locations + results.Range(func(key tspath.Path, response *response[Resp]) bool { + if response.forOriginalLocation && seenProjects.AddIfAbsent(key) && response.complete { + return yield(response.result) + } + return true + }) + } + } + + // Outer loop - to complete work if more is added after completing existing queue + for { + // Process existing known projects first + wg.RunAndWait() + if ctx.Err() != nil { + return ctx.Err() + } + // No need to use mu here since we are not in parallel at this point + if err != nil { + return err + } + + wg = core.NewWorkGroup(false) + hasMoreWork := false + if defaultDefinition != nil { + requestedProjectTrees := make(map[tspath.Path]struct{}) + results.Range(func(key tspath.Path, response *response[Resp]) bool { + if response.complete { + requestedProjectTrees[key] = struct{}{} + } + return true + }) + + // Load more projects based on default definition found + for _, loadedProject := range s.session.GetSnapshotLoadingProjectTree(ctx, requestedProjectTrees).ProjectCollection.Projects() { + if ctx.Err() != nil { + return ctx.Err() + } + + // Can loop forever without this (enqueue here, dequeue above, repeat) + if !canSearchProject(loadedProject) || loadedProject.GetProgram() == nil { + continue + } + + // Enqueue the project and location for further processing + if loadedProject.HasFile(defaultDefinition.TextDocumentURI().FileName()) { + enqueueItem(projectAndTextDocumentPosition{ + project: loadedProject, + Uri: defaultDefinition.TextDocumentURI(), + Position: defaultDefinition.TextDocumentPosition(), + }) + hasMoreWork = true + } else if sourcePos := defaultDefinition.GetSourcePosition(); sourcePos != nil && loadedProject.HasFile(sourcePos.TextDocumentURI().FileName()) { + enqueueItem(projectAndTextDocumentPosition{ + project: loadedProject, + Uri: sourcePos.TextDocumentURI(), + Position: sourcePos.TextDocumentPosition(), + }) + hasMoreWork = true + } else if generatedPos := defaultDefinition.GetGeneratedPosition(); generatedPos != nil && loadedProject.HasFile(generatedPos.TextDocumentURI().FileName()) { + enqueueItem(projectAndTextDocumentPosition{ + project: loadedProject, + Uri: generatedPos.TextDocumentURI(), + Position: generatedPos.TextDocumentPosition(), + }) + hasMoreWork = true + } + } + } + if !hasMoreWork { + break + } + } + + var resp Resp + if results.Size() > 1 { + resp = combineResults(getResultsIterator()) + } else { + // Single result, return that directly + for value := range getResultsIterator() { + resp = value + break + } + } + + s.sendResult(req.ID, resp) + return nil + } +} + func (s *Server) recover(req *lsproto.RequestMessage) { if r := recover(); r != nil { stack := debug.Stack() @@ -555,20 +851,22 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ } s.initializeParams = params + s.clientCapabilities = resolveClientCapabilities(params.Capabilities) + + if _, err := fmt.Fprint(s.stderr, "Resolved client capabilities: "); err != nil { + return nil, err + } + if err := jsonutil.MarshalIndentWrite(s.stderr, &s.clientCapabilities, "", "\t"); err != nil { + return nil, err + } s.positionEncoding = lsproto.PositionEncodingKindUTF16 - if genCapabilities := s.initializeParams.Capabilities.General; genCapabilities != nil && genCapabilities.PositionEncodings != nil { - if slices.Contains(*genCapabilities.PositionEncodings, lsproto.PositionEncodingKindUTF8) { - s.positionEncoding = lsproto.PositionEncodingKindUTF8 - } + if slices.Contains(s.clientCapabilities.General.PositionEncodings, lsproto.PositionEncodingKindUTF8) { + s.positionEncoding = lsproto.PositionEncodingKindUTF8 } if s.initializeParams.Locale != nil { - locale, err := language.Parse(*s.initializeParams.Locale) - if err != nil { - return nil, err - } - s.locale = locale + s.locale, _ = locale.Parse(*s.initializeParams.Locale) } if s.initializeParams.Trace != nil && *s.initializeParams.Trace == "verbose" { @@ -641,6 +939,19 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ DocumentHighlightProvider: &lsproto.BooleanOrDocumentHighlightOptions{ Boolean: ptrTo(true), }, + SelectionRangeProvider: &lsproto.BooleanOrSelectionRangeOptionsOrSelectionRangeRegistrationOptions{ + Boolean: ptrTo(true), + }, + InlayHintProvider: &lsproto.BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions{ + Boolean: ptrTo(true), + }, + CodeActionProvider: &lsproto.BooleanOrCodeActionOptions{ + CodeActionOptions: &lsproto.CodeActionOptions{ + CodeActionKinds: &[]lsproto.CodeActionKind{ + lsproto.CodeActionKindQuickFix, + }, + }, + }, }, } @@ -648,15 +959,12 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ } func (s *Server) handleInitialized(ctx context.Context, params *lsproto.InitializedParams) error { - if shouldEnableWatch(s.initializeParams) { + if s.clientCapabilities.Workspace.DidChangeWatchedFiles.DynamicRegistration { s.watchEnabled = true } cwd := s.cwd - if s.initializeParams.Capabilities != nil && - s.initializeParams.Capabilities.Workspace != nil && - s.initializeParams.Capabilities.Workspace.WorkspaceFolders != nil && - ptrIsTrue(s.initializeParams.Capabilities.Workspace.WorkspaceFolders) && + if s.clientCapabilities.Workspace.WorkspaceFolders && s.initializeParams.WorkspaceFolders != nil && s.initializeParams.WorkspaceFolders.WorkspaceFolders != nil && len(*s.initializeParams.WorkspaceFolders.WorkspaceFolders) == 1 { @@ -670,16 +978,25 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali cwd = s.cwd } + var disablePushDiagnostics bool + if s.initializeParams != nil && s.initializeParams.InitializationOptions != nil { + if s.initializeParams.InitializationOptions.DisablePushDiagnostics != nil { + disablePushDiagnostics = *s.initializeParams.InitializationOptions.DisablePushDiagnostics + } + } + s.session = project.NewSession(&project.SessionInit{ Options: &project.SessionOptions{ - CurrentDirectory: cwd, - DefaultLibraryPath: s.defaultLibraryPath, - TypingsLocation: s.typingsLocation, - PositionEncoding: s.positionEncoding, - WatchEnabled: s.watchEnabled, - LoggingEnabled: true, - DebounceDelay: 500 * time.Millisecond, - MakeHost: project.NewProjectHost, + CurrentDirectory: cwd, + DefaultLibraryPath: s.defaultLibraryPath, + TypingsLocation: s.typingsLocation, + PositionEncoding: s.positionEncoding, + WatchEnabled: s.watchEnabled, + LoggingEnabled: true, + DebounceDelay: 500 * time.Millisecond, + PushDiagnosticsEnabled: !disablePushDiagnostics, + Locale: s.locale, + MakeHost: project.NewProjectHost, }, FS: s.fs, Logger: s.logger, @@ -687,7 +1004,36 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali NpmExecutor: s, ParseCache: s.parseCache, }) - // !!! temporary; remove when we have `handleDidChangeConfiguration`/implicit project config support + + userPreferences, err := s.RequestConfiguration(ctx) + if err != nil { + return err + } + s.session.InitializeWithConfig(userPreferences) + + _, err = sendClientRequest(ctx, s, lsproto.ClientRegisterCapabilityInfo, &lsproto.RegistrationParams{ + Registrations: []*lsproto.Registration{ + { + Id: "typescript-config-watch-id", + Method: string(lsproto.MethodWorkspaceDidChangeConfiguration), + RegisterOptions: &lsproto.RegisterOptions{ + DidChangeConfiguration: &lsproto.DidChangeConfigurationRegistrationOptions{ + Section: &lsproto.StringOrStrings{ + // !!! Both the 'javascript' and 'js/ts' scopes need to be watched for settings as well. + Strings: &[]string{"typescript"}, + }, + }, + }, + }, + }, + }) + if err != nil { + return fmt.Errorf("failed to register configuration change watcher: %w", err) + } + + // !!! temporary. + // Remove when we have `handleDidChangeConfiguration`/implicit project config support + // derived from 'js/ts.implicitProjectConfig.*'. if s.compilerOptionsForInferredProjects != nil { s.session.DidChangeCompilerOptionsForInferredProjects(ctx, s.compilerOptionsForInferredProjects) } @@ -704,6 +1050,21 @@ func (s *Server) handleExit(ctx context.Context, params any) error { return io.EOF } +func (s *Server) handleDidChangeWorkspaceConfiguration(ctx context.Context, params *lsproto.DidChangeConfigurationParams) error { + settings, ok := params.Settings.(map[string]any) + if !ok { + return nil + } + // !!! Both the 'javascript' and 'js/ts' scopes need to be checked for settings as well. + tsSettings := settings["typescript"] + userPreferences := s.session.UserPreferences() + if parsed := userPreferences.Parse(tsSettings); parsed != nil { + userPreferences = parsed + } + s.session.Configure(userPreferences) + return nil +} + func (s *Server) handleDidOpen(ctx context.Context, params *lsproto.DidOpenTextDocumentParams) error { s.session.DidOpenFile(ctx, params.TextDocument.Uri, params.TextDocument.Version, params.TextDocument.Text, params.TextDocument.LanguageId) return nil @@ -758,8 +1119,6 @@ func (s *Server) handleSignatureHelp(ctx context.Context, languageService *ls.La params.TextDocument.Uri, params.Position, params.Context, - s.initializeParams.Capabilities.TextDocument.SignatureHelp, - &ls.UserPreferences{}, ) } @@ -771,9 +1130,25 @@ func (s *Server) handleTypeDefinition(ctx context.Context, ls *ls.LanguageServic return ls.ProvideTypeDefinition(ctx, params.TextDocument.Uri, params.Position) } -func (s *Server) handleReferences(ctx context.Context, ls *ls.LanguageService, params *lsproto.ReferenceParams) (lsproto.ReferencesResponse, error) { +func (s *Server) handleReferences(ctx context.Context, ls *ls.LanguageService, params *lsproto.ReferenceParams, originalNode *ast.Node, symbolAndEntries []*ls.SymbolAndEntries) (lsproto.ReferencesResponse, error) { // findAllReferences - return ls.ProvideReferences(ctx, params) + return ls.ProvideReferencesFromSymbolAndEntries(ctx, params, originalNode, symbolAndEntries) +} + +func combineReferences(results iter.Seq[lsproto.ReferencesResponse]) lsproto.ReferencesResponse { + var combined []lsproto.Location + var seenLocations collections.Set[lsproto.Location] + for resp := range results { + if resp.Locations != nil { + for _, loc := range *resp.Locations { + if !seenLocations.Has(loc) { + seenLocations.Add(loc) + combined = append(combined, loc) + } + } + } + } + return lsproto.LocationsOrNull{Locations: &combined} } func (s *Server) handleImplementations(ctx context.Context, ls *ls.LanguageService, params *lsproto.ImplementationParams) (lsproto.ImplementationResponse, error) { @@ -782,25 +1157,17 @@ func (s *Server) handleImplementations(ctx context.Context, ls *ls.LanguageServi } func (s *Server) handleCompletion(ctx context.Context, languageService *ls.LanguageService, params *lsproto.CompletionParams) (lsproto.CompletionResponse, error) { - // !!! get user preferences return languageService.ProvideCompletion( ctx, params.TextDocument.Uri, params.Position, params.Context, - getCompletionClientCapabilities(s.initializeParams), - &ls.UserPreferences{ - IncludeCompletionsForModuleExports: core.TSTrue, - IncludeCompletionsForImportStatements: core.TSTrue, - }) + ) } func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsproto.CompletionItem, reqMsg *lsproto.RequestMessage) (lsproto.CompletionResolveResponse, error) { - data, err := ls.GetCompletionItemData(params) - if err != nil { - return nil, err - } - languageService, err := s.session.GetLanguageService(ctx, ls.FileNameToDocumentURI(data.FileName)) + data := params.Data + languageService, err := s.session.GetLanguageService(ctx, lsconv.FileNameToDocumentURI(data.FileName)) if err != nil { return nil, err } @@ -809,11 +1176,6 @@ func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsprot ctx, params, data, - getCompletionClientCapabilities(s.initializeParams), - &ls.UserPreferences{ - IncludeCompletionsForModuleExports: core.TSTrue, - IncludeCompletionsForImportStatements: core.TSTrue, - }, ) } @@ -845,25 +1207,85 @@ func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, ls *ls.Language } func (s *Server) handleWorkspaceSymbol(ctx context.Context, params *lsproto.WorkspaceSymbolParams, reqMsg *lsproto.RequestMessage) (lsproto.WorkspaceSymbolResponse, error) { - snapshot, release := s.session.Snapshot() - defer release() + snapshot := s.session.GetSnapshotLoadingProjectTree(ctx, nil) defer s.recover(reqMsg) + programs := core.Map(snapshot.ProjectCollection.Projects(), (*project.Project).GetProgram) - return ls.ProvideWorkspaceSymbols(ctx, programs, snapshot.Converters(), params.Query) + return ls.ProvideWorkspaceSymbols( + ctx, + programs, + snapshot.Converters(), + snapshot.UserPreferences(), + params.Query) } func (s *Server) handleDocumentSymbol(ctx context.Context, ls *ls.LanguageService, params *lsproto.DocumentSymbolParams) (lsproto.DocumentSymbolResponse, error) { return ls.ProvideDocumentSymbols(ctx, params.TextDocument.Uri) } -func (s *Server) handleRename(ctx context.Context, ls *ls.LanguageService, params *lsproto.RenameParams) (lsproto.RenameResponse, error) { - return ls.ProvideRename(ctx, params) +func (s *Server) handleRename(ctx context.Context, ls *ls.LanguageService, params *lsproto.RenameParams, originalNode *ast.Node, symbolAndEntries []*ls.SymbolAndEntries) (lsproto.RenameResponse, error) { + return ls.ProvideRenameFromSymbolAndEntries(ctx, params, originalNode, symbolAndEntries) +} + +func combineRenameResponse(results iter.Seq[lsproto.RenameResponse]) lsproto.RenameResponse { + combined := make(map[lsproto.DocumentUri][]*lsproto.TextEdit) + seenChanges := make(map[lsproto.DocumentUri]*collections.Set[lsproto.Range]) + // !!! this is not used any more so we will skip this part of deduplication and combining + // DocumentChanges *[]TextDocumentEditOrCreateFileOrRenameFileOrDeleteFile `json:"documentChanges,omitzero"` + // ChangeAnnotations *map[string]*ChangeAnnotation `json:"changeAnnotations,omitzero"` + + for resp := range results { + if resp.WorkspaceEdit != nil && resp.WorkspaceEdit.Changes != nil { + for doc, changes := range *resp.WorkspaceEdit.Changes { + seenSet, ok := seenChanges[doc] + if !ok { + seenSet = &collections.Set[lsproto.Range]{} + seenChanges[doc] = seenSet + } + changesForDoc, exists := combined[doc] + if !exists { + changesForDoc = []*lsproto.TextEdit{} + } + for _, change := range changes { + if !seenSet.Has(change.Range) { + seenSet.Add(change.Range) + changesForDoc = append(changesForDoc, change) + } + } + combined[doc] = changesForDoc + } + } + } + if len(combined) > 0 { + return lsproto.RenameResponse{ + WorkspaceEdit: &lsproto.WorkspaceEdit{ + Changes: &combined, + }, + } + } + return lsproto.RenameResponse{} } func (s *Server) handleDocumentHighlight(ctx context.Context, ls *ls.LanguageService, params *lsproto.DocumentHighlightParams) (lsproto.DocumentHighlightResponse, error) { return ls.ProvideDocumentHighlights(ctx, params.TextDocument.Uri, params.Position) } +func (s *Server) handleSelectionRange(ctx context.Context, ls *ls.LanguageService, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { + return ls.ProvideSelectionRanges(ctx, params) +} + +func (s *Server) handleCodeAction(ctx context.Context, ls *ls.LanguageService, params *lsproto.CodeActionParams) (lsproto.CodeActionResponse, error) { + return ls.ProvideCodeActions(ctx, params) +} + +func (s *Server) handleInlayHint( + ctx context.Context, + languageService *ls.LanguageService, + params *lsproto.InlayHintParams, +) (lsproto.InlayHintResponse, error) { + return languageService.ProvideInlayHint(ctx, params) +} + func (s *Server) Log(msg ...any) { fmt.Fprintln(s.stderr, msg...) } @@ -878,9 +1300,7 @@ func (s *Server) SetCompilerOptionsForInferredProjects(ctx context.Context, opti // NpmInstall implements ata.NpmExecutor func (s *Server) NpmInstall(cwd string, args []string) ([]byte, error) { - cmd := exec.Command("npm", args...) - cmd.Dir = cwd - return cmd.Output() + return s.npmInstall(cwd, args) } func isBlockingMethod(method lsproto.Method) bool { @@ -891,7 +1311,9 @@ func isBlockingMethod(method lsproto.Method) bool { lsproto.MethodTextDocumentDidChange, lsproto.MethodTextDocumentDidSave, lsproto.MethodTextDocumentDidClose, - lsproto.MethodWorkspaceDidChangeWatchedFiles: + lsproto.MethodWorkspaceDidChangeWatchedFiles, + lsproto.MethodWorkspaceDidChangeConfiguration, + lsproto.MethodWorkspaceConfiguration: return true } return false @@ -901,24 +1323,28 @@ func ptrTo[T any](v T) *T { return &v } -func ptrIsTrue(v *bool) bool { - if v == nil { - return false - } - return *v -} +func resolveClientCapabilities(caps *lsproto.ClientCapabilities) lsproto.ResolvedClientCapabilities { + resolved := lsproto.ResolveClientCapabilities(caps) -func shouldEnableWatch(params *lsproto.InitializeParams) bool { - if params == nil || params.Capabilities == nil || params.Capabilities.Workspace == nil { - return false + // Some clients claim that push and pull diagnostics have different capabilities, + // including vscode-languageclient v9. Work around this by defaulting any missing + // pull diagnostic caps with the pull diagnostic equivalents. + // + // TODO: remove when we upgrade to vscode-languageclient v10, which fixes this issue. + publish := resolved.TextDocument.PublishDiagnostics + diagnostic := &resolved.TextDocument.Diagnostic + if !diagnostic.RelatedInformation && publish.RelatedInformation { + diagnostic.RelatedInformation = true } - return params.Capabilities.Workspace.DidChangeWatchedFiles != nil && - ptrIsTrue(params.Capabilities.Workspace.DidChangeWatchedFiles.DynamicRegistration) -} - -func getCompletionClientCapabilities(params *lsproto.InitializeParams) *lsproto.CompletionClientCapabilities { - if params == nil || params.Capabilities == nil || params.Capabilities.TextDocument == nil { - return nil + if !diagnostic.CodeDescriptionSupport && publish.CodeDescriptionSupport { + diagnostic.CodeDescriptionSupport = true + } + if !diagnostic.DataSupport && publish.DataSupport { + diagnostic.DataSupport = true } - return params.Capabilities.TextDocument.Completion + if len(diagnostic.TagSupport.ValueSet) == 0 && len(publish.TagSupport.ValueSet) > 0 { + diagnostic.TagSupport.ValueSet = publish.TagSupport.ValueSet + } + + return resolved } diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 56a94cec74..00c72852b3 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -42,16 +42,21 @@ func unresolved() *resolved { type resolutionKindSpecificLoader = func(extensions extensions, candidate string, onlyRecordFailures bool) *resolved type tracer struct { - traces []string + traces []DiagAndArgs } -func (t *tracer) write(msg string) { +type DiagAndArgs struct { + Message *diagnostics.Message + Args []any +} + +func (t *tracer) write(diag *diagnostics.Message, args ...any) { if t != nil { - t.traces = append(t.traces, msg) + t.traces = append(t.traces, DiagAndArgs{Message: diag, Args: args}) } } -func (t *tracer) getTraces() []string { +func (t *tracer) getTraces() []DiagAndArgs { if t != nil { return t.traces } @@ -143,8 +148,8 @@ func GetCompilerOptionsWithRedirect(compilerOptions *core.CompilerOptions, redir } type ResolverInterface interface { - ResolveModuleName(moduleName string, containingFile string, kind *string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedModule, []string) - ResolveTypeReferenceDirective(typeReferenceDirectiveName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedTypeReferenceDirective, []string) + ResolveModuleName(moduleName string, containingFile string, importAttributeType *string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedModule, []DiagAndArgs) + ResolveTypeReferenceDirective(typeReferenceDirectiveName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedTypeReferenceDirective, []DiagAndArgs) GetPackageJsonScopeIfApplicable(path string) *packagejson.InfoCacheEntry GetPackageScopeForPath(directory string) *packagejson.InfoCacheEntry GetImpliedNodeFormatForFile(path string, packageJsonType string) core.ModuleKind @@ -202,7 +207,7 @@ func (r *Resolver) GetPackageJsonScopeIfApplicable(path string) *packagejson.Inf func (r *tracer) traceResolutionUsingProjectReference(redirectedReference ResolvedProjectReference) { if redirectedReference != nil && redirectedReference.CompilerOptions() != nil { - r.write(diagnostics.Using_compiler_options_of_project_reference_redirect_0.Format(redirectedReference.ConfigName())) + r.write(diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.ConfigName()) } } @@ -211,7 +216,7 @@ func (r *Resolver) ResolveTypeReferenceDirective( containingFile string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference, -) (*ResolvedTypeReferenceDirective, []string) { +) (*ResolvedTypeReferenceDirective, []DiagAndArgs) { traceBuilder := r.newTraceBuilder() compilerOptions := GetCompilerOptionsWithRedirect(r.compilerOptions, redirectedReference) @@ -219,7 +224,7 @@ func (r *Resolver) ResolveTypeReferenceDirective( typeRoots, fromConfig := compilerOptions.GetEffectiveTypeRoots(r.host.GetCurrentDirectory()) if traceBuilder != nil { - traceBuilder.write(diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2.Format(typeReferenceDirectiveName, containingFile, strings.Join(typeRoots, ","))) + traceBuilder.write(diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, strings.Join(typeRoots, ",")) traceBuilder.traceResolutionUsingProjectReference(redirectedReference) } @@ -232,24 +237,23 @@ func (r *Resolver) ResolveTypeReferenceDirective( return result, traceBuilder.getTraces() } -func (r *Resolver) ResolveModuleName(moduleName string, containingFile string, kind *string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedModule, []string) { +func (r *Resolver) ResolveModuleName(moduleName string, containingFile string, importAttributeType *string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedModule, []DiagAndArgs) { traceBuilder := r.newTraceBuilder() compilerOptions := GetCompilerOptionsWithRedirect(r.compilerOptions, redirectedReference) if traceBuilder != nil { - traceBuilder.write(diagnostics.Resolving_module_0_from_1.Format(moduleName, containingFile)) + traceBuilder.write(diagnostics.Resolving_module_0_from_1, moduleName, containingFile) traceBuilder.traceResolutionUsingProjectReference(redirectedReference) } containingDirectory := tspath.GetDirectoryPath(containingFile) - moduleResolution := compilerOptions.ModuleResolution - if moduleResolution == core.ModuleResolutionKindUnknown { - moduleResolution = compilerOptions.GetModuleResolutionKind() + moduleResolution := compilerOptions.GetModuleResolutionKind() + if compilerOptions.ModuleResolution != moduleResolution { if traceBuilder != nil { - traceBuilder.write(diagnostics.Module_resolution_kind_is_not_specified_using_0.Format(moduleResolution.String())) + traceBuilder.write(diagnostics.Module_resolution_kind_is_not_specified_using_0, moduleResolution.String()) } } else { if traceBuilder != nil { - traceBuilder.write(diagnostics.Explicitly_specified_module_resolution_kind_Colon_0.Format(moduleResolution.String())) + traceBuilder.write(diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, moduleResolution.String()) } } @@ -265,12 +269,12 @@ func (r *Resolver) ResolveModuleName(moduleName string, containingFile string, k if traceBuilder != nil { if result.IsResolved() { if result.PackageId.Name != "" { - traceBuilder.write(diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2.Format(moduleName, result.ResolvedFileName, result.PackageId.String())) + traceBuilder.write(diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.ResolvedFileName, result.PackageId.String()) } else { - traceBuilder.write(diagnostics.Module_name_0_was_successfully_resolved_to_1.Format(moduleName, result.ResolvedFileName)) + traceBuilder.write(diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.ResolvedFileName) } } else { - traceBuilder.write(diagnostics.Module_name_0_was_not_resolved.Format(moduleName)) + traceBuilder.write(diagnostics.Module_name_0_was_not_resolved, moduleName) } } @@ -299,7 +303,7 @@ func (r *Resolver) tryResolveFromTypingsLocation(moduleName string, containingDi traceBuilder, ) if traceBuilder != nil { - traceBuilder.write(diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2.Format(r.projectName, moduleName, r.typingsLocation)) + traceBuilder.write(diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, r.projectName, moduleName, r.typingsLocation) } globalResolved := state.loadModuleFromImmediateNodeModulesDirectory(extensionsDeclaration, r.typingsLocation, false) if globalResolved == nil { @@ -322,20 +326,20 @@ func (r *Resolver) resolveConfig(moduleName string, containingFile string) *Reso func (r *tracer) traceTypeReferenceDirectiveResult(typeReferenceDirectiveName string, result *ResolvedTypeReferenceDirective) { if !result.IsResolved() { - r.write(diagnostics.Type_reference_directive_0_was_not_resolved.Format(typeReferenceDirectiveName)) + r.write(diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName) } else if result.PackageId.Name != "" { - r.write(diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3.Format( + r.write(diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.ResolvedFileName, result.PackageId.String(), result.Primary, - )) + ) } else { - r.write(diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2.Format( + r.write(diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.ResolvedFileName, result.Primary, - )) + ) } } @@ -343,13 +347,13 @@ func (r *resolutionState) resolveTypeReferenceDirective(typeRoots []string, from // Primary lookup if len(typeRoots) > 0 { if r.tracer != nil { - r.tracer.write(diagnostics.Resolving_with_primary_search_path_0.Format(strings.Join(typeRoots, ", "))) + r.tracer.write(diagnostics.Resolving_with_primary_search_path_0, strings.Join(typeRoots, ", ")) } for _, typeRoot := range typeRoots { candidate := r.getCandidateFromTypeRoot(typeRoot) directoryExists := r.resolver.host.FS().DirectoryExists(candidate) if !directoryExists && r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(typeRoot)) + r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot) } if fromConfig { // Custom typeRoots resolve as file or directory just like we do modules @@ -366,14 +370,14 @@ func (r *resolutionState) resolveTypeReferenceDirective(typeRoots []string, from } } } else if r.tracer != nil { - r.tracer.write(diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths.Format()) + r.tracer.write(diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths) } // Secondary lookup var resolved *resolved if !fromConfig || !fromInferredTypesContainingFile { if r.tracer != nil { - r.tracer.write(diagnostics.Looking_up_in_node_modules_folder_initial_location_0.Format(r.containingDirectory)) + r.tracer.write(diagnostics.Looking_up_in_node_modules_folder_initial_location_0, r.containingDirectory) } if !tspath.IsExternalModuleNameRelative(r.name) { resolved = r.loadModuleFromNearestNodeModulesDirectory(false /*typesScopeOnly*/) @@ -382,7 +386,7 @@ func (r *resolutionState) resolveTypeReferenceDirective(typeRoots []string, from resolved = r.nodeLoadModuleByRelativeName(extensionsDeclaration, candidate, false /*onlyRecordFailures*/, true /*considerPackageJson*/) } } else if r.tracer != nil { - r.tracer.write(diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder.Format()) + r.tracer.write(diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder) } return r.createResolvedTypeReferenceDirective(resolved, false /*primary*/) } @@ -398,7 +402,7 @@ func (r *resolutionState) getCandidateFromTypeRoot(typeRoot string) string { func (r *resolutionState) mangleScopedPackageName(name string) string { mangled := MangleScopedPackageName(name) if r.tracer != nil && mangled != name { - r.tracer.write(diagnostics.Scoped_package_detected_looking_in_0.Format(mangled)) + r.tracer.write(diagnostics.Scoped_package_detected_looking_in_0, mangled) } return mangled } @@ -421,9 +425,9 @@ func (r *resolutionState) resolveNodeLike() *ResolvedModule { if r.tracer != nil { conditions := strings.Join(core.Map(r.conditions, func(c string) string { return `'` + c + `'` }), ", ") if r.esmMode { - r.tracer.write(diagnostics.Resolving_in_0_mode_with_conditions_1.Format("ESM", conditions)) + r.tracer.write(diagnostics.Resolving_in_0_mode_with_conditions_1, "ESM", conditions) } else { - r.tracer.write(diagnostics.Resolving_in_0_mode_with_conditions_1.Format("CJS", conditions)) + r.tracer.write(diagnostics.Resolving_in_0_mode_with_conditions_1, "CJS", conditions) } } result := r.resolveNodeLikeWorker() @@ -437,7 +441,7 @@ func (r *resolutionState) resolveNodeLike() *ResolvedModule { !extensionIsOk(extensionsTypeScript|extensionsDeclaration, result.Extension) && slices.Contains(r.conditions, "import") { if r.tracer != nil { - r.tracer.write(diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update.Format()) + r.tracer.write(diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update) } r.features = r.features & ^NodeResolutionFeaturesExports r.extensions = r.extensions & (extensionsTypeScript | extensionsDeclaration) @@ -468,12 +472,12 @@ func (r *resolutionState) resolveNodeLikeWorker() *ResolvedModule { } if strings.Contains(r.name, ":") { if r.tracer != nil { - r.tracer.write(diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1.Format(r.name, r.extensions.String())) + r.tracer.write(diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1, r.name, r.extensions.String()) } return r.createResolvedModule(nil, false) } if r.tracer != nil { - r.tracer.write(diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1.Format(r.name, r.extensions.String())) + r.tracer.write(diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1, r.name, r.extensions.String()) } if resolved := r.loadModuleFromNearestNodeModulesDirectory(false /*typesScopeOnly*/); !resolved.shouldContinueSearching() { return r.createResolvedModuleHandlingSymlink(resolved) @@ -545,7 +549,7 @@ func (r *resolutionState) loadModuleFromSelfNameReference() *resolved { func (r *resolutionState) loadModuleFromImports() *resolved { if r.name == "#" || strings.HasPrefix(r.name, "#/") { if r.tracer != nil { - r.tracer.write(diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions.Format(r.name)) + r.tracer.write(diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, r.name) } return continueSearching() } @@ -553,7 +557,7 @@ func (r *resolutionState) loadModuleFromImports() *resolved { scope := r.getPackageScopeForPath(directoryPath) if !scope.Exists() { if r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve.Format(directoryPath)) + r.tracer.write(diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath) } return continueSearching() } @@ -561,7 +565,7 @@ func (r *resolutionState) loadModuleFromImports() *resolved { // !!! Old compiler only checks for undefined, but then assumes `imports` is an object if present. // Maybe should have a new diagnostic for imports of an invalid type. Also, array should be handled? if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_no_imports_defined.Format(scope.PackageDirectory)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_no_imports_defined, scope.PackageDirectory) } return continueSearching() } @@ -571,7 +575,7 @@ func (r *resolutionState) loadModuleFromImports() *resolved { } if r.tracer != nil { - r.tracer.write(diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1.Format(r.name, scope.PackageDirectory)) + r.tracer.write(diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, r.name, scope.PackageDirectory) } return continueSearching() } @@ -604,7 +608,7 @@ func (r *resolutionState) loadModuleFromExports(packageInfo *packagejson.InfoCac } if r.tracer != nil { - r.tracer.write(diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1.Format(subpath, packageInfo.PackageDirectory)) + r.tracer.write(diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, packageInfo.PackageDirectory) } return continueSearching() } @@ -656,7 +660,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio targetString, _ := target.Value.(string) if !isPattern && len(subpath) > 0 && !strings.HasSuffix(targetString, "/") { if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.PackageDirectory, moduleName) } return continueSearching() } @@ -667,8 +671,8 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio combinedLookup = strings.ReplaceAll(targetString, "*", subpath) } if r.tracer != nil { - r.tracer.write(diagnostics.Using_0_subpath_1_with_target_2.Format("imports", key, combinedLookup)) - r.tracer.write(diagnostics.Resolving_module_0_from_1.Format(combinedLookup, scope.PackageDirectory+"/")) + r.tracer.write(diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup) + r.tracer.write(diagnostics.Resolving_module_0_from_1, combinedLookup, scope.PackageDirectory+"/") } name, containingDirectory := r.name, r.containingDirectory r.name, r.containingDirectory = combinedLookup, scope.PackageDirectory+"/" @@ -687,7 +691,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio return continueSearching() } if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.PackageDirectory, moduleName) } return continueSearching() } @@ -700,7 +704,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio partsAfterFirst := parts[1:] if slices.Contains(partsAfterFirst, "..") || slices.Contains(partsAfterFirst, ".") || slices.Contains(partsAfterFirst, "node_modules") { if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.PackageDirectory, moduleName) } return continueSearching() } @@ -710,7 +714,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio subpathParts := tspath.GetPathComponents(subpath, "") if slices.Contains(subpathParts, "..") || slices.Contains(subpathParts, ".") || slices.Contains(subpathParts, "node_modules") { if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.PackageDirectory, moduleName) } return continueSearching() } @@ -722,7 +726,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio } else { messageTarget = targetString + subpath } - r.tracer.write(diagnostics.Using_0_subpath_1_with_target_2.Format(core.IfElse(isImports, "imports", "exports"), key, messageTarget)) + r.tracer.write(diagnostics.Using_0_subpath_1_with_target_2, core.IfElse(isImports, "imports", "exports"), key, messageTarget) } var finalPath string if isPattern { @@ -741,39 +745,39 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio case packagejson.JSONValueTypeObject: if r.tracer != nil { - r.tracer.write(diagnostics.Entering_conditional_exports.Format()) + r.tracer.write(diagnostics.Entering_conditional_exports) } for condition := range target.AsObject().Keys() { if r.conditionMatches(condition) { if r.tracer != nil { - r.tracer.write(diagnostics.Matched_0_condition_1.Format(core.IfElse(isImports, "imports", "exports"), condition)) + r.tracer.write(diagnostics.Matched_0_condition_1, core.IfElse(isImports, "imports", "exports"), condition) } subTarget, _ := target.AsObject().Get(condition) if result := r.loadModuleFromTargetExportOrImport(extensions, moduleName, scope, isImports, subTarget, subpath, isPattern, key); !result.shouldContinueSearching() { if r.tracer != nil { - r.tracer.write(diagnostics.Resolved_under_condition_0.Format(condition)) + r.tracer.write(diagnostics.Resolved_under_condition_0, condition) } if r.tracer != nil { - r.tracer.write(diagnostics.Exiting_conditional_exports.Format()) + r.tracer.write(diagnostics.Exiting_conditional_exports) } return result } else if r.tracer != nil { - r.tracer.write(diagnostics.Failed_to_resolve_under_condition_0.Format(condition)) + r.tracer.write(diagnostics.Failed_to_resolve_under_condition_0, condition) } } else { if r.tracer != nil { - r.tracer.write(diagnostics.Saw_non_matching_condition_0.Format(condition)) + r.tracer.write(diagnostics.Saw_non_matching_condition_0, condition) } } } if r.tracer != nil { - r.tracer.write(diagnostics.Exiting_conditional_exports.Format()) + r.tracer.write(diagnostics.Exiting_conditional_exports) } return continueSearching() case packagejson.JSONValueTypeArray: if len(target.AsArray()) == 0 { if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.PackageDirectory, moduleName) } return continueSearching() } @@ -785,13 +789,13 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio case packagejson.JSONValueTypeNull: if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_explicitly_maps_specifier_1_to_null.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.PackageDirectory, moduleName) } return continueSearching() } if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1.Format(scope.PackageDirectory, moduleName)) + r.tracer.write(diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.PackageDirectory, moduleName) } return continueSearching() } @@ -911,7 +915,7 @@ func (r *resolutionState) loadModuleFromNearestNodeModulesDirectory(typesScopeOn // (1) if priorityExtensions != 0 { if r.tracer != nil { - r.tracer.write(diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0.Format(priorityExtensions.String())) + r.tracer.write(diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0, priorityExtensions.String()) } if result := r.loadModuleFromNearestNodeModulesDirectoryWorker(priorityExtensions, mode, typesScopeOnly); !result.shouldContinueSearching() { return result @@ -920,7 +924,7 @@ func (r *resolutionState) loadModuleFromNearestNodeModulesDirectory(typesScopeOn // (2) if secondaryExtensions != 0 && !typesScopeOnly { if r.tracer != nil { - r.tracer.write(diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0.Format(secondaryExtensions.String())) + r.tracer.write(diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0, secondaryExtensions.String()) } return r.loadModuleFromNearestNodeModulesDirectoryWorker(secondaryExtensions, mode, typesScopeOnly) } @@ -946,7 +950,7 @@ func (r *resolutionState) loadModuleFromImmediateNodeModulesDirectory(extensions nodeModulesFolder := tspath.CombinePaths(directory, "node_modules") nodeModulesFolderExists := r.resolver.host.FS().DirectoryExists(nodeModulesFolder) if !nodeModulesFolderExists && r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(nodeModulesFolder)) + r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder) } if !typesScopeOnly { @@ -959,7 +963,7 @@ func (r *resolutionState) loadModuleFromImmediateNodeModulesDirectory(extensions nodeModulesAtTypes := tspath.CombinePaths(nodeModulesFolder, "@types") nodeModulesAtTypesExists := nodeModulesFolderExists && r.resolver.host.FS().DirectoryExists(nodeModulesAtTypes) if !nodeModulesAtTypesExists && r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(nodeModulesAtTypes)) + r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes) } return r.loadModuleFromSpecificNodeModulesDirectory(extensionsDeclaration, r.mangleScopedPackageName(r.name), nodeModulesAtTypes, nodeModulesAtTypesExists) } @@ -1036,7 +1040,7 @@ func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensi versionPaths := packageInfo.Contents.GetVersionPaths(r.getTraceFunc()) if versionPaths.Exists() { if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2.Format(versionPaths.Version, core.Version(), rest)) + r.tracer.write(diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.Version, core.Version(), rest) } packageDirectoryExists := nodeModulesDirectoryExists && r.resolver.host.FS().DirectoryExists(packageDirectory) pathPatterns := TryParsePatterns(versionPaths.GetPaths()) @@ -1151,7 +1155,7 @@ func (r *resolutionState) getParsedPatternsForPaths() *ParsedPatterns { func (r *resolutionState) tryLoadModuleUsingPathsIfEligible() *resolved { if r.compilerOptions.Paths.Size() > 0 && !tspath.PathIsRelative(r.name) { if r.tracer != nil { - r.tracer.write(diagnostics.X_paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0.Format(r.name)) + r.tracer.write(diagnostics.X_paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, r.name) } } else { return continueSearching() @@ -1175,13 +1179,13 @@ func (r *resolutionState) tryLoadModuleUsingPaths(extensions extensions, moduleN if matchedPattern := MatchPatternOrExact(pathPatterns, moduleName); matchedPattern.IsValid() { matchedStar := matchedPattern.MatchedText(moduleName) if r.tracer != nil { - r.tracer.write(diagnostics.Module_name_0_matched_pattern_1.Format(moduleName, matchedPattern.Text)) + r.tracer.write(diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern.Text) } for _, subst := range paths.GetOrZero(matchedPattern.Text) { path := strings.Replace(subst, "*", matchedStar, 1) candidate := tspath.NormalizePath(tspath.CombinePaths(containingDirectory, path)) if r.tracer != nil { - r.tracer.write(diagnostics.Trying_substitution_0_candidate_module_location_Colon_1.Format(subst, path)) + r.tracer.write(diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path) } // A path mapping may have an extension if extension := tspath.TryGetExtensionFromPath(subst); extension != "" { @@ -1206,7 +1210,7 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { } if r.tracer != nil { - r.tracer.write(diagnostics.X_rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0.Format(r.name)) + r.tracer.write(diagnostics.X_rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, r.name) } candidate := tspath.NormalizePath(tspath.CombinePaths(r.containingDirectory, r.name)) @@ -1225,7 +1229,7 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { (matchedNormalizedPrefix == "" || len(matchedNormalizedPrefix) < len(normalizedRoot)) if r.tracer != nil { - r.tracer.write(diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2.Format(normalizedRoot, candidate, isLongestMatchingPrefix)) + r.tracer.write(diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix) } if isLongestMatchingPrefix { @@ -1236,13 +1240,13 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { if matchedNormalizedPrefix != "" { if r.tracer != nil { - r.tracer.write(diagnostics.Longest_matching_prefix_for_0_is_1.Format(candidate, matchedNormalizedPrefix)) + r.tracer.write(diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix) } suffix := candidate[len(matchedNormalizedPrefix):] // first - try to load from a initial location if r.tracer != nil { - r.tracer.write(diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2.Format(suffix, matchedNormalizedPrefix, candidate)) + r.tracer.write(diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate) } loader := func(extensions extensions, candidate string, onlyRecordFailures bool) *resolved { return r.nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, true /*considerPackageJson*/) @@ -1252,7 +1256,7 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { } if r.tracer != nil { - r.tracer.write(diagnostics.Trying_other_entries_in_rootDirs.Format()) + r.tracer.write(diagnostics.Trying_other_entries_in_rootDirs) } // then try to resolve using remaining entries in rootDirs for _, rootDir := range r.compilerOptions.RootDirs { @@ -1262,7 +1266,7 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { } candidate := tspath.CombinePaths(tspath.NormalizePath(rootDir), suffix) if r.tracer != nil { - r.tracer.write(diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2.Format(suffix, rootDir, candidate)) + r.tracer.write(diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate) } baseDirectory := tspath.GetDirectoryPath(candidate) if resolvedFileName := loader(r.extensions, candidate, !r.resolver.host.FS().DirectoryExists(baseDirectory)); !resolvedFileName.shouldContinueSearching() { @@ -1270,7 +1274,7 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { } } if r.tracer != nil { - r.tracer.write(diagnostics.Module_resolution_using_rootDirs_has_failed.Format()) + r.tracer.write(diagnostics.Module_resolution_using_rootDirs_has_failed) } } return continueSearching() @@ -1278,14 +1282,14 @@ func (r *resolutionState) tryLoadModuleUsingRootDirs() *resolved { func (r *resolutionState) nodeLoadModuleByRelativeName(extensions extensions, candidate string, onlyRecordFailures bool, considerPackageJson bool) *resolved { if r.tracer != nil { - r.tracer.write(diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1.Format(candidate, extensions.String())) + r.tracer.write(diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1, candidate, extensions.String()) } if !tspath.HasTrailingDirectorySeparator(candidate) { if !onlyRecordFailures { parentOfCandidate := tspath.GetDirectoryPath(candidate) if !r.resolver.host.FS().DirectoryExists(parentOfCandidate) { if r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(parentOfCandidate)) + r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate) } onlyRecordFailures = true } @@ -1304,7 +1308,7 @@ func (r *resolutionState) nodeLoadModuleByRelativeName(extensions extensions, ca candidateExists := r.resolver.host.FS().DirectoryExists(candidate) if !candidateExists { if r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(candidate)) + r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate) } onlyRecordFailures = true } @@ -1346,7 +1350,7 @@ func (r *resolutionState) loadModuleFromFileNoImplicitExtensions(extensions exte extension := candidate[len(extensionless):] if r.tracer != nil { - r.tracer.write(diagnostics.File_name_0_has_a_1_extension_stripping_it.Format(candidate, extension)) + r.tracer.write(diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension) } return r.tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures) } @@ -1500,11 +1504,11 @@ func (r *resolutionState) tryFileLookup(fileName string, onlyRecordFailures bool if !onlyRecordFailures { if r.resolver.host.FS().FileExists(fileName) { if r.tracer != nil { - r.tracer.write(diagnostics.File_0_exists_use_it_as_a_name_resolution_result.Format(fileName)) + r.tracer.write(diagnostics.File_0_exists_use_it_as_a_name_resolution_result, fileName) } return true } else if r.tracer != nil { - r.tracer.write(diagnostics.File_0_does_not_exist.Format(fileName)) + r.tracer.write(diagnostics.File_0_does_not_exist, fileName) } } r.failedLookupLocations = append(r.failedLookupLocations, fileName) @@ -1576,7 +1580,7 @@ func (r *resolutionState) loadNodeModuleFromDirectoryWorker(ext extensions, cand moduleName = tspath.GetRelativePathFromDirectory(candidate, indexPath, tspath.ComparePathsOptions{}) } if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2.Format(versionPaths.Version, core.Version(), moduleName)) + r.tracer.write(diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.Version, core.Version(), moduleName) } pathPatterns := TryParsePatterns(versionPaths.GetPaths()) if result := r.tryLoadModuleUsingPaths(ext, moduleName, candidate, versionPaths.GetPaths(), pathPatterns, loader, onlyRecordFailuresForPackageFile); !result.shouldContinueSearching() { @@ -1664,7 +1668,7 @@ func (r *resolutionState) getPackageJsonInfo(packageDirectory string, onlyRecord if existing := r.resolver.packageJsonInfoCache.Get(packageJsonPath); existing != nil { if existing.Contents != nil { if r.tracer != nil { - r.tracer.write(diagnostics.File_0_exists_according_to_earlier_cached_lookups.Format(packageJsonPath)) + r.tracer.write(diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath) } r.affectingLocations = append(r.affectingLocations, packageJsonPath) if existing.PackageDirectory == packageDirectory { @@ -1678,7 +1682,7 @@ func (r *resolutionState) getPackageJsonInfo(packageDirectory string, onlyRecord } } else { if existing.DirectoryExists && r.tracer != nil { - r.tracer.write(diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups.Format(packageJsonPath)) + r.tracer.write(diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath) } r.failedLookupLocations = append(r.failedLookupLocations, packageJsonPath) return nil @@ -1689,15 +1693,16 @@ func (r *resolutionState) getPackageJsonInfo(packageDirectory string, onlyRecord if directoryExists && r.resolver.host.FS().FileExists(packageJsonPath) { // Ignore error contents, _ := r.resolver.host.FS().ReadFile(packageJsonPath) - packageJsonContent, _ := packagejson.Parse([]byte(contents)) + packageJsonContent, err := packagejson.Parse([]byte(contents)) if r.tracer != nil { - r.tracer.write(diagnostics.Found_package_json_at_0.Format(packageJsonPath)) + r.tracer.write(diagnostics.Found_package_json_at_0, packageJsonPath) } result := &packagejson.InfoCacheEntry{ PackageDirectory: packageDirectory, DirectoryExists: true, Contents: &packagejson.PackageJson{ - Fields: packageJsonContent, + Fields: packageJsonContent, + Parseable: err == nil, }, } result = r.resolver.packageJsonInfoCache.Set(packageJsonPath, result) @@ -1705,7 +1710,7 @@ func (r *resolutionState) getPackageJsonInfo(packageDirectory string, onlyRecord return result } else { if directoryExists && r.tracer != nil { - r.tracer.write(diagnostics.File_0_does_not_exist.Format(packageJsonPath)) + r.tracer.write(diagnostics.File_0_does_not_exist, packageJsonPath) } _ = r.resolver.packageJsonInfoCache.Set(packageJsonPath, &packagejson.InfoCacheEntry{ PackageDirectory: packageDirectory, @@ -1744,7 +1749,7 @@ func (r *resolutionState) readPackageJsonPeerDependencies(packageJsonInfo *packa return "" } if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_has_a_peerDependencies_field.Message()) + r.tracer.write(diagnostics.X_package_json_has_a_peerDependencies_field) } packageDirectory := r.realPath(packageJsonInfo.PackageDirectory) nodeModulesIndex := strings.LastIndex(packageDirectory, "/node_modules") @@ -1762,10 +1767,10 @@ func (r *resolutionState) readPackageJsonPeerDependencies(packageJsonInfo *packa builder.WriteString("@") builder.WriteString(version) if r.tracer != nil { - r.tracer.write(diagnostics.Found_peerDependency_0_with_1_version.Format(name, version)) + r.tracer.write(diagnostics.Found_peerDependency_0_with_1_version, name, version) } } else if r.tracer != nil { - r.tracer.write(diagnostics.Failed_to_find_peerDependency_0.Format(name)) + r.tracer.write(diagnostics.Failed_to_find_peerDependency_0, name) } } return builder.String() @@ -1774,7 +1779,7 @@ func (r *resolutionState) readPackageJsonPeerDependencies(packageJsonInfo *packa func (r *resolutionState) realPath(path string) string { rp := tspath.NormalizePath(r.resolver.host.FS().Realpath(path)) if r.tracer != nil { - r.tracer.write(diagnostics.Resolving_real_path_for_0_result_1.Format(path, rp)) + r.tracer.write(diagnostics.Resolving_real_path_for_0_result_1, path, rp) } return rp } @@ -1785,11 +1790,11 @@ func (r *resolutionState) validatePackageJSONField(fieldName string, field packa return true } if r.tracer != nil { - r.tracer.write(diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2.Format(fieldName, field.ExpectedJSONType(), field.ActualJSONType())) + r.tracer.write(diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, field.ExpectedJSONType(), field.ActualJSONType()) } } if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_does_not_have_a_0_field.Format(fieldName)) + r.tracer.write(diagnostics.X_package_json_does_not_have_a_0_field, fieldName) } return false } @@ -1800,13 +1805,13 @@ func (r *resolutionState) getPackageJSONPathField(fieldName string, field *packa } if field.Value == "" { if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_had_a_falsy_0_field.Format(fieldName)) + r.tracer.write(diagnostics.X_package_json_had_a_falsy_0_field, fieldName) } return "", false } path := tspath.NormalizePath(tspath.CombinePaths(directory, field.Value)) if r.tracer != nil { - r.tracer.write(diagnostics.X_package_json_has_0_field_1_that_references_2.Format(fieldName, field.Value, path)) + r.tracer.write(diagnostics.X_package_json_has_0_field_1_that_references_2, fieldName, field.Value, path) } return path, true } @@ -1827,7 +1832,7 @@ func (r *resolutionState) conditionMatches(condition string) bool { return false } -func (r *resolutionState) getTraceFunc() func(string) { +func (r *resolutionState) getTraceFunc() func(m *diagnostics.Message, args ...any) { if r.tracer != nil { return r.tracer.write } @@ -1971,11 +1976,11 @@ func matchesPatternWithTrailer(target string, name string) bool { if strings.HasSuffix(target, "*") { return false } - starPos := strings.Index(target, "*") - if starPos == -1 { + before, after, ok := strings.Cut(target, "*") + if !ok { return false } - return strings.HasPrefix(name, target[:starPos]) && strings.HasSuffix(name, target[starPos+1:]) + return strings.HasPrefix(name, before) && strings.HasSuffix(name, after) } /** True if `extension` is one of the supported `extensions`. */ diff --git a/internal/module/resolver_test.go b/internal/module/resolver_test.go deleted file mode 100644 index 6aafa55829..0000000000 --- a/internal/module/resolver_test.go +++ /dev/null @@ -1,398 +0,0 @@ -package module_test - -import ( - "io" - "os" - "path/filepath" - "regexp" - "slices" - "sync" - "testing" - - "github.com/go-json-experiment/json" - "github.com/go-json-experiment/json/jsontext" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/jsonutil" - "github.com/microsoft/typescript-go/internal/module" - "github.com/microsoft/typescript-go/internal/repo" - "github.com/microsoft/typescript-go/internal/testutil/baseline" - "github.com/microsoft/typescript-go/internal/tspath" - "github.com/microsoft/typescript-go/internal/vfs" - "github.com/microsoft/typescript-go/internal/vfs/vfstest" - "gotest.tools/v3/assert" - "gotest.tools/v3/assert/cmp" -) - -var skip = []string{ - "allowJsCrossMonorepoPackage.ts", - "APILibCheck.ts", - "APISample_compile.ts", - "APISample_jsdoc.ts", - "APISample_linter.ts", - "APISample_parseConfig.ts", - "APISample_transform.ts", - "APISample_Watch.ts", - "APISample_watcher.ts", - "APISample_WatchWithDefaults.ts", - "APISample_WatchWithOwnWatchHost.ts", - "bundlerNodeModules1(module=esnext).ts", - "bundlerNodeModules1(module=preserve).ts", - "commonJsExportTypeDeclarationError.ts", - "commonSourceDir5.ts", - "commonSourceDirectory.ts", - "computedEnumMemberSyntacticallyString2(isolatedmodules=false).ts", - "computedEnumMemberSyntacticallyString2(isolatedmodules=true).ts", - "declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.ts", - "declarationEmitForGlobalishSpecifierSymlink.ts", - "declarationEmitForGlobalishSpecifierSymlink2.ts", - "declarationEmitReexportedSymlinkReference.ts", - "declarationEmitReexportedSymlinkReference2.ts", - "declarationEmitReexportedSymlinkReference3.ts", - "declarationEmitSymlinkPaths.ts", - "decoratorMetadataTypeOnlyExport.ts", - "decoratorMetadataTypeOnlyImport.ts", - "enumNoInitializerFollowsNonLiteralInitializer.ts", - "enumWithNonLiteralStringInitializer.ts", - "es6ImportWithJsDocTags.ts", - "importAttributes9.ts", - "importSpecifiers_js.ts", - "importTag17.ts", - "isolatedModulesShadowGlobalTypeNotValue(isolatedmodules=false,verbatimmodulesyntax=false).ts", - "isolatedModulesShadowGlobalTypeNotValue(isolatedmodules=false,verbatimmodulesyntax=true).ts", - "isolatedModulesShadowGlobalTypeNotValue(isolatedmodules=true,verbatimmodulesyntax=false).ts", - "isolatedModulesShadowGlobalTypeNotValue(isolatedmodules=true,verbatimmodulesyntax=true).ts", - "jsDeclarationEmitExportedClassWithExtends.ts", - "jsxNamespaceGlobalReexport.tsx", - "jsxNamespaceGlobalReexportMissingAliasTarget.tsx", - "mergeSymbolReexportedTypeAliasInstantiation.ts", - "mergeSymbolReexportInterface.ts", - "mergeSymbolRexportFunction.ts", - "missingMemberErrorHasShortPath.ts", - "moduleResolutionAsTypeReferenceDirective.ts", - "moduleResolutionAsTypeReferenceDirectiveAmbient.ts", - "moduleResolutionAsTypeReferenceDirectiveScoped.ts", - "moduleResolutionWithSymlinks_notInNodeModules.ts", - "moduleResolutionWithSymlinks_preserveSymlinks.ts", - "moduleResolutionWithSymlinks_referenceTypes.ts", - "moduleResolutionWithSymlinks_withOutDir.ts", - "moduleResolutionWithSymlinks.ts", - "nodeAllowJsPackageSelfName(module=node16).ts", - "nodeAllowJsPackageSelfName(module=nodenext).ts", - "nodeAllowJsPackageSelfName2.ts", - "nodeModulesAllowJsConditionalPackageExports(module=node16).ts", - "nodeModulesAllowJsConditionalPackageExports(module=nodenext).ts", - "nodeModulesAllowJsPackageExports(module=node16).ts", - "nodeModulesAllowJsPackageExports(module=nodenext).ts", - "nodeModulesAllowJsPackageImports(module=node16).ts", - "nodeModulesAllowJsPackageImports(module=nodenext).ts", - "nodeModulesAllowJsPackagePatternExports(module=node16).ts", - "nodeModulesAllowJsPackagePatternExports(module=nodenext).ts", - "nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).ts", - "nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).ts", - "nodeModulesConditionalPackageExports(module=node16).ts", - "nodeModulesConditionalPackageExports(module=nodenext).ts", - "nodeModulesDeclarationEmitWithPackageExports(module=node16).ts", - "nodeModulesDeclarationEmitWithPackageExports(module=nodenext).ts", - "nodeModulesExportsBlocksTypesVersions(module=node16).ts", - "nodeModulesExportsBlocksTypesVersions(module=nodenext).ts", - "nodeModulesImportResolutionIntoExport(module=node16).ts", - "nodeModulesImportResolutionIntoExport(module=nodenext).ts", - "nodeModulesImportResolutionNoCycle(module=node16).ts", - "nodeModulesImportResolutionNoCycle(module=nodenext).ts", - "nodeModulesPackageExports(module=node16).ts", - "nodeModulesPackageExports(module=nodenext).ts", - "nodeModulesPackagePatternExports(module=node16).ts", - "nodeModulesPackagePatternExports(module=nodenext).ts", - "nodeModulesPackagePatternExportsExclude(module=node16).ts", - "nodeModulesPackagePatternExportsExclude(module=nodenext).ts", - "nodeModulesPackagePatternExportsTrailers(module=node16).ts", - "nodeModulesPackagePatternExportsTrailers(module=nodenext).ts", - "nodeNextImportModeImplicitIndexResolution.ts", - "nodeNextImportModeImplicitIndexResolution2.ts", - "nodeNextPackageImportMapRootDir.ts", - "nodeNextPackageSelfNameWithOutDir.ts", - "nodeNextPackageSelfNameWithOutDirDeclDir.ts", - "nodeNextPackageSelfNameWithOutDirDeclDirComposite.ts", - "nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.ts", - "nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.ts", - "nodeNextPackageSelfNameWithOutDirDeclDirRootDir.ts", - "nodeNextPackageSelfNameWithOutDirRootDir.ts", - "resolutionModeImportType1(moduleresolution=bundler).ts", - "resolutionModeImportType1(moduleresolution=node10).ts", - "resolutionModeTypeOnlyImport1(moduleresolution=bundler).ts", - "resolutionModeTypeOnlyImport1(moduleresolution=node10).ts", - "selfNameAndImportsEmitInclusion.ts", - "selfNameModuleAugmentation.ts", - "symbolLinkDeclarationEmitModuleNames.ts", - "symbolLinkDeclarationEmitModuleNamesImportRef.ts", - "symbolLinkDeclarationEmitModuleNamesRootDir.ts", - "symlinkedWorkspaceDependenciesNoDirectLinkGeneratesDeepNonrelativeName.ts", - "symlinkedWorkspaceDependenciesNoDirectLinkGeneratesNonrelativeName.ts", - "symlinkedWorkspaceDependenciesNoDirectLinkOptionalGeneratesNonrelativeName.ts", - "symlinkedWorkspaceDependenciesNoDirectLinkPeerGeneratesNonrelativeName.ts", - "typeGuardNarrowsIndexedAccessOfKnownProperty8.ts", - "typesVersions.ambientModules.ts", - "typesVersions.multiFile.ts", - "typesVersionsDeclarationEmit.ambient.ts", - "typesVersionsDeclarationEmit.multiFile.ts", - "typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.ts", - "typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.ts", -} - -type vfsModuleResolutionHost struct { - mu sync.Mutex - fs vfs.FS - currentDirectory string - traces []string -} - -func fixRoot(path string) string { - rootLength := tspath.GetRootLength(path) - if rootLength == 0 { - return tspath.CombinePaths("/.src", path) - } - return path -} - -func newVFSModuleResolutionHost(files map[string]string, currentDirectory string) *vfsModuleResolutionHost { - fs := make(map[string]string, len(files)) - for name, content := range files { - fs[fixRoot(name)] = content - } - if currentDirectory == "" { - currentDirectory = "/.src" - } else if currentDirectory[0] != '/' { - currentDirectory = "/.src/" + currentDirectory - } - return &vfsModuleResolutionHost{ - fs: vfstest.FromMap(fs, true /*useCaseSensitiveFileNames*/), - currentDirectory: currentDirectory, - } -} - -func (v *vfsModuleResolutionHost) FS() vfs.FS { - return v.fs -} - -// GetCurrentDirectory implements ModuleResolutionHost. -func (v *vfsModuleResolutionHost) GetCurrentDirectory() string { - return v.currentDirectory -} - -// Trace implements ModuleResolutionHost. -func (v *vfsModuleResolutionHost) Trace(msg string) { - v.mu.Lock() - defer v.mu.Unlock() - v.traces = append(v.traces, msg) -} - -type functionCall struct { - call string - args rawArgs - returnValue map[string]any -} -type traceTestCase struct { - name string - currentDirectory string - trace bool - compilerOptions *core.CompilerOptions - files map[string]string - calls []functionCall -} -type rawFile struct { - Name string `json:"name"` - Content string `json:"content"` -} -type rawArgs struct { - // getPackageScopeForPath - Directory string `json:"directory"` - - // resolveModuleName, resolveTypeReferenceDirective - Name string `json:"name"` - ContainingFile string `json:"containingFile"` - CompilerOptions *core.CompilerOptions `json:"compilerOptions"` - ResolutionMode int `json:"resolutionMode"` - RedirectedRef *struct { - SourceFile struct { - FileName string `json:"fileName"` - } `json:"sourceFile"` - CommandLine struct { - CompilerOptions *core.CompilerOptions `json:"options"` - } `json:"commandLine"` - } `json:"redirectedReference"` -} -type rawTest struct { - Test string `json:"test"` - CurrentDirectory string `json:"currentDirectory"` - Trace bool `json:"trace"` - Files []rawFile `json:"files"` - Call string `json:"call"` - Args rawArgs `json:"args"` - Return map[string]any `json:"return"` -} - -var typesVersionsMessageRegex = regexp.MustCompile(`that matches compiler version '[^']+'`) - -func sanitizeTraceOutput(trace string) string { - return typesVersionsMessageRegex.ReplaceAllString(trace, "that matches compiler version '3.1.0-dev'") -} - -type RedirectRef struct { - fileName string - options *core.CompilerOptions -} - -func (r *RedirectRef) ConfigName() string { - return r.fileName -} - -func (r *RedirectRef) CompilerOptions() *core.CompilerOptions { - return r.options -} - -var _ module.ResolvedProjectReference = (*RedirectRef)(nil) - -func doCall(t *testing.T, resolver *module.Resolver, call functionCall, skipLocations bool) { - switch call.call { - case "resolveModuleName", "resolveTypeReferenceDirective": - var redirectedReference module.ResolvedProjectReference - if call.args.RedirectedRef != nil { - redirectedReference = &RedirectRef{ - fileName: call.args.RedirectedRef.SourceFile.FileName, - options: call.args.RedirectedRef.CommandLine.CompilerOptions, - } - } - - errorMessageArgs := []any{call.args.Name, call.args.ContainingFile} - if call.call == "resolveModuleName" { - resolved, _ := resolver.ResolveModuleName(call.args.Name, call.args.ContainingFile, nil, core.ModuleKind(call.args.ResolutionMode), redirectedReference) - assert.Check(t, resolved != nil, "ResolveModuleName should not return nil", errorMessageArgs) - if expectedResolvedModule, ok := call.returnValue["resolvedModule"].(map[string]any); ok { - assert.Check(t, resolved.IsResolved(), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.ResolvedFileName, expectedResolvedModule["resolvedFileName"].(string)), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.Extension, expectedResolvedModule["extension"].(string)), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.ResolvedUsingTsExtension, expectedResolvedModule["resolvedUsingTsExtension"].(bool)), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.IsExternalLibraryImport, expectedResolvedModule["isExternalLibraryImport"].(bool)), errorMessageArgs) - } else { - assert.Check(t, !resolved.IsResolved(), errorMessageArgs) - } - } else { - resolved, _ := resolver.ResolveTypeReferenceDirective(call.args.Name, call.args.ContainingFile, core.ModuleKind(call.args.ResolutionMode), redirectedReference) - assert.Check(t, resolved != nil, "ResolveTypeReferenceDirective should not return nil", errorMessageArgs) - if expectedResolvedTypeReferenceDirective, ok := call.returnValue["resolvedTypeReferenceDirective"].(map[string]any); ok { - assert.Check(t, resolved.IsResolved(), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.ResolvedFileName, expectedResolvedTypeReferenceDirective["resolvedFileName"].(string)), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.Primary, expectedResolvedTypeReferenceDirective["primary"].(bool)), errorMessageArgs) - assert.Check(t, cmp.Equal(resolved.IsExternalLibraryImport, expectedResolvedTypeReferenceDirective["isExternalLibraryImport"].(bool)), errorMessageArgs) - } else { - assert.Check(t, !resolved.IsResolved(), errorMessageArgs) - } - } - case "getPackageScopeForPath": - resolver.GetPackageScopeForPath(call.args.Directory) - default: - t.Errorf("Unexpected call: %s", call.call) - } -} - -func runTraceBaseline(t *testing.T, test traceTestCase) { - t.Run(test.name, func(t *testing.T) { - t.Parallel() - - host := newVFSModuleResolutionHost(test.files, test.currentDirectory) - resolver := module.NewResolver(host, test.compilerOptions, "", "") - - for _, call := range test.calls { - doCall(t, resolver, call, false /*skipLocations*/) - if t.Failed() { - t.FailNow() - } - } - - t.Run("concurrent", func(t *testing.T) { - concurrentHost := newVFSModuleResolutionHost(test.files, test.currentDirectory) - concurrentResolver := module.NewResolver(concurrentHost, test.compilerOptions, "", "") - - var wg sync.WaitGroup - for _, call := range test.calls { - wg.Add(1) - go func() { - defer wg.Done() - doCall(t, concurrentResolver, call, true /*skipLocations*/) - }() - } - - wg.Wait() - }) - - if test.trace { - t.Run("trace", func(t *testing.T) { - output, err := jsonutil.MarshalIndent(resolver, "", " ") - if err != nil { - t.Fatal(err) - } - baseline.Run( - t, - tspath.RemoveFileExtension(test.name)+".trace.json", - sanitizeTraceOutput(string(output)), - baseline.Options{Subfolder: "module/resolver"}, - ) - }) - } - }) -} - -func TestModuleResolver(t *testing.T) { - t.Parallel() - testsFilePath := filepath.Join(repo.TestDataPath, "fixtures", "module", "resolvertests.json") - // Read file one line at a time - file, err := os.Open(testsFilePath) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { - file.Close() - }) - decoder := jsontext.NewDecoder(file) - var currentTestCase traceTestCase - for { - if decoder.PeekKind() == 0 { - _, err := decoder.ReadToken() - if err == io.EOF { //nolint:errorlint - break - } - t.Fatal(err) - } - - var testJSON rawTest - if err := json.UnmarshalDecode(decoder, &testJSON); err != nil { - t.Fatal(err) - } - if testJSON.Files != nil { - if currentTestCase.name != "" && !slices.Contains(skip, currentTestCase.name) { - runTraceBaseline(t, currentTestCase) - } - currentTestCase = traceTestCase{ - name: testJSON.Test, - currentDirectory: testJSON.CurrentDirectory, - // !!! no traces are passing yet because of missing cache implementation - trace: false, - files: make(map[string]string, len(testJSON.Files)), - } - for _, file := range testJSON.Files { - currentTestCase.files[file.Name] = file.Content - } - } else if testJSON.Call != "" { - currentTestCase.calls = append(currentTestCase.calls, functionCall{ - call: testJSON.Call, - args: testJSON.Args, - returnValue: testJSON.Return, - }) - if currentTestCase.compilerOptions == nil && testJSON.Args.CompilerOptions != nil { - currentTestCase.compilerOptions = testJSON.Args.CompilerOptions - } - } else { - t.Fatalf("Unexpected JSON: %v", testJSON) - } - } -} diff --git a/internal/module/util.go b/internal/module/util.go index 7f6d093d05..04f75150f4 100644 --- a/internal/module/util.go +++ b/internal/module/util.go @@ -45,7 +45,7 @@ func ParsePackageName(moduleName string) (packageName, rest string) { } func MangleScopedPackageName(packageName string) string { - if packageName[0] == '@' { + if len(packageName) > 0 && packageName[0] == '@' { idx := strings.Index(packageName, "/") if idx == -1 { return packageName diff --git a/internal/modulespecifiers/specifiers.go b/internal/modulespecifiers/specifiers.go index df85a4aa76..c914aafed8 100644 --- a/internal/modulespecifiers/specifiers.go +++ b/internal/modulespecifiers/specifiers.go @@ -81,8 +81,8 @@ func GetModuleSpecifiersWithInfo( func tryGetModuleNameFromAmbientModule(moduleSymbol *ast.Symbol, checker CheckerShape) string { for _, decl := range moduleSymbol.Declarations { - if isNonGlobalAmbientModule(decl) && (!ast.IsModuleAugmentationExternal(decl) || !tspath.IsExternalModuleNameRelative(decl.Name().AsStringLiteral().Text)) { - return decl.Name().AsStringLiteral().Text + if isNonGlobalAmbientModule(decl) && (!ast.IsModuleAugmentationExternal(decl) || !tspath.IsExternalModuleNameRelative(decl.Name().Text())) { + return decl.Name().Text() } } @@ -123,7 +123,7 @@ func tryGetModuleNameFromAmbientModule(moduleSymbol *ast.Symbol, checker Checker } // TODO: Possible strada bug - isn't this insufficient in the presence of merge symbols? if exportSymbol == d.Symbol() { - return possibleContainer.Name().AsStringLiteral().Text + return possibleContainer.Name().Text() } } return "" @@ -793,6 +793,8 @@ func tryDirectoryWithPackageJson( fileName := moduleFileToTry[parts.PackageRootIndex+1:] if fileName == "index.d.ts" || fileName == "index.js" || fileName == "index.ts" || fileName == "index.tsx" { return pkgJsonDirAttemptResult{moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath} + } else { + return pkgJsonDirAttemptResult{moduleFileToTry: moduleFileToTry} } } @@ -801,11 +803,7 @@ func tryDirectoryWithPackageJson( importMode = host.GetDefaultResolutionModeForFile(importingSourceFile) } - var packageJsonContent *packagejson.PackageJson - if packageJson != nil { - packageJsonContent = packageJson.GetContents() - } - + packageJsonContent := packageJson.GetContents() if options.GetResolvePackageJsonImports() { // The package name that we found in node_modules could be different from the package // name in the package.json content via url/filepath dependency specifiers. We need to @@ -1195,9 +1193,7 @@ func tryGetModuleNameFromExportsOrImports( return tspath.CombinePaths(packageName, fragmentWithJsExtension) } case MatchingModePattern: - starPos := strings.Index(pathOrPattern, "*") - leadingSlice := pathOrPattern[0:starPos] - trailingSlice := pathOrPattern[starPos+1:] + leadingSlice, trailingSlice, _ := strings.Cut(pathOrPattern, "*") caseSensitive := host.UseCaseSensitiveFileNames() if canTryTsExtension && stringutil.HasPrefix(targetFilePath, leadingSlice, caseSensitive) && stringutil.HasSuffix(targetFilePath, trailingSlice, caseSensitive) { starReplacement := targetFilePath[len(leadingSlice) : len(targetFilePath)-len(trailingSlice)] diff --git a/internal/modulespecifiers/types.go b/internal/modulespecifiers/types.go index c22e906af5..c112ff29ce 100644 --- a/internal/modulespecifiers/types.go +++ b/internal/modulespecifiers/types.go @@ -70,7 +70,7 @@ type ModuleSpecifierGenerationHost interface { type ImportModuleSpecifierPreference string const ( - ImportModuleSpecifierPreferenceNone ImportModuleSpecifierPreference = "" + ImportModuleSpecifierPreferenceNone ImportModuleSpecifierPreference = "" // !!! ImportModuleSpecifierPreferenceShortest ImportModuleSpecifierPreference = "shortest" ImportModuleSpecifierPreferenceProjectRelative ImportModuleSpecifierPreference = "project-relative" ImportModuleSpecifierPreferenceRelative ImportModuleSpecifierPreference = "relative" @@ -80,7 +80,7 @@ const ( type ImportModuleSpecifierEndingPreference string const ( - ImportModuleSpecifierEndingPreferenceNone ImportModuleSpecifierEndingPreference = "" + ImportModuleSpecifierEndingPreferenceNone ImportModuleSpecifierEndingPreference = "" // !!! ImportModuleSpecifierEndingPreferenceAuto ImportModuleSpecifierEndingPreference = "auto" ImportModuleSpecifierEndingPreferenceMinimal ImportModuleSpecifierEndingPreference = "minimal" ImportModuleSpecifierEndingPreferenceIndex ImportModuleSpecifierEndingPreference = "index" diff --git a/internal/nodebuilder/types.go b/internal/nodebuilder/types.go index ab10b8c171..91d562628c 100644 --- a/internal/nodebuilder/types.go +++ b/internal/nodebuilder/types.go @@ -26,7 +26,7 @@ type SymbolTracker interface { } // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! -type Flags int32 +type Flags uint32 const ( FlagsNone Flags = 0 diff --git a/internal/outputpaths/outputpaths.go b/internal/outputpaths/outputpaths.go index 097a7ccc2c..30de419a0b 100644 --- a/internal/outputpaths/outputpaths.go +++ b/internal/outputpaths/outputpaths.go @@ -40,7 +40,6 @@ func (o *OutputPaths) DeclarationMapPath() string { } func GetOutputPathsFor(sourceFile *ast.SourceFile, options *core.CompilerOptions, host OutputPathsHost, forceDtsEmit bool) *OutputPaths { - // !!! bundle not implemented, may be deprecated ownOutputFilePath := getOwnEmitOutputFilePath(sourceFile.FileName(), options, host, GetOutputExtension(sourceFile.FileName(), options.Jsx)) isJsonFile := ast.IsJsonSourceFile(sourceFile) // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it diff --git a/internal/packagejson/cache.go b/internal/packagejson/cache.go index 7b72a4e3e9..0295e4e76f 100644 --- a/internal/packagejson/cache.go +++ b/internal/packagejson/cache.go @@ -14,33 +14,54 @@ var typeScriptVersion = semver.MustParse(core.Version()) type PackageJson struct { Fields + Parseable bool versionPaths VersionPaths - versionTraces []string + versionTraces []diagnosticAndArgs once sync.Once } -func (p *PackageJson) GetVersionPaths(trace func(string)) VersionPaths { +type diagnosticAndArgs struct { + message *diagnostics.Message + args []any +} + +func (p *PackageJson) GetVersionPaths(trace func(m *diagnostics.Message, args ...any)) VersionPaths { p.once.Do(func() { if p.Fields.TypesVersions.Type == JSONValueTypeNotPresent { - p.versionTraces = append(p.versionTraces, diagnostics.X_package_json_does_not_have_a_0_field.Format("typesVersions")) + p.versionTraces = append(p.versionTraces, diagnosticAndArgs{ + diagnostics.X_package_json_does_not_have_a_0_field, + []any{"typesVersions"}, + }) return } if p.Fields.TypesVersions.Type != JSONValueTypeObject { - p.versionTraces = append(p.versionTraces, diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2.Format("typesVersions", "object", p.Fields.TypesVersions.Type.String())) + p.versionTraces = append(p.versionTraces, diagnosticAndArgs{ + diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, + []any{"typesVersions", "object", p.Fields.TypesVersions.Type.String()}, + }) return } - p.versionTraces = append(p.versionTraces, diagnostics.X_package_json_has_a_typesVersions_field_with_version_specific_path_mappings.Format("typesVersions")) + p.versionTraces = append(p.versionTraces, diagnosticAndArgs{ + diagnostics.X_package_json_has_a_typesVersions_field_with_version_specific_path_mappings, + []any{"typesVersions"}, + }) for key, value := range p.Fields.TypesVersions.AsObject().Entries() { keyRange, ok := semver.TryParseVersionRange(key) if !ok { - p.versionTraces = append(p.versionTraces, diagnostics.X_package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range.Format(key)) + p.versionTraces = append(p.versionTraces, diagnosticAndArgs{ + diagnostics.X_package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, + []any{key}, + }) continue } if keyRange.Test(&typeScriptVersion) { if value.Type != JSONValueTypeObject { - p.versionTraces = append(p.versionTraces, diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2.Format("typesVersions['"+key+"']", "object", value.Type.String())) + p.versionTraces = append(p.versionTraces, diagnosticAndArgs{ + diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, + []any{"typesVersions['" + key + "']", "object", value.Type.String()}, + }) return } p.versionPaths = VersionPaths{ @@ -51,11 +72,14 @@ func (p *PackageJson) GetVersionPaths(trace func(string)) VersionPaths { } } - p.versionTraces = append(p.versionTraces, diagnostics.X_package_json_does_not_have_a_typesVersions_entry_that_matches_version_0.Format(core.VersionMajorMinor())) + p.versionTraces = append(p.versionTraces, diagnosticAndArgs{ + diagnostics.X_package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, + []any{core.VersionMajorMinor()}, + }) }) if trace != nil { for _, msg := range p.versionTraces { - trace(msg) + trace(msg.message, msg.args...) } } return p.versionPaths diff --git a/internal/packagejson/packagejson.go b/internal/packagejson/packagejson.go index 5db60cebab..7ada92993e 100644 --- a/internal/packagejson/packagejson.go +++ b/internal/packagejson/packagejson.go @@ -28,6 +28,33 @@ type DependencyFields struct { OptionalDependencies Expected[map[string]string] `json:"optionalDependencies"` } +// HasDependency returns true if the package.json has a dependency with the given name +// under any of the dependency fields (dependencies, devDependencies, peerDependencies, +// optionalDependencies). +func (df *DependencyFields) HasDependency(name string) bool { + if deps, ok := df.Dependencies.GetValue(); ok { + if _, ok := deps[name]; ok { + return true + } + } + if devDeps, ok := df.DevDependencies.GetValue(); ok { + if _, ok := devDeps[name]; ok { + return true + } + } + if peerDeps, ok := df.PeerDependencies.GetValue(); ok { + if _, ok := peerDeps[name]; ok { + return true + } + } + if optDeps, ok := df.OptionalDependencies.GetValue(); ok { + if _, ok := optDeps[name]; ok { + return true + } + } + return false +} + type Fields struct { HeaderFields PathFields diff --git a/internal/parser/jsdoc.go b/internal/parser/jsdoc.go index db6a24f4d8..a3eec501ce 100644 --- a/internal/parser/jsdoc.go +++ b/internal/parser/jsdoc.go @@ -711,7 +711,7 @@ func isObjectOrObjectArrayTypeReference(node *ast.TypeNode) bool { default: if ast.IsTypeReferenceNode(node) { ref := node.AsTypeReferenceNode() - return ast.IsIdentifier(ref.TypeName) && ref.TypeName.AsIdentifier().Text == "Object" && ref.TypeArguments == nil + return ast.IsIdentifier(ref.TypeName) && ref.TypeName.Text() == "Object" && ref.TypeArguments == nil } return false } @@ -759,7 +759,7 @@ func (p *Parser) parseNestedTypeLiteral(typeExpression *ast.Node, name *ast.Enti if child.Kind == ast.KindJSDocParameterTag || child.Kind == ast.KindJSDocPropertyTag { children = append(children, child) } else if child.Kind == ast.KindJSDocTemplateTag { - p.parseErrorAtRange(child.AsJSDocTemplateTag().TagName.Loc, diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag) + p.parseErrorAtRange(child.TagName().Loc, diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag) } } if children != nil { @@ -918,8 +918,14 @@ func (p *Parser) parseTypedefTag(start int, tagName *ast.IdentifierNode, indent if childTypeTag != nil && childTypeTag.TypeExpression != nil && !isObjectOrObjectArrayTypeReference(childTypeTag.TypeExpression.Type()) { typeExpression = childTypeTag.TypeExpression } else { - typeExpression = p.finishNode(jsdocTypeLiteral, jsdocPropertyTags[0].Pos()) + // !!! This differs from Strada but prevents a crash + pos := start + if len(jsdocPropertyTags) > 0 { + pos = jsdocPropertyTags[0].Pos() + } + typeExpression = p.finishNode(jsdocTypeLiteral, pos) } + end = typeExpression.End() } } @@ -961,7 +967,7 @@ func (p *Parser) parseCallbackTagParameters(indent int) *ast.NodeList { break } if child.Kind == ast.KindJSDocTemplateTag { - p.parseErrorAtRange(child.AsJSDocTemplateTag().TagName.Loc, diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag) + p.parseErrorAtRange(child.TagName().Loc, diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag) break } parameters = append(parameters, child) @@ -1027,7 +1033,7 @@ func textsEqual(a *ast.EntityName, b *ast.EntityName) bool { return false } } - return a.AsIdentifier().Text == b.AsIdentifier().Text + return a.Text() == b.Text() } func (p *Parser) parseChildPropertyTag(indent int) *ast.Node { diff --git a/internal/parser/parser.go b/internal/parser/parser.go index a51566f02d..615286cf6b 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -498,12 +498,21 @@ func (p *Parser) reparseTopLevelAwait(sourceFile *ast.SourceFile) *ast.Node { func (p *Parser) parseListIndex(kind ParsingContext, parseElement func(p *Parser, index int) *ast.Node) []*ast.Node { saveParsingContexts := p.parsingContexts p.parsingContexts |= 1 << kind + outerReparseList := p.reparseList + p.reparseList = nil list := make([]*ast.Node, 0, 16) for i := 0; !p.isListTerminator(kind); i++ { if p.isListElement(kind, false /*inErrorRecovery*/) { - elt := parseElement(p, i) + elt := parseElement(p, len(list)) if len(p.reparseList) > 0 { - list = append(list, p.reparseList...) + for _, e := range p.reparseList { + // Propagate @typedef type alias declarations outwards to a context that permits them. + if (ast.IsJSTypeAliasDeclaration(e) || ast.IsJSImportDeclaration(e)) && kind != PCSourceElements && kind != PCBlockStatements { + outerReparseList = append(outerReparseList, e) + } else { + list = append(list, e) + } + } p.reparseList = nil } list = append(list, elt) @@ -513,6 +522,7 @@ func (p *Parser) parseListIndex(kind ParsingContext, parseElement func(p *Parser break } } + p.reparseList = outerReparseList p.parsingContexts = saveParsingContexts return p.nodeSlicePool.Clone(list) } @@ -611,7 +621,7 @@ func (p *Parser) isInSomeParsingContext() bool { // We should be in at least one parsing context, be it SourceElements while parsing // a SourceFile, or JSDocComment when lazily parsing JSDoc. debug.Assert(p.parsingContexts != 0, "Missing parsing context") - for kind := ParsingContext(0); kind < PCCount; kind++ { + for kind := range PCCount { if p.parsingContexts&(1<(......
)) --> (
(......)
) // (no need to error; the parent will error) @@ -4595,7 +4607,7 @@ func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionConte missingIdentifier := p.finishNodeWithEnd(p.newIdentifier(""), end, end) newClosingElement := p.finishNodeWithEnd(p.factory.NewJsxClosingElement(missingIdentifier), end, end) newLast := p.finishNodeWithEnd( - p.factory.NewJsxElement(lastChild.AsJsxElement().OpeningElement, lastChild.AsJsxElement().Children, newClosingElement), + p.factory.NewJsxElement(lastChild.AsJsxElement().OpeningElement, lastChild.Children(), newClosingElement), lastChild.AsJsxElement().OpeningElement.Pos(), end, ) @@ -4603,8 +4615,8 @@ func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionConte if lastChild.AsJsxElement().OpeningElement != nil { lastChild.AsJsxElement().OpeningElement.Parent = newLast } - if lastChild.AsJsxElement().Children != nil { - for _, c := range lastChild.AsJsxElement().Children.Nodes { + if lastChild.Children() != nil { + for _, c := range lastChild.Children().Nodes { c.Parent = newLast } } @@ -4613,13 +4625,13 @@ func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionConte closingElement = lastChild.AsJsxElement().ClosingElement } else { closingElement = p.parseJsxClosingElement(opening, inExpressionContext) - if !tagNamesAreEquivalent(opening.AsJsxOpeningElement().TagName, closingElement.AsJsxClosingElement().TagName) { - if openingTag != nil && ast.IsJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.AsJsxClosingElement().TagName, openingTag.AsJsxOpeningElement().TagName) { + if !tagNamesAreEquivalent(opening.TagName(), closingElement.TagName()) { + if openingTag != nil && ast.IsJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.TagName(), openingTag.TagName()) { // opening incorrectly matched with its parent's closing -- put error on opening - p.parseErrorAtRange(opening.AsJsxOpeningElement().TagName.Loc, diagnostics.JSX_element_0_has_no_corresponding_closing_tag, scanner.GetTextOfNodeFromSourceText(p.sourceText, opening.AsJsxOpeningElement().TagName, false /*includeTrivia*/)) + p.parseErrorAtRange(opening.TagName().Loc, diagnostics.JSX_element_0_has_no_corresponding_closing_tag, scanner.GetTextOfNodeFromSourceText(p.sourceText, opening.TagName(), false /*includeTrivia*/)) } else { // other opening/closing mismatches -- put error on closing - p.parseErrorAtRange(closingElement.AsJsxClosingElement().TagName.Loc, diagnostics.Expected_corresponding_JSX_closing_tag_for_0, scanner.GetTextOfNodeFromSourceText(p.sourceText, opening.AsJsxOpeningElement().TagName, false /*includeTrivia*/)) + p.parseErrorAtRange(closingElement.TagName().Loc, diagnostics.Expected_corresponding_JSX_closing_tag_for_0, scanner.GetTextOfNodeFromSourceText(p.sourceText, opening.TagName(), false /*includeTrivia*/)) } } } @@ -4669,8 +4681,8 @@ func (p *Parser) parseJsxChildren(openingTag *ast.Expression) *ast.NodeList { } list = append(list, child) if ast.IsJsxOpeningElement(openingTag) && child.Kind == ast.KindJsxElement && - !tagNamesAreEquivalent(child.AsJsxElement().OpeningElement.AsJsxOpeningElement().TagName, child.AsJsxElement().ClosingElement.AsJsxClosingElement().TagName) && - tagNamesAreEquivalent(openingTag.AsJsxOpeningElement().TagName, child.AsJsxElement().ClosingElement.AsJsxClosingElement().TagName) { + !tagNamesAreEquivalent(child.AsJsxElement().OpeningElement.TagName(), child.AsJsxElement().ClosingElement.TagName()) && + tagNamesAreEquivalent(openingTag.TagName(), child.AsJsxElement().ClosingElement.TagName()) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher break } @@ -4689,10 +4701,10 @@ func (p *Parser) parseJsxChild(openingTag *ast.Node, token ast.Kind) *ast.Expres } else { // We want the error span to cover only 'Foo.Bar' in < Foo.Bar > // or to cover only 'Foo' in < Foo > - tag := openingTag.AsJsxOpeningElement().TagName + tag := openingTag.TagName() start := min(scanner.SkipTrivia(p.sourceText, tag.Pos()), tag.End()) p.parseErrorAt(start, tag.End(), diagnostics.JSX_element_0_has_no_corresponding_closing_tag, - scanner.GetTextOfNodeFromSourceText(p.sourceText, openingTag.AsJsxOpeningElement().TagName, false /*includeTrivia*/)) + scanner.GetTextOfNodeFromSourceText(p.sourceText, openingTag.TagName(), false /*includeTrivia*/)) } return nil case ast.KindLessThanSlashToken, ast.KindConflictMarkerTrivia: @@ -4759,7 +4771,7 @@ func (p *Parser) parseJsxClosingElement(open *ast.Node, inExpressionContext bool tagName := p.parseJsxElementName() if p.parseExpectedWithDiagnostic(ast.KindGreaterThanToken, nil /*diagnosticMessage*/, false /*shouldAdvance*/) { // manually advance the scanner in order to look for jsx text inside jsx - if inExpressionContext || !tagNamesAreEquivalent(open.AsJsxOpeningElement().TagName, tagName) { + if inExpressionContext || !tagNamesAreEquivalent(open.TagName(), tagName) { p.nextToken() } else { p.scanJsxText() @@ -5239,7 +5251,7 @@ func (p *Parser) parsePropertyAccessExpressionRest(pos int, expression *ast.Expr p.parseErrorAtRange(p.skipRangeTrivia(name.Loc), diagnostics.An_optional_chain_cannot_contain_private_identifiers) } if ast.IsExpressionWithTypeArguments(expression) { - typeArguments := expression.AsExpressionWithTypeArguments().TypeArguments + typeArguments := expression.TypeArgumentList() if typeArguments != nil { loc := core.NewTextRange(typeArguments.Pos()-1, scanner.SkipTrivia(p.sourceText, typeArguments.End())+1) p.parseErrorAtRange(loc, diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access) @@ -5254,15 +5266,15 @@ func (p *Parser) tryReparseOptionalChain(node *ast.Expression) bool { } // check for an optional chain in a non-null expression if ast.IsNonNullExpression(node) { - expr := node.AsNonNullExpression().Expression + expr := node.Expression() for ast.IsNonNullExpression(expr) && expr.Flags&ast.NodeFlagsOptionalChain == 0 { - expr = expr.AsNonNullExpression().Expression + expr = expr.Expression() } if expr.Flags&ast.NodeFlagsOptionalChain != 0 { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. for ast.IsNonNullExpression(node) { node.Flags |= ast.NodeFlagsOptionalChain - node = node.AsNonNullExpression().Expression + node = node.Expression() } return true } @@ -5279,11 +5291,11 @@ func (p *Parser) parseElementAccessExpressionRest(pos int, expression *ast.Expre argument := p.parseExpressionAllowIn() switch argument.Kind { case ast.KindStringLiteral: - argument.AsStringLiteral().Text = p.internIdentifier(argument.AsStringLiteral().Text) + argument.AsStringLiteral().Text = p.internIdentifier(argument.Text()) case ast.KindNoSubstitutionTemplateLiteral: - argument.AsNoSubstitutionTemplateLiteral().Text = p.internIdentifier(argument.AsNoSubstitutionTemplateLiteral().Text) + argument.AsNoSubstitutionTemplateLiteral().Text = p.internIdentifier(argument.Text()) case ast.KindNumericLiteral: - argument.AsNumericLiteral().Text = p.internIdentifier(argument.AsNumericLiteral().Text) + argument.AsNumericLiteral().Text = p.internIdentifier(argument.Text()) } argumentExpression = argument } @@ -5307,7 +5319,7 @@ func (p *Parser) parseCallExpressionRest(pos int, expression *ast.Expression) *a if typeArguments != nil || p.token == ast.KindOpenParenToken { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments if questionDotToken == nil && expression.Kind == ast.KindExpressionWithTypeArguments { - typeArguments = expression.AsExpressionWithTypeArguments().TypeArguments + typeArguments = expression.TypeArgumentList() expression = expression.AsExpressionWithTypeArguments().Expression } inner := expression @@ -5602,7 +5614,7 @@ func (p *Parser) parseNewExpressionOrNewDotTarget() *ast.Node { var typeArguments *ast.NodeList // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments if expression.Kind == ast.KindExpressionWithTypeArguments { - typeArguments = expression.AsExpressionWithTypeArguments().TypeArguments + typeArguments = expression.TypeArgumentList() expression = expression.AsExpressionWithTypeArguments().Expression } if p.token == ast.KindQuestionDotToken { @@ -6245,15 +6257,15 @@ func tagNamesAreEquivalent(lhs *ast.Expression, rhs *ast.Expression) bool { } switch lhs.Kind { case ast.KindIdentifier: - return lhs.AsIdentifier().Text == rhs.AsIdentifier().Text + return lhs.Text() == rhs.Text() case ast.KindThisKeyword: return true case ast.KindJsxNamespacedName: - return lhs.AsJsxNamespacedName().Namespace.AsIdentifier().Text == rhs.AsJsxNamespacedName().Namespace.AsIdentifier().Text && - lhs.AsJsxNamespacedName().Name().AsIdentifier().Text == rhs.AsJsxNamespacedName().Name().AsIdentifier().Text + return lhs.AsJsxNamespacedName().Namespace.Text() == rhs.AsJsxNamespacedName().Namespace.Text() && + lhs.AsJsxNamespacedName().Name().Text() == rhs.AsJsxNamespacedName().Name().Text() case ast.KindPropertyAccessExpression: return lhs.AsPropertyAccessExpression().Name().Text() == rhs.AsPropertyAccessExpression().Name().Text() && - tagNamesAreEquivalent(lhs.AsPropertyAccessExpression().Expression, rhs.AsPropertyAccessExpression().Expression) + tagNamesAreEquivalent(lhs.Expression(), rhs.Expression()) } panic("Unhandled case in tagNamesAreEquivalent") } @@ -6387,6 +6399,9 @@ func skipNonBlanks(text string, pos int) int { } func skipTo(text string, pos int, s string) int { + if pos >= len(text) { + return -1 + } i := strings.Index(text[pos:], s) if i < 0 { return -1 @@ -6442,7 +6457,7 @@ func (p *Parser) processPragmasIntoFields(context *ast.SourceFile) { case typesOk: var parsed core.ResolutionMode if resolutionModeOk { - parsed = parseResolutionMode(resolutionMode.Value, resolutionMode.Pos(), resolutionMode.End() /*, reportDiagnostic*/) + parsed = p.parseResolutionMode(resolutionMode.Value, resolutionMode.Pos(), resolutionMode.End()) } context.TypeReferenceDirectives = append(context.TypeReferenceDirectives, &ast.FileReference{ TextRange: types.TextRange, @@ -6483,16 +6498,17 @@ func (p *Parser) processPragmasIntoFields(context *ast.SourceFile) { } } -func parseResolutionMode(mode string, pos int, end int /*reportDiagnostic: PragmaDiagnosticReporter*/) (resolutionKind core.ResolutionMode) { +func (p *Parser) parseResolutionMode(mode string, pos int, end int) (resolutionKind core.ResolutionMode) { if mode == "import" { resolutionKind = core.ModuleKindESNext + return resolutionKind } if mode == "require" { resolutionKind = core.ModuleKindCommonJS + return resolutionKind } + p.parseErrorAt(pos, end, diagnostics.X_resolution_mode_should_be_either_require_or_import) return resolutionKind - // reportDiagnostic(pos, end - pos, Diagnostics.resolution_mode_should_be_either_require_or_import); - // return undefined; } func (p *Parser) jsErrorAtRange(loc core.TextRange, message *diagnostics.Message, args ...any) { @@ -6505,7 +6521,7 @@ func (p *Parser) checkJSSyntax(node *ast.Node) *ast.Node { } switch node.Kind { case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: - if token := node.PostfixToken(); token != nil && token.Flags&ast.NodeFlagsReparsed == 0 && ast.IsQuestionToken(token) { + if token := node.QuestionToken(); token != nil && token.Flags&ast.NodeFlagsReparsed == 0 && ast.IsQuestionToken(token) { p.jsErrorAtRange(token.Loc, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?") } fallthrough @@ -6517,7 +6533,7 @@ func (p *Parser) checkJSSyntax(node *ast.Node) *ast.Node { p.jsErrorAtRange(t.Loc, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files) } case ast.KindImportDeclaration: - if clause := node.AsImportDeclaration().ImportClause; clause != nil && clause.IsTypeOnly() { + if clause := node.ImportClause(); clause != nil && clause.IsTypeOnly() { p.jsErrorAtRange(node.Loc, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type") } case ast.KindExportDeclaration: @@ -6566,11 +6582,9 @@ func (p *Parser) checkJSSyntax(node *ast.Node) *ast.Node { } fallthrough case ast.KindVariableStatement, ast.KindPropertyDeclaration: - if modifiers := node.Modifiers(); modifiers != nil { - for _, modifier := range modifiers.Nodes { - if modifier.Flags&ast.NodeFlagsReparsed == 0 && modifier.Kind != ast.KindDecorator && ast.ModifierToFlag(modifier.Kind)&ast.ModifierFlagsJavaScript == 0 { - p.jsErrorAtRange(modifier.Loc, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind)) - } + for _, modifier := range node.ModifierNodes() { + if modifier.Flags&ast.NodeFlagsReparsed == 0 && modifier.Kind != ast.KindDecorator && ast.ModifierToFlag(modifier.Kind)&ast.ModifierFlagsJavaScript == 0 { + p.jsErrorAtRange(modifier.Loc, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind)) } } case ast.KindParameter: diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index 4cea055265..b2f2b9a6e4 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -1,4 +1,4 @@ -package parser +package parser_test import ( "io/fs" @@ -10,7 +10,9 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/repo" + "github.com/microsoft/typescript-go/internal/testrunner" "github.com/microsoft/typescript-go/internal/testutil/fixtures" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs/osvfs" @@ -46,7 +48,7 @@ func BenchmarkParse(b *testing.B) { } for b.Loop() { - ParseSourceFile(opts, sourceText, scriptKind) + parser.ParseSourceFile(opts, sourceText, scriptKind) } }) } @@ -94,7 +96,6 @@ func FuzzParser(f *testing.F) { "src", "scripts", "Herebyfile.mjs", - // "tests/cases", } var extensions collections.Set[string] @@ -111,19 +112,53 @@ func FuzzParser(f *testing.F) { sourceText, err := os.ReadFile(file.path) assert.NilError(f, err) extension := tspath.TryGetExtensionFromPath(file.path) - f.Add(extension, string(sourceText), int(core.ScriptTargetESNext), int(ast.JSDocParsingModeParseAll)) + f.Add(extension, string(sourceText), uint8(ast.JSDocParsingModeParseAll), false, false) } } - f.Fuzz(func(t *testing.T, extension string, sourceText string, scriptTarget_ int, jsdocParsingMode_ int) { - scriptTarget := core.ScriptTarget(scriptTarget_) - jsdocParsingMode := ast.JSDocParsingMode(jsdocParsingMode_) + testDirs := []string{ + filepath.Join(repo.TypeScriptSubmodulePath, "tests/cases/compiler"), + filepath.Join(repo.TypeScriptSubmodulePath, "tests/cases/conformance"), + filepath.Join(repo.TestDataPath, "tests/cases/compiler"), + } - if !extensions.Has(extension) { - t.Skip() + for _, testDir := range testDirs { + if _, err := os.Stat(testDir); os.IsNotExist(err) { + continue + } + + for file := range allParsableFiles(f, testDir) { + sourceText, err := os.ReadFile(file.path) + assert.NilError(f, err) + + type testFile struct { + content string + name string + } + + testUnits, _, _, _, err := testrunner.ParseTestFilesAndSymlinks( + string(sourceText), + file.path, + func(filename string, content string, fileOptions map[string]string) (testFile, error) { + return testFile{content: content, name: filename}, nil + }, + ) + assert.NilError(f, err) + + for _, unit := range testUnits { + extension := tspath.TryGetExtensionFromPath(unit.name) + if extension == "" { + continue + } + f.Add(extension, unit.content, uint8(ast.JSDocParsingModeParseAll), false, false) + } } + } + + f.Fuzz(func(t *testing.T, extension string, sourceText string, jsdocParsingMode_ uint8, externalModuleIndicatorOptionsJSX bool, externalModuleIndicatorOptionsForce bool) { + jsdocParsingMode := ast.JSDocParsingMode(jsdocParsingMode_) - if scriptTarget < core.ScriptTargetNone || scriptTarget > core.ScriptTargetLatest { + if !extensions.Has(extension) { t.Skip() } @@ -138,8 +173,12 @@ func FuzzParser(f *testing.F) { FileName: fileName, Path: path, JSDocParsingMode: jsdocParsingMode, + ExternalModuleIndicatorOptions: ast.ExternalModuleIndicatorOptions{ + JSX: externalModuleIndicatorOptionsJSX, + Force: externalModuleIndicatorOptionsForce, + }, } - ParseSourceFile(opts, sourceText, core.GetScriptKindFromFileName(fileName)) + parser.ParseSourceFile(opts, sourceText, core.GetScriptKindFromFileName(fileName)) }) } diff --git a/internal/parser/references.go b/internal/parser/references.go index c5fda691c6..7a6b4c01c8 100644 --- a/internal/parser/references.go +++ b/internal/parser/references.go @@ -28,7 +28,7 @@ func collectModuleReferences(file *ast.SourceFile, node *ast.Statement, inAmbien // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. if moduleNameExpr != nil && ast.IsStringLiteral(moduleNameExpr) { - moduleName := moduleNameExpr.AsStringLiteral().Text + moduleName := moduleNameExpr.Text() if moduleName != "" && (!inAmbientModule || !tspath.IsExternalModuleNameRelative(moduleName)) { ast.SetImportsOfSourceFile(file, append(file.Imports(), moduleNameExpr)) // !!! removed `&& p.currentNodeModulesDepth == 0` @@ -64,8 +64,8 @@ func collectModuleReferences(file *ast.SourceFile, node *ast.Statement, inAmbien // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted // NOTE: body of ambient module is always a module block, if it exists - if node.AsModuleDeclaration().Body != nil { - for _, statement := range node.AsModuleDeclaration().Body.AsModuleBlock().Statements.Nodes { + if node.Body() != nil { + for _, statement := range node.Body().Statements() { collectModuleReferences(file, statement, true /*inAmbientModule*/) } } diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 446e461985..c795ad3d82 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -19,22 +19,19 @@ func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { if p.scriptKind != core.ScriptKindJS && p.scriptKind != core.ScriptKindJSX { return } - if node.Kind != ast.KindExpressionStatement || node.AsExpressionStatement().Expression.Kind != ast.KindBinaryExpression { + if node.Kind != ast.KindExpressionStatement || node.Expression().Kind != ast.KindBinaryExpression { return } - bin := node.AsExpressionStatement().Expression.AsBinaryExpression() + bin := node.Expression().AsBinaryExpression() kind := ast.GetAssignmentDeclarationKind(bin) var export *ast.Node switch kind { case ast.JSDeclarationKindModuleExports: export = p.factory.NewJSExportAssignment(nil, p.factory.DeepCloneReparse(bin.Right)) case ast.JSDeclarationKindExportsProperty: - mod := p.factory.NewModifier(ast.KindExportKeyword) - mod.Flags = p.contextFlags | ast.NodeFlagsReparsed - mod.Loc = bin.Loc // TODO: Name can sometimes be a string literal, so downstream code needs to handle this export = p.factory.NewCommonJSExport( - p.newModifierList(bin.Loc, p.nodeSlicePool.NewSlice1(mod)), + nil, p.factory.DeepCloneReparse(ast.GetElementOrPropertyAccessName(bin.Left)), nil, /*typeNode*/ p.factory.DeepCloneReparse(bin.Right)) @@ -70,17 +67,11 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) { switch tag.Kind { case ast.KindJSDocTypedefTag: - // !!! Don't mark typedefs as exported if they are not in a module - typeExpression := tag.AsJSDocTypedefTag().TypeExpression + typeExpression := tag.TypeExpression() if typeExpression == nil { break } - export := p.factory.NewModifier(ast.KindExportKeyword) - export.Loc = tag.Loc - export.Flags = p.contextFlags | ast.NodeFlagsReparsed - modifiers := p.newModifierList(export.Loc, p.nodeSlicePool.NewSlice1(export)) - - typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, p.factory.DeepCloneReparse(tag.AsJSDocTypedefTag().Name()), nil, nil) + typeAlias := p.factory.NewJSTypeAliasDeclaration(nil, p.factory.DeepCloneReparse(tag.AsJSDocTypedefTag().Name()), nil, nil) typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag) var t *ast.Node switch typeExpression.Kind { @@ -99,14 +90,8 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod if callbackTag.TypeExpression == nil { break } - - export := p.factory.NewModifier(ast.KindExportKeyword) - export.Loc = tag.Loc - export.Flags = p.contextFlags | ast.NodeFlagsReparsed - modifiers := p.newModifierList(export.Loc, p.nodeSlicePool.NewSlice1(export)) functionType := p.reparseJSDocSignature(callbackTag.TypeExpression, tag, jsDoc, tag, nil) - - typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, p.factory.DeepCloneReparse(callbackTag.FullName), nil, functionType) + typeAlias := p.factory.NewJSTypeAliasDeclaration(nil, p.factory.DeepCloneReparse(callbackTag.FullName), nil, functionType) typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag) p.finishReparsedNode(typeAlias, tag) p.reparseList = append(p.reparseList, typeAlias) @@ -140,10 +125,14 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD signature = p.factory.NewFunctionDeclaration(clonedModifiers, nil, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil) case ast.KindMethodDeclaration, ast.KindMethodSignature: signature = p.factory.NewMethodDeclaration(clonedModifiers, nil, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil, nil) + case ast.KindGetAccessor: + signature = p.factory.NewGetAccessorDeclaration(clonedModifiers, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil) + case ast.KindSetAccessor: + signature = p.factory.NewSetAccessorDeclaration(clonedModifiers, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil) case ast.KindConstructor: signature = p.factory.NewConstructorDeclaration(clonedModifiers, nil, nil, nil, nil, nil) case ast.KindJSDocCallbackTag: - signature = p.factory.NewFunctionTypeNode(nil, nil, nil) + signature = p.factory.NewFunctionTypeNode(nil, nil, p.factory.NewKeywordTypeNode(ast.KindAnyKeyword)) default: panic("Unexpected kind " + fun.Kind.String()) } @@ -188,12 +177,12 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD } signature.FunctionLikeData().Parameters = p.newNodeList(jsSignature.AsJSDocSignature().Parameters.Loc, parameters) - if jsSignature.Type() != nil && jsSignature.Type().AsJSDocReturnTag().TypeExpression != nil { - signature.FunctionLikeData().Type = p.factory.DeepCloneReparse(jsSignature.Type().AsJSDocReturnTag().TypeExpression.Type()) + if jsSignature.Type() != nil && jsSignature.Type().TypeExpression() != nil { + signature.FunctionLikeData().Type = p.factory.DeepCloneReparse(jsSignature.Type().TypeExpression().Type()) } loc := jsSignature if tag.Kind == ast.KindJSDocOverloadTag { - loc = tag.AsJSDocOverloadTag().TagName + loc = tag.TagName() } p.finishReparsedNode(signature, loc) return signature @@ -294,8 +283,8 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) case ast.KindVariableStatement: if parent.AsVariableStatement().DeclarationList != nil { for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { - if declaration.Type() == nil && tag.AsJSDocTypeTag().TypeExpression != nil { - declaration.AsMutable().SetType(p.factory.DeepCloneReparse(tag.AsJSDocTypeTag().TypeExpression.Type())) + if declaration.Type() == nil && tag.TypeExpression() != nil { + declaration.AsMutable().SetType(p.factory.DeepCloneReparse(tag.TypeExpression().Type())) p.finishMutatedNode(declaration) return } @@ -304,30 +293,30 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) case ast.KindVariableDeclaration, ast.KindCommonJSExport, ast.KindExportAssignment, ast.KindJSExportAssignment, ast.KindPropertyDeclaration, ast.KindPropertyAssignment, ast.KindShorthandPropertyAssignment: - if parent.Type() == nil && tag.AsJSDocTypeTag().TypeExpression != nil { - parent.AsMutable().SetType(p.factory.DeepCloneReparse(tag.AsJSDocTypeTag().TypeExpression.Type())) + if parent.Type() == nil && tag.TypeExpression() != nil { + parent.AsMutable().SetType(p.factory.DeepCloneReparse(tag.TypeExpression().Type())) p.finishMutatedNode(parent) return } case ast.KindParameter: - if parent.Type() == nil && tag.AsJSDocTypeTag().TypeExpression != nil { - parent.AsMutable().SetType(p.reparseJSDocTypeLiteral(tag.AsJSDocTypeTag().TypeExpression.Type())) + if parent.Type() == nil && tag.TypeExpression() != nil { + parent.AsMutable().SetType(p.reparseJSDocTypeLiteral(tag.TypeExpression().Type())) p.finishMutatedNode(parent) return } case ast.KindExpressionStatement: - if parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { - bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() - if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone && tag.AsJSDocTypeTag().TypeExpression != nil { - bin.AsMutable().SetType(p.factory.DeepCloneReparse(tag.AsJSDocTypeTag().TypeExpression.Type())) + if parent.Expression().Kind == ast.KindBinaryExpression { + bin := parent.Expression().AsBinaryExpression() + if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone && tag.TypeExpression() != nil { + bin.AsMutable().SetType(p.factory.DeepCloneReparse(tag.TypeExpression().Type())) p.finishMutatedNode(bin.AsNode()) return } } case ast.KindReturnStatement, ast.KindParenthesizedExpression: - if tag.AsJSDocTypeTag().TypeExpression != nil { + if parent.Expression() != nil && tag.TypeExpression() != nil { parent.AsMutable().SetExpression(p.makeNewCast( - p.factory.DeepCloneReparse(tag.AsJSDocTypeTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(tag.TypeExpression().Type()), p.factory.DeepCloneReparse(parent.Expression()), true /*isAssertion*/)) p.finishMutatedNode(parent) @@ -336,8 +325,8 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } if fun, ok := getFunctionLikeHost(parent); ok { noTypedParams := core.Every(fun.Parameters(), func(param *ast.Node) bool { return param.Type() == nil }) - if fun.Type() == nil && noTypedParams && tag.AsJSDocTypeTag().TypeExpression != nil { - fun.FunctionLikeData().FullSignature = p.factory.DeepCloneReparse(tag.AsJSDocTypeTag().TypeExpression.Type()) + if fun.TypeParameterList() == nil && fun.Type() == nil && noTypedParams && tag.TypeExpression() != nil { + fun.FunctionLikeData().FullSignature = p.factory.DeepCloneReparse(tag.TypeExpression().Type()) p.finishMutatedNode(fun) } } @@ -346,9 +335,9 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) case ast.KindVariableStatement: if parent.AsVariableStatement().DeclarationList != nil { for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { - if declaration.Initializer() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { + if declaration.Initializer() != nil && tag.TypeExpression() != nil { declaration.AsMutable().SetInitializer(p.makeNewCast( - p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(tag.TypeExpression().Type()), p.factory.DeepCloneReparse(declaration.Initializer()), false /*isAssertion*/)) p.finishMutatedNode(declaration) @@ -358,29 +347,38 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } case ast.KindVariableDeclaration, ast.KindCommonJSExport, - ast.KindPropertyDeclaration, ast.KindPropertyAssignment, ast.KindShorthandPropertyAssignment: - if parent.Initializer() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { + ast.KindPropertyDeclaration, ast.KindPropertyAssignment: + if parent.Initializer() != nil && tag.TypeExpression() != nil { parent.AsMutable().SetInitializer(p.makeNewCast( - p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(tag.TypeExpression().Type()), p.factory.DeepCloneReparse(parent.Initializer()), false /*isAssertion*/)) p.finishMutatedNode(parent) } + case ast.KindShorthandPropertyAssignment: + shorthand := parent.AsShorthandPropertyAssignment() + if shorthand.ObjectAssignmentInitializer != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { + shorthand.ObjectAssignmentInitializer = p.makeNewCast( + p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(shorthand.ObjectAssignmentInitializer), + false /*isAssertion*/) + p.finishMutatedNode(parent) + } case ast.KindReturnStatement, ast.KindParenthesizedExpression, ast.KindExportAssignment, ast.KindJSExportAssignment: - if parent.Expression() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { + if parent.Expression() != nil && tag.TypeExpression() != nil { parent.AsMutable().SetExpression(p.makeNewCast( - p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(tag.TypeExpression().Type()), p.factory.DeepCloneReparse(parent.Expression()), false /*isAssertion*/)) p.finishMutatedNode(parent) } case ast.KindExpressionStatement: - if parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { - bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() - if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone && tag.AsJSDocSatisfiesTag().TypeExpression != nil { + if parent.Expression().Kind == ast.KindBinaryExpression { + bin := parent.Expression().AsBinaryExpression() + if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone && tag.TypeExpression() != nil { bin.Right = p.makeNewCast( - p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(tag.TypeExpression().Type()), p.factory.DeepCloneReparse(bin.Right), false /*isAssertion*/) p.finishMutatedNode(bin.AsNode()) @@ -389,7 +387,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } case ast.KindJSDocTemplateTag: if fun, ok := getFunctionLikeHost(parent); ok { - if fun.TypeParameters() == nil { + if fun.TypeParameters() == nil && fun.FunctionLikeData().FullSignature == nil { fun.FunctionLikeData().TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/) p.finishMutatedNode(fun) } @@ -407,7 +405,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } case ast.KindJSDocParameterTag: - if fun, ok := getFunctionLikeHost(parent); ok { + if fun, ok := getFunctionLikeHost(parent); ok && fun.FunctionLikeData().FullSignature == nil { parameterTag := tag.AsJSDocParameterOrPropertyTag() if param, ok := findMatchingParameter(fun, parameterTag, jsDoc); ok { if param.Type == nil && parameterTag.TypeExpression != nil { @@ -436,7 +434,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) if tag.AsJSDocThisTag().TypeExpression != nil { thisParam.AsParameterDeclaration().Type = p.factory.DeepCloneReparse(tag.AsJSDocThisTag().TypeExpression.Type()) } - p.finishReparsedNode(thisParam, tag.AsJSDocThisTag().TagName) + p.finishReparsedNode(thisParam, tag.TagName()) newParams := p.nodeSlicePool.NewSlice(len(params) + 1) newParams[0] = thisParam @@ -449,15 +447,15 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } case ast.KindJSDocReturnTag: - if fun, ok := getFunctionLikeHost(parent); ok { - if fun.Type() == nil && tag.AsJSDocReturnTag().TypeExpression != nil { - fun.FunctionLikeData().Type = p.factory.DeepCloneReparse(tag.AsJSDocReturnTag().TypeExpression.Type()) + if fun, ok := getFunctionLikeHost(parent); ok && fun.FunctionLikeData().FullSignature == nil { + if fun.Type() == nil && tag.TypeExpression() != nil { + fun.FunctionLikeData().Type = p.factory.DeepCloneReparse(tag.TypeExpression().Type()) p.finishMutatedNode(fun) } } case ast.KindJSDocReadonlyTag, ast.KindJSDocPrivateTag, ast.KindJSDocPublicTag, ast.KindJSDocProtectedTag, ast.KindJSDocOverrideTag: if parent.Kind == ast.KindExpressionStatement { - parent = parent.AsExpressionStatement().Expression + parent = parent.Expression() } switch parent.Kind { case ast.KindPropertyDeclaration, ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindBinaryExpression: @@ -484,7 +482,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) nodes[0] = modifier loc = tag.Loc } else { - nodes = append(parent.Modifiers().Nodes, modifier) + nodes = append(parent.ModifierNodes(), modifier) loc = parent.Modifiers().Loc } parent.AsMutable().SetModifiers(p.newModifierList(loc, nodes)) @@ -522,7 +520,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) return node.AsHeritageClause().Token == ast.KindExtendsKeyword }); extendsClause != nil && len(extendsClause.AsHeritageClause().Types.Nodes) == 1 { target := extendsClause.AsHeritageClause().Types.Nodes[0].AsExpressionWithTypeArguments() - source := tag.AsJSDocAugmentsTag().ClassName.AsExpressionWithTypeArguments() + source := tag.ClassName().AsExpressionWithTypeArguments() if ast.HasSamePropertyAccessName(target.Expression, source.Expression) { if target.TypeArguments == nil && source.TypeArguments != nil { newArguments := p.nodeSlicePool.NewSlice(len(source.TypeArguments.Nodes)) @@ -582,13 +580,17 @@ func getFunctionLikeHost(host *ast.Node) (*ast.Node, bool) { } } } else if host.Kind == ast.KindPropertyAssignment { - fun = host.AsPropertyAssignment().Initializer + fun = host.Initializer() } else if host.Kind == ast.KindPropertyDeclaration { - fun = host.AsPropertyDeclaration().Initializer + fun = host.Initializer() } else if host.Kind == ast.KindExportAssignment { - fun = host.AsExportAssignment().Expression + fun = host.Expression() } else if host.Kind == ast.KindReturnStatement { - fun = host.AsReturnStatement().Expression + fun = host.Expression() + } else if host.Kind == ast.KindExpressionStatement { + if ast.IsBinaryExpression(host.Expression()) { + fun = host.Expression().AsBinaryExpression().Right + } } if ast.IsFunctionLike(fun) { return fun, true diff --git a/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a b/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a index bcaba2fc86..dff3eb9368 100644 --- a/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a +++ b/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a @@ -1,5 +1,6 @@ go test fuzz v1 string(".ts") -string("/**@0\n * */0") -int(99) -int(0) +string("") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/0ec0d5de7f0264d9 b/internal/parser/testdata/fuzz/FuzzParser/0ec0d5de7f0264d9 new file mode 100644 index 0000000000..3199b97092 --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/0ec0d5de7f0264d9 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".js") +string("00000000000000000000000000000000000000000000000000000000000\"00000000000000000000000\n/**@type */return") +byte('\x00') +bool(true) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/3d59c16f3abc20e1 b/internal/parser/testdata/fuzz/FuzzParser/3d59c16f3abc20e1 new file mode 100644 index 0000000000..7025036252 --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/3d59c16f3abc20e1 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("/**@typedef @type object00") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/4c0324cd37d955ff b/internal/parser/testdata/fuzz/FuzzParser/4c0324cd37d955ff new file mode 100644 index 0000000000..fb1b7aa812 --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/4c0324cd37d955ff @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("@00await") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/6944735deac09149 b/internal/parser/testdata/fuzz/FuzzParser/6944735deac09149 new file mode 100644 index 0000000000..c9caf93eba --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/6944735deac09149 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("/*/") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/7d4c688e1df61349 b/internal/parser/testdata/fuzz/FuzzParser/7d4c688e1df61349 new file mode 100644 index 0000000000..8a57001ea2 --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/7d4c688e1df61349 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".js") +string("0%{\n/**@satisfies */A") +byte('\x00') +bool(true) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe b/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe index c416e2e17a..dff3eb9368 100644 --- a/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe +++ b/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe @@ -1,5 +1,6 @@ go test fuzz v1 string(".ts") -string("/") -int(99) -int(1) +string("") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/c5dc3279768e5a11 b/internal/parser/testdata/fuzz/FuzzParser/c5dc3279768e5a11 new file mode 100644 index 0000000000..505e4516a4 --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/c5dc3279768e5a11 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("/**") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/testdata/fuzz/FuzzParser/f48591d3b8f41eca b/internal/parser/testdata/fuzz/FuzzParser/f48591d3b8f41eca new file mode 100644 index 0000000000..14b3a7639d --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/f48591d3b8f41eca @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".js") +string("c(0000{\n/**@overload */get 0") +byte('\x00') +bool(false) +bool(true) diff --git a/internal/parser/testdata/fuzz/FuzzParser/f6dbdaa8568c9488 b/internal/parser/testdata/fuzz/FuzzParser/f6dbdaa8568c9488 new file mode 100644 index 0000000000..315b16bfac --- /dev/null +++ b/internal/parser/testdata/fuzz/FuzzParser/f6dbdaa8568c9488 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string(")import A,await") +byte('\x00') +bool(false) +bool(false) diff --git a/internal/parser/utilities.go b/internal/parser/utilities.go index ee31ae4704..2e143a835b 100644 --- a/internal/parser/utilities.go +++ b/internal/parser/utilities.go @@ -41,7 +41,9 @@ func GetJSDocCommentRanges(f *ast.NodeFactory, commentRanges []ast.CommentRange, } // Keep if the comment starts with '/**' but not if it is '/**/' return slices.DeleteFunc(commentRanges, func(comment ast.CommentRange) bool { - return comment.End() > node.End() || text[comment.Pos()+1] != '*' || text[comment.Pos()+2] != '*' || text[comment.Pos()+3] == '/' + commentStart := comment.Pos() + commentLen := comment.End() - commentStart + return comment.End() > node.End() || commentLen < 4 || text[commentStart+1] != '*' || text[commentStart+2] != '*' || text[commentStart+3] == '/' }) } diff --git a/internal/pprof/pprof.go b/internal/pprof/pprof.go index 23692f4dbf..2523c94885 100644 --- a/internal/pprof/pprof.go +++ b/internal/pprof/pprof.go @@ -8,7 +8,7 @@ import ( "runtime/pprof" ) -type profileSession struct { +type ProfileSession struct { cpuFilePath string memFilePath string cpuFile *os.File @@ -17,7 +17,7 @@ type profileSession struct { } // BeginProfiling starts CPU and memory profiling, writing the profiles to the specified directory. -func BeginProfiling(profileDir string, logWriter io.Writer) *profileSession { +func BeginProfiling(profileDir string, logWriter io.Writer) *ProfileSession { if err := os.MkdirAll(profileDir, 0o755); err != nil { panic(err) } @@ -39,7 +39,7 @@ func BeginProfiling(profileDir string, logWriter io.Writer) *profileSession { panic(err) } - return &profileSession{ + return &ProfileSession{ cpuFilePath: cpuProfilePath, memFilePath: memProfilePath, cpuFile: cpuFile, @@ -48,7 +48,7 @@ func BeginProfiling(profileDir string, logWriter io.Writer) *profileSession { } } -func (p *profileSession) Stop() { +func (p *ProfileSession) Stop() { pprof.StopCPUProfile() err := pprof.Lookup("allocs").WriteTo(p.memFile, 0) if err != nil { diff --git a/internal/printer/emitcontext.go b/internal/printer/emitcontext.go index 5105bc711d..cff450debf 100644 --- a/internal/printer/emitcontext.go +++ b/internal/printer/emitcontext.go @@ -899,7 +899,7 @@ func (c *EmitContext) VisitFunctionBody(node *ast.BlockOrExpression, visitor *as return c.Factory.UpdateBlock( updated.AsBlock(), - c.MergeEnvironmentList(updated.AsBlock().Statements, declarations), + c.MergeEnvironmentList(updated.StatementList(), declarations), ) } @@ -917,9 +917,9 @@ func (c *EmitContext) VisitIterationBody(body *ast.Statement, visitor *ast.NodeV statements := c.EndLexicalEnvironment() if len(statements) > 0 { if ast.IsBlock(updated) { - statements = append(statements, updated.AsBlock().Statements.Nodes...) + statements = append(statements, updated.Statements()...) statementsList := c.Factory.NewNodeList(statements) - statementsList.Loc = updated.AsBlock().Statements.Loc + statementsList.Loc = updated.StatementList().Loc return c.Factory.UpdateBlock(updated.AsBlock(), statementsList) } statements = append(statements, updated) diff --git a/internal/printer/factory.go b/internal/printer/factory.go index adbd0a2cf2..714ac3d4b0 100644 --- a/internal/printer/factory.go +++ b/internal/printer/factory.go @@ -381,7 +381,7 @@ func (f *NodeFactory) RestoreOuterExpressions(outerExpression *ast.Expression, i // Ensures `"use strict"` is the first statement of a slice of statements. func (f *NodeFactory) EnsureUseStrict(statements []*ast.Statement) []*ast.Statement { for _, statement := range statements { - if ast.IsPrologueDirective(statement) && statement.AsExpressionStatement().Expression.Text() == "use strict" { + if ast.IsPrologueDirective(statement) && statement.Expression().Text() == "use strict" { return statements } else { break @@ -399,7 +399,7 @@ func (f *NodeFactory) SplitStandardPrologue(source []*ast.Statement) (prologue [ return source[:i], source[i:] } } - return nil, source + return source, nil } // Splits a slice of statements into two parts: custom prologue statements (e.g., with `EFCustomPrologue` set) and the rest of the statements @@ -548,17 +548,7 @@ func (f *NodeFactory) NewDisposeResourcesHelper(envBinding *ast.Expression) *ast // !!! ES2018 Helpers // Chains a sequence of expressions using the __assign helper or Object.assign if available in the target func (f *NodeFactory) NewAssignHelper(attributesSegments []*ast.Expression, scriptTarget core.ScriptTarget) *ast.Expression { - if scriptTarget >= core.ScriptTargetES2015 { - return f.NewCallExpression(f.NewPropertyAccessExpression(f.NewIdentifier("Object"), nil, f.NewIdentifier("assign"), ast.NodeFlagsNone), nil, nil, f.NewNodeList(attributesSegments), ast.NodeFlagsNone) - } - f.emitContext.RequestEmitHelper(assignHelper) - return f.NewCallExpression( - f.NewUnscopedHelperName("__assign"), - nil, - nil, - f.NewNodeList(attributesSegments), - ast.NodeFlagsNone, - ) + return f.NewCallExpression(f.NewPropertyAccessExpression(f.NewIdentifier("Object"), nil, f.NewIdentifier("assign"), ast.NodeFlagsNone), nil, nil, f.NewNodeList(attributesSegments), ast.NodeFlagsNone) } // ES2018 Destructuring Helpers diff --git a/internal/printer/helpers.go b/internal/printer/helpers.go index 0b3918af7b..a2d1348917 100644 --- a/internal/printer/helpers.go +++ b/internal/printer/helpers.go @@ -100,23 +100,6 @@ var disposeResourcesHelper = &EmitHelper{ // !!! Class Fields Helpers // !!! ES2018 Helpers -var assignHelper = &EmitHelper{ - Name: "typescript:assign", - ImportName: "__assign", - Scoped: false, - Priority: &Priority{1}, - Text: `var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -};`, -} // !!! ES2018 Destructuring Helpers var restHelper = &EmitHelper{ diff --git a/internal/printer/namegenerator_test.go b/internal/printer/namegenerator_test.go index 26d638a884..89cf50add0 100644 --- a/internal/printer/namegenerator_test.go +++ b/internal/printer/namegenerator_test.go @@ -354,8 +354,8 @@ func TestGeneratedNameForNamespace3(t *testing.T) { file := parsetestutil.ParseTypeScript("namespace ns1 { namespace foo { var foo; } } namespace ns2 { namespace foo { var foo; } }", false /*jsx*/) binder.BindSourceFile(file) - ns1 := file.Statements.Nodes[0].AsModuleDeclaration().Body.AsModuleBlock().Statements.Nodes[0] - ns2 := file.Statements.Nodes[1].AsModuleDeclaration().Body.AsModuleBlock().Statements.Nodes[0] + ns1 := file.Statements.Nodes[0].Body().Statements()[0] + ns2 := file.Statements.Nodes[1].Body().Statements()[0] name1 := ec.Factory.NewGeneratedNameForNode(ns1) name2 := ec.Factory.NewGeneratedNameForNode(ns2) @@ -376,8 +376,8 @@ func TestGeneratedNameForNamespace4(t *testing.T) { file := parsetestutil.ParseTypeScript("namespace ns1 { namespace foo { var foo; } } namespace ns2 { namespace foo { var foo; } }", false /*jsx*/) binder.BindSourceFile(file) - ns1 := file.Statements.Nodes[0].AsModuleDeclaration().Body.AsModuleBlock().Statements.Nodes[0] - ns2 := file.Statements.Nodes[1].AsModuleDeclaration().Body.AsModuleBlock().Statements.Nodes[0] + ns1 := file.Statements.Nodes[0].Body().Statements()[0] + ns2 := file.Statements.Nodes[1].Body().Statements()[0] name1 := ec.Factory.NewGeneratedNameForNode(ns1) name2 := ec.Factory.NewGeneratedNameForNode(ns2) @@ -542,7 +542,7 @@ func TestGeneratedNameForClassExpression(t *testing.T) { file := parsetestutil.ParseTypeScript("(class {})", false /*jsx*/) binder.BindSourceFile(file) - n := file.Statements.Nodes[0].AsExpressionStatement().Expression.AsParenthesizedExpression().Expression + n := file.Statements.Nodes[0].Expression().Expression() name1 := ec.Factory.NewGeneratedNameForNode(n) g := &printer.NameGenerator{Context: ec, GetTextOfNode: (*ast.Node).Text} @@ -559,7 +559,7 @@ func TestGeneratedNameForMethod1(t *testing.T) { file := parsetestutil.ParseTypeScript("class C { m() {} }", false /*jsx*/) binder.BindSourceFile(file) - n := file.Statements.Nodes[0].AsClassDeclaration().Members.Nodes[0] + n := file.Statements.Nodes[0].Members()[0] name1 := ec.Factory.NewGeneratedNameForNode(n) g := &printer.NameGenerator{Context: ec, GetTextOfNode: (*ast.Node).Text} @@ -576,7 +576,7 @@ func TestGeneratedNameForMethod2(t *testing.T) { file := parsetestutil.ParseTypeScript("class C { 0() {} }", false /*jsx*/) binder.BindSourceFile(file) - n := file.Statements.Nodes[0].AsClassDeclaration().Members.Nodes[0] + n := file.Statements.Nodes[0].Members()[0] name1 := ec.Factory.NewGeneratedNameForNode(n) g := &printer.NameGenerator{Context: ec, GetTextOfNode: (*ast.Node).Text} @@ -593,7 +593,7 @@ func TestGeneratedPrivateNameForMethod(t *testing.T) { file := parsetestutil.ParseTypeScript("class C { m() {} }", false /*jsx*/) binder.BindSourceFile(file) - n := file.Statements.Nodes[0].AsClassDeclaration().Members.Nodes[0] + n := file.Statements.Nodes[0].Members()[0] name1 := ec.Factory.NewGeneratedPrivateNameForNode(n) g := &printer.NameGenerator{Context: ec, GetTextOfNode: (*ast.Node).Text} @@ -610,7 +610,7 @@ func TestGeneratedNameForComputedPropertyName(t *testing.T) { file := parsetestutil.ParseTypeScript("class C { [x] }", false /*jsx*/) binder.BindSourceFile(file) - n := file.Statements.Nodes[0].AsClassDeclaration().Members.Nodes[0].Name() + n := file.Statements.Nodes[0].Members()[0].Name() name1 := ec.Factory.NewGeneratedNameForNode(n) g := &printer.NameGenerator{Context: ec, GetTextOfNode: (*ast.Node).Text} diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 6a1c10b6d8..799ec8d551 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -783,10 +783,9 @@ func (p *Printer) shouldEmitBlockFunctionBodyOnSingleLine(body *ast.Block) bool } func (p *Printer) shouldEmitOnNewLine(node *ast.Node, format ListFormat) bool { - // !!! TODO: enable multiline emit - // if p.emitContext.EmitFlags(node)&EFStartOnNewLine != 0 { - // return true - // } + if p.emitContext.EmitFlags(node)&EFStartOnNewLine != 0 { + return true + } return format&LFPreferNewLine != 0 } @@ -869,10 +868,9 @@ func (p *Printer) shouldAllowTrailingComma(node *ast.Node, list *ast.NodeList) b ast.KindImportAttributes: return true case ast.KindClassExpression, - ast.KindClassDeclaration: - return list == node.ClassLikeData().TypeParameters - case ast.KindInterfaceDeclaration: - return list == node.AsInterfaceDeclaration().TypeParameters + ast.KindClassDeclaration, + ast.KindInterfaceDeclaration: + return list == node.TypeParameterList() case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindMethodDeclaration: @@ -1559,10 +1557,10 @@ func (p *Printer) emitFunctionBody(body *ast.Block) { if p.shouldEmitBlockFunctionBodyOnSingleLine(body) && statementOffset == 0 && pos == p.writer.GetTextPos() { p.decreaseIndent() - p.emitList((*Printer).emitStatement, body.AsNode(), body.Statements, LFSingleLineFunctionBodyStatements) + p.emitListRange((*Printer).emitStatement, body.AsNode(), body.Statements, LFSingleLineFunctionBodyStatements, statementOffset, -1) p.increaseIndent() } else { - p.emitList((*Printer).emitStatement, body.AsNode(), body.Statements, LFMultiLineFunctionBodyStatements) + p.emitListRange((*Printer).emitStatement, body.AsNode(), body.Statements, LFMultiLineFunctionBodyStatements, statementOffset, -1) } p.emitDetachedCommentsAfterStatementList(body.AsNode(), body.Statements.Loc, detachedState) @@ -3754,7 +3752,7 @@ func (p *Printer) emitCommonJSExport(node *ast.CommonJSExport) { p.writeSpace() if node.Name().Kind == ast.KindStringLiteral { // TODO: This doesn't work for illegal names. - p.write(node.Name().AsStringLiteral().Text) + p.write(node.Name().Text()) } else { p.emitBindingName(node.Name()) } @@ -4022,7 +4020,7 @@ func (p *Printer) emitJsxOpeningElement(node *ast.JsxOpeningElement) { indented := p.writeLineSeparatorsAndIndentBefore(node.TagName, node.AsNode()) p.emitJsxTagName(node.TagName) p.emitTypeArguments(node.AsNode(), node.TypeArguments) - if attributes := node.Attributes.AsJsxAttributes(); len(attributes.Properties.Nodes) > 0 { + if len(node.Attributes.Properties()) > 0 { p.writeSpace() } p.emitJsxAttributes(node.Attributes.AsJsxAttributes()) @@ -4385,18 +4383,24 @@ func (p *Printer) emitSourceFile(node *ast.SourceFile) { p.writeLine() - state := p.emitDetachedCommentsBeforeStatementList(node.AsNode(), node.Statements.Loc) p.pushNameGenerationScope(node.AsNode()) p.generateAllNames(node.Statements) index := 0 + var state *commentState if node.ScriptKind != core.ScriptKindJSON { p.emitShebangIfNeeded(node) index = p.emitPrologueDirectives(node.Statements) + if !p.writer.IsAtStartOfLine() { + p.writeLine() + } + state = p.emitDetachedCommentsBeforeStatementList(node.AsNode(), node.Statements.Loc) p.emitHelpers(node.AsNode()) if node.IsDeclarationFile { p.emitTripleSlashDirectives(node) } + } else { + state = p.emitDetachedCommentsBeforeStatementList(node.AsNode(), node.Statements.Loc) } // !!! Emit triple-slash directives @@ -4533,9 +4537,9 @@ func (p *Printer) hasTrailingComma(parentNode *ast.Node, children *ast.NodeList) originalList := children switch originalParent.Kind { case ast.KindObjectLiteralExpression: - originalList = originalParent.AsObjectLiteralExpression().Properties + originalList = originalParent.PropertyList() case ast.KindArrayLiteralExpression: - originalList = originalParent.AsArrayLiteralExpression().Elements + originalList = originalParent.ElementList() case ast.KindCallExpression, ast.KindNewExpression: switch children { case parentNode.TypeArgumentList(): @@ -4567,13 +4571,11 @@ func (p *Printer) hasTrailingComma(parentNode *ast.Node, children *ast.NodeList) } case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern: switch children { - case parentNode.AsBindingPattern().Elements: - originalList = originalParent.AsBindingPattern().Elements + case parentNode.ElementList(): + originalList = originalParent.ElementList() } - case ast.KindNamedImports: - originalList = originalParent.AsNamedImports().Elements - case ast.KindNamedExports: - originalList = originalParent.AsNamedExports().Elements + case ast.KindNamedImports, ast.KindNamedExports: + originalList = originalParent.ElementList() case ast.KindImportAttributes: originalList = originalParent.AsImportAttributes().Attributes } @@ -4949,9 +4951,6 @@ func (p *Printer) Write(node *ast.Node, sourceFile *ast.SourceFile, writer EmitT case ast.KindSourceFile: p.emitSourceFile(node.AsSourceFile()) - case ast.KindBundle: - panic("not implemented") - // Transformation nodes case ast.KindNotEmittedTypeElement: p.emitNotEmittedTypeElement(node.AsNotEmittedTypeElement()) @@ -5084,7 +5083,7 @@ func (p *Printer) emitDetachedCommentsBeforeStatementList(node *ast.Node, detach containerPos := p.containerPos containerEnd := p.containerEnd declarationListContainerEnd := p.declarationListContainerEnd - skipLeadingComments := emitFlags&EFNoLeadingComments == 0 && !ast.PositionIsSynthesized(detachedRange.Pos()) + skipLeadingComments := ast.PositionIsSynthesized(detachedRange.Pos()) || emitFlags&EFNoLeadingComments != 0 if !skipLeadingComments { p.emitDetachedCommentsAndUpdateCommentsInfo(detachedRange) @@ -5645,31 +5644,20 @@ func (p *Printer) generateNames(node *ast.Node) { } switch node.Kind { - case ast.KindBlock: - p.generateAllNames(node.AsBlock().Statements) - case ast.KindLabeledStatement: - p.generateNames(node.AsLabeledStatement().Statement) - case ast.KindWithStatement: - p.generateNames(node.AsWithStatement().Statement) - case ast.KindDoStatement: - p.generateNames(node.AsDoStatement().Statement) - case ast.KindWhileStatement: - p.generateNames(node.AsWhileStatement().Statement) + case ast.KindBlock, ast.KindCaseClause, ast.KindDefaultClause: + p.generateAllNames(node.StatementList()) + case ast.KindLabeledStatement, ast.KindWithStatement, ast.KindDoStatement, ast.KindWhileStatement: + p.generateNames(node.Statement()) case ast.KindIfStatement: p.generateNames(node.AsIfStatement().ThenStatement) p.generateNames(node.AsIfStatement().ElseStatement) - case ast.KindForStatement: - p.generateNames(node.AsForStatement().Initializer) - p.generateNames(node.AsForStatement().Statement) - case ast.KindForOfStatement, ast.KindForInStatement: - p.generateNames(node.AsForInOrOfStatement().Initializer) - p.generateNames(node.AsForInOrOfStatement().Statement) + case ast.KindForStatement, ast.KindForOfStatement, ast.KindForInStatement: + p.generateNames(node.Initializer()) + p.generateNames(node.Statement()) case ast.KindSwitchStatement: p.generateNames(node.AsSwitchStatement().CaseBlock) case ast.KindCaseBlock: p.generateAllNames(node.AsCaseBlock().Clauses) - case ast.KindCaseClause, ast.KindDefaultClause: - p.generateAllNames(node.AsCaseOrDefaultClause().Statements) case ast.KindTryStatement: p.generateNames(node.AsTryStatement().TryBlock) p.generateNames(node.AsTryStatement().CatchClause) @@ -5690,7 +5678,7 @@ func (p *Printer) generateNames(node *ast.Node) { p.generateNames(node.AsFunctionDeclaration().Body) } case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern: - p.generateAllNames(node.AsBindingPattern().Elements) + p.generateAllNames(node.ElementList()) case ast.KindImportDeclaration, ast.KindJSImportDeclaration: p.generateNames(node.AsImportDeclaration().ImportClause) case ast.KindImportClause: @@ -5699,7 +5687,7 @@ func (p *Printer) generateNames(node *ast.Node) { case ast.KindNamespaceImport, ast.KindNamespaceExport: p.generateNameIfNeeded(node.Name()) case ast.KindNamedImports: - p.generateAllNames(node.AsNamedImports().Elements) + p.generateAllNames(node.ElementList()) case ast.KindImportSpecifier: n := node.AsImportSpecifier() if n.PropertyName != nil { diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index 823de528a2..ad37b673c1 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -2468,7 +2468,7 @@ func TestNoTrailingCommaAfterTransform(t *testing.T) { visitor = emitContext.NewNodeVisitor(func(node *ast.Node) *ast.Node { switch node.Kind { case ast.KindNonNullExpression: - node = node.AsNonNullExpression().Expression + node = node.Expression() default: node = node.VisitEachChild(visitor) } @@ -2489,7 +2489,7 @@ func TestTrailingCommaAfterTransform(t *testing.T) { visitor = emitContext.NewNodeVisitor(func(node *ast.Node) *ast.Node { switch node.Kind { case ast.KindNonNullExpression: - node = node.AsNonNullExpression().Expression + node = node.Expression() default: node = node.VisitEachChild(visitor) } diff --git a/internal/printer/utilities.go b/internal/printer/utilities.go index 41f20efb10..5716e75d6c 100644 --- a/internal/printer/utilities.go +++ b/internal/printer/utilities.go @@ -252,7 +252,7 @@ func getLiteralText(node *ast.LiteralLikeNode, sourceFile *ast.SourceFile, flags // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. var b strings.Builder - text := node.TemplateLiteralLikeData().Text + text := node.Text() rawText := node.TemplateLiteralLikeData().RawText raw := len(rawText) > 0 || len(text) == 0 @@ -443,14 +443,8 @@ func getContainingNodeArray(node *ast.Node) *ast.NodeList { switch node.Kind { case ast.KindTypeParameter: switch { - case ast.IsFunctionLike(parent): - return parent.FunctionLikeData().TypeParameters - case ast.IsClassLike(parent): - return parent.ClassLikeData().TypeParameters - case ast.IsInterfaceDeclaration(parent): - return parent.AsInterfaceDeclaration().TypeParameters - case ast.IsTypeOrJSTypeAliasDeclaration(parent): - return parent.AsTypeAliasDeclaration().TypeParameters + case ast.IsFunctionLike(parent) || ast.IsClassLike(parent) || ast.IsInterfaceDeclaration(parent) || ast.IsTypeOrJSTypeAliasDeclaration(parent): + return parent.TypeParameterList() case ast.IsInferTypeNode(parent): break default: @@ -487,32 +481,20 @@ func getContainingNodeArray(node *ast.Node) *ast.NodeList { // } switch parent.Kind { - case ast.KindTypeLiteral: - if ast.IsTypeElement(node) { - return parent.AsTypeLiteralNode().Members - } - case ast.KindInterfaceDeclaration: + case ast.KindTypeLiteral, ast.KindInterfaceDeclaration: if ast.IsTypeElement(node) { - return parent.AsInterfaceDeclaration().Members + return parent.MemberList() } case ast.KindUnionType: return parent.AsUnionTypeNode().Types case ast.KindIntersectionType: return parent.AsIntersectionTypeNode().Types - case ast.KindTupleType: - return parent.AsTupleTypeNode().Elements - case ast.KindArrayLiteralExpression: - return parent.AsArrayLiteralExpression().Elements + case ast.KindArrayLiteralExpression, ast.KindTupleType, ast.KindNamedImports, ast.KindNamedExports: + return parent.ElementList() case ast.KindCommaListExpression: panic("not implemented") - case ast.KindNamedImports: - return parent.AsNamedImports().Elements - case ast.KindNamedExports: - return parent.AsNamedExports().Elements - case ast.KindObjectLiteralExpression: - return parent.AsObjectLiteralExpression().Properties - case ast.KindJsxAttributes: - return parent.AsJsxAttributes().Properties + case ast.KindObjectLiteralExpression, ast.KindJsxAttributes: + return parent.PropertyList() case ast.KindCallExpression: p := parent.AsCallExpression() switch { @@ -529,41 +511,29 @@ func getContainingNodeArray(node *ast.Node) *ast.NodeList { case node != p.Expression: return p.Arguments } - case ast.KindJsxElement: + case ast.KindJsxElement, ast.KindJsxFragment: if ast.IsJsxChild(node) { - return parent.AsJsxElement().Children + return parent.Children() } - case ast.KindJsxFragment: - if ast.IsJsxChild(node) { - return parent.AsJsxFragment().Children - } - case ast.KindJsxOpeningElement: + case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: if ast.IsTypeNode(node) { - return parent.AsJsxOpeningElement().TypeArguments + return parent.TypeArgumentList() } - case ast.KindJsxSelfClosingElement: - if ast.IsTypeNode(node) { - return parent.AsJsxSelfClosingElement().TypeArguments - } - case ast.KindBlock: - return parent.AsBlock().Statements - case ast.KindCaseClause, ast.KindDefaultClause: - return parent.AsCaseOrDefaultClause().Statements - case ast.KindModuleBlock: - return parent.AsModuleBlock().Statements + case ast.KindBlock, ast.KindModuleBlock, ast.KindCaseClause, ast.KindDefaultClause: + return parent.StatementList() case ast.KindCaseBlock: return parent.AsCaseBlock().Clauses case ast.KindClassDeclaration, ast.KindClassExpression: if ast.IsClassElement(node) { - return parent.ClassLikeData().Members + return parent.MemberList() } case ast.KindEnumDeclaration: if ast.IsEnumMember(node) { - return parent.AsEnumDeclaration().Members + return parent.MemberList() } case ast.KindSourceFile: if ast.IsStatement(node) { - return parent.AsSourceFile().Statements + return parent.StatementList() } } @@ -640,13 +610,13 @@ func greatestEnd(end int, nodes ...interface{ End() int }) int { func skipSynthesizedParentheses(node *ast.Node) *ast.Node { for node.Kind == ast.KindParenthesizedExpression && ast.NodeIsSynthesized(node) { - node = node.AsParenthesizedExpression().Expression + node = node.Expression() } return node } func isNewExpressionWithoutArguments(node *ast.Node) bool { - return node.Kind == ast.KindNewExpression && node.AsNewExpression().Arguments == nil + return node.Kind == ast.KindNewExpression && node.ArgumentList() == nil } func isBinaryOperation(node *ast.Node, token ast.Kind) bool { @@ -660,7 +630,7 @@ func isImmediatelyInvokedFunctionExpressionOrArrowFunction(node *ast.Expression) if !ast.IsCallExpression(node) { return false } - node = ast.SkipPartiallyEmittedExpressions(node.AsCallExpression().Expression) + node = ast.SkipPartiallyEmittedExpressions(node.Expression()) return ast.IsFunctionExpression(node) || ast.IsArrowFunction(node) } diff --git a/internal/project/api.go b/internal/project/api.go index ea84b3adb5..ad96de170f 100644 --- a/internal/project/api.go +++ b/internal/project/api.go @@ -7,7 +7,7 @@ import ( ) func (s *Session) OpenProject(ctx context.Context, configFileName string) (*Project, error) { - fileChanges, overlays, ataChanges := s.flushChanges(ctx) + fileChanges, overlays, ataChanges, _ := s.flushChanges(ctx) newSnapshot := s.UpdateSnapshot(ctx, overlays, SnapshotChange{ fileChanges: fileChanges, ataChanges: ataChanges, diff --git a/internal/project/ata/validatepackagename_test.go b/internal/project/ata/validatepackagename_test.go index 9a12206dd6..1a9ab43862 100644 --- a/internal/project/ata/validatepackagename_test.go +++ b/internal/project/ata/validatepackagename_test.go @@ -13,7 +13,7 @@ func TestValidatePackageName(t *testing.T) { t.Parallel() packageName := "a" for range 8 { - packageName += packageName + packageName += packageName //nolint:perfsprint } status, _, _ := ata.ValidatePackageName(packageName) assert.Equal(t, status, ata.NameTooLong) diff --git a/internal/project/background/queue.go b/internal/project/background/queue.go index 4a425e569e..c4157dcb62 100644 --- a/internal/project/background/queue.go +++ b/internal/project/background/queue.go @@ -25,11 +25,9 @@ func (q *Queue) Enqueue(ctx context.Context, fn func(context.Context)) { } q.mu.RUnlock() - q.wg.Add(1) - go func() { - defer q.wg.Done() + q.wg.Go(func() { fn(ctx) - }() + }) } // Wait waits for all active tasks to complete. diff --git a/internal/project/bulkcache_test.go b/internal/project/bulkcache_test.go new file mode 100644 index 0000000000..e9b116f7c8 --- /dev/null +++ b/internal/project/bulkcache_test.go @@ -0,0 +1,341 @@ +package project_test + +import ( + "context" + "fmt" + "testing" + + "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/project" + "github.com/microsoft/typescript-go/internal/testutil/projecttestutil" + "gotest.tools/v3/assert" +) + +func TestBulkCacheInvalidation(t *testing.T) { + t.Parallel() + + if !bundled.Embedded { + t.Skip("bundled files are not embedded") + } + + // Base file structure for testing + baseFiles := map[string]any{ + "/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "target": "es2015", + "types": ["node"] + }, + "include": ["src/**/*"] + }`, + "/project/src/index.ts": `import { helper } from "./helper"; console.log(helper);`, + "/project/src/helper.ts": `export const helper = "test";`, + "/project/src/utils/lib.ts": `export function util() { return "util"; }`, + + "/project/node_modules/@types/node/index.d.ts": `import "./fs"; import "./console";`, + "/project/node_modules/@types/node/fs.d.ts": ``, + "/project/node_modules/@types/node/console.d.ts": ``, + } + + t.Run("large number of node_modules changes invalidates only node_modules cache", func(t *testing.T) { + t.Parallel() + test := func(t *testing.T, fileEvents []*lsproto.FileEvent, expectNodeModulesInvalidation bool) { + session, utils := projecttestutil.Setup(baseFiles) + + // Open a file to create the project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, baseFiles["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + // Get initial snapshot and verify config + ls, err := session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015) + + snapshotBefore, release := session.Snapshot() + defer release() + configBefore := snapshotBefore.ConfigFileRegistry + + // Update tsconfig.json on disk to test that configs don't get reloaded + err = utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true, + "target": "esnext", + "types": ["node"] + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + // Update fs.d.ts in node_modules + err = utils.FS().WriteFile("/project/node_modules/@types/node/fs.d.ts", "new text", false) + assert.NilError(t, err) + + // Process the excessive node_modules changes + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // Get language service again to trigger snapshot update + ls, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + snapshotAfter, release := session.Snapshot() + defer release() + configAfter := snapshotAfter.ConfigFileRegistry + + // Config should NOT have been reloaded (target should remain ES2015, not esnext) + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015, "Config should not have been reloaded for node_modules-only changes") + + // Config registry should be the same instance (no configs reloaded) + assert.Equal(t, configBefore, configAfter, "Config registry should not have changed for node_modules-only changes") + + fsDtsText := snapshotAfter.GetFile("/project/node_modules/@types/node/fs.d.ts").Content() + if expectNodeModulesInvalidation { + assert.Equal(t, fsDtsText, "new text") + } else { + assert.Equal(t, fsDtsText, "") + } + } + + t.Run("with file existing in cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/node_modules/generated/file%d.js", lsproto.FileChangeTypeCreated) + // Include two files in the program to trigger a full program creation. + // Exclude fs.d.ts to show that its content still gets invalidated. + fileEvents = append(fileEvents, &lsproto.FileEvent{ + Uri: "file:///project/node_modules/@types/node/index.d.ts", + Type: lsproto.FileChangeTypeChanged, + }, &lsproto.FileEvent{ + Uri: "file:///project/node_modules/@types/node/console.d.ts", + Type: lsproto.FileChangeTypeChanged, + }) + + test(t, fileEvents, true) + }) + + t.Run("without file existing in cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/node_modules/generated/file%d.js", lsproto.FileChangeTypeCreated) + test(t, fileEvents, false) + }) + }) + + t.Run("large number of changes outside node_modules", func(t *testing.T) { + t.Parallel() + test := func(t *testing.T, fileEvents []*lsproto.FileEvent, expectConfigReload bool) { + session, utils := projecttestutil.Setup(baseFiles) + + // Open a file to create the project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, baseFiles["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + // Get initial state + ls, err := session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015) + + // Update tsconfig.json on disk + err = utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true, + "target": "esnext", + "types": ["node"] + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + // Add root file + err = utils.FS().WriteFile("/project/src/rootFile.ts", `console.log("root file")`, false) + assert.NilError(t, err) + + session.DidChangeWatchedFiles(context.Background(), fileEvents) + ls, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + if expectConfigReload { + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetESNext, "Config should have been reloaded for changes outside node_modules") + assert.Check(t, ls.GetProgram().GetSourceFile("/project/src/rootFile.ts") != nil, "New root file should be present") + } else { + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015, "Config should not have been reloaded for changes outside node_modules") + assert.Check(t, ls.GetProgram().GetSourceFile("/project/src/rootFile.ts") == nil, "New root file should not be present") + } + } + + t.Run("with event matching include glob", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/generated/file%d.ts", lsproto.FileChangeTypeCreated) + fileEvents = append(fileEvents, &lsproto.FileEvent{ + Uri: "file:///project/src/rootFile.ts", + Type: lsproto.FileChangeTypeCreated, + }) + test(t, fileEvents, true) + }) + + t.Run("without event matching include glob", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/generated/file%d.ts", lsproto.FileChangeTypeCreated) + test(t, fileEvents, false) + }) + }) + + t.Run("large number of changes outside node_modules causes project reevaluation", func(t *testing.T) { + t.Parallel() + session, utils := projecttestutil.Setup(baseFiles) + + // Open a file that will initially use the root tsconfig + session.DidOpenFile(context.Background(), "file:///project/src/utils/lib.ts", 1, baseFiles["/project/src/utils/lib.ts"].(string), lsproto.LanguageKindTypeScript) + + // Initially, the file should use the root project (strict mode) + snapshot, release := session.Snapshot() + defer release() + initialProject := snapshot.GetDefaultProject("file:///project/src/utils/lib.ts") + assert.Equal(t, initialProject.Name(), "/project/tsconfig.json", "Should initially use root tsconfig") + + // Get language service to verify initial strict mode + ls, err := session.GetLanguageService(context.Background(), "file:///project/src/utils/lib.ts") + assert.NilError(t, err) + assert.Equal(t, ls.GetProgram().Options().Strict, core.TSTrue, "Should initially use strict mode from root config") + + // Now create the nested tsconfig (this would normally be detected, but we'll simulate a missed event) + err = utils.FS().WriteFile("/project/src/utils/tsconfig.json", `{ + "compilerOptions": { + "strict": false, + "target": "esnext" + } + }`, false) + assert.NilError(t, err) + + // Create excessive changes to trigger bulk invalidation + fileEvents := generateFileEvents(1001, "file:///project/src/generated/file%d.ts", lsproto.FileChangeTypeCreated) + + // Process the excessive changes - this should trigger project reevaluation + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // Get language service - this should now find the nested config and switch projects + ls, err = session.GetLanguageService(context.Background(), "file:///project/src/utils/lib.ts") + assert.NilError(t, err) + + snapshot, release = session.Snapshot() + defer release() + newProject := snapshot.GetDefaultProject("file:///project/src/utils/lib.ts") + + // The file should now use the nested tsconfig + assert.Equal(t, newProject.Name(), "/project/src/utils/tsconfig.json", "Should now use nested tsconfig after bulk invalidation") + assert.Equal(t, ls.GetProgram().Options().Strict, core.TSFalse, "Should now use non-strict mode from nested config") + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetESNext, "Should use esnext target from nested config") + }) + + t.Run("config file names cache", func(t *testing.T) { + t.Parallel() + test := func(t *testing.T, fileEvents []*lsproto.FileEvent, expectConfigDiscovery bool, testName string) { + files := map[string]any{ + "/project/src/index.ts": `console.log("test");`, // No tsconfig initially + } + session, utils := projecttestutil.Setup(files) + + // Open file without tsconfig - should create inferred project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, files["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + snapshot, release := session.Snapshot() + defer release() + assert.Assert(t, snapshot.ProjectCollection.InferredProject() != nil, "Should have inferred project") + assert.Equal(t, snapshot.GetDefaultProject("file:///project/src/index.ts").Kind, project.KindInferred) + + // Create a tsconfig that would affect this file (simulating a missed creation event) + err := utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + + // Process the changes + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // Get language service to trigger config discovery + _, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + snapshot, release = session.Snapshot() + defer release() + newProject := snapshot.GetDefaultProject("file:///project/src/index.ts") + + // Check expected behavior + if expectConfigDiscovery { + // Should now use configured project instead of inferred + assert.Equal(t, newProject.Kind, project.KindConfigured, "Should now use configured project after cache invalidation") + assert.Equal(t, newProject.Name(), "/project/tsconfig.json", "Should use the newly discovered tsconfig") + } else { + // Should still use inferred project (config file names cache not cleared) + assert.Assert(t, newProject == snapshot.ProjectCollection.InferredProject(), "Should still use inferred project after node_modules-only changes") + } + } + + t.Run("excessive changes only in node_modules does not affect config file names cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/node_modules/generated/file%d.js", lsproto.FileChangeTypeCreated) + test(t, fileEvents, false, "node_modules changes should not clear config cache") + }) + + t.Run("excessive changes outside node_modules clears config file names cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/src/generated/file%d.ts", lsproto.FileChangeTypeCreated) + // Presence of any tsconfig.json file event triggers rediscovery for config for all open files + fileEvents = append(fileEvents, &lsproto.FileEvent{ + Uri: lsproto.DocumentUri("file:///project/src/generated/tsconfig.json"), + Type: lsproto.FileChangeTypeCreated, + }) + test(t, fileEvents, true, "non-node_modules changes should clear config cache") + }) + }) + + // Simulate external build tool changing files in dist/ (not included by any project) + t.Run("excessive changes in dist folder do not invalidate", func(t *testing.T) { + t.Parallel() + files := map[string]any{ + "/project/src/index.ts": `console.log("test");`, // No tsconfig initially + } + session, utils := projecttestutil.Setup(files) + + // Open file without tsconfig - should create inferred project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, files["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + snapshot, release := session.Snapshot() + defer release() + assert.Equal(t, snapshot.GetDefaultProject("file:///project/src/index.ts").Kind, project.KindInferred) + + // Create a tsconfig that would affect this file (simulating a missed creation event) + // This should NOT be discovered after dist-folder changes + err := utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + + // Create excessive changes in dist folder only + fileEvents := generateFileEvents(1001, "file:///project/dist/generated/file%d.js", lsproto.FileChangeTypeCreated) + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // File should still use inferred project (config file names cache NOT cleared for dist changes) + _, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + snapshot, release = session.Snapshot() + defer release() + newProject := snapshot.GetDefaultProject("file:///project/src/index.ts") + assert.Equal(t, newProject.Kind, project.KindInferred, "dist-folder changes should not cause config discovery") + // This assertion will fail until we implement logic to ignore dist folder changes + }) +} + +// Helper function to generate excessive file change events +func generateFileEvents(count int, pathTemplate string, changeType lsproto.FileChangeType) []*lsproto.FileEvent { + var events []*lsproto.FileEvent + for i := range count { + events = append(events, &lsproto.FileEvent{ + Uri: lsproto.DocumentUri(fmt.Sprintf(pathTemplate, i)), + Type: changeType, + }) + } + return events +} diff --git a/internal/project/checkerpool.go b/internal/project/checkerpool.go index 6bcbcc686d..0e1ba1cd04 100644 --- a/internal/project/checkerpool.go +++ b/internal/project/checkerpool.go @@ -12,7 +12,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" ) -type checkerPool struct { +type CheckerPool struct { maxCheckers int program *compiler.Program @@ -20,19 +20,21 @@ type checkerPool struct { cond *sync.Cond createCheckersOnce sync.Once checkers []*checker.Checker + locks []sync.Mutex inUse map[*checker.Checker]bool fileAssociations map[*ast.SourceFile]int requestAssociations map[string]int log func(msg string) } -var _ compiler.CheckerPool = (*checkerPool)(nil) +var _ compiler.CheckerPool = (*CheckerPool)(nil) -func newCheckerPool(maxCheckers int, program *compiler.Program, log func(msg string)) *checkerPool { - pool := &checkerPool{ +func newCheckerPool(maxCheckers int, program *compiler.Program, log func(msg string)) *CheckerPool { + pool := &CheckerPool{ program: program, maxCheckers: maxCheckers, checkers: make([]*checker.Checker, maxCheckers), + locks: make([]sync.Mutex, maxCheckers), inUse: make(map[*checker.Checker]bool), requestAssociations: make(map[string]int), log: log, @@ -42,7 +44,7 @@ func newCheckerPool(maxCheckers int, program *compiler.Program, log func(msg str return pool } -func (p *checkerPool) GetCheckerForFile(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) { +func (p *CheckerPool) GetCheckerForFile(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) { p.mu.Lock() defer p.mu.Unlock() @@ -75,36 +77,52 @@ func (p *checkerPool) GetCheckerForFile(ctx context.Context, file *ast.SourceFil return checker, p.createRelease(requestID, index, checker) } -func (p *checkerPool) GetChecker(ctx context.Context) (*checker.Checker, func()) { +// GetCheckerForFileExclusive is the same as GetCheckerForFile but also locks a mutex associated with the checker. +// Call `done` to free the lock. +func (p *CheckerPool) GetCheckerForFileExclusive(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) { + panic("unimplemented") // implement if used by LS +} + +func (p *CheckerPool) GetChecker(ctx context.Context) (*checker.Checker, func()) { p.mu.Lock() defer p.mu.Unlock() checker, index := p.getCheckerLocked(core.GetRequestID(ctx)) return checker, p.createRelease(core.GetRequestID(ctx), index, checker) } -func (p *checkerPool) Files(checker *checker.Checker) iter.Seq[*ast.SourceFile] { +func (p *CheckerPool) Files(checker *checker.Checker) iter.Seq[*ast.SourceFile] { panic("unimplemented") } -func (p *checkerPool) GetAllCheckers(ctx context.Context) ([]*checker.Checker, func()) { +func (p *CheckerPool) Count() int { + return p.maxCheckers +} + +func (p *CheckerPool) ForEachCheckerParallel(ctx context.Context, cb func(idx int, c *checker.Checker)) { p.mu.Lock() defer p.mu.Unlock() requestID := core.GetRequestID(ctx) if requestID == "" { - panic("cannot call GetAllCheckers on a project.checkerPool without a request ID") + panic("cannot call ForEachCheckerParallel on a project.checkerPool without a request ID") } // A request can only access one checker if c, release := p.getRequestCheckerLocked(requestID); c != nil { - return []*checker.Checker{c}, release + defer release() + cb(0, c) + return } + // TODO: Does this ever work without deadlocking? `p.GetChecker` also tries to lock this mutex. + // Should this just be a panic? c, release := p.GetChecker(ctx) - return []*checker.Checker{c}, release + defer release() + cb(0, c) + return } -func (p *checkerPool) getCheckerLocked(requestID string) (*checker.Checker, int) { +func (p *CheckerPool) getCheckerLocked(requestID string) (*checker.Checker, int) { if checker, index := p.getImmediatelyAvailableChecker(); checker != nil { p.inUse[checker] = true if requestID != "" { @@ -130,7 +148,7 @@ func (p *checkerPool) getCheckerLocked(requestID string) (*checker.Checker, int) return checker, index } -func (p *checkerPool) getRequestCheckerLocked(requestID string) (*checker.Checker, func()) { +func (p *CheckerPool) getRequestCheckerLocked(requestID string) (*checker.Checker, func()) { if index, ok := p.requestAssociations[requestID]; ok { checker := p.checkers[index] if checker != nil { @@ -146,7 +164,7 @@ func (p *checkerPool) getRequestCheckerLocked(requestID string) (*checker.Checke return nil, noop } -func (p *checkerPool) getImmediatelyAvailableChecker() (*checker.Checker, int) { +func (p *CheckerPool) getImmediatelyAvailableChecker() (*checker.Checker, int) { for i, checker := range p.checkers { if checker == nil { continue @@ -159,7 +177,7 @@ func (p *checkerPool) getImmediatelyAvailableChecker() (*checker.Checker, int) { return nil, -1 } -func (p *checkerPool) waitForAvailableChecker() (*checker.Checker, int) { +func (p *CheckerPool) waitForAvailableChecker() (*checker.Checker, int) { p.log("checkerpool: Waiting for an available checker") for { p.cond.Wait() @@ -170,7 +188,7 @@ func (p *checkerPool) waitForAvailableChecker() (*checker.Checker, int) { } } -func (p *checkerPool) createRelease(requestId string, index int, checker *checker.Checker) func() { +func (p *CheckerPool) createRelease(requestId string, index int, checker *checker.Checker) func() { return func() { p.mu.Lock() defer p.mu.Unlock() @@ -188,7 +206,7 @@ func (p *checkerPool) createRelease(requestId string, index int, checker *checke } } -func (p *checkerPool) isFullLocked() bool { +func (p *CheckerPool) isFullLocked() bool { for _, checker := range p.checkers { if checker == nil { return false @@ -197,10 +215,10 @@ func (p *checkerPool) isFullLocked() bool { return true } -func (p *checkerPool) createCheckerLocked() (*checker.Checker, int) { +func (p *CheckerPool) createCheckerLocked() (*checker.Checker, int) { for i, existing := range p.checkers { if existing == nil { - checker := checker.NewChecker(p.program) + checker, _ := checker.NewChecker(p.program) p.checkers[i] = checker return checker, i } @@ -208,7 +226,7 @@ func (p *checkerPool) createCheckerLocked() (*checker.Checker, int) { panic("called createCheckerLocked when pool is full") } -func (p *checkerPool) isRequestCheckerInUse(requestID string) bool { +func (p *CheckerPool) isRequestCheckerInUse(requestID string) bool { p.mu.Lock() defer p.mu.Unlock() @@ -221,7 +239,7 @@ func (p *checkerPool) isRequestCheckerInUse(requestID string) bool { return false } -func (p *checkerPool) size() int { +func (p *CheckerPool) size() int { p.mu.Lock() defer p.mu.Unlock() size := 0 diff --git a/internal/project/client.go b/internal/project/client.go index e223389eb6..46b5393a05 100644 --- a/internal/project/client.go +++ b/internal/project/client.go @@ -10,4 +10,5 @@ type Client interface { WatchFiles(ctx context.Context, id WatcherID, watchers []*lsproto.FileSystemWatcher) error UnwatchFiles(ctx context.Context, id WatcherID) error RefreshDiagnostics(ctx context.Context) error + PublishDiagnostics(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error } diff --git a/internal/project/compilerhost.go b/internal/project/compilerhost.go index f7ff520542..b88cc61cc4 100644 --- a/internal/project/compilerhost.go +++ b/internal/project/compilerhost.go @@ -7,6 +7,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/project/logging" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -156,7 +157,7 @@ func (c *compilerHost) GetSourceFile(opts ast.SourceFileParseOptions) *ast.Sourc } // Trace implements compiler.CompilerHost. -func (c *compilerHost) Trace(msg string) { +func (c *compilerHost) Trace(msg *diagnostics.Message, args ...any) { panic("unimplemented") } diff --git a/internal/project/configfileregistry.go b/internal/project/configfileregistry.go index 801d249be7..45d862f48a 100644 --- a/internal/project/configfileregistry.go +++ b/internal/project/configfileregistry.go @@ -1,6 +1,7 @@ package project import ( + "iter" "maps" "github.com/microsoft/typescript-go/internal/core" @@ -19,6 +20,7 @@ type ConfigFileRegistry struct { } type configFileEntry struct { + fileName string pendingReload PendingReload commandLine *tsoptions.ParsedCommandLine // retainingProjects is the set of projects that have called acquireConfig @@ -41,11 +43,12 @@ type configFileEntry struct { // when this is set, no other fields will be used. retainingConfigs map[tspath.Path]struct{} // rootFilesWatch is a watch for the root files of this config file. - rootFilesWatch *WatchedFiles[patternsAndIgnored] + rootFilesWatch *WatchedFiles[PatternsAndIgnored] } func newConfigFileEntry(fileName string) *configFileEntry { return &configFileEntry{ + fileName: fileName, pendingReload: PendingReloadFull, rootFilesWatch: NewWatchedFiles( "root files for "+fileName, @@ -55,8 +58,9 @@ func newConfigFileEntry(fileName string) *configFileEntry { } } -func newExtendedConfigFileEntry(extendingConfigPath tspath.Path) *configFileEntry { +func newExtendedConfigFileEntry(fileName string, extendingConfigPath tspath.Path) *configFileEntry { return &configFileEntry{ + fileName: fileName, pendingReload: PendingReloadFull, retainingConfigs: map[tspath.Path]struct{}{extendingConfigPath: {}}, } @@ -64,6 +68,7 @@ func newExtendedConfigFileEntry(extendingConfigPath tspath.Path) *configFileEntr func (e *configFileEntry) Clone() *configFileEntry { return &configFileEntry{ + fileName: e.fileName, pendingReload: e.pendingReload, commandLine: e.commandLine, // !!! eagerly cloning these maps makes everything more convenient, @@ -104,6 +109,73 @@ func (c *ConfigFileRegistry) clone() *ConfigFileRegistry { } } +// For testing +type TestConfigEntry struct { + FileName string + RetainingProjects iter.Seq[tspath.Path] + RetainingOpenFiles iter.Seq[tspath.Path] + RetainingConfigs iter.Seq[tspath.Path] +} + +// For testing +func (c *ConfigFileRegistry) ForEachTestConfigEntry(cb func(tspath.Path, *TestConfigEntry)) { + if c != nil { + for path, entry := range c.configs { + cb(path, &TestConfigEntry{ + FileName: entry.fileName, + RetainingProjects: maps.Keys(entry.retainingProjects), + RetainingOpenFiles: maps.Keys(entry.retainingOpenFiles), + RetainingConfigs: maps.Keys(entry.retainingConfigs), + }) + } + } +} + +// For testing +func (c *ConfigFileRegistry) GetTestConfigEntry(path tspath.Path) *TestConfigEntry { + if c != nil { + if entry, ok := c.configs[path]; ok { + return &TestConfigEntry{ + FileName: entry.fileName, + RetainingProjects: maps.Keys(entry.retainingProjects), + RetainingOpenFiles: maps.Keys(entry.retainingOpenFiles), + RetainingConfigs: maps.Keys(entry.retainingConfigs), + } + } + } + return nil +} + +type TestConfigFileNamesEntry struct { + NearestConfigFileName string + Ancestors map[string]string +} + +// For testing +func (c *ConfigFileRegistry) ForEachTestConfigFileNamesEntry(cb func(tspath.Path, *TestConfigFileNamesEntry)) { + if c != nil { + for path, entry := range c.configFileNames { + cb(path, &TestConfigFileNamesEntry{ + NearestConfigFileName: entry.nearestConfigFileName, + Ancestors: entry.ancestors, + }) + } + } +} + +// For testing +func (c *ConfigFileRegistry) GetTestConfigFileNamesEntry(path tspath.Path) *TestConfigFileNamesEntry { + if c != nil { + if entry, ok := c.configFileNames[path]; ok { + return &TestConfigFileNamesEntry{ + NearestConfigFileName: entry.nearestConfigFileName, + Ancestors: entry.ancestors, + } + } + } + return nil +} + type configFileNames struct { // nearestConfigFileName is the file name of the nearest ancestor config file. nearestConfigFileName string diff --git a/internal/project/configfileregistrybuilder.go b/internal/project/configfileregistrybuilder.go index a4b5a7ff6d..051ab23186 100644 --- a/internal/project/configfileregistrybuilder.go +++ b/internal/project/configfileregistrybuilder.go @@ -25,7 +25,7 @@ var ( // all changes have been made. type configFileRegistryBuilder struct { fs *snapshotFSBuilder - extendedConfigCache *extendedConfigCache + extendedConfigCache *ExtendedConfigCache sessionOptions *SessionOptions base *ConfigFileRegistry @@ -36,7 +36,7 @@ type configFileRegistryBuilder struct { func newConfigFileRegistryBuilder( fs *snapshotFSBuilder, oldConfigFileRegistry *ConfigFileRegistry, - extendedConfigCache *extendedConfigCache, + extendedConfigCache *ExtendedConfigCache, sessionOptions *SessionOptions, logger *logging.LogTree, ) *configFileRegistryBuilder { @@ -76,10 +76,10 @@ func (c *configFileRegistryBuilder) Finalize() *ConfigFileRegistry { return newRegistry } -func (c *configFileRegistryBuilder) findOrAcquireConfigForOpenFile( +func (c *configFileRegistryBuilder) findOrAcquireConfigForFile( configFileName string, configFilePath tspath.Path, - openFilePath tspath.Path, + filePath tspath.Path, loadKind projectLoadKind, logger *logging.LogTree, ) *tsoptions.ParsedCommandLine { @@ -90,7 +90,7 @@ func (c *configFileRegistryBuilder) findOrAcquireConfigForOpenFile( } return nil case projectLoadKindCreate: - return c.acquireConfigForOpenFile(configFileName, configFilePath, openFilePath, logger) + return c.acquireConfigForFile(configFileName, configFilePath, filePath, logger) default: panic(fmt.Sprintf("unknown project load kind: %d", loadKind)) } @@ -122,7 +122,7 @@ func (c *configFileRegistryBuilder) updateExtendingConfigs(extendingConfigPath t for _, extendedConfig := range newCommandLine.ExtendedSourceFiles() { extendedConfigPath := c.fs.toPath(extendedConfig) newExtendedConfigPaths.Add(extendedConfigPath) - entry, loaded := c.configs.LoadOrStore(extendedConfigPath, newExtendedConfigFileEntry(extendingConfigPath)) + entry, loaded := c.configs.LoadOrStore(extendedConfigPath, newExtendedConfigFileEntry(extendedConfig, extendingConfigPath)) if loaded { entry.ChangeIf( func(config *configFileEntry) bool { @@ -216,7 +216,7 @@ func (c *configFileRegistryBuilder) updateRootFilesWatch(fileName string, entry } slices.Sort(globs) - entry.rootFilesWatch = entry.rootFilesWatch.Clone(patternsAndIgnored{ + entry.rootFilesWatch = entry.rootFilesWatch.Clone(PatternsAndIgnored{ patterns: globs, ignored: ignored, }) @@ -248,17 +248,19 @@ func (c *configFileRegistryBuilder) acquireConfigForProject(fileName string, pat return entry.Value().commandLine } -// acquireConfigForOpenFile loads a config file entry from the cache, or parses it if not already +// acquireConfigForFile loads a config file entry from the cache, or parses it if not already // cached, then adds the open file to `retainingOpenFiles` to keep it alive in the cache. -// Each `acquireConfigForOpenFile` call that passes an `openFilePath` +// Each `acquireConfigForFile` call that passes an `openFilePath` // should be accompanied by an eventual `releaseConfigForOpenFile` call with the same open file. -func (c *configFileRegistryBuilder) acquireConfigForOpenFile(configFileName string, configFilePath tspath.Path, openFilePath tspath.Path, logger *logging.LogTree) *tsoptions.ParsedCommandLine { +func (c *configFileRegistryBuilder) acquireConfigForFile(configFileName string, configFilePath tspath.Path, filePath tspath.Path, logger *logging.LogTree) *tsoptions.ParsedCommandLine { entry, _ := c.configs.LoadOrStore(configFilePath, newConfigFileEntry(configFileName)) var needsRetainOpenFile bool entry.ChangeIf( func(config *configFileEntry) bool { - _, alreadyRetaining := config.retainingOpenFiles[openFilePath] - needsRetainOpenFile = !alreadyRetaining + if c.fs.isOpenFile(filePath) { + _, alreadyRetaining := config.retainingOpenFiles[filePath] + needsRetainOpenFile = !alreadyRetaining + } return needsRetainOpenFile || config.pendingReload != PendingReloadNone }, func(config *configFileEntry) { @@ -266,7 +268,7 @@ func (c *configFileRegistryBuilder) acquireConfigForOpenFile(configFileName stri if config.retainingOpenFiles == nil { config.retainingOpenFiles = make(map[tspath.Path]struct{}) } - config.retainingOpenFiles[openFilePath] = struct{}{} + config.retainingOpenFiles[filePath] = struct{}{} } c.reloadIfNeeded(config, configFileName, configFilePath, logger) }, @@ -317,10 +319,48 @@ func (r changeFileResult) IsEmpty() bool { return len(r.affectedProjects) == 0 && len(r.affectedFiles) == 0 } +func (c *configFileRegistryBuilder) invalidateCache(logger *logging.LogTree) changeFileResult { + var affectedProjects map[tspath.Path]struct{} + var affectedFiles map[tspath.Path]struct{} + + logger.Log("Too many files changed; marking all configs for reload") + c.configFileNames.Range(func(entry *dirty.MapEntry[tspath.Path, *configFileNames]) bool { + if affectedFiles == nil { + affectedFiles = make(map[tspath.Path]struct{}) + } + affectedFiles[entry.Key()] = struct{}{} + return true + }) + c.configFileNames.Clear() + + c.configs.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *configFileEntry]) bool { + entry.Change(func(entry *configFileEntry) { + affectedProjects = core.CopyMapInto(affectedProjects, entry.retainingProjects) + if entry.pendingReload != PendingReloadFull { + text, ok := c.FS().ReadFile(entry.fileName) + if !ok || text != entry.commandLine.ConfigFile.SourceFile.Text() { + entry.pendingReload = PendingReloadFull + } else { + entry.pendingReload = PendingReloadFileNames + } + } + }) + return true + }) + + return changeFileResult{ + affectedProjects: affectedProjects, + affectedFiles: affectedFiles, + } +} + func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, logger *logging.LogTree) changeFileResult { var affectedProjects map[tspath.Path]struct{} var affectedFiles map[tspath.Path]struct{} + var shouldInvalidateCache bool + logger.Log("Summarizing file changes") + hasExcessiveChanges := summary.HasExcessiveWatchEvents() && summary.IncludesWatchChangeOutsideNodeModules createdFiles := make(map[tspath.Path]string, summary.Created.Len()) createdOrDeletedFiles := make(map[tspath.Path]struct{}, summary.Created.Len()+summary.Deleted.Len()) createdOrChangedOrDeletedFiles := make(map[tspath.Path]struct{}, summary.Changed.Len()+summary.Deleted.Len()) @@ -366,6 +406,10 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo logger.Log("Checking if any changed files are config files") for path := range createdOrChangedOrDeletedFiles { if entry, ok := c.configs.Load(path); ok { + if hasExcessiveChanges { + return c.invalidateCache(logger) + } + affectedProjects = core.CopyMapInto(affectedProjects, c.handleConfigChange(entry, logger)) for extendingConfigPath := range entry.Value().retainingConfigs { if extendingConfigEntry, ok := c.configs.Load(extendingConfigPath); ok { @@ -377,6 +421,27 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo } } + // Handle created/deleted files named "tsconfig.json" or "jsconfig.json" + for path := range createdOrDeletedFiles { + baseName := tspath.GetBaseFileName(string(path)) + if baseName == "tsconfig.json" || baseName == "jsconfig.json" { + if hasExcessiveChanges { + return c.invalidateCache(logger) + } + directoryPath := path.GetDirectoryPath() + c.configFileNames.Range(func(entry *dirty.MapEntry[tspath.Path, *configFileNames]) bool { + if directoryPath.ContainsPath(entry.Key()) { + if affectedFiles == nil { + affectedFiles = make(map[tspath.Path]struct{}) + } + affectedFiles[entry.Key()] = struct{}{} + entry.Delete() + } + return true + }) + } + } + // Handle possible root file creation if len(createdFiles) > 0 { c.configs.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *configFileEntry]) bool { @@ -400,27 +465,13 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo } maps.Copy(affectedProjects, config.retainingProjects) logger.Logf("Root files for config %s changed", entry.Key()) + shouldInvalidateCache = hasExcessiveChanges }, ) - return true + return !shouldInvalidateCache }) - } - - // Handle created/deleted files named "tsconfig.json" or "jsconfig.json" - for path := range createdOrDeletedFiles { - baseName := tspath.GetBaseFileName(string(path)) - if baseName == "tsconfig.json" || baseName == "jsconfig.json" { - directoryPath := path.GetDirectoryPath() - c.configFileNames.Range(func(entry *dirty.MapEntry[tspath.Path, *configFileNames]) bool { - if directoryPath.ContainsPath(entry.Key()) { - if affectedFiles == nil { - affectedFiles = make(map[tspath.Path]struct{}) - } - affectedFiles[entry.Key()] = struct{}{} - entry.Delete() - } - return true - }) + if shouldInvalidateCache { + return c.invalidateCache(logger) } } @@ -465,7 +516,7 @@ func (c *configFileRegistryBuilder) computeConfigFileName(fileName string, skipS return result } -func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, path tspath.Path, loadKind projectLoadKind, logger *logging.LogTree) string { +func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, path tspath.Path, logger *logging.LogTree) string { if isDynamicFileName(fileName) { return "" } @@ -474,13 +525,8 @@ func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, pa return entry.Value().nearestConfigFileName } - if loadKind == projectLoadKindFind { - return "" - } - configName := c.computeConfigFileName(fileName, false, logger) - - if _, ok := c.fs.overlays[path]; ok { + if c.fs.isOpenFile(path) { c.configFileNames.Add(path, &configFileNames{ nearestConfigFileName: configName, }) @@ -488,7 +534,25 @@ func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, pa return configName } -func (c *configFileRegistryBuilder) getAncestorConfigFileName(fileName string, path tspath.Path, configFileName string, loadKind projectLoadKind, logger *logging.LogTree) string { +func (c *configFileRegistryBuilder) forEachConfigFileNameFor(fileName string, path tspath.Path, cb func(configFileName string)) { + if isDynamicFileName(fileName) { + return + } + + if entry, ok := c.configFileNames.Get(path); ok { + configFileName := entry.Value().nearestConfigFileName + for configFileName != "" { + cb(configFileName) + if ancestorConfigName, found := entry.Value().ancestors[configFileName]; found { + configFileName = ancestorConfigName + } else { + return + } + } + } +} + +func (c *configFileRegistryBuilder) getAncestorConfigFileName(fileName string, path tspath.Path, configFileName string, logger *logging.LogTree) string { if isDynamicFileName(fileName) { return "" } @@ -497,18 +561,15 @@ func (c *configFileRegistryBuilder) getAncestorConfigFileName(fileName string, p if !ok { return "" } + if ancestorConfigName, found := entry.Value().ancestors[configFileName]; found { return ancestorConfigName } - if loadKind == projectLoadKindFind { - return "" - } - // Look for config in parent folders of config file result := c.computeConfigFileName(configFileName, true, logger) - if _, ok := c.fs.overlays[path]; ok { + if c.fs.isOpenFile(path) { entry.Change(func(value *configFileNames) { if value.ancestors == nil { value.ancestors = make(map[string]string) diff --git a/internal/project/dirty/map.go b/internal/project/dirty/map.go index 9097afc579..10f72d7ae4 100644 --- a/internal/project/dirty/map.go +++ b/internal/project/dirty/map.go @@ -127,6 +127,11 @@ func (m *Map[K, V]) Range(fn func(*MapEntry[K, V]) bool) { } } +func (m *Map[K, V]) Clear() { + m.dirty = make(map[K]*MapEntry[K, V]) + m.base = make(map[K]V) +} + func (m *Map[K, V]) Finalize() (result map[K]V, changed bool) { if len(m.dirty) == 0 { return m.base, false // no changes, return base map diff --git a/internal/project/extendedconfigcache.go b/internal/project/extendedconfigcache.go index 38654c55ae..59537b0110 100644 --- a/internal/project/extendedconfigcache.go +++ b/internal/project/extendedconfigcache.go @@ -9,7 +9,7 @@ import ( "github.com/zeebo/xxh3" ) -type extendedConfigCache struct { +type ExtendedConfigCache struct { entries collections.SyncMap[tspath.Path, *extendedConfigCacheEntry] } @@ -20,7 +20,7 @@ type extendedConfigCacheEntry struct { refCount int } -func (c *extendedConfigCache) Acquire(fh FileHandle, path tspath.Path, parse func() *tsoptions.ExtendedConfigCacheEntry) *tsoptions.ExtendedConfigCacheEntry { +func (c *ExtendedConfigCache) Acquire(fh FileHandle, path tspath.Path, parse func() *tsoptions.ExtendedConfigCacheEntry) *tsoptions.ExtendedConfigCacheEntry { entry, loaded := c.loadOrStoreNewLockedEntry(path) defer entry.mu.Unlock() var hash xxh3.Uint128 @@ -35,27 +35,38 @@ func (c *extendedConfigCache) Acquire(fh FileHandle, path tspath.Path, parse fun return entry.entry } -func (c *extendedConfigCache) Ref(path tspath.Path) { +func (c *ExtendedConfigCache) Ref(path tspath.Path) { if entry, ok := c.entries.Load(path); ok { entry.mu.Lock() + if entry.refCount <= 0 { + // Entry was deleted while we were acquiring the lock + newEntry, loaded := c.loadOrStoreNewLockedEntry(path) + if !loaded { + newEntry.entry = entry.entry + newEntry.hash = entry.hash + } + entry.mu.Unlock() + newEntry.mu.Unlock() + return + } entry.refCount++ entry.mu.Unlock() } } -func (c *extendedConfigCache) Deref(path tspath.Path) { +func (c *ExtendedConfigCache) Deref(path tspath.Path) { if entry, ok := c.entries.Load(path); ok { entry.mu.Lock() entry.refCount-- remove := entry.refCount <= 0 - entry.mu.Unlock() if remove { c.entries.Delete(path) } + entry.mu.Unlock() } } -func (c *extendedConfigCache) Has(path tspath.Path) bool { +func (c *ExtendedConfigCache) Has(path tspath.Path) bool { _, ok := c.entries.Load(path) return ok } @@ -63,11 +74,16 @@ func (c *extendedConfigCache) Has(path tspath.Path) bool { // loadOrStoreNewLockedEntry loads an existing entry or creates a new one. The returned // entry's mutex is locked and its refCount is incremented (or initialized to 1 // in the case of a new entry). -func (c *extendedConfigCache) loadOrStoreNewLockedEntry(path tspath.Path) (*extendedConfigCacheEntry, bool) { +func (c *ExtendedConfigCache) loadOrStoreNewLockedEntry(path tspath.Path) (*extendedConfigCacheEntry, bool) { entry := &extendedConfigCacheEntry{refCount: 1} entry.mu.Lock() if existing, loaded := c.entries.LoadOrStore(path, entry); loaded { existing.mu.Lock() + if existing.refCount <= 0 { + // Entry was deleted while we were acquiring the lock + existing.mu.Unlock() + return c.loadOrStoreNewLockedEntry(path) + } existing.refCount++ return existing, true } diff --git a/internal/project/filechange.go b/internal/project/filechange.go index 2f702add0e..e23184bff5 100644 --- a/internal/project/filechange.go +++ b/internal/project/filechange.go @@ -6,6 +6,8 @@ import ( "github.com/zeebo/xxh3" ) +const excessiveChangeThreshold = 1000 + type FileChangeKind int const ( @@ -18,6 +20,10 @@ const ( FileChangeKindWatchDelete ) +func (k FileChangeKind) IsWatchKind() bool { + return k == FileChangeKindWatchCreate || k == FileChangeKindWatchChange || k == FileChangeKindWatchDelete +} + type FileChange struct { Kind FileChangeKind URI lsproto.DocumentUri @@ -38,8 +44,20 @@ type FileChangeSummary struct { Created collections.Set[lsproto.DocumentUri] // Only set when file watching is enabled Deleted collections.Set[lsproto.DocumentUri] + + // IncludesWatchChangeOutsideNodeModules is true if the summary includes a create, change, or delete watch + // event of a file outside a node_modules directory. + IncludesWatchChangeOutsideNodeModules bool } func (f FileChangeSummary) IsEmpty() bool { return f.Opened == "" && len(f.Closed) == 0 && f.Changed.Len() == 0 && f.Created.Len() == 0 && f.Deleted.Len() == 0 } + +func (f FileChangeSummary) HasExcessiveWatchEvents() bool { + return f.Created.Len()+f.Deleted.Len()+f.Changed.Len() > excessiveChangeThreshold +} + +func (f FileChangeSummary) HasExcessiveNonCreateWatchEvents() bool { + return f.Deleted.Len()+f.Changed.Len() > excessiveChangeThreshold +} diff --git a/internal/project/overlayfs.go b/internal/project/overlayfs.go index 47ec2d95f9..3a5e369059 100644 --- a/internal/project/overlayfs.go +++ b/internal/project/overlayfs.go @@ -2,10 +2,11 @@ package project import ( "maps" + "strings" "sync" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/sourcemap" "github.com/microsoft/typescript-go/internal/tspath" @@ -24,7 +25,7 @@ type FileHandle interface { Version() int32 MatchesDiskText() bool IsOverlay() bool - LSPLineMap() *ls.LSPLineMap + LSPLineMap() *lsconv.LSPLineMap ECMALineInfo() *sourcemap.ECMALineInfo Kind() core.ScriptKind } @@ -35,7 +36,7 @@ type fileBase struct { hash xxh3.Uint128 lineMapOnce sync.Once - lineMap *ls.LSPLineMap + lineMap *lsconv.LSPLineMap lineInfoOnce sync.Once lineInfo *sourcemap.ECMALineInfo } @@ -52,9 +53,9 @@ func (f *fileBase) Content() string { return f.content } -func (f *fileBase) LSPLineMap() *ls.LSPLineMap { +func (f *fileBase) LSPLineMap() *lsconv.LSPLineMap { f.lineMapOnce.Do(func() { - f.lineMap = ls.ComputeLSPLineStarts(f.content) + f.lineMap = lsconv.ComputeLSPLineStarts(f.content) }) return f.lineMap } @@ -110,17 +111,17 @@ func (f *diskFile) Clone() *diskFile { } } -var _ FileHandle = (*overlay)(nil) +var _ FileHandle = (*Overlay)(nil) -type overlay struct { +type Overlay struct { fileBase version int32 kind core.ScriptKind matchesDiskText bool } -func newOverlay(fileName string, content string, version int32, kind core.ScriptKind) *overlay { - return &overlay{ +func newOverlay(fileName string, content string, version int32, kind core.ScriptKind) *Overlay { + return &Overlay{ fileBase: fileBase{ fileName: fileName, content: content, @@ -131,21 +132,21 @@ func newOverlay(fileName string, content string, version int32, kind core.Script } } -func (o *overlay) Version() int32 { +func (o *Overlay) Version() int32 { return o.version } -func (o *overlay) Text() string { +func (o *Overlay) Text() string { return o.content } // MatchesDiskText may return false negatives, but never false positives. -func (o *overlay) MatchesDiskText() bool { +func (o *Overlay) MatchesDiskText() bool { return o.matchesDiskText } // !!! optimization: incorporate mtime -func (o *overlay) computeMatchesDiskText(fs vfs.FS) bool { +func (o *Overlay) computeMatchesDiskText(fs vfs.FS) bool { if isDynamicFileName(o.fileName) { return false } @@ -156,11 +157,11 @@ func (o *overlay) computeMatchesDiskText(fs vfs.FS) bool { return xxh3.Hash128([]byte(diskContent)) == o.hash } -func (o *overlay) IsOverlay() bool { +func (o *Overlay) IsOverlay() bool { return true } -func (o *overlay) Kind() core.ScriptKind { +func (o *Overlay) Kind() core.ScriptKind { return o.kind } @@ -170,10 +171,10 @@ type overlayFS struct { positionEncoding lsproto.PositionEncodingKind mu sync.RWMutex - overlays map[tspath.Path]*overlay + overlays map[tspath.Path]*Overlay } -func newOverlayFS(fs vfs.FS, overlays map[tspath.Path]*overlay, positionEncoding lsproto.PositionEncodingKind, toPath func(string) tspath.Path) *overlayFS { +func newOverlayFS(fs vfs.FS, overlays map[tspath.Path]*Overlay, positionEncoding lsproto.PositionEncodingKind, toPath func(string) tspath.Path) *overlayFS { return &overlayFS{ fs: fs, positionEncoding: positionEncoding, @@ -182,7 +183,7 @@ func newOverlayFS(fs vfs.FS, overlays map[tspath.Path]*overlay, positionEncoding } } -func (fs *overlayFS) Overlays() map[tspath.Path]*overlay { +func (fs *overlayFS) Overlays() map[tspath.Path]*Overlay { fs.mu.RLock() defer fs.mu.RUnlock() return fs.overlays @@ -205,7 +206,7 @@ func (fs *overlayFS) getFile(fileName string) FileHandle { return newDiskFile(fileName, content) } -func (fs *overlayFS) processChanges(changes []FileChange) (FileChangeSummary, map[tspath.Path]*overlay) { +func (fs *overlayFS) processChanges(changes []FileChange) (FileChangeSummary, map[tspath.Path]*Overlay) { fs.mu.Lock() defer fs.mu.Unlock() @@ -237,6 +238,10 @@ func (fs *overlayFS) processChanges(changes []FileChange) (FileChangeSummary, ma fileEventMap[uri] = events } + if !result.IncludesWatchChangeOutsideNodeModules && change.Kind.IsWatchKind() && !strings.Contains(string(uri), "/node_modules/") { + result.IncludesWatchChangeOutsideNodeModules = true + } + switch change.Kind { case FileChangeKindOpen: events.openChange = &change @@ -299,7 +304,7 @@ func (fs *overlayFS) processChanges(changes []FileChange) (FileChangeSummary, ma uri.FileName(), events.openChange.Content, events.openChange.Version, - ls.LanguageKindToScriptKind(events.openChange.LanguageKind), + lsconv.LanguageKindToScriptKind(events.openChange.LanguageKind), ) continue } @@ -330,7 +335,7 @@ func (fs *overlayFS) processChanges(changes []FileChange) (FileChangeSummary, ma panic("overlay not found for changed file: " + uri) } for _, change := range events.changes { - converters := ls.NewConverters(fs.positionEncoding, func(fileName string) *ls.LSPLineMap { + converters := lsconv.NewConverters(fs.positionEncoding, func(fileName string) *lsconv.LSPLineMap { return o.LSPLineMap() }) for _, textChange := range change.Changes { diff --git a/internal/project/overlayfs_test.go b/internal/project/overlayfs_test.go index 5f044bcacd..cb297f464a 100644 --- a/internal/project/overlayfs_test.go +++ b/internal/project/overlayfs_test.go @@ -19,7 +19,7 @@ func TestProcessChanges(t *testing.T) { }, false /* useCaseSensitiveFileNames */) return newOverlayFS( testFS, - make(map[tspath.Path]*overlay), + make(map[tspath.Path]*Overlay), lsproto.PositionEncodingKindUTF16, func(fileName string) tspath.Path { return tspath.Path(fileName) diff --git a/internal/project/parsecache.go b/internal/project/parsecache.go index caf8851584..48ccf8a9e7 100644 --- a/internal/project/parsecache.go +++ b/internal/project/parsecache.go @@ -63,6 +63,17 @@ func (c *ParseCache) Ref(file *ast.SourceFile) { key := newParseCacheKey(file.ParseOptions(), file.ScriptKind) if entry, ok := c.entries.Load(key); ok { entry.mu.Lock() + if entry.refCount <= 0 && !c.Options.DisableDeletion { + // Entry was deleted while we were acquiring the lock + newEntry, loaded := c.loadOrStoreNewLockedEntry(key) + if !loaded { + newEntry.sourceFile = entry.sourceFile + newEntry.hash = entry.hash + } + entry.mu.Unlock() + newEntry.mu.Unlock() + return + } entry.refCount++ entry.mu.Unlock() } else { @@ -76,10 +87,10 @@ func (c *ParseCache) Deref(file *ast.SourceFile) { entry.mu.Lock() entry.refCount-- remove := entry.refCount <= 0 - entry.mu.Unlock() if !c.Options.DisableDeletion && remove { c.entries.Delete(key) } + entry.mu.Unlock() } } @@ -92,6 +103,11 @@ func (c *ParseCache) loadOrStoreNewLockedEntry(key parseCacheKey) (*parseCacheEn existing, loaded := c.entries.LoadOrStore(key, entry) if loaded { existing.mu.Lock() + if existing.refCount <= 0 && !c.Options.DisableDeletion { + // Existing entry was deleted while we were acquiring the lock + existing.mu.Unlock() + return c.loadOrStoreNewLockedEntry(key) + } existing.refCount++ return existing, true } diff --git a/internal/project/project.go b/internal/project/project.go index ed734b7e7f..11098c1e05 100644 --- a/internal/project/project.go +++ b/internal/project/project.go @@ -68,13 +68,16 @@ type Project struct { ProgramUpdateKind ProgramUpdateKind // The ID of the snapshot that created the program stored in this project. ProgramLastUpdate uint64 + // Set of projects that this project could be referencing. + // Only set before actually loading config file to get actual project references + potentialProjectReferences *collections.Set[tspath.Path] - programFilesWatch *WatchedFiles[patternsAndIgnored] + programFilesWatch *WatchedFiles[PatternsAndIgnored] failedLookupsWatch *WatchedFiles[map[tspath.Path]string] affectingLocationsWatch *WatchedFiles[map[tspath.Path]string] - typingsWatch *WatchedFiles[patternsAndIgnored] + typingsWatch *WatchedFiles[PatternsAndIgnored] - checkerPool *checkerPool + checkerPool *CheckerPool // installedTypingsInfo is the value of `project.ComputeTypingsInfo()` that was // used during the most recently completed typings installation. @@ -192,10 +195,18 @@ func (p *Project) ConfigFilePath() tspath.Path { return p.configFilePath } +func (p *Project) Id() tspath.Path { + return p.configFilePath +} + func (p *Project) GetProgram() *compiler.Program { return p.Program } +func (p *Project) HasFile(fileName string) bool { + return p.containsFile(p.toPath(fileName)) +} + func (p *Project) containsFile(path tspath.Path) bool { return p.Program != nil && p.Program.GetSourceFileByPath(path) != nil } @@ -220,6 +231,7 @@ func (p *Project) Clone() *Project { Program: p.Program, ProgramUpdateKind: ProgramUpdateKindNone, ProgramLastUpdate: p.ProgramLastUpdate, + potentialProjectReferences: p.potentialProjectReferences, programFilesWatch: p.programFilesWatch, failedLookupsWatch: p.failedLookupsWatch, @@ -267,16 +279,42 @@ func (p *Project) getCommandLineWithTypingsFiles() *tsoptions.ParsedCommandLine return p.commandLineWithTypingsFiles } +func (p *Project) setPotentialProjectReference(configFilePath tspath.Path) { + if p.potentialProjectReferences == nil { + p.potentialProjectReferences = &collections.Set[tspath.Path]{} + } else { + p.potentialProjectReferences = p.potentialProjectReferences.Clone() + } + p.potentialProjectReferences.Add(configFilePath) +} + +func (p *Project) hasPotentialProjectReference(references map[tspath.Path]struct{}) bool { + if p.CommandLine != nil { + for _, path := range p.CommandLine.ResolvedProjectReferencePaths() { + if _, has := references[p.toPath(path)]; has { + return true + } + } + } else if p.potentialProjectReferences != nil { + for path := range p.potentialProjectReferences.Keys() { + if _, has := references[path]; has { + return true + } + } + } + return false +} + type CreateProgramResult struct { Program *compiler.Program UpdateKind ProgramUpdateKind - CheckerPool *checkerPool + CheckerPool *CheckerPool } func (p *Project) CreateProgram() CreateProgramResult { updateKind := ProgramUpdateKindNewFiles var programCloned bool - var checkerPool *checkerPool + var checkerPool *CheckerPool var newProgram *compiler.Program // Create the command line, potentially augmented with typing files @@ -327,7 +365,7 @@ func (p *Project) CreateProgram() CreateProgramResult { } } -func (p *Project) CloneWatchers(workspaceDir string, libDir string) (programFilesWatch *WatchedFiles[patternsAndIgnored], failedLookupsWatch *WatchedFiles[map[tspath.Path]string], affectingLocationsWatch *WatchedFiles[map[tspath.Path]string]) { +func (p *Project) CloneWatchers(workspaceDir string, libDir string) (programFilesWatch *WatchedFiles[PatternsAndIgnored], failedLookupsWatch *WatchedFiles[map[tspath.Path]string], affectingLocationsWatch *WatchedFiles[map[tspath.Path]string]) { failedLookups := make(map[tspath.Path]string) affectingLocations := make(map[tspath.Path]string) programFiles := getNonRootFileGlobs(workspaceDir, libDir, p.Program.GetSourceFiles(), p.CommandLine.FileNamesByPath(), tspath.ComparePathsOptions{ diff --git a/internal/project/project_stringer_generated.go b/internal/project/project_stringer_generated.go index 4c17d1ebe8..a0a58f43d2 100644 --- a/internal/project/project_stringer_generated.go +++ b/internal/project/project_stringer_generated.go @@ -17,8 +17,9 @@ const _Kind_name = "InferredConfigured" var _Kind_index = [...]uint8{0, 8, 18} func (i Kind) String() string { - if i < 0 || i >= Kind(len(_Kind_index)-1) { + idx := int(i) - 0 + if i < 0 || idx >= len(_Kind_index)-1 { return "Kind(" + strconv.FormatInt(int64(i), 10) + ")" } - return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] + return _Kind_name[_Kind_index[idx]:_Kind_index[idx+1]] } diff --git a/internal/project/project_test.go b/internal/project/project_test.go index 90ad9cda64..d4042f5d57 100644 --- a/internal/project/project_test.go +++ b/internal/project/project_test.go @@ -175,3 +175,137 @@ func TestProject(t *testing.T) { assert.NilError(t, err) }) } + +func TestPushDiagnostics(t *testing.T) { + t.Parallel() + if !bundled.Embedded { + t.Skip("bundled files are not embedded") + } + + t.Run("publishes program diagnostics on initial program creation", func(t *testing.T) { + t.Parallel() + files := map[string]any{ + "/src/tsconfig.json": `{"compilerOptions": {"baseUrl": "."}}`, + "/src/index.ts": "export const x = 1;", + } + session, utils := projecttestutil.Setup(files) + session.DidOpenFile(context.Background(), "file:///src/index.ts", 1, files["/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + _, err := session.GetLanguageService(context.Background(), lsproto.DocumentUri("file:///src/index.ts")) + assert.NilError(t, err) + + session.WaitForBackgroundTasks() + + calls := utils.Client().PublishDiagnosticsCalls() + assert.Assert(t, len(calls) > 0, "expected at least one PublishDiagnostics call") + + // Find the call for tsconfig.json + var tsconfigCall *struct { + Ctx context.Context + Params *lsproto.PublishDiagnosticsParams + } + for i := range calls { + if calls[i].Params.Uri == "file:///src/tsconfig.json" { + tsconfigCall = &calls[i] + break + } + } + assert.Assert(t, tsconfigCall != nil, "expected PublishDiagnostics call for tsconfig.json") + assert.Assert(t, len(tsconfigCall.Params.Diagnostics) > 0, "expected at least one diagnostic") + }) + + t.Run("clears diagnostics when project is removed", func(t *testing.T) { + t.Parallel() + files := map[string]any{ + "/src/tsconfig.json": `{"compilerOptions": {"baseUrl": "."}}`, + "/src/index.ts": "export const x = 1;", + "/src2/tsconfig.json": `{"compilerOptions": {}}`, + "/src2/index.ts": "export const y = 2;", + } + session, utils := projecttestutil.Setup(files) + session.DidOpenFile(context.Background(), "file:///src/index.ts", 1, files["/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + _, err := session.GetLanguageService(context.Background(), lsproto.DocumentUri("file:///src/index.ts")) + assert.NilError(t, err) + session.WaitForBackgroundTasks() + + // Open a file in a different project to trigger cleanup of the first + session.DidCloseFile(context.Background(), "file:///src/index.ts") + session.DidOpenFile(context.Background(), "file:///src2/index.ts", 1, files["/src2/index.ts"].(string), lsproto.LanguageKindTypeScript) + _, err = session.GetLanguageService(context.Background(), lsproto.DocumentUri("file:///src2/index.ts")) + assert.NilError(t, err) + session.WaitForBackgroundTasks() + + calls := utils.Client().PublishDiagnosticsCalls() + // Should have at least one call for the first project with diagnostics, + // and one clearing it after switching projects + var firstProjectCalls []struct { + Ctx context.Context + Params *lsproto.PublishDiagnosticsParams + } + for i := range calls { + if calls[i].Params.Uri == "file:///src/tsconfig.json" { + firstProjectCalls = append(firstProjectCalls, calls[i]) + } + } + assert.Assert(t, len(firstProjectCalls) >= 2, "expected at least 2 PublishDiagnostics calls for first project") + // Last call should clear diagnostics + lastCall := firstProjectCalls[len(firstProjectCalls)-1] + assert.Equal(t, len(lastCall.Params.Diagnostics), 0, "expected empty diagnostics after project cleanup") + }) + + t.Run("updates diagnostics when program changes", func(t *testing.T) { + t.Parallel() + files := map[string]any{ + "/src/tsconfig.json": `{"compilerOptions": {"baseUrl": "."}}`, + "/src/index.ts": "export const x = 1;", + } + session, utils := projecttestutil.Setup(files) + session.DidOpenFile(context.Background(), "file:///src/index.ts", 1, files["/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + _, err := session.GetLanguageService(context.Background(), lsproto.DocumentUri("file:///src/index.ts")) + assert.NilError(t, err) + session.WaitForBackgroundTasks() + + initialCallCount := len(utils.Client().PublishDiagnosticsCalls()) + + // Change the tsconfig to remove baseUrl + err = utils.FS().WriteFile("/src/tsconfig.json", `{"compilerOptions": {}}`, false) + assert.NilError(t, err) + session.DidChangeWatchedFiles(context.Background(), []*lsproto.FileEvent{{Uri: lsproto.DocumentUri("file:///src/tsconfig.json"), Type: lsproto.FileChangeTypeChanged}}) + _, err = session.GetLanguageService(context.Background(), lsproto.DocumentUri("file:///src/index.ts")) + assert.NilError(t, err) + session.WaitForBackgroundTasks() + + calls := utils.Client().PublishDiagnosticsCalls() + assert.Assert(t, len(calls) > initialCallCount, "expected additional PublishDiagnostics call after change") + + // Find the last call for tsconfig.json + var lastTsconfigCall *struct { + Ctx context.Context + Params *lsproto.PublishDiagnosticsParams + } + for i := len(calls) - 1; i >= 0; i-- { + if calls[i].Params.Uri == "file:///src/tsconfig.json" { + lastTsconfigCall = &calls[i] + break + } + } + assert.Assert(t, lastTsconfigCall != nil, "expected PublishDiagnostics call for tsconfig.json") + // After fixing the error, there should be no program diagnostics + assert.Equal(t, len(lastTsconfigCall.Params.Diagnostics), 0, "expected no diagnostics after removing baseUrl option") + }) + + t.Run("does not publish for inferred projects", func(t *testing.T) { + t.Parallel() + files := map[string]any{ + "/src/index.ts": "let x: number = 'not a number';", + } + session, utils := projecttestutil.Setup(files) + session.DidOpenFile(context.Background(), "file:///src/index.ts", 1, files["/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + _, err := session.GetLanguageService(context.Background(), lsproto.DocumentUri("file:///src/index.ts")) + assert.NilError(t, err) + session.WaitForBackgroundTasks() + + calls := utils.Client().PublishDiagnosticsCalls() + // Should not have any calls since inferred projects don't have tsconfig.json + assert.Equal(t, len(calls), 0, "expected no PublishDiagnostics calls for inferred projects") + }) +} diff --git a/internal/project/projectcollection.go b/internal/project/projectcollection.go index aebf7293a8..127e0986ed 100644 --- a/internal/project/projectcollection.go +++ b/internal/project/projectcollection.go @@ -29,6 +29,8 @@ type ProjectCollection struct { apiOpenedProjects map[tspath.Path]struct{} } +func (c *ProjectCollection) ConfigFileRegistry() *ConfigFileRegistry { return c.configFileRegistry } + func (c *ProjectCollection) ConfiguredProject(path tspath.Path) *Project { return c.configuredProjects[path] } @@ -91,6 +93,19 @@ func (c *ProjectCollection) InferredProject() *Project { return c.inferredProject } +func (c *ProjectCollection) GetProjectsContainingFile(path tspath.Path) []*Project { + var projects []*Project + for _, project := range c.ConfiguredProjects() { + if project.containsFile(path) { + projects = append(projects, project) + } + } + if c.inferredProject != nil && c.inferredProject.containsFile(path) { + projects = append(projects, c.inferredProject) + } + return projects +} + // !!! result could be cached func (c *ProjectCollection) GetDefaultProject(fileName string, path tspath.Path) *Project { if result, ok := c.fileDefaultProjects[path]; ok { diff --git a/internal/project/projectcollectionbuilder.go b/internal/project/projectcollectionbuilder.go index a5338b3fe3..709fe44aff 100644 --- a/internal/project/projectcollectionbuilder.go +++ b/internal/project/projectcollectionbuilder.go @@ -30,7 +30,7 @@ type ProjectCollectionBuilder struct { makeHost func(currentDirectory string, project *Project, builder *ProjectCollectionBuilder, logger *logging.LogTree) ProjectHost host ProjectHost parseCache *ParseCache - extendedConfigCache *extendedConfigCache + extendedConfigCache *ExtendedConfigCache ctx context.Context fs *snapshotFSBuilder @@ -40,9 +40,10 @@ type ProjectCollectionBuilder struct { newSnapshotID uint64 programStructureChanged bool - fileDefaultProjects map[tspath.Path]tspath.Path - configuredProjects *dirty.SyncMap[tspath.Path, *Project] - inferredProject *dirty.Box[*Project] + + fileDefaultProjects map[tspath.Path]tspath.Path + configuredProjects *dirty.SyncMap[tspath.Path, *Project] + inferredProject *dirty.Box[*Project] apiOpenedProjects map[tspath.Path]struct{} } @@ -57,7 +58,7 @@ func newProjectCollectionBuilder( compilerOptionsForInferredProjects *core.CompilerOptions, sessionOptions *SessionOptions, parseCache *ParseCache, - extendedConfigCache *extendedConfigCache, + extendedConfigCache *ExtendedConfigCache, makeHost func(currentDirectory string, project *Project, builder *ProjectCollectionBuilder, logger *logging.LogTree) ProjectHost, ) *ProjectCollectionBuilder { return &ProjectCollectionBuilder{ @@ -190,6 +191,18 @@ func (b *ProjectCollectionBuilder) DidChangeFiles(summary FileChangeSummary, log logChangeFileResult(configChangeResult, configChangeLogger) b.forEachProject(func(entry dirty.Value[*Project]) bool { + // Only consider change/delete; creates are handled by the config file registry + if summary.HasExcessiveNonCreateWatchEvents() { + entry.Change(func(p *Project) { + p.dirty = true + p.dirtyFilePath = "" + if logger != nil { + logger.Logf("Marking project as dirty due to excessive watch changes: %s", p.configFilePath) + } + }) + return true + } + // Handle closed and changed files b.markFilesChanged(entry, changedFiles, lsproto.FileChangeTypeChanged, logger) if entry.Value().Kind == KindInferred && len(summary.Closed) > 0 { @@ -235,17 +248,67 @@ func (b *ProjectCollectionBuilder) DidChangeFiles(summary FileChangeSummary, log fileName := summary.Opened.FileName() path := b.toPath(fileName) var toRemoveProjects collections.Set[tspath.Path] - openFileResult := b.ensureConfiguredProjectAndAncestorsForOpenFile(fileName, path, logger) + openFileResult := b.ensureConfiguredProjectAndAncestorsForFile(fileName, path, logger) b.configuredProjects.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *Project]) bool { - toRemoveProjects.Add(entry.Value().configFilePath) - b.updateProgram(entry, logger) + toRemoveProjects.Add(entry.Key()) return true }) + var isReferencedBy func(project *Project, refPath tspath.Path, seenProjects *collections.Set[*Project]) bool + isReferencedBy = func(project *Project, refPath tspath.Path, seenProjects *collections.Set[*Project]) bool { + if !seenProjects.AddIfAbsent(project) { + return false + } + + if project.potentialProjectReferences != nil { + for potentialRef := range project.potentialProjectReferences.Keys() { + if potentialRef == refPath { + return true + } + } + for potentialRef := range project.potentialProjectReferences.Keys() { + if refProject, foundRef := b.configuredProjects.Load(potentialRef); foundRef && isReferencedBy(refProject.Value(), refPath, seenProjects) { + return true + } + } + } else if program := project.GetProgram(); program != nil && !program.RangeResolvedProjectReference(func(referencePath tspath.Path, _ *tsoptions.ParsedCommandLine, _ *tsoptions.ParsedCommandLine, _ int) bool { + return referencePath != refPath + }) { + return true + } + return false + } + + retainProjectAndReferences := func(project *Project) { + // Retain project + toRemoveProjects.Delete(project.configFilePath) + if program := project.GetProgram(); program != nil { + program.RangeResolvedProjectReference(func(referencePath tspath.Path, _ *tsoptions.ParsedCommandLine, _ *tsoptions.ParsedCommandLine, _ int) bool { + if _, ok := b.configuredProjects.Load(referencePath); ok { + toRemoveProjects.Delete(referencePath) + } + return true + }) + } + } + + retainDefaultConfiguredProject := func(openFile string, openFilePath tspath.Path, project *Project) { + // Retain project and its references + retainProjectAndReferences(project) + + // Retain all the ancestor projects + b.configFileRegistryBuilder.forEachConfigFileNameFor(openFile, openFilePath, func(configFileName string) { + if ancestor := b.findOrCreateProject(configFileName, b.toPath(configFileName), projectLoadKindFind, logger); ancestor != nil { + retainProjectAndReferences(ancestor.Value()) + } + }) + } var inferredProjectFiles []string for _, overlay := range b.fs.overlays { - if p := b.findDefaultConfiguredProject(overlay.FileName(), b.toPath(overlay.FileName())); p != nil { - toRemoveProjects.Delete(p.Value().configFilePath) + openFile := overlay.FileName() + openFilePath := b.toPath(openFile) + if p := b.findDefaultConfiguredProject(openFile, openFilePath); p != nil { + retainDefaultConfiguredProject(openFile, openFilePath, p.Value()) } else { inferredProjectFiles = append(inferredProjectFiles, overlay.FileName()) } @@ -282,51 +345,156 @@ func logChangeFileResult(result changeFileResult, logger *logging.LogTree) { func (b *ProjectCollectionBuilder) DidRequestFile(uri lsproto.DocumentUri, logger *logging.LogTree) { startTime := time.Now() fileName := uri.FileName() - hasChanges := b.programStructureChanged - - // See if we can find a default project without updating a bunch of stuff. path := b.toPath(fileName) - if result := b.findDefaultProject(fileName, path); result != nil { - hasChanges = b.updateProgram(result, logger) || hasChanges - if result.Value() != nil { - return + if b.fs.isOpenFile(path) { + hasChanges := b.programStructureChanged + + // See if we can find a default project without updating a bunch of stuff. + if result := b.findDefaultProject(fileName, path); result != nil { + hasChanges = b.updateProgram(result, logger) || hasChanges + if result.Value() != nil { + return + } } - } - // Make sure all projects we know about are up to date... - b.configuredProjects.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *Project]) bool { - hasChanges = b.updateProgram(entry, logger) || hasChanges - return true - }) - if hasChanges { - // If the structure of other projects changed, we might need to move files - // in/out of the inferred project. - var inferredProjectFiles []string - for path, overlay := range b.fs.overlays { - if b.findDefaultConfiguredProject(overlay.FileName(), path) == nil { - inferredProjectFiles = append(inferredProjectFiles, overlay.FileName()) + // Make sure all projects we know about are up to date... + b.configuredProjects.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *Project]) bool { + hasChanges = b.updateProgram(entry, logger) || hasChanges + return true + }) + if hasChanges { + // If the structure of other projects changed, we might need to move files + // in/out of the inferred project. + var inferredProjectFiles []string + for path, overlay := range b.fs.overlays { + if b.findDefaultConfiguredProject(overlay.FileName(), path) == nil { + inferredProjectFiles = append(inferredProjectFiles, overlay.FileName()) + } + } + if len(inferredProjectFiles) > 0 { + b.updateInferredProjectRoots(inferredProjectFiles, logger) } } - if len(inferredProjectFiles) > 0 { - b.updateInferredProjectRoots(inferredProjectFiles, logger) + + if b.inferredProject.Value() != nil { + b.updateProgram(b.inferredProject, logger) } + + // At this point we should be able to find the default project for the file without + // creating anything else. Initially, I verified that and panicked if nothing was found, + // but that panic was getting triggered by fourslash infrastructure when it told us to + // open a package.json file. This is something the VS Code client would never do, but + // it seems possible that another client would. There's no point in panicking; we don't + // really even have an error condition until it tries to ask us language questions about + // a non-TS-handleable file. + } else { + b.ensureConfiguredProjectAndAncestorsForFile(fileName, path, logger) } - if b.inferredProject.Value() != nil { - b.updateProgram(b.inferredProject, logger) + if logger != nil { + elapsed := time.Since(startTime) + logger.Log(fmt.Sprintf("Completed file request for %s in %v", fileName, elapsed)) + } +} + +func (b *ProjectCollectionBuilder) DidRequestProject(projectId tspath.Path, logger *logging.LogTree) { + startTime := time.Now() + if projectId == inferredProjectName { + // Update inferred project + if b.inferredProject.Value() != nil { + b.updateProgram(b.inferredProject, logger) + } + } else { + if entry, ok := b.configuredProjects.Load(projectId); ok { + b.updateProgram(entry, logger) + } } - // At this point we should be able to find the default project for the file without - // creating anything else. Initially, I verified that and panicked if nothing was found, - // but that panic was getting triggered by fourslash infrastructure when it told us to - // open a package.json file. This is something the VS Code client would never do, but - // it seems possible that another client would. There's no point in panicking; we don't - // really even have an error condition until it tries to ask us language questions about - // a non-TS-handleable file. + if logger != nil { + elapsed := time.Since(startTime) + logger.Log(fmt.Sprintf("Completed project update request for %s in %v", projectId, elapsed)) + } +} + +func (b *ProjectCollectionBuilder) DidRequestProjectTrees(projectsReferenced map[tspath.Path]struct{}, logger *logging.LogTree) { + startTime := time.Now() + + var currentProjects []tspath.Path + b.configuredProjects.Range(func(sme *dirty.SyncMapEntry[tspath.Path, *Project]) bool { + currentProjects = append(currentProjects, sme.Key()) + return true + }) + + var seenProjects collections.SyncSet[tspath.Path] + wg := core.NewWorkGroup(false) + for _, projectId := range currentProjects { + wg.Queue(func() { + if entry, ok := b.configuredProjects.Load(projectId); ok { + // If this project has potential project reference for any of the project we are loading ancestor tree for + // load this project first + if project := entry.Value(); project != nil && (projectsReferenced == nil || project.hasPotentialProjectReference(projectsReferenced)) { + b.updateProgram(entry, logger) + } + b.ensureProjectTree(wg, entry, projectsReferenced, &seenProjects, logger) + } + }) + } + wg.RunAndWait() if logger != nil { elapsed := time.Since(startTime) - logger.Log(fmt.Sprintf("Completed file request for %s in %v", fileName, elapsed)) + logger.Log(fmt.Sprintf("Completed project tree request for %v in %v", maps.Keys(projectsReferenced), elapsed)) + } +} + +func (b *ProjectCollectionBuilder) ensureProjectTree( + wg core.WorkGroup, + entry *dirty.SyncMapEntry[tspath.Path, *Project], + projectsReferenced map[tspath.Path]struct{}, + seenProjects *collections.SyncSet[tspath.Path], + logger *logging.LogTree, +) { + if !seenProjects.AddIfAbsent(entry.Key()) { + return + } + + project := entry.Value() + if project == nil { + return + } + + program := project.GetProgram() + if program == nil { + return + } + + // If this project disables child load ignore it + if program.CommandLine().CompilerOptions().DisableReferencedProjectLoad.IsTrue() { + return + } + + children := program.GetResolvedProjectReferences() + if children == nil { + return + } + for _, childConfig := range children { + wg.Queue(func() { + if projectsReferenced != nil && program.RangeResolvedProjectReferenceInChildConfig( + childConfig, + func(referencePath tspath.Path, config *tsoptions.ParsedCommandLine, _ *tsoptions.ParsedCommandLine, _ int) bool { + _, isReferenced := projectsReferenced[referencePath] + return !isReferenced + }) { + return + } + + // Load this child project since this is referenced + childProjectEntry := b.findOrCreateProject(childConfig.ConfigName(), childConfig.ConfigFile.SourceFile.Path(), projectLoadKindCreate, logger) + b.updateProgram(childProjectEntry, logger) + + // Ensure children for this project + b.ensureProjectTree(wg, childProjectEntry, projectsReferenced, seenProjects, logger) + }) } } @@ -400,7 +568,7 @@ func (b *ProjectCollectionBuilder) markProjectsAffectedByConfigChanges( var hasChanges bool for path := range configChangeResult.affectedFiles { fileName := b.fs.overlays[path].FileName() - _ = b.ensureConfiguredProjectAndAncestorsForOpenFile(fileName, path, logger) + _ = b.ensureConfiguredProjectAndAncestorsForFile(fileName, path, logger) hasChanges = true } @@ -441,7 +609,7 @@ func (b *ProjectCollectionBuilder) findDefaultConfiguredProject(fileName string, }) if multipleCandidates { - if p := b.findOrCreateDefaultConfiguredProjectForOpenScriptInfo(fileName, path, projectLoadKindFind, nil).project; p != nil { + if p := b.findOrCreateDefaultConfiguredProjectForFile(fileName, path, projectLoadKindFind, nil).project; p != nil { return p } } @@ -449,28 +617,53 @@ func (b *ProjectCollectionBuilder) findDefaultConfiguredProject(fileName string, return configuredProjects[project] } -func (b *ProjectCollectionBuilder) ensureConfiguredProjectAndAncestorsForOpenFile(fileName string, path tspath.Path, logger *logging.LogTree) searchResult { - result := b.findOrCreateDefaultConfiguredProjectForOpenScriptInfo(fileName, path, projectLoadKindCreate, logger) - if result.project != nil { - // !!! sheetal todo this later - // // Create ancestor tree for findAllRefs (dont load them right away) - // forEachAncestorProjectLoad( - // info, - // tsconfigProject!, - // ancestor => { - // seenProjects.set(ancestor.project, kind); - // }, - // kind, - // `Creating project possibly referencing default composite project ${defaultProject.getProjectName()} of open file ${info.fileName}`, - // allowDeferredClosed, - // reloadedProjects, - // /*searchOnlyPotentialSolution*/ true, - // delayReloadedConfiguredProjects, - // ); +func (b *ProjectCollectionBuilder) ensureConfiguredProjectAndAncestorsForFile(fileName string, path tspath.Path, logger *logging.LogTree) searchResult { + result := b.findOrCreateDefaultConfiguredProjectForFile(fileName, path, projectLoadKindCreate, logger) + if result.project != nil && b.fs.isOpenFile(path) { + b.createAncestorTree(fileName, path, &result, logger) } return result } +func (b *ProjectCollectionBuilder) createAncestorTree(fileName string, path tspath.Path, openResult *searchResult, logger *logging.LogTree) { + project := openResult.project.Value() + for { + // Skip if project is not composite and we are only looking for solution + if project.CommandLine != nil && + (!project.CommandLine.CompilerOptions().Composite.IsTrue() || + project.CommandLine.CompilerOptions().DisableSolutionSearching.IsTrue()) { + return + } + + // Get config file name + ancestorConfigName := b.configFileRegistryBuilder.getAncestorConfigFileName(fileName, path, project.configFileName, logger) + if ancestorConfigName == "" { + return + } + + // find or delay load the project + ancestorPath := b.toPath(ancestorConfigName) + ancestor := b.findOrCreateProject(ancestorConfigName, ancestorPath, projectLoadKindCreate, logger) + if ancestor == nil { + return + } + + openResult.retain.Add(ancestorPath) + + // If this ancestor is new and was not updated because we are just creating it for future loading + // eg when invoking find all references or rename that could span multiple projects + // we would make the current project as its potential project reference + if ancestor.Value().CommandLine == nil && + (project.CommandLine == nil || project.CommandLine.CompilerOptions().Composite.IsTrue()) { + ancestor.Change(func(ancestorProject *Project) { + ancestorProject.setPotentialProjectReference(project.configFilePath) + }) + } + + project = ancestor.Value() + } +} + type searchNode struct { configFileName string loadKind projectLoadKind @@ -523,7 +716,7 @@ func (b *ProjectCollectionBuilder) findOrCreateDefaultConfiguredProjectWorker( }, func(node searchNode) (isResult bool, stop bool) { configFilePath := b.toPath(node.configFileName) - config := b.configFileRegistryBuilder.findOrAcquireConfigForOpenFile(node.configFileName, configFilePath, path, node.loadKind, node.logger.Fork("Acquiring config for open file")) + config := b.configFileRegistryBuilder.findOrAcquireConfigForFile(node.configFileName, configFilePath, path, node.loadKind, node.logger.Fork("Acquiring config for open file")) if config == nil { node.logger.Log("Config file for project does not already exist") return false, false @@ -621,7 +814,7 @@ func (b *ProjectCollectionBuilder) findOrCreateDefaultConfiguredProjectWorker( return *fallback } } - if ancestorConfigName := b.configFileRegistryBuilder.getAncestorConfigFileName(fileName, path, configFileName, loadKind, logger); ancestorConfigName != "" { + if ancestorConfigName := b.configFileRegistryBuilder.getAncestorConfigFileName(fileName, path, configFileName, logger); ancestorConfigName != "" { return b.findOrCreateDefaultConfiguredProjectWorker( fileName, path, @@ -645,7 +838,7 @@ func (b *ProjectCollectionBuilder) findOrCreateDefaultConfiguredProjectWorker( return searchResult{retain: retain} } -func (b *ProjectCollectionBuilder) findOrCreateDefaultConfiguredProjectForOpenScriptInfo( +func (b *ProjectCollectionBuilder) findOrCreateDefaultConfiguredProjectForFile( fileName string, path tspath.Path, loadKind projectLoadKind, @@ -659,7 +852,7 @@ func (b *ProjectCollectionBuilder) findOrCreateDefaultConfiguredProjectForOpenSc entry, _ := b.configuredProjects.Load(key) return searchResult{project: entry} } - if configFileName := b.configFileRegistryBuilder.getConfigFileNameForFile(fileName, path, loadKind, logger); configFileName != "" { + if configFileName := b.configFileRegistryBuilder.getConfigFileNameForFile(fileName, path, logger); configFileName != "" { startTime := time.Now() result := b.findOrCreateDefaultConfiguredProjectWorker( fileName, @@ -776,6 +969,7 @@ func (b *ProjectCollectionBuilder) updateProgram(entry dirty.Value[*Project], lo entry.Change(func(p *Project) { p.CommandLine = commandLine p.commandLineWithTypingsFiles = nil + p.potentialProjectReferences = nil }) } } @@ -873,8 +1067,9 @@ func (b *ProjectCollectionBuilder) deleteConfiguredProject(project dirty.Value[* logger.Log("Deleting configured project: " + project.Value().configFileName) } if program := project.Value().Program; program != nil { - program.ForEachResolvedProjectReference(func(referencePath tspath.Path, config *tsoptions.ParsedCommandLine, _ *tsoptions.ParsedCommandLine, _ int) { + program.RangeResolvedProjectReference(func(referencePath tspath.Path, config *tsoptions.ParsedCommandLine, _ *tsoptions.ParsedCommandLine, _ int) bool { b.configFileRegistryBuilder.releaseConfigForProject(referencePath, projectPath) + return true }) } b.configFileRegistryBuilder.releaseConfigForProject(projectPath, projectPath) diff --git a/internal/project/projectcollectionbuilder_test.go b/internal/project/projectcollectionbuilder_test.go index bc40f9fd1c..48fc87fff3 100644 --- a/internal/project/projectcollectionbuilder_test.go +++ b/internal/project/projectcollectionbuilder_test.go @@ -320,9 +320,11 @@ func TestProjectCollectionBuilder(t *testing.T) { session.DidOpenFile(context.Background(), uri, 1, content, lsproto.LanguageKindTypeScript) snapshot, release := session.Snapshot() defer release() - assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 1) + assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 2) demoProject := snapshot.ProjectCollection.ConfiguredProject(tspath.Path("/home/src/projects/project/demos/tsconfig.json")) assert.Assert(t, demoProject != nil) + solutionProject := snapshot.ProjectCollection.ConfiguredProject(tspath.Path("/home/src/projects/project/tsconfig.json")) + assert.Assert(t, solutionProject != nil) // Verify the default project is the demos project (not the app project that excludes demos files) defaultProject := snapshot.GetDefaultProject(uri) diff --git a/internal/project/projectreferencesprogram_test.go b/internal/project/projectreferencesprogram_test.go index df4062bfb7..9e3c68f98e 100644 --- a/internal/project/projectreferencesprogram_test.go +++ b/internal/project/projectreferencesprogram_test.go @@ -7,6 +7,7 @@ import ( "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project" "github.com/microsoft/typescript-go/internal/testutil/projecttestutil" @@ -85,7 +86,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -109,7 +110,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -133,7 +134,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -157,7 +158,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -181,7 +182,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -205,7 +206,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -229,7 +230,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() @@ -253,7 +254,7 @@ func TestProjectReferencesProgram(t *testing.T) { defer release() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 0) - uri := lsproto.DocumentUri("file://" + aTest) + uri := lsconv.FileNameToDocumentURI(aTest) session.DidOpenFile(context.Background(), uri, 1, files[aTest].(string), lsproto.LanguageKindTypeScript) snapshot, release = session.Snapshot() diff --git a/internal/project/session.go b/internal/project/session.go index bcd01ddf90..2e3392a28b 100644 --- a/internal/project/session.go +++ b/internal/project/session.go @@ -13,7 +13,10 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project/ata" "github.com/microsoft/typescript-go/internal/project/background" @@ -30,20 +33,24 @@ const ( UpdateReasonDidChangeCompilerOptionsForInferredProjects UpdateReasonRequestedLanguageServicePendingChanges UpdateReasonRequestedLanguageServiceProjectNotLoaded + UpdateReasonRequestedLanguageServiceForFileNotOpen UpdateReasonRequestedLanguageServiceProjectDirty + UpdateReasonRequestedLoadProjectTree ) // SessionOptions are the immutable initialization options for a session. // Snapshots may reference them as a pointer since they never change. type SessionOptions struct { - CurrentDirectory string - DefaultLibraryPath string - TypingsLocation string - PositionEncoding lsproto.PositionEncodingKind - WatchEnabled bool - LoggingEnabled bool - DebounceDelay time.Duration - MakeHost func(currentDirectory string, project *Project, builder *ProjectCollectionBuilder, logger *logging.LogTree) ProjectHost + CurrentDirectory string + DefaultLibraryPath string + TypingsLocation string + PositionEncoding lsproto.PositionEncodingKind + WatchEnabled bool + LoggingEnabled bool + PushDiagnosticsEnabled bool + DebounceDelay time.Duration + Locale locale.Locale + MakeHost func(currentDirectory string, project *Project, builder *ProjectCollectionBuilder, logger *logging.LogTree) ProjectHost } type SessionInit struct { @@ -74,12 +81,15 @@ type Session struct { parseCache *ParseCache // extendedConfigCache is the ref-counted cache of tsconfig ASTs // that are used in the "extends" of another tsconfig. - extendedConfigCache *extendedConfigCache + extendedConfigCache *ExtendedConfigCache // programCounter counts how many snapshots reference a program. // When a program is no longer referenced, its source files are // released from the parseCache. programCounter *programCounter + // read-only after initialization + initialPreferences *lsutil.UserPreferences + userPreferences *lsutil.UserPreferences // !!! update to Config compilerOptionsForInferredProjects *core.CompilerOptions typingsInstaller *ata.TypingsInstaller backgroundQueue *background.Queue @@ -93,6 +103,9 @@ type Session struct { snapshot *Snapshot snapshotMu sync.RWMutex + pendingConfigChanges bool + configRWMu sync.Mutex + // pendingFileChanges are accumulated from textDocument/* events delivered // by the LSP server through DidOpenFile(), DidChangeFile(), etc. They are // applied to the next snapshot update. @@ -124,12 +137,12 @@ func NewSession(init *SessionInit) *Session { toPath := func(fileName string) tspath.Path { return tspath.ToPath(fileName, currentDirectory, useCaseSensitiveFileNames) } - overlayFS := newOverlayFS(init.FS, make(map[tspath.Path]*overlay), init.Options.PositionEncoding, toPath) + overlayFS := newOverlayFS(init.FS, make(map[tspath.Path]*Overlay), init.Options.PositionEncoding, toPath) parseCache := init.ParseCache if parseCache == nil { parseCache = &ParseCache{} } - extendedConfigCache := &extendedConfigCache{} + extendedConfigCache := &ExtendedConfigCache{} session := &Session{ options: init.Options, @@ -142,7 +155,6 @@ func NewSession(init *SessionInit) *Session { extendedConfigCache: extendedConfigCache, programCounter: &programCounter{}, backgroundQueue: background.NewQueue(), - snapshotID: atomic.Uint64{}, snapshot: NewSnapshot( uint64(0), &SnapshotFS{ @@ -154,6 +166,7 @@ func NewSession(init *SessionInit) *Session { extendedConfigCache, &ConfigFileRegistry{}, nil, + Config{}, toPath, ), pendingATAChanges: make(map[tspath.Path]*ATAStateChange), @@ -181,11 +194,35 @@ func (s *Session) GetCurrentDirectory() string { return s.options.CurrentDirectory } +// Gets current UserPreferences, always a copy +func (s *Session) UserPreferences() *lsutil.UserPreferences { + s.configRWMu.Lock() + defer s.configRWMu.Unlock() + return s.userPreferences.Copy() +} + +// Gets original UserPreferences of the session +func (s *Session) NewUserPreferences() *lsutil.UserPreferences { + return s.initialPreferences.CopyOrDefault() +} + // Trace implements module.ResolutionHost func (s *Session) Trace(msg string) { panic("ATA module resolution should not use tracing") } +func (s *Session) Configure(userPreferences *lsutil.UserPreferences) { + s.configRWMu.Lock() + defer s.configRWMu.Unlock() + s.pendingConfigChanges = true + s.userPreferences = userPreferences +} + +func (s *Session) InitializeWithConfig(userPreferences *lsutil.UserPreferences) { + s.initialPreferences = userPreferences.CopyOrDefault() + s.Configure(s.initialPreferences) +} + func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, version int32, content string, languageKind lsproto.LanguageKind) { s.cancelDiagnosticsRefresh() s.pendingFileChangesMu.Lock() @@ -199,9 +236,11 @@ func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, vers changes, overlays := s.flushChangesLocked(ctx) s.pendingFileChangesMu.Unlock() s.UpdateSnapshot(ctx, overlays, SnapshotChange{ - reason: UpdateReasonDidOpenFile, - fileChanges: changes, - requestedURIs: []lsproto.DocumentUri{uri}, + reason: UpdateReasonDidOpenFile, + fileChanges: changes, + ResourceRequest: ResourceRequest{ + Documents: []lsproto.DocumentUri{uri}, + }, }) } @@ -343,44 +382,136 @@ func (s *Session) Snapshot() (*Snapshot, func()) { } } -func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUri) (*ls.LanguageService, error) { +func (s *Session) getSnapshot( + ctx context.Context, + request ResourceRequest, +) *Snapshot { var snapshot *Snapshot - fileChanges, overlays, ataChanges := s.flushChanges(ctx) - updateSnapshot := !fileChanges.IsEmpty() || len(ataChanges) > 0 + fileChanges, overlays, ataChanges, newConfig := s.flushChanges(ctx) + updateSnapshot := !fileChanges.IsEmpty() || len(ataChanges) > 0 || newConfig != nil if updateSnapshot { // If there are pending file changes, we need to update the snapshot. // Sending the requested URI ensures that the project for this URI is loaded. - snapshot = s.UpdateSnapshot(ctx, overlays, SnapshotChange{ - reason: UpdateReasonRequestedLanguageServicePendingChanges, - fileChanges: fileChanges, - ataChanges: ataChanges, - requestedURIs: []lsproto.DocumentUri{uri}, + return s.UpdateSnapshot(ctx, overlays, SnapshotChange{ + reason: UpdateReasonRequestedLanguageServicePendingChanges, + fileChanges: fileChanges, + ataChanges: ataChanges, + newConfig: newConfig, + ResourceRequest: request, }) + } + + // If there are no pending file changes, we can try to use the current snapshot. + s.snapshotMu.RLock() + snapshot = s.snapshot + s.snapshotMu.RUnlock() + + var updateReason UpdateReason + if len(request.Projects) > 0 { + updateReason = UpdateReasonRequestedLanguageServiceProjectDirty + } else if request.ProjectTree != nil { + updateReason = UpdateReasonRequestedLoadProjectTree } else { - // If there are no pending file changes, we can try to use the current snapshot. - s.snapshotMu.RLock() - snapshot = s.snapshot - s.snapshotMu.RUnlock() + for _, document := range request.Documents { + if snapshot.fs.isOpenFile(document.FileName()) { + // The current snapshot does not have an up to date project for the URI, + // so we need to update the snapshot to ensure the project is loaded. + // !!! Allow multiple projects to update in parallel + project := snapshot.GetDefaultProject(document) + if project == nil { + updateReason = UpdateReasonRequestedLanguageServiceProjectNotLoaded + break + } else if project.dirty { + updateReason = UpdateReasonRequestedLanguageServiceProjectDirty + break + } + } else { + updateReason = UpdateReasonRequestedLanguageServiceForFileNotOpen + break + } + } } - project := snapshot.GetDefaultProject(uri) - if project == nil && !updateSnapshot || project != nil && project.dirty { - // The current snapshot does not have an up to date project for the URI, - // so we need to update the snapshot to ensure the project is loaded. - // !!! Allow multiple projects to update in parallel + if updateReason != UpdateReasonUnknown { snapshot = s.UpdateSnapshot(ctx, overlays, SnapshotChange{ - reason: core.IfElse(project == nil, UpdateReasonRequestedLanguageServiceProjectNotLoaded, UpdateReasonRequestedLanguageServiceProjectDirty), - requestedURIs: []lsproto.DocumentUri{uri}, + reason: updateReason, + ResourceRequest: request, }) - project = snapshot.GetDefaultProject(uri) } + return snapshot +} + +func (s *Session) getSnapshotAndDefaultProject(ctx context.Context, uri lsproto.DocumentUri) (*Snapshot, *Project, *ls.LanguageService, error) { + snapshot := s.getSnapshot( + ctx, + ResourceRequest{Documents: []lsproto.DocumentUri{uri}}, + ) + project := snapshot.GetDefaultProject(uri) + if project == nil { + return nil, nil, nil, fmt.Errorf("no project found for URI %s", uri) + } + return snapshot, project, ls.NewLanguageService(project.GetProgram(), snapshot), nil +} + +func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUri) (*ls.LanguageService, error) { + _, _, languageService, err := s.getSnapshotAndDefaultProject(ctx, uri) + if err != nil { + return nil, err + } + return languageService, nil +} + +func (s *Session) GetLanguageServiceAndProjectsForFile(ctx context.Context, uri lsproto.DocumentUri) (*Project, *ls.LanguageService, []*Project, error) { + snapshot, project, defaultLs, err := s.getSnapshotAndDefaultProject(ctx, uri) + if err != nil { + return nil, nil, nil, err + } + // !!! TODO: sheetal: Get other projects that contain the file with symlink + allProjects := snapshot.GetProjectsContainingFile(uri) + return project, defaultLs, allProjects, nil +} + +func (s *Session) GetProjectsForFile(ctx context.Context, uri lsproto.DocumentUri) ([]*Project, error) { + snapshot := s.getSnapshot( + ctx, + ResourceRequest{Documents: []lsproto.DocumentUri{uri}}, + ) + + // !!! TODO: sheetal: Get other projects that contain the file with symlink + allProjects := snapshot.GetProjectsContainingFile(uri) + return allProjects, nil +} + +func (s *Session) GetLanguageServiceForProjectWithFile(ctx context.Context, project *Project, uri lsproto.DocumentUri) *ls.LanguageService { + snapshot := s.getSnapshot( + ctx, + ResourceRequest{Projects: []tspath.Path{project.Id()}}, + ) + // Ensure we have updated project + project = snapshot.ProjectCollection.GetProjectByPath(project.Id()) if project == nil { - return nil, fmt.Errorf("no project found for URI %s", uri) + return nil } - return ls.NewLanguageService(project.GetProgram(), snapshot), nil + // if program doesnt contain this file any more ignore it + if !project.HasFile(uri.FileName()) { + return nil + } + return ls.NewLanguageService(project.GetProgram(), snapshot) +} + +func (s *Session) GetSnapshotLoadingProjectTree( + ctx context.Context, + // If null, all project trees need to be loaded, otherwise only those that are referenced + requestedProjectTrees map[tspath.Path]struct{}, +) *Snapshot { + snapshot := s.getSnapshot( + ctx, + ResourceRequest{ProjectTree: &ProjectTreeRequest{requestedProjectTrees}}, + ) + return snapshot } -func (s *Session) UpdateSnapshot(ctx context.Context, overlays map[tspath.Path]*overlay, change SnapshotChange) *Snapshot { +func (s *Session) UpdateSnapshot(ctx context.Context, overlays map[tspath.Path]*Overlay, change SnapshotChange) *Snapshot { s.snapshotMu.Lock() oldSnapshot := s.snapshot newSnapshot := oldSnapshot.Clone(ctx, change, overlays, s) @@ -398,6 +529,7 @@ func (s *Session) UpdateSnapshot(ctx context.Context, overlays map[tspath.Path]* } // Enqueue logging, watch updates, and diagnostic refresh tasks + // !!! userPreferences/configuration updates s.backgroundQueue.Enqueue(context.Background(), func(ctx context.Context) { if s.options.LoggingEnabled { s.logger.Write(newSnapshot.builderLogs.String()) @@ -409,6 +541,7 @@ func (s *Session) UpdateSnapshot(ctx context.Context, overlays map[tspath.Path]* s.logger.Log(err) } } + s.publishProgramDiagnostics(oldSnapshot, newSnapshot) }) return newSnapshot @@ -557,7 +690,7 @@ func (s *Session) Close() { s.backgroundQueue.Close() } -func (s *Session) flushChanges(ctx context.Context) (FileChangeSummary, map[tspath.Path]*overlay, map[tspath.Path]*ATAStateChange) { +func (s *Session) flushChanges(ctx context.Context) (FileChangeSummary, map[tspath.Path]*Overlay, map[tspath.Path]*ATAStateChange, *Config) { s.pendingFileChangesMu.Lock() defer s.pendingFileChangesMu.Unlock() s.pendingATAChangesMu.Lock() @@ -565,11 +698,20 @@ func (s *Session) flushChanges(ctx context.Context) (FileChangeSummary, map[tspa pendingATAChanges := s.pendingATAChanges s.pendingATAChanges = make(map[tspath.Path]*ATAStateChange) fileChanges, overlays := s.flushChangesLocked(ctx) - return fileChanges, overlays, pendingATAChanges + s.configRWMu.Lock() + defer s.configRWMu.Unlock() + var newConfig *Config + if s.pendingConfigChanges { + newConfig = &Config{ + tsUserPreferences: s.userPreferences.Copy(), + } + } + s.pendingConfigChanges = false + return fileChanges, overlays, pendingATAChanges, newConfig } // flushChangesLocked should only be called with s.pendingFileChangesMu held. -func (s *Session) flushChangesLocked(ctx context.Context) (FileChangeSummary, map[tspath.Path]*overlay) { +func (s *Session) flushChangesLocked(ctx context.Context) (FileChangeSummary, map[tspath.Path]*Overlay) { if len(s.pendingFileChanges) == 0 { return FileChangeSummary{}, s.fs.Overlays() } @@ -650,6 +792,57 @@ func (s *Session) NpmInstall(cwd string, npmInstallArgs []string) ([]byte, error return s.npmExecutor.NpmInstall(cwd, npmInstallArgs) } +func (s *Session) publishProgramDiagnostics(oldSnapshot *Snapshot, newSnapshot *Snapshot) { + if !s.options.PushDiagnosticsEnabled { + return + } + + ctx := context.Background() + collections.DiffOrderedMaps( + oldSnapshot.ProjectCollection.ProjectsByPath(), + newSnapshot.ProjectCollection.ProjectsByPath(), + func(configFilePath tspath.Path, addedProject *Project) { + if !shouldPublishProgramDiagnostics(addedProject, newSnapshot.ID()) { + return + } + s.publishProjectDiagnostics(ctx, string(configFilePath), addedProject.Program.GetProgramDiagnostics(), newSnapshot.converters) + }, + func(configFilePath tspath.Path, removedProject *Project) { + if removedProject.Kind != KindConfigured { + return + } + s.publishProjectDiagnostics(ctx, string(configFilePath), nil, oldSnapshot.converters) + }, + func(configFilePath tspath.Path, oldProject, newProject *Project) { + if !shouldPublishProgramDiagnostics(newProject, newSnapshot.ID()) { + return + } + s.publishProjectDiagnostics(ctx, string(configFilePath), newProject.Program.GetProgramDiagnostics(), newSnapshot.converters) + }, + ) +} + +func shouldPublishProgramDiagnostics(p *Project, snapshotID uint64) bool { + if p.Kind != KindConfigured || p.Program == nil || p.ProgramLastUpdate != snapshotID { + return false + } + return p.ProgramUpdateKind > ProgramUpdateKindCloned +} + +func (s *Session) publishProjectDiagnostics(ctx context.Context, configFilePath string, diagnostics []*ast.Diagnostic, converters *lsconv.Converters) { + lspDiagnostics := make([]*lsproto.Diagnostic, 0, len(diagnostics)) + for _, diag := range diagnostics { + lspDiagnostics = append(lspDiagnostics, lsconv.DiagnosticToLSPPush(ctx, converters, diag)) + } + + if err := s.client.PublishDiagnostics(ctx, &lsproto.PublishDiagnosticsParams{ + Uri: lsconv.FileNameToDocumentURI(configFilePath), + Diagnostics: lspDiagnostics, + }); err != nil && s.options.LoggingEnabled { + s.logger.Logf("Error publishing diagnostics: %v", err) + } +} + func (s *Session) triggerATAForUpdatedProjects(newSnapshot *Snapshot) { for _, project := range newSnapshot.ProjectCollection.Projects() { if project.ShouldTriggerATA(newSnapshot.ID()) { diff --git a/internal/project/snapshot.go b/internal/project/snapshot.go index 77a35ffc08..ad7fedc210 100644 --- a/internal/project/snapshot.go +++ b/internal/project/snapshot.go @@ -3,12 +3,16 @@ package project import ( "context" "fmt" + "maps" + "slices" "sync/atomic" "time" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project/ata" "github.com/microsoft/typescript-go/internal/project/dirty" @@ -26,13 +30,14 @@ type Snapshot struct { // so can be a pointer. sessionOptions *SessionOptions toPath func(fileName string) tspath.Path - converters *ls.Converters + converters *lsconv.Converters // Immutable state, cloned between snapshots fs *SnapshotFS ProjectCollection *ProjectCollection ConfigFileRegistry *ConfigFileRegistry compilerOptionsForInferredProjects *core.CompilerOptions + config Config builderLogs *logging.LogTree apiError error @@ -44,9 +49,10 @@ func NewSnapshot( fs *SnapshotFS, sessionOptions *SessionOptions, parseCache *ParseCache, - extendedConfigCache *extendedConfigCache, + extendedConfigCache *ExtendedConfigCache, configFileRegistry *ConfigFileRegistry, compilerOptionsForInferredProjects *core.CompilerOptions, + config Config, toPath func(fileName string) tspath.Path, ) *Snapshot { s := &Snapshot{ @@ -59,8 +65,9 @@ func NewSnapshot( ConfigFileRegistry: configFileRegistry, ProjectCollection: &ProjectCollection{toPath: toPath}, compilerOptionsForInferredProjects: compilerOptionsForInferredProjects, + config: config, } - s.converters = ls.NewConverters(s.sessionOptions.PositionEncoding, s.LSPLineMap) + s.converters = lsconv.NewConverters(s.sessionOptions.PositionEncoding, s.LSPLineMap) s.refCount.Store(1) return s } @@ -71,11 +78,18 @@ func (s *Snapshot) GetDefaultProject(uri lsproto.DocumentUri) *Project { return s.ProjectCollection.GetDefaultProject(fileName, path) } +func (s *Snapshot) GetProjectsContainingFile(uri lsproto.DocumentUri) []*Project { + fileName := uri.FileName() + path := s.toPath(fileName) + // TODO!! sheetal may be change this to handle symlinks!! + return s.ProjectCollection.GetProjectsContainingFile(path) +} + func (s *Snapshot) GetFile(fileName string) FileHandle { return s.fs.GetFile(fileName) } -func (s *Snapshot) LSPLineMap(fileName string) *ls.LSPLineMap { +func (s *Snapshot) LSPLineMap(fileName string) *lsconv.LSPLineMap { if file := s.fs.GetFile(fileName); file != nil { return file.LSPLineMap() } @@ -89,7 +103,15 @@ func (s *Snapshot) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo { return nil } -func (s *Snapshot) Converters() *ls.Converters { +func (s *Snapshot) UserPreferences() *lsutil.UserPreferences { + return s.config.tsUserPreferences +} + +func (s *Snapshot) FormatOptions() *format.FormatCodeSettings { + return s.config.formatOptions +} + +func (s *Snapshot) Converters() *lsconv.Converters { return s.converters } @@ -115,22 +137,47 @@ type APISnapshotRequest struct { UpdateProjects *collections.Set[tspath.Path] } +type ProjectTreeRequest struct { + // If null, all project trees need to be loaded, otherwise only those that are referenced + referencedProjects map[tspath.Path]struct{} +} + +type ResourceRequest struct { + // Documents are URIs that were requested by the client. + // The new snapshot should ensure projects for these URIs have loaded programs. + // If the requested Documents are not open, ensure that their default project is created + Documents []lsproto.DocumentUri + // Update requested Projects. + // this is used when we want to get LS and from all the Projects the file can be part of + Projects []tspath.Path + // Update and ensure project trees that reference the projects + // This is used to compute the solution and project tree so that + // we can find references across all the projects in the solution irrespective of which project is open + ProjectTree *ProjectTreeRequest +} + type SnapshotChange struct { + ResourceRequest reason UpdateReason // fileChanges are the changes that have occurred since the last snapshot. fileChanges FileChangeSummary - // requestedURIs are URIs that were requested by the client. - // The new snapshot should ensure projects for these URIs have loaded programs. - requestedURIs []lsproto.DocumentUri // compilerOptionsForInferredProjects is the compiler options to use for inferred projects. // It should only be set the value in the next snapshot should be changed. If nil, the // value from the previous snapshot will be copied to the new snapshot. compilerOptionsForInferredProjects *core.CompilerOptions + newConfig *Config // ataChanges contains ATA-related changes to apply to projects in the new snapshot. ataChanges map[tspath.Path]*ATAStateChange apiRequest *APISnapshotRequest } +type Config struct { + tsUserPreferences *lsutil.UserPreferences + // jsUserPreferences *lsutil.UserPreferences + formatOptions *format.FormatCodeSettings + // tsserverOptions +} + // ATAStateChange represents a change to a project's ATA state. type ATAStateChange struct { ProjectID tspath.Path @@ -143,7 +190,7 @@ type ATAStateChange struct { Logs *logging.LogTree } -func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays map[tspath.Path]*overlay, session *Session) *Snapshot { +func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays map[tspath.Path]*Overlay, session *Session) *Snapshot { var logger *logging.LogTree // Print in-progress logs immediately if cloning fails @@ -158,23 +205,54 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma if session.options.LoggingEnabled { logger = logging.NewLogTree(fmt.Sprintf("Cloning snapshot %d", s.id)) + getDetails := func() string { + details := "" + if len(change.Documents) != 0 { + details += fmt.Sprintf(" Documents: %v", change.Documents) + } + if len(change.Projects) != 0 { + details += fmt.Sprintf(" Projects: %v", change.Projects) + } + if change.ProjectTree != nil { + details += fmt.Sprintf(" ProjectTree: %v", slices.Collect(maps.Keys(change.ProjectTree.referencedProjects))) + } + return details + } switch change.reason { case UpdateReasonDidOpenFile: logger.Logf("Reason: DidOpenFile - %s", change.fileChanges.Opened) case UpdateReasonDidChangeCompilerOptionsForInferredProjects: logger.Logf("Reason: DidChangeCompilerOptionsForInferredProjects") case UpdateReasonRequestedLanguageServicePendingChanges: - logger.Logf("Reason: RequestedLanguageService (pending file changes) - %v", change.requestedURIs) + logger.Logf("Reason: RequestedLanguageService (pending file changes) - %v", getDetails()) case UpdateReasonRequestedLanguageServiceProjectNotLoaded: - logger.Logf("Reason: RequestedLanguageService (project not loaded) - %v", change.requestedURIs) + logger.Logf("Reason: RequestedLanguageService (project not loaded) - %v", getDetails()) + case UpdateReasonRequestedLanguageServiceForFileNotOpen: + logger.Logf("Reason: RequestedLanguageService (file not open) - %v", getDetails()) case UpdateReasonRequestedLanguageServiceProjectDirty: - logger.Logf("Reason: RequestedLanguageService (project dirty) - %v", change.requestedURIs) + logger.Logf("Reason: RequestedLanguageService (project dirty) - %v", getDetails()) + case UpdateReasonRequestedLoadProjectTree: + logger.Logf("Reason: RequestedLoadProjectTree - %v", getDetails()) } } start := time.Now() fs := newSnapshotFSBuilder(session.fs.fs, overlays, s.fs.diskFiles, session.options.PositionEncoding, s.toPath) - fs.markDirtyFiles(change.fileChanges) + if change.fileChanges.HasExcessiveWatchEvents() { + invalidateStart := time.Now() + if !fs.watchChangesOverlapCache(change.fileChanges) { + change.fileChanges.Changed = collections.Set[lsproto.DocumentUri]{} + change.fileChanges.Deleted = collections.Set[lsproto.DocumentUri]{} + } else if change.fileChanges.IncludesWatchChangeOutsideNodeModules { + fs.invalidateCache() + logger.Logf("Excessive watch changes detected, invalidated file cache in %v", time.Since(invalidateStart)) + } else { + fs.invalidateNodeModulesCache() + logger.Logf("npm install detected, invalidated node_modules cache in %v", time.Since(invalidateStart)) + } + } else { + fs.markDirtyFiles(change.fileChanges) + } compilerOptionsForInferredProjects := s.compilerOptionsForInferredProjects if change.compilerOptionsForInferredProjects != nil { @@ -210,10 +288,18 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma projectCollectionBuilder.DidChangeFiles(change.fileChanges, logger.Fork("DidChangeFiles")) } - for _, uri := range change.requestedURIs { + for _, uri := range change.Documents { projectCollectionBuilder.DidRequestFile(uri, logger.Fork("DidRequestFile")) } + for _, projectId := range change.Projects { + projectCollectionBuilder.DidRequestProject(projectId, logger.Fork("DidRequestProject")) + } + + if change.ProjectTree != nil { + projectCollectionBuilder.DidRequestProjectTrees(change.ProjectTree.referencedProjects, logger.Fork("DidRequestProjectTrees")) + } + projectCollection, configFileRegistry := projectCollectionBuilder.Finalize(logger) // Clean cached disk files not touched by any open project. It's not important that we do this on @@ -232,7 +318,7 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma removedFiles := 0 fs.diskFiles.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *diskFile]) bool { for _, project := range projectCollection.Projects() { - if project.host.SeenFiles().Has(entry.Key()) { + if project.host != nil && project.host.SeenFiles().Has(entry.Key()) { return true } } @@ -246,6 +332,16 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma } } + config := s.config + if change.newConfig != nil { + if change.newConfig.tsUserPreferences != nil { + config.tsUserPreferences = change.newConfig.tsUserPreferences.CopyOrDefault() + } + if change.newConfig.formatOptions != nil { + config.formatOptions = change.newConfig.formatOptions + } + } + snapshotFS, _ := fs.Finalize() newSnapshot := NewSnapshot( newSnapshotID, @@ -255,6 +351,7 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma session.extendedConfigCache, nil, compilerOptionsForInferredProjects, + config, s.toPath, ) newSnapshot.parentId = s.id diff --git a/internal/project/snapshotfs.go b/internal/project/snapshotfs.go index b6fe0e6d5e..dc02cb89cf 100644 --- a/internal/project/snapshotfs.go +++ b/internal/project/snapshotfs.go @@ -1,6 +1,7 @@ package project import ( + "strings" "sync" "github.com/microsoft/typescript-go/internal/collections" @@ -25,7 +26,7 @@ var ( type SnapshotFS struct { toPath func(fileName string) tspath.Path fs vfs.FS - overlays map[tspath.Path]*overlay + overlays map[tspath.Path]*Overlay diskFiles map[tspath.Path]*diskFile readFiles collections.SyncMap[tspath.Path, memoizedDiskFile] } @@ -53,16 +54,22 @@ func (s *SnapshotFS) GetFile(fileName string) FileHandle { return entry() } +func (s *SnapshotFS) isOpenFile(fileName string) bool { + path := s.toPath(fileName) + _, ok := s.overlays[path] + return ok +} + type snapshotFSBuilder struct { fs vfs.FS - overlays map[tspath.Path]*overlay + overlays map[tspath.Path]*Overlay diskFiles *dirty.SyncMap[tspath.Path, *diskFile] toPath func(string) tspath.Path } func newSnapshotFSBuilder( fs vfs.FS, - overlays map[tspath.Path]*overlay, + overlays map[tspath.Path]*Overlay, diskFiles map[tspath.Path]*diskFile, positionEncoding lsproto.PositionEncodingKind, toPath func(fileName string) tspath.Path, @@ -91,6 +98,11 @@ func (s *snapshotFSBuilder) Finalize() (*SnapshotFS, bool) { }, changed } +func (s *snapshotFSBuilder) isOpenFile(path tspath.Path) bool { + _, ok := s.overlays[path] + return ok +} + func (s *snapshotFSBuilder) GetFile(fileName string) FileHandle { path := s.toPath(fileName) return s.GetFileByPath(fileName, path) @@ -122,6 +134,42 @@ func (s *snapshotFSBuilder) GetFileByPath(fileName string, path tspath.Path) Fil return entry.Value() } +func (s *snapshotFSBuilder) watchChangesOverlapCache(change FileChangeSummary) bool { + for uri := range change.Changed.Keys() { + path := s.toPath(uri.FileName()) + if _, ok := s.diskFiles.Load(path); ok { + return true + } + } + for uri := range change.Deleted.Keys() { + path := s.toPath(uri.FileName()) + if _, ok := s.diskFiles.Load(path); ok { + return true + } + } + return false +} + +func (s *snapshotFSBuilder) invalidateCache() { + s.diskFiles.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *diskFile]) bool { + entry.Change(func(file *diskFile) { + file.needsReload = true + }) + return true + }) +} + +func (s *snapshotFSBuilder) invalidateNodeModulesCache() { + s.diskFiles.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *diskFile]) bool { + if strings.Contains(string(entry.Key()), "/node_modules/") { + entry.Change(func(file *diskFile) { + file.needsReload = true + }) + } + return true + }) +} + func (s *snapshotFSBuilder) markDirtyFiles(change FileChangeSummary) { for uri := range change.Changed.Keys() { path := s.toPath(uri.FileName()) diff --git a/internal/project/untitled_test.go b/internal/project/untitled_test.go index 54d3cfa763..3910ef0099 100644 --- a/internal/project/untitled_test.go +++ b/internal/project/untitled_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/bundled" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsconv" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil/projecttestutil" "gotest.tools/v3/assert" @@ -23,7 +23,7 @@ func TestUntitledReferences(t *testing.T) { convertedFileName := untitledURI.FileName() t.Logf("URI '%s' converts to filename '%s'", untitledURI, convertedFileName) - backToURI := ls.FileNameToDocumentURI(convertedFileName) + backToURI := lsconv.FileNameToDocumentURI(convertedFileName) t.Logf("Filename '%s' converts back to URI '%s'", convertedFileName, backToURI) if string(backToURI) != string(untitledURI) { @@ -71,7 +71,9 @@ x++;` Context: &lsproto.ReferenceContext{IncludeDeclaration: true}, } - resp, err := languageService.ProvideReferences(ctx, refParams) + originalNode, symbolAndEntries, ok := languageService.ProvideSymbolsAndEntries(ctx, refParams.TextDocumentURI(), refParams.Position, false) + assert.Assert(t, ok) + resp, err := languageService.ProvideReferencesFromSymbolAndEntries(ctx, refParams, originalNode, symbolAndEntries) assert.NilError(t, err) refs := *resp.Locations @@ -144,7 +146,9 @@ x++;` Context: &lsproto.ReferenceContext{IncludeDeclaration: true}, } - resp, err := languageService.ProvideReferences(ctx, refParams) + originalNode, symbolAndEntries, ok := languageService.ProvideSymbolsAndEntries(ctx, refParams.TextDocumentURI(), refParams.Position, false) + assert.Assert(t, ok) + resp, err := languageService.ProvideReferencesFromSymbolAndEntries(ctx, refParams, originalNode, symbolAndEntries) assert.NilError(t, err) refs := *resp.Locations diff --git a/internal/project/watch.go b/internal/project/watch.go index 2354040e3e..cdab89ad13 100644 --- a/internal/project/watch.go +++ b/internal/project/watch.go @@ -30,7 +30,7 @@ type fileSystemWatcherValue struct { id WatcherID } -type patternsAndIgnored struct { +type PatternsAndIgnored struct { patterns []string ignored map[string]struct{} } @@ -53,7 +53,7 @@ var watcherID atomic.Uint64 type WatchedFiles[T any] struct { name string watchKind lsproto.WatchKind - computeGlobPatterns func(input T) patternsAndIgnored + computeGlobPatterns func(input T) PatternsAndIgnored mu sync.RWMutex input T @@ -63,7 +63,7 @@ type WatchedFiles[T any] struct { id uint64 } -func NewWatchedFiles[T any](name string, watchKind lsproto.WatchKind, computeGlobPatterns func(input T) patternsAndIgnored) *WatchedFiles[T] { +func NewWatchedFiles[T any](name string, watchKind lsproto.WatchKind, computeGlobPatterns func(input T) PatternsAndIgnored) *WatchedFiles[T] { return &WatchedFiles[T]{ id: watcherID.Add(1), name: name, @@ -129,13 +129,13 @@ func (w *WatchedFiles[T]) Clone(input T) *WatchedFiles[T] { } } -func createResolutionLookupGlobMapper(workspaceDirectory string, libDirectory string, currentDirectory string, useCaseSensitiveFileNames bool) func(data map[tspath.Path]string) patternsAndIgnored { +func createResolutionLookupGlobMapper(workspaceDirectory string, libDirectory string, currentDirectory string, useCaseSensitiveFileNames bool) func(data map[tspath.Path]string) PatternsAndIgnored { comparePathsOptions := tspath.ComparePathsOptions{ CurrentDirectory: currentDirectory, UseCaseSensitiveFileNames: useCaseSensitiveFileNames, } - return func(data map[tspath.Path]string) patternsAndIgnored { + return func(data map[tspath.Path]string) PatternsAndIgnored { var ignored map[string]struct{} var seenDirs collections.Set[string] var includeWorkspace, includeRoot, includeLib bool @@ -196,7 +196,7 @@ func createResolutionLookupGlobMapper(workspaceDirectory string, libDirectory st } } - return patternsAndIgnored{ + return PatternsAndIgnored{ patterns: globs, ignored: ignored, } @@ -209,7 +209,7 @@ func getTypingsLocationsGlobs( workspaceDirectory string, currentDirectory string, useCaseSensitiveFileNames bool, -) patternsAndIgnored { +) PatternsAndIgnored { var includeTypingsLocation, includeWorkspace bool externalDirectories := make(map[tspath.Path]string) globs := make(map[tspath.Path]string) @@ -243,7 +243,7 @@ func getTypingsLocationsGlobs( for _, dir := range externalDirectoryParents { globs[tspath.ToPath(dir, currentDirectory, useCaseSensitiveFileNames)] = getRecursiveGlobPattern(dir) } - return patternsAndIgnored{ + return PatternsAndIgnored{ patterns: slices.Collect(maps.Values(globs)), ignored: ignored, } @@ -315,7 +315,7 @@ func extractLookups[T resolutionWithLookupLocations]( } } -func getNonRootFileGlobs(workspaceDir string, libDirectory string, sourceFiles []*ast.SourceFile, rootFiles map[tspath.Path]string, comparePathsOptions tspath.ComparePathsOptions) patternsAndIgnored { +func getNonRootFileGlobs(workspaceDir string, libDirectory string, sourceFiles []*ast.SourceFile, rootFiles map[tspath.Path]string, comparePathsOptions tspath.ComparePathsOptions) PatternsAndIgnored { var globs []string var includeWorkspace, includeLib bool var ignored map[string]struct{} @@ -350,7 +350,7 @@ func getNonRootFileGlobs(workspaceDir string, libDirectory string, sourceFiles [ })...) ignored = ignoredDirs } - return patternsAndIgnored{ + return PatternsAndIgnored{ patterns: globs, ignored: ignored, } diff --git a/internal/repo/paths.go b/internal/repo/paths.go index 237a8d0467..2d329b1b61 100644 --- a/internal/repo/paths.go +++ b/internal/repo/paths.go @@ -50,12 +50,12 @@ func TypeScriptSubmoduleExists() bool { return typeScriptSubmoduleExists() } -type skippable interface { +type SkippableTest interface { Helper() Skipf(format string, args ...any) } -func SkipIfNoTypeScriptSubmodule(t skippable) { +func SkipIfNoTypeScriptSubmodule(t SkippableTest) { t.Helper() if !typeScriptSubmoduleExists() { t.Skipf("TypeScript submodule does not exist") diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 58bb1d81c8..0367bd0214 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1455,6 +1455,9 @@ func (s *Scanner) scanIdentifierParts() string { func (s *Scanner) scanString(jsxAttributeString bool) string { quote := s.char() + if quote == '\'' { + s.tokenFlags |= ast.TokenFlagsSingleQuote + } s.pos++ // Fast path for simple strings without escape sequences. strLen := strings.IndexRune(s.text[s.pos:], quote) @@ -1626,6 +1629,13 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { codePoint := s.scanUnicodeEscape(flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0) if codePoint < 0 { return s.text[start:s.pos] + } else if codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' { + savedPos := s.pos + nextCodePoint := s.scanUnicodeEscape(flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0) + if codePointIsLowSurrogate(nextCodePoint) { + return string(surrogatePairToCodepoint(codePoint, nextCodePoint)) + } + s.pos = savedPos // restore position because we do not consume nextCodePoint } return string(codePoint) case 'x': @@ -1820,7 +1830,7 @@ func (s *Scanner) scanNumberFragment() string { start := s.pos allowSeparator := false isPreviousTokenSeparator := false - result := "" + var result strings.Builder for { ch := s.char() if ch == '_' { @@ -1828,7 +1838,7 @@ func (s *Scanner) scanNumberFragment() string { if allowSeparator { allowSeparator = false isPreviousTokenSeparator = true - result += s.text[start:s.pos] + result.WriteString(s.text[start:s.pos]) } else { s.tokenFlags |= ast.TokenFlagsContainsInvalidSeparator if isPreviousTokenSeparator { @@ -1853,7 +1863,8 @@ func (s *Scanner) scanNumberFragment() string { s.tokenFlags |= ast.TokenFlagsContainsInvalidSeparator s.errorAt(diagnostics.Numeric_separators_are_not_allowed_here, s.pos-1, 1) } - return result + s.text[start:s.pos] + result.WriteString(s.text[start:s.pos]) + return result.String() } func (s *Scanner) scanDigits() (string, bool) { @@ -2331,10 +2342,10 @@ func GetTokenPosOfNode(node *ast.Node, sourceFile *ast.SourceFile, includeJSDoc func getErrorRangeForArrowFunction(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { pos := SkipTrivia(sourceFile.Text(), node.Pos()) - body := node.AsArrowFunction().Body + body := node.Body() if body != nil && body.Kind == ast.KindBlock { - startLine, _ := GetECMALineAndCharacterOfPosition(sourceFile, body.Pos()) - endLine, _ := GetECMALineAndCharacterOfPosition(sourceFile, body.End()) + startLine := GetECMALineOfPosition(sourceFile, body.Pos()) + endLine := GetECMALineOfPosition(sourceFile, body.End()) if startLine < endLine { // The arrow function spans multiple lines, // make the error span be the first line, inclusive. @@ -2370,7 +2381,7 @@ func GetErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextR case ast.KindCaseClause, ast.KindDefaultClause: start := SkipTrivia(sourceFile.Text(), node.Pos()) end := node.End() - statements := node.AsCaseOrDefaultClause().Statements.Nodes + statements := node.Statements() if len(statements) != 0 { end = statements[0].Pos() } @@ -2430,9 +2441,15 @@ func GetECMALineStarts(sourceFile ast.SourceFileLike) []core.TextPos { return sourceFile.ECMALineMap() } +func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int { + lineMap := GetECMALineStarts(sourceFile) + return ComputeLineOfPosition(lineMap, pos) +} + func GetECMALineAndCharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) { lineMap := GetECMALineStarts(sourceFile) line = ComputeLineOfPosition(lineMap, pos) + // !!! TODO: this is suspect; these are rune counts, not UTF-8 _or_ UTF-16 offsets. character = utf8.RuneCountInString(sourceFile.Text()[lineMap[line]:pos]) return line, character } @@ -2448,7 +2465,7 @@ func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int { } } -func GetECMAPositionOfLineAndCharacter(sourceFile *ast.SourceFile, line int, character int) int { +func GetECMAPositionOfLineAndCharacter(sourceFile ast.SourceFileLike, line int, character int) int { return ComputePositionOfLineAndCharacter(GetECMALineStarts(sourceFile), line, character) } diff --git a/internal/scanner/utilities.go b/internal/scanner/utilities.go index 06ba7cf666..06b29a1e2a 100644 --- a/internal/scanner/utilities.go +++ b/internal/scanner/utilities.go @@ -8,6 +8,25 @@ import ( "github.com/microsoft/typescript-go/internal/core" ) +const ( + surr1 = 0xd800 + surr2 = 0xdc00 + surr3 = 0xe000 + surrSelf = 0x10000 +) + +func codePointIsHighSurrogate(r rune) bool { + return surr1 <= r && r < surr2 +} + +func codePointIsLowSurrogate(r rune) bool { + return surr2 <= r && r < surr3 +} + +func surrogatePairToCodepoint(r1, r2 rune) rune { + return (r1-surr1)<<10 | (r2 - surr2) + surrSelf +} + func tokenIsIdentifierOrKeyword(token ast.Kind) bool { return token >= ast.KindIdentifier } diff --git a/internal/sourcemap/util.go b/internal/sourcemap/util.go index c36003eec4..4605aa6cd0 100644 --- a/internal/sourcemap/util.go +++ b/internal/sourcemap/util.go @@ -9,18 +9,20 @@ import ( // Tries to find the sourceMappingURL comment at the end of a file. func TryGetSourceMappingURL(lineInfo *ECMALineInfo) string { - for index := lineInfo.LineCount() - 1; index >= 0; index-- { - line := lineInfo.LineText(index) - line = strings.TrimLeftFunc(line, unicode.IsSpace) - line = strings.TrimRightFunc(line, stringutil.IsLineBreak) - if len(line) == 0 { - continue - } - if len(line) < 4 || !strings.HasPrefix(line, "//") || line[2] != '#' && line[2] != '@' || line[3] != ' ' { - break - } - if url, ok := strings.CutPrefix(line[4:], "sourceMappingURL="); ok { - return strings.TrimRightFunc(url, unicode.IsSpace) + if lineInfo != nil { + for index := lineInfo.LineCount() - 1; index >= 0; index-- { + line := lineInfo.LineText(index) + line = strings.TrimLeftFunc(line, unicode.IsSpace) + line = strings.TrimRightFunc(line, stringutil.IsLineBreak) + if len(line) == 0 { + continue + } + if len(line) < 4 || !strings.HasPrefix(line, "//") || line[2] != '#' && line[2] != '@' || line[3] != ' ' { + break + } + if url, ok := strings.CutPrefix(line[4:], "sourceMappingURL="); ok { + return strings.TrimRightFunc(url, unicode.IsSpace) + } } } return "" diff --git a/internal/stringutil/compare.go b/internal/stringutil/compare.go index 832e1dbcf1..0fb1cd3975 100644 --- a/internal/stringutil/compare.go +++ b/internal/stringutil/compare.go @@ -98,3 +98,23 @@ func CompareStringsCaseInsensitiveThenSensitive(a, b string) Comparison { } return CompareStringsCaseSensitive(a, b) } + +// CompareStringsCaseInsensitiveEslintCompatible performs a case-insensitive comparison +// using toLowerCase() instead of toUpperCase() for ESLint compatibility. +// +// `CompareStringsCaseInsensitive` transforms letters to uppercase for unicode reasons, +// while eslint's `sort-imports` rule transforms letters to lowercase. Which one you choose +// affects the relative order of letters and ASCII characters 91-96, of which `_` is a +// valid character in an identifier. So if we used `CompareStringsCaseInsensitive` for +// import sorting, TypeScript and eslint would disagree about the correct case-insensitive +// sort order for `__String` and `Foo`. Since eslint's whole job is to create consistency +// by enforcing nitpicky details like this, it makes way more sense for us to just adopt +// their convention so users can have auto-imports without making eslint angry. +func CompareStringsCaseInsensitiveEslintCompatible(a, b string) Comparison { + if a == b { + return ComparisonEqual + } + a = strings.ToLower(a) + b = strings.ToLower(b) + return strings.Compare(a, b) +} diff --git a/internal/stringutil/format.go b/internal/stringutil/format.go deleted file mode 100644 index 3c52e36d4e..0000000000 --- a/internal/stringutil/format.go +++ /dev/null @@ -1,19 +0,0 @@ -package stringutil - -import ( - "fmt" - "regexp" - "strconv" -) - -var placeholderRegexp = regexp.MustCompile(`{(\d+)}`) - -func Format(text string, args []any) string { - return placeholderRegexp.ReplaceAllStringFunc(text, func(match string) string { - index, err := strconv.ParseInt(match[1:len(match)-1], 10, 0) - if err != nil || int(index) >= len(args) { - panic("Invalid formatting placeholder") - } - return fmt.Sprintf("%v", args[int(index)]) - }) -} diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index 215cba9c8d..a79e1874a2 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -182,9 +182,25 @@ func (r *CompilerBaselineRunner) runSingleConfigTest(t *testing.T, testName stri payload := makeUnitsFromTest(test.content, test.filename) compilerTest := newCompilerTest(t, testName, test.filename, &payload, config) - switch compilerTest.options.GetEmitModuleKind() { + switch compilerTest.options.Module { case core.ModuleKindAMD, core.ModuleKindUMD, core.ModuleKindSystem: - t.Skipf("Skipping test %s with unsupported module kind %s", testName, compilerTest.options.GetEmitModuleKind()) + t.Skipf("Skipping test %s with unsupported module kind %s", testName, compilerTest.options.Module) + } + switch compilerTest.options.ModuleResolution { + case core.ModuleResolutionKindNode10, core.ModuleResolutionKindClassic: + t.Skipf("Skipping test %s with unsupported module resolution kind %d", testName, compilerTest.options.ModuleResolution) + } + if compilerTest.options.ESModuleInterop.IsFalse() { + t.Skipf("Skipping test %s with esModuleInterop=false", testName) + } + if compilerTest.options.AllowSyntheticDefaultImports.IsFalse() { + t.Skipf("Skipping test %s with allowSyntheticDefaultImports=false", testName) + } + if compilerTest.options.BaseUrl != "" { + t.Skipf("Skipping test %s with baseUrl set", testName) + } + if compilerTest.options.OutFile != "" { + t.Skipf("Skipping test %s with outFile set", testName) } compilerTest.verifyDiagnostics(t, r.testSuitName, r.isSubmodule) @@ -193,8 +209,6 @@ func (r *CompilerBaselineRunner) runSingleConfigTest(t *testing.T, testName stri compilerTest.verifySourceMapRecord(t, r.testSuitName, r.isSubmodule) compilerTest.verifyTypesAndSymbols(t, r.testSuitName, r.isSubmodule) compilerTest.verifyModuleResolution(t, r.testSuitName, r.isSubmodule) - // !!! Verify all baselines - compilerTest.verifyUnionOrdering(t) compilerTest.verifyParentPointers(t) } @@ -337,11 +351,6 @@ func newCompilerTest( } var concurrentSkippedErrorBaselines = map[string]string{ - "circular1.ts": "Circular error reported in an extra position.", - "circular3.ts": "Circular error reported in an extra position.", - "recursiveExportAssignmentAndFindAliasedType1.ts": "Circular error reported in an extra position.", - "recursiveExportAssignmentAndFindAliasedType2.ts": "Circular error reported in an extra position.", - "recursiveExportAssignmentAndFindAliasedType3.ts": "Circular error reported in an extra position.", "typeOnlyMerge2.ts": "Type-only merging is not detected when files are checked on different checkers.", "typeOnlyMerge3.ts": "Type-only merging is not detected when files are checked on different checkers.", } @@ -357,9 +366,8 @@ func (c *compilerTest) verifyDiagnostics(t *testing.T, suiteName string, isSubmo defer testutil.RecoverAndFail(t, "Panic on creating error baseline for test "+c.filename) files := core.Concatenate(c.tsConfigFiles, core.Concatenate(c.toBeCompiled, c.otherFiles)) tsbaseline.DoErrorBaseline(t, c.configuredName, files, c.result.Diagnostics, c.result.Options.Pretty.IsTrue(), baseline.Options{ - Subfolder: suiteName, - IsSubmodule: isSubmodule, - IsSubmoduleAccepted: c.containsUnsupportedOptionsForDiagnostics(), + Subfolder: suiteName, + IsSubmodule: isSubmodule, DiffFixupOld: func(old string) string { var sb strings.Builder sb.Grow(len(old)) @@ -399,11 +407,6 @@ func (c *compilerTest) verifyJavaScriptOutput(t *testing.T, suiteName string, is return } - if c.options.OutFile != "" { - // Just return, no t.Skip; this is unsupported so testing them is not helpful. - return - } - t.Run("output", func(t *testing.T) { if msg, ok := skippedEmitTests[c.basename]; ok { t.Skip(msg) @@ -431,11 +434,6 @@ func (c *compilerTest) verifyJavaScriptOutput(t *testing.T, suiteName string, is } func (c *compilerTest) verifySourceMapOutput(t *testing.T, suiteName string, isSubmodule bool) { - if c.options.OutFile != "" { - // Just return, no t.Skip; this is unsupported so testing them is not helpful. - return - } - t.Run("sourcemap", func(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on creating source map output for test "+c.filename) headerComponents := tspath.GetPathComponentsRelativeTo(repo.TestDataPath, c.filename, tspath.ComparePathsOptions{}) @@ -456,11 +454,6 @@ func (c *compilerTest) verifySourceMapOutput(t *testing.T, suiteName string, isS } func (c *compilerTest) verifySourceMapRecord(t *testing.T, suiteName string, isSubmodule bool) { - if c.options.OutFile != "" { - // Just return, no t.Skip; this is unsupported so testing them is not helpful. - return - } - t.Run("sourcemap record", func(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on creating source map record for test "+c.filename) headerComponents := tspath.GetPathComponentsRelativeTo(repo.TestDataPath, c.filename, tspath.ComparePathsOptions{}) @@ -535,9 +528,8 @@ func createHarnessTestFile(unit *testUnit, currentDirectory string) *harnessutil func (c *compilerTest) verifyUnionOrdering(t *testing.T) { t.Run("union ordering", func(t *testing.T) { - checkers, done := c.result.Program.GetTypeCheckers(t.Context()) - defer done() - for _, c := range checkers { + p := c.result.Program.Program() + p.ForEachCheckerParallel(t.Context(), func(_ int, c *checker.Checker) { for union := range c.UnionTypes() { types := union.Types() @@ -555,7 +547,7 @@ func (c *compilerTest) verifyUnionOrdering(t *testing.T) { assert.Assert(t, slices.Equal(shuffled, types), "compareTypes does not sort union types consistently") } } - } + }) }) } @@ -590,17 +582,3 @@ func (c *compilerTest) verifyParentPointers(t *testing.T) { } }) } - -func (c *compilerTest) containsUnsupportedOptionsForDiagnostics() bool { - if len(c.result.Program.UnsupportedExtensions()) != 0 { - return true - } - if c.options.BaseUrl != "" { - return true - } - if c.options.OutFile != "" { - return true - } - - return false -} diff --git a/internal/testrunner/test_case_parser.go b/internal/testrunner/test_case_parser.go index 62fa71de79..e8fbe2de3b 100644 --- a/internal/testrunner/test_case_parser.go +++ b/internal/testrunner/test_case_parser.go @@ -107,6 +107,13 @@ func makeUnitsFromTest(code string, fileName string) testCaseContent { } } +type ParseTestFilesOptions struct { + // If true, allows test content to appear before the first @Filename directive. + // In this case, an implicit first file is created using the fileName parameter. + // This matches the behavior of the TypeScript fourslash test harness. + AllowImplicitFirstFile bool +} + // Given a test file containing // @FileName and // @symlink directives, // return an array of named units of code to be added to an existing compiler instance, // along with a map of symlinks and the current directory. @@ -114,6 +121,15 @@ func ParseTestFilesAndSymlinks[T any]( code string, fileName string, parseFile func(filename string, content string, fileOptions map[string]string) (T, error), +) (units []T, symlinks map[string]string, currentDir string, globalOptions map[string]string, e error) { + return ParseTestFilesAndSymlinksWithOptions(code, fileName, parseFile, ParseTestFilesOptions{}) +} + +func ParseTestFilesAndSymlinksWithOptions[T any]( + code string, + fileName string, + parseFile func(filename string, content string, fileOptions map[string]string) (T, error), + options ParseTestFilesOptions, ) (units []T, symlinks map[string]string, currentDir string, globalOptions map[string]string, e error) { // List of all the subfiles we've parsed out var testUnits []T @@ -123,6 +139,11 @@ func ParseTestFilesAndSymlinks[T any]( // Stuff related to the subfile we're parsing var currentFileContent strings.Builder var currentFileName string + if options.AllowImplicitFirstFile { + // For fourslash tests, initialize currentFileName to the fileName parameter + // so content before the first @Filename directive goes into an implicit first file + currentFileName = fileName + } var currentDirectory string var parseError error currentFileOptions := make(map[string]string) @@ -158,13 +179,16 @@ func ParseTestFilesAndSymlinks[T any]( // New metadata statement after having collected some code to go with the previous metadata if currentFileName != "" { - // Store result file - newTestFile, e := parseFile(currentFileName, currentFileContent.String(), currentFileOptions) - if e != nil { - parseError = e - break + // Store result file - always save for regular tests, but skip empty implicit first file for fourslash + shouldSaveFile := currentFileContent.Len() != 0 || !options.AllowImplicitFirstFile + if shouldSaveFile { + newTestFile, e := parseFile(currentFileName, currentFileContent.String(), currentFileOptions) + if e != nil { + parseError = e + break + } + testUnits = append(testUnits, newTestFile) } - testUnits = append(testUnits, newTestFile) // Reset local data currentFileContent.Reset() @@ -172,11 +196,27 @@ func ParseTestFilesAndSymlinks[T any]( currentFileOptions = make(map[string]string) } else { // First metadata marker in the file - currentFileName = strings.TrimSpace(testMetaData[2]) - if currentFileContent.Len() != 0 && scanner.SkipTrivia(currentFileContent.String(), 0) != currentFileContent.Len() { + hasContentBeforeFirstFilename := currentFileContent.Len() != 0 && scanner.SkipTrivia(currentFileContent.String(), 0) != currentFileContent.Len() + if hasContentBeforeFirstFilename && !options.AllowImplicitFirstFile { panic("Non-comment test content appears before the first '// @Filename' directive") } + + // If we have content before the first @Filename and AllowImplicitFirstFile is true, + // we need to save it as an implicit first file before starting the new file + if hasContentBeforeFirstFilename && options.AllowImplicitFirstFile && currentFileName != "" { + // Store the implicit first file + newTestFile, e := parseFile(currentFileName, currentFileContent.String(), currentFileOptions) + if e != nil { + parseError = e + break + } + testUnits = append(testUnits, newTestFile) + } + + // Reset for the new file currentFileContent.Reset() + currentFileName = strings.TrimSpace(testMetaData[2]) + currentFileOptions = make(map[string]string) } } else { // Subfile content line diff --git a/internal/testutil/baseline/baseline.go b/internal/testutil/baseline/baseline.go index 18559f9ca5..1d2afd939b 100644 --- a/internal/testutil/baseline/baseline.go +++ b/internal/testutil/baseline/baseline.go @@ -21,6 +21,7 @@ type Options struct { IsSubmodule bool IsSubmoduleAccepted bool DiffFixupOld func(string) string + DiffFixupNew func(string) string SkipDiffWithOld bool } @@ -64,7 +65,7 @@ func Run(t *testing.T, fileName string, actual string, opts Options) { localPath := filepath.Join(localRoot, outRoot, origSubfolder, diffFileName) referencePath := filepath.Join(referenceRoot, outRoot, origSubfolder, diffFileName) - diff := getBaselineDiff(t, actual, submoduleExpected, fileName, opts.DiffFixupOld) + diff := getBaselineDiff(t, actual, submoduleExpected, fileName, opts.DiffFixupOld, opts.DiffFixupNew) writeComparison(t, diff, localPath, referencePath, false) } @@ -113,10 +114,13 @@ func DiffText(oldName string, newName string, expected string, actual string) st }) } -func getBaselineDiff(t *testing.T, actual string, expected string, fileName string, fixupOld func(string) string) string { +func getBaselineDiff(t *testing.T, actual string, expected string, fileName string, fixupOld func(string) string, fixupNew func(string) string) string { if fixupOld != nil { expected = fixupOld(expected) } + if fixupNew != nil { + actual = fixupNew(actual) + } if actual == expected { return NoContent } diff --git a/internal/testutil/fsbaselineutil/differ.go b/internal/testutil/fsbaselineutil/differ.go new file mode 100644 index 0000000000..285d5e345e --- /dev/null +++ b/internal/testutil/fsbaselineutil/differ.go @@ -0,0 +1,122 @@ +package fsbaselineutil + +import ( + "fmt" + "io" + "io/fs" + "maps" + "slices" + "time" + + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/vfs/iovfs" + "github.com/microsoft/typescript-go/internal/vfs/vfstest" +) + +type DiffEntry struct { + Content string + MTime time.Time + IsWritten bool + SymlinkTarget string +} + +type Snapshot struct { + Snap map[string]*DiffEntry + DefaultLibs *collections.SyncSet[string] +} + +type FSDiffer struct { + FS iovfs.FsWithSys + DefaultLibs func() *collections.SyncSet[string] + WrittenFiles *collections.SyncSet[string] + + serializedDiff *Snapshot +} + +func (d *FSDiffer) MapFs() *vfstest.MapFS { + return d.FS.FSys().(*vfstest.MapFS) +} + +func (d *FSDiffer) SerializedDiff() *Snapshot { + return d.serializedDiff +} + +func (d *FSDiffer) BaselineFSwithDiff(baseline io.Writer) { + // todo: baselines the entire fs, possibly doesn't correctly diff all cases of emitted files, since emit isn't fully implemented and doesn't always emit the same way as strada + snap := map[string]*DiffEntry{} + + diffs := map[string]string{} + + for path, file := range d.MapFs().Entries() { + if file.Mode&fs.ModeSymlink != 0 { + target, ok := d.MapFs().GetTargetOfSymlink(path) + if !ok { + panic("Failed to resolve symlink target: " + path) + } + newEntry := &DiffEntry{SymlinkTarget: target} + snap[path] = newEntry + d.addFsEntryDiff(diffs, newEntry, path) + continue + } else if file.Mode.IsRegular() { + newEntry := &DiffEntry{Content: string(file.Data), MTime: file.ModTime, IsWritten: d.WrittenFiles.Has(path)} + snap[path] = newEntry + d.addFsEntryDiff(diffs, newEntry, path) + } + } + if d.serializedDiff != nil { + for path := range d.serializedDiff.Snap { + if fileInfo := d.MapFs().GetFileInfo(path); fileInfo == nil { + // report deleted + d.addFsEntryDiff(diffs, nil, path) + } + } + } + var defaultLibs collections.SyncSet[string] + if d.DefaultLibs != nil && d.DefaultLibs() != nil { + d.DefaultLibs().Range(func(libPath string) bool { + defaultLibs.Add(libPath) + return true + }) + } + d.serializedDiff = &Snapshot{ + Snap: snap, + DefaultLibs: &defaultLibs, + } + diffKeys := slices.Collect(maps.Keys(diffs)) + slices.Sort(diffKeys) + for _, path := range diffKeys { + fmt.Fprint(baseline, "//// ["+path+"] ", diffs[path], "\n") + } + fmt.Fprintln(baseline) + *d.WrittenFiles = collections.SyncSet[string]{} // Reset written files after baseline +} + +func (d *FSDiffer) addFsEntryDiff(diffs map[string]string, newDirContent *DiffEntry, path string) { + var oldDirContent *DiffEntry + var defaultLibs *collections.SyncSet[string] + if d.serializedDiff != nil { + oldDirContent = d.serializedDiff.Snap[path] + defaultLibs = d.serializedDiff.DefaultLibs + } + // todo handle more cases of fs changes + if oldDirContent == nil { + if d.DefaultLibs == nil || d.DefaultLibs() == nil || !d.DefaultLibs().Has(path) { + if newDirContent.SymlinkTarget != "" { + diffs[path] = "-> " + newDirContent.SymlinkTarget + " *new*" + } else { + diffs[path] = "*new* \n" + newDirContent.Content + } + } + } else if newDirContent == nil { + diffs[path] = "*deleted*" + } else if newDirContent.Content != oldDirContent.Content { + diffs[path] = "*modified* \n" + newDirContent.Content + } else if newDirContent.IsWritten { + diffs[path] = "*rewrite with same content*" + } else if newDirContent.MTime != oldDirContent.MTime { + diffs[path] = "*mTime changed*" + } else if defaultLibs != nil && defaultLibs.Has(path) && d.DefaultLibs != nil && d.DefaultLibs() != nil && !d.DefaultLibs().Has(path) { + // Lib file that was read + diffs[path] = "*Lib*\n" + newDirContent.Content + } +} diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 772eb169c0..482552a77a 100644 --- a/internal/testutil/harnessutil/harnessutil.go +++ b/internal/testutil/harnessutil/harnessutil.go @@ -21,6 +21,9 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/execute/incremental" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/repo" @@ -530,8 +533,8 @@ func NewTracerForBaselining(opts tspath.ComparePathsOptions, builder *strings.Bu } } -func (t *TracerForBaselining) Trace(msg string) { - t.TraceWithWriter(t.builder, msg, true) +func (t *TracerForBaselining) Trace(msg *diagnostics.Message, args ...any) { + t.TraceWithWriter(t.builder, msg.Localize(locale.Default, args...), true) } func (t *TracerForBaselining) TraceWithWriter(w io.Writer, msg string, usePackageJsonCache bool) { @@ -544,7 +547,7 @@ func (t *TracerForBaselining) sanitizeTrace(msg string, usePackageJsonCache bool return str } // caching of fs in trace to be replaces with non caching version - if str := strings.TrimSuffix(msg, "' does not exist according to earlier cached lookups."); str != msg { + if str, ok := strings.CutSuffix(msg, "' does not exist according to earlier cached lookups."); ok { file := strings.TrimPrefix(str, "File '") if usePackageJsonCache { filePath := tspath.ToPath(file, t.opts.CurrentDirectory, t.opts.UseCaseSensitiveFileNames) @@ -556,7 +559,7 @@ func (t *TracerForBaselining) sanitizeTrace(msg string, usePackageJsonCache bool } return fmt.Sprintf("File '%s' does not exist.", file) } - if str := strings.TrimSuffix(msg, "' exists according to earlier cached lookups."); str != msg { + if str, ok := strings.CutSuffix(msg, "' exists according to earlier cached lookups."); ok { file := strings.TrimPrefix(str, "File '") if usePackageJsonCache { filePath := tspath.ToPath(file, t.opts.CurrentDirectory, t.opts.UseCaseSensitiveFileNames) @@ -569,7 +572,7 @@ func (t *TracerForBaselining) sanitizeTrace(msg string, usePackageJsonCache bool return fmt.Sprintf("Found 'package.json' at '%s'.", file) } if usePackageJsonCache { - if str := strings.TrimSuffix(msg, "' does not exist."); str != msg { + if str, ok := strings.CutSuffix(msg, "' does not exist."); ok { file := strings.TrimPrefix(str, "File '") filePath := tspath.ToPath(file, t.opts.CurrentDirectory, t.opts.UseCaseSensitiveFileNames) if _, has := t.packageJsonCache[filePath]; !has { @@ -579,7 +582,7 @@ func (t *TracerForBaselining) sanitizeTrace(msg string, usePackageJsonCache bool return fmt.Sprintf("File '%s' does not exist according to earlier cached lookups.", file) } } - if str := strings.TrimPrefix(msg, "Found 'package.json' at '"); str != msg { + if str, ok := strings.CutPrefix(msg, "Found 'package.json' at '"); ok { file := strings.TrimSuffix(str, "'.") filePath := tspath.ToPath(file, t.opts.CurrentDirectory, t.opts.UseCaseSensitiveFileNames) if _, has := t.packageJsonCache[filePath]; !has { @@ -687,13 +690,13 @@ func compileFilesWithHost( } emitResult := program.Emit(ctx, compiler.EmitOptions{}) - return newCompilationResult(config.CompilerOptions(), program, emitResult, diagnostics, harnessOptions) + return newCompilationResult(host, config.CompilerOptions(), program, emitResult, diagnostics, harnessOptions) } type CompilationResult struct { Diagnostics []*ast.Diagnostic Result *compiler.EmitResult - Program *compiler.Program + Program compiler.ProgramLike Options *core.CompilerOptions HarnessOptions *HarnessOptions JS collections.OrderedMap[string, *TestFile] @@ -705,6 +708,7 @@ type CompilationResult struct { inputs []*TestFile inputsAndOutputs collections.OrderedMap[string, *CompilationOutput] Trace string + Host compiler.CompilerHost } type CompilationOutput struct { @@ -715,8 +719,9 @@ type CompilationOutput struct { } func newCompilationResult( + host compiler.CompilerHost, options *core.CompilerOptions, - program *compiler.Program, + program compiler.ProgramLike, result *compiler.EmitResult, diagnostics []*ast.Diagnostic, harnessOptions *HarnessOptions, @@ -731,9 +736,10 @@ func newCompilationResult( Program: program, Options: options, HarnessOptions: harnessOptions, + Host: host, } - fs := program.Host().FS().(*OutputRecorderFS) + fs := host.FS().(*OutputRecorderFS) if fs != nil && program != nil { // Corsa, unlike Strada, can use multiple threads for emit. As a result, the order of outputs is non-deterministic. // To make the order deterministic, we sort the outputs by the order of the inputs. @@ -803,7 +809,7 @@ func compareTestFiles(a *TestFile, b *TestFile) int { } func (c *CompilationResult) getOutputPath(path string, ext string) string { - path = tspath.ResolvePath(c.Program.GetCurrentDirectory(), path) + path = tspath.ResolvePath(c.Host.GetCurrentDirectory(), path) var outDir string if ext == ".d.ts" || ext == ".d.mts" || ext == ".d.cts" || (strings.HasSuffix(ext, ".ts") && strings.Contains(ext, ".d.")) { outDir = c.Options.DeclarationDir @@ -817,17 +823,17 @@ func (c *CompilationResult) getOutputPath(path string, ext string) string { common := c.Program.CommonSourceDirectory() if common != "" { path = tspath.GetRelativePathFromDirectory(common, path, tspath.ComparePathsOptions{ - UseCaseSensitiveFileNames: c.Program.UseCaseSensitiveFileNames(), - CurrentDirectory: c.Program.GetCurrentDirectory(), + UseCaseSensitiveFileNames: c.Host.FS().UseCaseSensitiveFileNames(), + CurrentDirectory: c.Host.GetCurrentDirectory(), }) - path = tspath.CombinePaths(tspath.ResolvePath(c.Program.GetCurrentDirectory(), c.Options.OutDir), path) + path = tspath.CombinePaths(tspath.ResolvePath(c.Host.GetCurrentDirectory(), c.Options.OutDir), path) } } return tspath.ChangeExtension(path, ext) } func (r *CompilationResult) FS() vfs.FS { - return r.Program.Host().FS() + return r.Host.FS() } func (r *CompilationResult) GetNumberOfJSFiles(includeJson bool) int { @@ -852,7 +858,7 @@ func (c *CompilationResult) Outputs() []*TestFile { } func (c *CompilationResult) GetInputsAndOutputsForFile(path string) *CompilationOutput { - return c.inputsAndOutputs.GetOrZero(tspath.ResolvePath(c.Program.GetCurrentDirectory(), path)) + return c.inputsAndOutputs.GetOrZero(tspath.ResolvePath(c.Host.GetCurrentDirectory(), path)) } func (c *CompilationResult) GetInputsForFile(path string) []*TestFile { @@ -915,7 +921,24 @@ func (c *CompilationResult) GetSourceMapRecord() string { return sourceMapRecorder.String() } -func createProgram(host compiler.CompilerHost, config *tsoptions.ParsedCommandLine) *compiler.Program { +type testBuildInfoReader struct { + inner incremental.BuildInfoReader +} + +func (t *testBuildInfoReader) ReadBuildInfo(config *tsoptions.ParsedCommandLine) *incremental.BuildInfo { + r := t.inner.ReadBuildInfo(config) + if r == nil { + return nil + } + r.Version = core.Version() + return r +} + +func getTestBuildInfoReader(host compiler.CompilerHost) *testBuildInfoReader { + return &testBuildInfoReader{inner: incremental.NewBuildInfoReader(host)} +} + +func createProgram(host compiler.CompilerHost, config *tsoptions.ParsedCommandLine) compiler.ProgramLike { var singleThreaded core.Tristate if testutil.TestProgramIsSingleThreaded() { singleThreaded = core.TSTrue @@ -927,6 +950,11 @@ func createProgram(host compiler.CompilerHost, config *tsoptions.ParsedCommandLi SingleThreaded: singleThreaded, } program := compiler.NewProgram(programOptions) + if config.CompilerOptions().Incremental.IsTrue() { + oldProgram := incremental.ReadBuildInfoProgram(config, getTestBuildInfoReader(host), host) + incrementalProgram := incremental.NewProgram(program, oldProgram, incremental.CreateHost(host), false) + return incrementalProgram + } return program } @@ -1033,7 +1061,7 @@ func splitOptionValues(t *testing.T, value string, option string) []string { star := false var includes []string var excludes []string - for _, s := range strings.Split(value, ",") { + for s := range strings.SplitSeq(value, ",") { s = strings.TrimSpace(s) if len(s) == 0 { continue diff --git a/internal/testutil/parsetestutil/parsetestutil.go b/internal/testutil/parsetestutil/parsetestutil.go index 589077b56c..4d0a4d20d5 100644 --- a/internal/testutil/parsetestutil/parsetestutil.go +++ b/internal/testutil/parsetestutil/parsetestutil.go @@ -27,7 +27,7 @@ func CheckDiagnostics(t *testing.T, file *ast.SourceFile) { t.Helper() if len(file.Diagnostics()) > 0 { var b strings.Builder - diagnosticwriter.WriteFormatDiagnostics(&b, file.Diagnostics(), &diagnosticwriter.FormattingOptions{ + diagnosticwriter.WriteFormatDiagnostics(&b, diagnosticwriter.FromASTDiagnostics(file.Diagnostics()), &diagnosticwriter.FormattingOptions{ NewLine: "\n", }) t.Error(b.String()) @@ -39,7 +39,7 @@ func CheckDiagnosticsMessage(t *testing.T, file *ast.SourceFile, message string) t.Helper() if len(file.Diagnostics()) > 0 { var b strings.Builder - diagnosticwriter.WriteFormatDiagnostics(&b, file.Diagnostics(), &diagnosticwriter.FormattingOptions{ + diagnosticwriter.WriteFormatDiagnostics(&b, diagnosticwriter.FromASTDiagnostics(file.Diagnostics()), &diagnosticwriter.FormattingOptions{ NewLine: "\n", }) t.Error(message + b.String()) diff --git a/internal/testutil/projecttestutil/clientmock_generated.go b/internal/testutil/projecttestutil/clientmock_generated.go index f2dff8fad5..2c310ceb13 100644 --- a/internal/testutil/projecttestutil/clientmock_generated.go +++ b/internal/testutil/projecttestutil/clientmock_generated.go @@ -21,6 +21,9 @@ var _ project.Client = &ClientMock{} // // // make and configure a mocked project.Client // mockedClient := &ClientMock{ +// PublishDiagnosticsFunc: func(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error { +// panic("mock out the PublishDiagnostics method") +// }, // RefreshDiagnosticsFunc: func(ctx context.Context) error { // panic("mock out the RefreshDiagnostics method") // }, @@ -37,6 +40,9 @@ var _ project.Client = &ClientMock{} // // } type ClientMock struct { + // PublishDiagnosticsFunc mocks the PublishDiagnostics method. + PublishDiagnosticsFunc func(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error + // RefreshDiagnosticsFunc mocks the RefreshDiagnostics method. RefreshDiagnosticsFunc func(ctx context.Context) error @@ -48,6 +54,13 @@ type ClientMock struct { // calls tracks calls to the methods. calls struct { + // PublishDiagnostics holds details about calls to the PublishDiagnostics method. + PublishDiagnostics []struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Params is the params argument value. + Params *lsproto.PublishDiagnosticsParams + } // RefreshDiagnostics holds details about calls to the RefreshDiagnostics method. RefreshDiagnostics []struct { // Ctx is the ctx argument value. @@ -70,11 +83,49 @@ type ClientMock struct { Watchers []*lsproto.FileSystemWatcher } } + lockPublishDiagnostics sync.RWMutex lockRefreshDiagnostics sync.RWMutex lockUnwatchFiles sync.RWMutex lockWatchFiles sync.RWMutex } +// PublishDiagnostics calls PublishDiagnosticsFunc. +func (mock *ClientMock) PublishDiagnostics(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error { + callInfo := struct { + Ctx context.Context + Params *lsproto.PublishDiagnosticsParams + }{ + Ctx: ctx, + Params: params, + } + mock.lockPublishDiagnostics.Lock() + mock.calls.PublishDiagnostics = append(mock.calls.PublishDiagnostics, callInfo) + mock.lockPublishDiagnostics.Unlock() + if mock.PublishDiagnosticsFunc == nil { + var errOut error + return errOut + } + return mock.PublishDiagnosticsFunc(ctx, params) +} + +// PublishDiagnosticsCalls gets all the calls that were made to PublishDiagnostics. +// Check the length with: +// +// len(mockedClient.PublishDiagnosticsCalls()) +func (mock *ClientMock) PublishDiagnosticsCalls() []struct { + Ctx context.Context + Params *lsproto.PublishDiagnosticsParams +} { + var calls []struct { + Ctx context.Context + Params *lsproto.PublishDiagnosticsParams + } + mock.lockPublishDiagnostics.RLock() + calls = mock.calls.PublishDiagnostics + mock.lockPublishDiagnostics.RUnlock() + return calls +} + // RefreshDiagnostics calls RefreshDiagnosticsFunc. func (mock *ClientMock) RefreshDiagnostics(ctx context.Context) error { callInfo := struct { diff --git a/internal/testutil/projecttestutil/projecttestutil.go b/internal/testutil/projecttestutil/projecttestutil.go index 169709d42c..476212b4e3 100644 --- a/internal/testutil/projecttestutil/projecttestutil.go +++ b/internal/testutil/projecttestutil/projecttestutil.go @@ -15,6 +15,7 @@ import ( "github.com/microsoft/typescript-go/internal/project/logging" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/vfs" + "github.com/microsoft/typescript-go/internal/vfs/iovfs" "github.com/microsoft/typescript-go/internal/vfs/vfstest" ) @@ -34,11 +35,16 @@ type TypingsInstallerOptions struct { } type SessionUtils struct { - fs vfs.FS - client *ClientMock - npmExecutor *NpmExecutorMock - tiOptions *TypingsInstallerOptions - logger logging.LogCollector + fsFromFileMap iovfs.FsWithSys + fs vfs.FS + client *ClientMock + npmExecutor *NpmExecutorMock + tiOptions *TypingsInstallerOptions + logger logging.LogCollector +} + +func (h *SessionUtils) FsFromFileMap() iovfs.FsWithSys { + return h.fsFromFileMap } func (h *SessionUtils) Client() *ClientMock { @@ -192,15 +198,28 @@ func SetupWithTypingsInstaller(files map[string]any, tiOptions *TypingsInstaller } func SetupWithOptionsAndTypingsInstaller(files map[string]any, options *project.SessionOptions, tiOptions *TypingsInstallerOptions) (*project.Session, *SessionUtils) { - fs := bundled.WrapFS(vfstest.FromMap(files, false /*useCaseSensitiveFileNames*/)) + init, sessionUtils := GetSessionInitOptions(files, options, tiOptions) + session := project.NewSession(init) + + return session, sessionUtils +} + +func WithRequestID(ctx context.Context) context.Context { + return core.WithRequestID(ctx, "0") +} + +func GetSessionInitOptions(files map[string]any, options *project.SessionOptions, tiOptions *TypingsInstallerOptions) (*project.SessionInit, *SessionUtils) { + fsFromFileMap := vfstest.FromMap(files, false /*useCaseSensitiveFileNames*/) + fs := bundled.WrapFS(fsFromFileMap) clientMock := &ClientMock{} npmExecutorMock := &NpmExecutorMock{} sessionUtils := &SessionUtils{ - fs: fs, - client: clientMock, - npmExecutor: npmExecutorMock, - tiOptions: tiOptions, - logger: logging.NewTestLogger(), + fsFromFileMap: fsFromFileMap.(iovfs.FsWithSys), + fs: fs, + client: clientMock, + npmExecutor: npmExecutorMock, + tiOptions: tiOptions, + logger: logging.NewTestLogger(), } // Configure the npm executor mock to handle typings installation @@ -209,26 +228,21 @@ func SetupWithOptionsAndTypingsInstaller(files map[string]any, options *project. // Use provided options or create default ones if options == nil { options = &project.SessionOptions{ - CurrentDirectory: "/", - DefaultLibraryPath: bundled.LibPath(), - TypingsLocation: TestTypingsLocation, - PositionEncoding: lsproto.PositionEncodingKindUTF8, - WatchEnabled: true, - LoggingEnabled: true, + CurrentDirectory: "/", + DefaultLibraryPath: bundled.LibPath(), + TypingsLocation: TestTypingsLocation, + PositionEncoding: lsproto.PositionEncodingKindUTF8, + WatchEnabled: true, + LoggingEnabled: true, + PushDiagnosticsEnabled: true, } } - session := project.NewSession(&project.SessionInit{ + return &project.SessionInit{ Options: options, FS: fs, Client: clientMock, NpmExecutor: npmExecutorMock, Logger: sessionUtils.logger, - }) - - return session, sessionUtils -} - -func WithRequestID(ctx context.Context) context.Context { - return core.WithRequestID(ctx, "0") + }, sessionUtils } diff --git a/internal/testutil/stringtestutil/stringtestutil.go b/internal/testutil/stringtestutil/stringtestutil.go index 4a1e70f271..482186d64c 100644 --- a/internal/testutil/stringtestutil/stringtestutil.go +++ b/internal/testutil/stringtestutil/stringtestutil.go @@ -29,7 +29,15 @@ func Dedent(text string) string { } } lines = lines[startLine : lastLine+1] - indentation := stringutil.GuessIndentation(lines) + mappedLines := make([]string, len(lines)) + for i, line := range lines { + if trimmed := strings.TrimSpace(line); trimmed == "" { + mappedLines[i] = "" + } else { + mappedLines[i] = line + } + } + indentation := stringutil.GuessIndentation(mappedLines) if indentation > 0 { for i := range lines { if len(lines[i]) > indentation { diff --git a/internal/testutil/tsbaseline/error_baseline.go b/internal/testutil/tsbaseline/error_baseline.go index 1490c267e5..9109a00c13 100644 --- a/internal/testutil/tsbaseline/error_baseline.go +++ b/internal/testutil/tsbaseline/error_baseline.go @@ -12,6 +12,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnosticwriter" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/testutil/harnessutil" "github.com/microsoft/typescript-go/internal/tspath" @@ -35,14 +36,14 @@ func DoErrorBaseline(t *testing.T, baselinePath string, inputFiles []*harnessuti baselinePath = tsExtension.ReplaceAllString(baselinePath, ".errors.txt") var errorBaseline string if len(errors) > 0 { - errorBaseline = getErrorBaseline(t, inputFiles, errors, pretty) + errorBaseline = GetErrorBaseline(t, inputFiles, diagnosticwriter.WrapASTDiagnostics(errors), diagnosticwriter.CompareASTDiagnostics, pretty) } else { errorBaseline = baseline.NoContent } baseline.Run(t, baselinePath, errorBaseline, opts) } -func minimalDiagnosticsToString(diagnostics []*ast.Diagnostic, pretty bool) string { +func minimalDiagnosticsToString(diagnostics []diagnosticwriter.Diagnostic, pretty bool) string { var output strings.Builder if pretty { diagnosticwriter.FormatDiagnosticsWithColorAndContext(&output, diagnostics, formatOpts) @@ -52,15 +53,15 @@ func minimalDiagnosticsToString(diagnostics []*ast.Diagnostic, pretty bool) stri return output.String() } -func getErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, diagnostics []*ast.Diagnostic, pretty bool) string { +func GetErrorBaseline[T diagnosticwriter.Diagnostic](t *testing.T, inputFiles []*harnessutil.TestFile, diagnostics []T, compareDiagnostics func(a, b T) int, pretty bool) string { t.Helper() - outputLines := iterateErrorBaseline(t, inputFiles, diagnostics, pretty) + outputLines := iterateErrorBaseline(t, inputFiles, diagnostics, compareDiagnostics, pretty) if pretty { var summaryBuilder strings.Builder diagnosticwriter.WriteErrorSummaryText( &summaryBuilder, - diagnostics, + diagnosticwriter.ToDiagnostics(diagnostics), formatOpts) summary := removeTestPathPrefixes(summaryBuilder.String(), false) outputLines = append(outputLines, summary) @@ -68,10 +69,10 @@ func getErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, diagnost return strings.Join(outputLines, "") } -func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inputDiagnostics []*ast.Diagnostic, pretty bool) []string { +func iterateErrorBaseline[T diagnosticwriter.Diagnostic](t *testing.T, inputFiles []*harnessutil.TestFile, inputDiagnostics []T, compareDiagnostics func(a, b T) int, pretty bool) []string { t.Helper() diagnostics := slices.Clone(inputDiagnostics) - slices.SortFunc(diagnostics, ast.CompareDiagnostics) + slices.SortFunc(diagnostics, compareDiagnostics) var outputLines strings.Builder // Count up all errors that were found in files other than lib.d.ts so we don't miss any @@ -90,13 +91,13 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu var result []string - outputErrorText := func(diag *ast.Diagnostic) { - message := diagnosticwriter.FlattenDiagnosticMessage(diag, harnessNewLine) + outputErrorText := func(diag diagnosticwriter.Diagnostic) { + message := diagnosticwriter.FlattenDiagnosticMessage(diag, harnessNewLine, locale.Default) var errLines []string - for _, line := range strings.Split(removeTestPathPrefixes(message, false), "\n") { + for line := range strings.SplitSeq(removeTestPathPrefixes(message, false), "\n") { line = strings.TrimSuffix(line, "\r") - if len(line) < 0 { + if len(line) == 0 { continue } out := fmt.Sprintf("!!! %s TS%d: %s", diag.Category().Name(), diag.Code(), line) @@ -106,13 +107,13 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu for _, info := range diag.RelatedInformation() { var location string if info.File() != nil { - location = " " + formatLocation(info.File(), info.Loc().Pos(), formatOpts, func(output io.Writer, text string, formatStyle string) { fmt.Fprint(output, text) }) + location = " " + formatLocation(info.File(), info.Pos(), formatOpts, func(output io.Writer, text string, formatStyle string) { fmt.Fprint(output, text) }) } location = removeTestPathPrefixes(location, false) if len(location) > 0 && isDefaultLibraryFile(info.File().FileName()) { location = diagnosticsLocationPattern.ReplaceAllString(location, "$1:--:--") } - errLines = append(errLines, fmt.Sprintf("!!! related TS%d%s: %s", info.Code(), location, diagnosticwriter.FlattenDiagnosticMessage(info, harnessNewLine))) + errLines = append(errLines, fmt.Sprintf("!!! related TS%d%s: %s", info.Code(), location, diagnosticwriter.FlattenDiagnosticMessage(info, harnessNewLine, locale.Default))) } for _, e := range errLines { @@ -133,7 +134,7 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu } } - topDiagnostics := minimalDiagnosticsToString(diagnostics, pretty) + topDiagnostics := minimalDiagnosticsToString(diagnosticwriter.ToDiagnostics(diagnostics), pretty) topDiagnostics = removeTestPathPrefixes(topDiagnostics, false) topDiagnostics = diagnosticsLocationPrefix.ReplaceAllString(topDiagnostics, "$1(--,--)") @@ -154,7 +155,7 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu dupeCase := map[string]int{} for _, inputFile := range inputFiles { // Filter down to the errors in the file - fileErrors := core.Filter(diagnostics, func(e *ast.Diagnostic) bool { + fileErrors := core.Filter(diagnostics, func(e T) bool { return e.File() != nil && tspath.ComparePaths(removeTestPathPrefixes(e.File().FileName(), false), removeTestPathPrefixes(inputFile.UnitName, false), tspath.ComparePathsOptions{}) == 0 }) @@ -193,8 +194,8 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu outputLines.WriteString(line) for _, errDiagnostic := range fileErrors { // Does any error start or continue on to this line? Emit squiggles - errStart := errDiagnostic.Loc().Pos() - end := errDiagnostic.Loc().End() + errStart := errDiagnostic.Pos() + end := errStart + errDiagnostic.Len() if end >= thisLineStart && (errStart < nextLineStart || lineIndex == len(lines)-1) { // How many characters from the start of this line the error starts at (could be positive or negative) relativeOffset := errStart - thisLineStart @@ -234,12 +235,12 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu numLibraryDiagnostics := core.CountWhere( diagnostics, - func(d *ast.Diagnostic) bool { + func(d T) bool { return d.File() != nil && (isDefaultLibraryFile(d.File().FileName()) || isBuiltFile(d.File().FileName())) }) numTsconfigDiagnostics := core.CountWhere( diagnostics, - func(d *ast.Diagnostic) bool { + func(d T) bool { return d.File() != nil && isTsConfigFile(d.File().FileName()) }) // Verify we didn't miss any errors in total @@ -248,7 +249,7 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu return result } -func formatLocation(file *ast.SourceFile, pos int, formatOpts *diagnosticwriter.FormattingOptions, writeWithStyleAndReset diagnosticwriter.FormattedWriter) string { +func formatLocation(file diagnosticwriter.FileLike, pos int, formatOpts *diagnosticwriter.FormattingOptions, writeWithStyleAndReset diagnosticwriter.FormattedWriter) string { var output strings.Builder diagnosticwriter.WriteLocation(&output, file, pos, formatOpts, writeWithStyleAndReset) return output.String() diff --git a/internal/testutil/tsbaseline/js_emit_baseline.go b/internal/testutil/tsbaseline/js_emit_baseline.go index 8b51c19349..9a16165a03 100644 --- a/internal/testutil/tsbaseline/js_emit_baseline.go +++ b/internal/testutil/tsbaseline/js_emit_baseline.go @@ -8,6 +8,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnosticwriter" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/testutil/harnessutil" @@ -59,7 +60,7 @@ func DoJSEmitBaseline( CompilerOptions: options.SourceFileAffecting(), }, file.Content, core.ScriptKindJSON) if len(fileParseResult.Diagnostics()) > 0 { - jsCode.WriteString(getErrorBaseline(t, []*harnessutil.TestFile{file}, fileParseResult.Diagnostics(), false /*pretty*/)) + jsCode.WriteString(GetErrorBaseline(t, []*harnessutil.TestFile{file}, diagnosticwriter.WrapASTDiagnostics(fileParseResult.Diagnostics()), diagnosticwriter.CompareASTDiagnostics, false /*pretty*/)) continue } } @@ -86,10 +87,11 @@ func DoJSEmitBaseline( if declFileCompilationResult != nil && len(declFileCompilationResult.declResult.Diagnostics) > 0 { jsCode.WriteString("\r\n\r\n//// [DtsFileErrors]\r\n") jsCode.WriteString("\r\n\r\n") - jsCode.WriteString(getErrorBaseline( + jsCode.WriteString(GetErrorBaseline( t, slices.Concat(tsConfigFiles, declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), - declFileCompilationResult.declResult.Diagnostics, + diagnosticwriter.WrapASTDiagnostics(declFileCompilationResult.declResult.Diagnostics), + diagnosticwriter.CompareASTDiagnostics, false, /*pretty*/ )) } @@ -201,7 +203,7 @@ func prepareDeclarationCompilationContext( var sourceFileName string if len(options.OutDir) != 0 { - sourceFilePath := tspath.GetNormalizedAbsolutePath(sourceFile.FileName(), result.Program.GetCurrentDirectory()) + sourceFilePath := tspath.GetNormalizedAbsolutePath(sourceFile.FileName(), result.Host.GetCurrentDirectory()) sourceFilePath = strings.Replace(sourceFilePath, result.Program.CommonSourceDirectory(), "", 1) sourceFileName = tspath.CombinePaths(options.OutDir, sourceFilePath) } else { diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index d8f40d133c..6a7e08878b 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -31,7 +31,7 @@ func DoTypeAndSymbolBaseline( t *testing.T, baselinePath string, header string, - program *compiler.Program, + program compiler.ProgramLike, allFiles []*harnessutil.TestFile, opts baseline.Options, skipTypeBaselines bool, @@ -95,7 +95,6 @@ func DoTypeAndSymbolBaseline( return sb.String()[:sb.Len()-1] } - typesOpts.IsSubmoduleAccepted = len(program.UnsupportedExtensions()) != 0 // TODO(jakebailey): read submoduleAccepted.txt checkBaselines(t, baselinePath, allFiles, fullWalker, header, typesOpts, false /*isSymbolBaseline*/) }) @@ -260,13 +259,13 @@ func iterateBaseline(allFiles []*harnessutil.TestFile, fullWalker *typeWriterWal } type typeWriterWalker struct { - program *compiler.Program + program compiler.ProgramLike hadErrorBaseline bool currentSourceFile *ast.SourceFile declarationTextCache map[*ast.Node]string } -func newTypeWriterWalker(program *compiler.Program, hadErrorBaseline bool) *typeWriterWalker { +func newTypeWriterWalker(program compiler.ProgramLike, hadErrorBaseline bool) *typeWriterWalker { return &typeWriterWalker{ program: program, hadErrorBaseline: hadErrorBaseline, @@ -277,7 +276,7 @@ func newTypeWriterWalker(program *compiler.Program, hadErrorBaseline bool) *type func (walker *typeWriterWalker) getTypeCheckerForCurrentFile() (*checker.Checker, func()) { // If we don't use the right checker for the file, its contents won't be up to date // since the types/symbols baselines appear to depend on files having been checked. - return walker.program.GetTypeCheckerForFile(context.Background(), walker.currentSourceFile) + return walker.program.Program().GetTypeCheckerForFile(context.Background(), walker.currentSourceFile) } type typeWriterResult struct { @@ -343,7 +342,7 @@ func forEachASTNode(node *ast.Node) []*ast.Node { func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk bool) *typeWriterResult { actualPos := scanner.SkipTrivia(walker.currentSourceFile.Text(), node.Pos()) - line, _ := scanner.GetECMALineAndCharacterOfPosition(walker.currentSourceFile, actualPos) + line := scanner.GetECMALineOfPosition(walker.currentSourceFile, actualPos) sourceText := scanner.GetSourceTextOfNodeFromSourceFile(walker.currentSourceFile, node, false /*includeTrivia*/) fileChecker, done := walker.getTypeCheckerForCurrentFile() defer done() @@ -391,7 +390,7 @@ func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk b builder := checker.NewNodeBuilder(fileChecker, ctx) typeFormatFlags := checker.TypeFormatFlagsNoTruncation | checker.TypeFormatFlagsAllowUniqueESSymbolType | checker.TypeFormatFlagsGenerateNamesForShadowedTypeParams typeNode := builder.TypeToTypeNode(t, node.Parent, nodebuilder.Flags(typeFormatFlags&checker.TypeFormatFlagsNodeBuilderFlagsMask)|nodebuilder.FlagsIgnoreErrors, nodebuilder.InternalFlagsAllowUnresolvedNames, nil) - if ast.IsIdentifier(node) && ast.IsTypeAliasDeclaration(node.Parent) && node.Parent.Name() == node && ast.IsIdentifier(typeNode) && typeNode.AsIdentifier().Text == node.AsIdentifier().Text { + if ast.IsIdentifier(node) && ast.IsTypeAliasDeclaration(node.Parent) && node.Parent.Name() == node && ast.IsIdentifier(typeNode) && typeNode.Text() == node.Text() { // for a complex type alias `type T = ...`, showing "T : T" isn't very helpful for type tests. When the type produced is the same as // the name of the type alias, recreate the type string without reusing the alias name typeNode = builder.TypeToTypeNode(t, node.Parent, nodebuilder.Flags((typeFormatFlags|checker.TypeFormatFlagsInTypeAlias)&checker.TypeFormatFlagsNodeBuilderFlagsMask)|nodebuilder.FlagsIgnoreErrors, nodebuilder.InternalFlagsAllowUnresolvedNames, nil) diff --git a/internal/transformers/declarations/diagnostics.go b/internal/transformers/declarations/diagnostics.go index 8505a9fafa..cbb7d48317 100644 --- a/internal/transformers/declarations/diagnostics.go +++ b/internal/transformers/declarations/diagnostics.go @@ -188,7 +188,7 @@ func createGetSymbolAccessibilityDiagnosticForNode(node *ast.Node) GetSymbolAcce diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2, diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, ) - errorNode := node.AsTypeAliasDeclaration().Type + errorNode := node.Type() typeName := node.Name() return &SymbolAccessibilityDiagnostic{ errorNode: errorNode, diff --git a/internal/transformers/declarations/transform.go b/internal/transformers/declarations/transform.go index 58cef207d5..360f8fcf30 100644 --- a/internal/transformers/declarations/transform.go +++ b/internal/transformers/declarations/transform.go @@ -50,7 +50,6 @@ type DeclarationTransformer struct { declarationFilePath string declarationMapPath string - isBundledEmit bool needsDeclare bool needsScopeFixMarker bool resultHasScopeMarker bool @@ -102,7 +101,6 @@ func (tx *DeclarationTransformer) visit(node *ast.Node) *ast.Node { if node == nil { return nil } - // !!! TODO: Bundle support? switch node.Kind { case ast.KindSourceFile: return tx.visitSourceFile(node.AsSourceFile()) @@ -120,7 +118,8 @@ func (tx *DeclarationTransformer) visit(node *ast.Node) *ast.Node { ast.KindJSImportDeclaration, ast.KindExportDeclaration, ast.KindJSExportAssignment, - ast.KindExportAssignment: + ast.KindExportAssignment, + ast.KindCommonJSExport: return tx.visitDeclarationStatements(node) // statements we elide case ast.KindBreakStatement, @@ -160,7 +159,6 @@ func (tx *DeclarationTransformer) visitSourceFile(node *ast.SourceFile) *ast.Nod return node.AsNode() } - tx.isBundledEmit = false tx.needsDeclare = true tx.needsScopeFixMarker = false tx.resultHasScopeMarker = false @@ -237,7 +235,7 @@ func (tx *DeclarationTransformer) transformAndReplaceLatePaintedStatements(state tx.state.lateMarkedStatements = tx.state.lateMarkedStatements[1:] saveNeedsDeclare := tx.needsDeclare - tx.needsDeclare = next.Parent != nil && ast.IsSourceFile(next.Parent) && !(ast.IsExternalModule(next.Parent.AsSourceFile()) && tx.isBundledEmit) + tx.needsDeclare = next.Parent != nil && ast.IsSourceFile(next.Parent) result := tx.transformTopLevelDeclaration(next) @@ -310,8 +308,6 @@ func (tx *DeclarationTransformer) getReferencedFiles(outputFilePath string) (res if file.IsDeclarationFile { declFileName = file.FileName() } else { - // !!! bundled emit support, omit bundled refs - // if (tx.isBundledEmit && contains((node as Bundle).sourceFiles, file)) continue paths := tx.host.GetOutputPathsFor(file, true) // Try to use output path for referenced file, or output js path if that doesn't exist, or the input path if all else fails declFileName = paths.DeclarationFilePath() @@ -403,7 +399,7 @@ func (tx *DeclarationTransformer) visitDeclarationSubtree(input *ast.Node) *ast. return nil } } - } else if !tx.resolver.IsLateBound(tx.EmitContext().ParseNode(input)) || !ast.IsEntityNameExpression(input.Name().AsComputedPropertyName().Expression) { + } else if !tx.resolver.IsLateBound(tx.EmitContext().ParseNode(input)) || !ast.IsEntityNameExpression(input.Name().Expression()) { return nil } } @@ -528,7 +524,7 @@ func (tx *DeclarationTransformer) checkName(node *ast.Node) { } tx.state.errorNameNode = node.Name() debug.Assert(ast.HasDynamicName(node)) // Should only be called with dynamic names - entityName := node.Name().AsComputedPropertyName().Expression + entityName := node.Name().Expression() tx.checkEntityNameVisibility(entityName, tx.enclosingDeclaration) if !tx.suppressNewDiagnosticContexts { tx.state.getSymbolAccessibilityDiagnostic = oldDiag @@ -921,15 +917,89 @@ func (tx *DeclarationTransformer) visitDeclarationStatements(input *ast.Node) *a input.Modifiers(), input.IsTypeOnly(), input.AsExportDeclaration().ExportClause, - tx.rewriteModuleSpecifier(input, input.AsExportDeclaration().ModuleSpecifier), + tx.rewriteModuleSpecifier(input, input.ModuleSpecifier()), tx.tryGetResolutionModeOverride(input.AsExportDeclaration().Attributes), ) + case ast.KindCommonJSExport: + if ast.IsSourceFile(input.Parent) { + tx.resultHasExternalModuleIndicator = true + } + tx.resultHasScopeMarker = true + name := input.AsCommonJSExport().Name() + if ast.IsIdentifier(name) { + if name.Text() == "default" { + // const _default: Type; export default _default; + newId := tx.Factory().NewUniqueNameEx("_default", printer.AutoGenerateOptions{Flags: printer.GeneratedIdentifierFlagsOptimistic}) + tx.state.getSymbolAccessibilityDiagnostic = func(_ printer.SymbolAccessibilityResult) *SymbolAccessibilityDiagnostic { + return &SymbolAccessibilityDiagnostic{ + diagnosticMessage: diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: input, + } + } + tx.tracker.PushErrorFallbackNode(input) + type_ := tx.ensureType(input, false) + varDecl := tx.Factory().NewVariableDeclaration(newId, nil, type_, nil) + tx.tracker.PopErrorFallbackNode() + var modList *ast.ModifierList + if tx.needsDeclare { + modList = tx.Factory().NewModifierList([]*ast.Node{tx.Factory().NewModifier(ast.KindDeclareKeyword)}) + } else { + modList = tx.Factory().NewModifierList([]*ast.Node{}) + } + statement := tx.Factory().NewVariableStatement(modList, tx.Factory().NewVariableDeclarationList(ast.NodeFlagsConst, tx.Factory().NewNodeList([]*ast.Node{varDecl}))) + + assignment := tx.Factory().NewExportAssignment(input.Modifiers(), false, nil, newId) + // Remove comments from the export declaration and copy them onto the synthetic _default declaration + tx.preserveJsDoc(statement, input) + tx.removeAllComments(assignment) + return tx.Factory().NewSyntaxList([]*ast.Node{statement, assignment}) + } else { + // export var name: Type + tx.tracker.PushErrorFallbackNode(input) + type_ := tx.ensureType(input, false) + varDecl := tx.Factory().NewVariableDeclaration(name, nil, type_, nil) + tx.tracker.PopErrorFallbackNode() + var modList *ast.ModifierList + if tx.needsDeclare { + modList = tx.Factory().NewModifierList([]*ast.Node{tx.Factory().NewModifier(ast.KindExportKeyword), tx.Factory().NewModifier(ast.KindDeclareKeyword)}) + } else { + modList = tx.Factory().NewModifierList([]*ast.Node{tx.Factory().NewModifier(ast.KindExportKeyword)}) + } + return tx.Factory().NewVariableStatement(modList, tx.Factory().NewVariableDeclarationList(ast.NodeFlagsNone, tx.Factory().NewNodeList([]*ast.Node{varDecl}))) + } + } else { + // const _exported: Type; export {_exported as "name"}; + newId := tx.Factory().NewUniqueNameEx("_exported", printer.AutoGenerateOptions{Flags: printer.GeneratedIdentifierFlagsOptimistic}) + tx.state.getSymbolAccessibilityDiagnostic = func(_ printer.SymbolAccessibilityResult) *SymbolAccessibilityDiagnostic { + return &SymbolAccessibilityDiagnostic{ + diagnosticMessage: diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: input, + } + } + tx.tracker.PushErrorFallbackNode(input) + type_ := tx.ensureType(input, false) + varDecl := tx.Factory().NewVariableDeclaration(newId, nil, type_, nil) + tx.tracker.PopErrorFallbackNode() + var modList *ast.ModifierList + if tx.needsDeclare { + modList = tx.Factory().NewModifierList([]*ast.Node{tx.Factory().NewModifier(ast.KindDeclareKeyword)}) + } else { + modList = tx.Factory().NewModifierList([]*ast.Node{}) + } + statement := tx.Factory().NewVariableStatement(modList, tx.Factory().NewVariableDeclarationList(ast.NodeFlagsConst, tx.Factory().NewNodeList([]*ast.Node{varDecl}))) + + assignment := tx.Factory().NewExportDeclaration(nil, false, tx.Factory().NewNamedExports(tx.Factory().NewNodeList([]*ast.Node{tx.Factory().NewExportSpecifier(false, newId, name)})), nil, nil) + // Remove comments from the export declaration and copy them onto the synthetic _default declaration + tx.preserveJsDoc(statement, input) + tx.removeAllComments(assignment) + return tx.Factory().NewSyntaxList([]*ast.Node{statement, assignment}) + } case ast.KindExportAssignment, ast.KindJSExportAssignment: if ast.IsSourceFile(input.Parent) { tx.resultHasExternalModuleIndicator = true } tx.resultHasScopeMarker = true - if input.AsExportAssignment().Expression.Kind == ast.KindIdentifier { + if input.Expression().Kind == ast.KindIdentifier { return input } // expression is non-identifier, create _default typed variable to reference @@ -972,11 +1042,6 @@ func (tx *DeclarationTransformer) rewriteModuleSpecifier(parent *ast.Node, input return nil } tx.resultHasExternalModuleIndicator = tx.resultHasExternalModuleIndicator || (parent.Kind != ast.KindModuleDeclaration && parent.Kind != ast.KindImportType) - if ast.IsStringLiteralLike(input) { - if tx.isBundledEmit { - // !!! TODO: support bundled emit specifier rewriting - } - } return input } @@ -1187,7 +1252,7 @@ func (tx *DeclarationTransformer) transformModuleDeclaration(input *ast.ModuleDe oldHasScopeFix := tx.resultHasScopeMarker tx.resultHasScopeMarker = false tx.needsScopeFixMarker = false - statements := tx.Visitor().VisitNodes(inner.AsModuleBlock().Statements) + statements := tx.Visitor().VisitNodes(inner.StatementList()) lateStatements := tx.transformAndReplaceLatePaintedStatements(statements) if input.Flags&ast.NodeFlagsAmbient != 0 { tx.needsScopeFixMarker = false // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" @@ -1268,7 +1333,7 @@ func (tx *DeclarationTransformer) transformClassDeclaration(input *ast.ClassDecl modifiers := tx.ensureModifiers(input.AsNode()) typeParameters := tx.ensureTypeParams(input.AsNode(), input.TypeParameters) - ctor := getFirstConstructorWithBody(input.AsNode()) + ctor := ast.GetFirstConstructorWithBody(input.AsNode()) var parameterProperties []*ast.Node if ctor != nil { oldDiag := tx.state.getSymbolAccessibilityDiagnostic @@ -1283,7 +1348,7 @@ func (tx *DeclarationTransformer) transformClassDeclaration(input *ast.ClassDecl updated := tx.Factory().NewPropertyDeclaration( tx.ensureModifiers(param), param.Name(), - param.AsParameterDeclaration().QuestionToken, + param.QuestionToken(), tx.ensureType(param, false), tx.ensureNoInitializer(param), ) @@ -1335,8 +1400,8 @@ func (tx *DeclarationTransformer) transformClassDeclaration(input *ast.ClassDecl if extendsClause != nil && !ast.IsEntityNameExpression(extendsClause.AsExpressionWithTypeArguments().Expression) && extendsClause.AsExpressionWithTypeArguments().Expression.Kind != ast.KindNullKeyword { oldId := "default" - if ast.NodeIsPresent(input.Name()) && ast.IsIdentifier(input.Name()) && len(input.Name().AsIdentifier().Text) > 0 { - oldId = input.Name().AsIdentifier().Text + if ast.NodeIsPresent(input.Name()) && ast.IsIdentifier(input.Name()) && len(input.Name().Text()) > 0 { + oldId = input.Name().Text() } newId := tx.Factory().NewUniqueNameEx(oldId+"_base", printer.AutoGenerateOptions{Flags: printer.GeneratedIdentifierFlagsOptimistic}) tx.state.getSymbolAccessibilityDiagnostic = func(_ printer.SymbolAccessibilityResult) *SymbolAccessibilityDiagnostic { @@ -1503,10 +1568,13 @@ func (tx *DeclarationTransformer) ensureModifierFlags(node *ast.Node) ast.Modifi additions = ast.ModifierFlagsAmbient } parentIsFile := node.Parent.Kind == ast.KindSourceFile - if !parentIsFile || (tx.isBundledEmit && parentIsFile && ast.IsExternalModule(node.Parent.AsSourceFile())) { + if !parentIsFile { mask ^= ast.ModifierFlagsAmbient additions = ast.ModifierFlagsNone } + if ast.IsImplicitlyExportedJSTypeAlias(node) { + additions |= ast.ModifierFlagsExport + } return maskModifierFlags(tx.host, node, mask, additions) } @@ -1597,8 +1665,8 @@ func (tx *DeclarationTransformer) filterBindingPatternInitializers(node *ast.Nod return node } else { // TODO: visitor to avoid always making new nodes? - elements := make([]*ast.Node, 0, len(node.AsBindingPattern().Elements.Nodes)) - for _, elem := range node.AsBindingPattern().Elements.Nodes { + elements := make([]*ast.Node, 0, len(node.Elements())) + for _, elem := range node.Elements() { if elem.Kind == ast.KindOmittedExpression { elements = append(elements, elem) continue @@ -1709,7 +1777,7 @@ func (tx *DeclarationTransformer) transformImportDeclaration(decl *ast.ImportDec } // Named imports (optionally with visible default) bindingList := core.Filter( - decl.ImportClause.AsImportClause().NamedBindings.AsNamedImports().Elements.Nodes, + decl.ImportClause.AsImportClause().NamedBindings.Elements(), func(b *ast.Node) bool { return tx.resolver.IsDeclarationVisible(b) }, diff --git a/internal/transformers/declarations/util.go b/internal/transformers/declarations/util.go index e6d71f5697..b716a1b338 100644 --- a/internal/transformers/declarations/util.go +++ b/internal/transformers/declarations/util.go @@ -64,7 +64,8 @@ func hasInferredType(node *ast.Node) bool { ast.KindPropertyAssignment, ast.KindShorthandPropertyAssignment, ast.KindJSDocParameterTag, - ast.KindJSDocPropertyTag: + ast.KindJSDocPropertyTag, + ast.KindCommonJSExport: return true default: // assertType(node); // !!! @@ -110,7 +111,7 @@ func getBindingNameVisible(resolver printer.EmitResolver, elem *ast.Node) bool { } if ast.IsBindingPattern(elem.Name()) { // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible - for _, elem := range elem.Name().AsBindingPattern().Elements.Nodes { + for _, elem := range elem.Name().Elements() { if getBindingNameVisible(resolver, elem) { return true } @@ -202,15 +203,6 @@ func shouldEmitFunctionProperties(input *ast.FunctionDeclaration) bool { return len(overloadSignatures) == 0 || overloadSignatures[len(overloadSignatures)-1] == input.AsNode() } -func getFirstConstructorWithBody(node *ast.Node) *ast.Node { - for _, member := range node.Members() { - if ast.IsConstructorDeclaration(member) && ast.NodeIsPresent(member.Body()) { - return member - } - } - return nil -} - func getEffectiveBaseTypeNode(node *ast.Node) *ast.Node { baseType := ast.GetClassExtendsHeritageElement(node) // !!! TODO: JSDoc support diff --git a/internal/transformers/estransforms/classthis.go b/internal/transformers/estransforms/classthis.go index 063201e4b6..73b747cb3d 100644 --- a/internal/transformers/estransforms/classthis.go +++ b/internal/transformers/estransforms/classthis.go @@ -14,7 +14,7 @@ func isClassThisAssignmentBlock(emitContext *printer.EmitContext, node *ast.Node if len(body.Statements.Nodes) == 1 { statement := body.Statements.Nodes[0] if ast.IsExpressionStatement(statement) { - expression := statement.AsExpressionStatement().Expression + expression := statement.Expression() if ast.IsAssignmentExpression(expression, true /*excludeCompoundAssignment*/) { binary := expression.AsBinaryExpression() return ast.IsIdentifier(binary.Left) && diff --git a/internal/transformers/estransforms/exponentiation.go b/internal/transformers/estransforms/exponentiation.go index f72a48fdd2..5bfddbe02d 100644 --- a/internal/transformers/estransforms/exponentiation.go +++ b/internal/transformers/estransforms/exponentiation.go @@ -43,8 +43,8 @@ func (ch *exponentiationTransformer) visitExponentiationAssignmentExpression(nod argumentExpressionTemp := ch.Factory().NewTempVariable() ch.EmitContext().AddVariableDeclaration(argumentExpressionTemp) - objExpr := ch.Factory().NewAssignmentExpression(expressionTemp, left.AsElementAccessExpression().Expression) - objExpr.Loc = left.AsElementAccessExpression().Expression.Loc + objExpr := ch.Factory().NewAssignmentExpression(expressionTemp, left.Expression()) + objExpr.Loc = left.Expression().Loc accessExpr := ch.Factory().NewAssignmentExpression(argumentExpressionTemp, left.AsElementAccessExpression().ArgumentExpression) accessExpr.Loc = left.AsElementAccessExpression().ArgumentExpression.Loc diff --git a/internal/transformers/estransforms/namedevaluation.go b/internal/transformers/estransforms/namedevaluation.go index e35851b39c..1aad19d04f 100644 --- a/internal/transformers/estransforms/namedevaluation.go +++ b/internal/transformers/estransforms/namedevaluation.go @@ -13,13 +13,13 @@ import ( * @internal */ func isClassNamedEvaluationHelperBlock(emitContext *printer.EmitContext, node *ast.Node) bool { - if !ast.IsClassStaticBlockDeclaration(node) || len(node.AsClassStaticBlockDeclaration().Body.AsBlock().Statements.Nodes) != 1 { + if !ast.IsClassStaticBlockDeclaration(node) || len(node.AsClassStaticBlockDeclaration().Body.Statements()) != 1 { return false } - statement := node.AsClassStaticBlockDeclaration().Body.AsBlock().Statements.Nodes[0] + statement := node.AsClassStaticBlockDeclaration().Body.Statements()[0] if ast.IsExpressionStatement(statement) { - expression := statement.AsExpressionStatement().Expression + expression := statement.Expression() if emitContext.IsCallToHelper(expression, "__setFunctionName") { arguments := expression.AsCallExpression().Arguments return len(arguments.Nodes) >= 2 && @@ -99,13 +99,13 @@ func isNamedEvaluationSource(node *ast.Node) bool { case ast.KindShorthandPropertyAssignment: return node.AsShorthandPropertyAssignment().ObjectAssignmentInitializer != nil case ast.KindVariableDeclaration: - return ast.IsIdentifier(node.AsVariableDeclaration().Name()) && node.AsVariableDeclaration().Initializer != nil + return ast.IsIdentifier(node.AsVariableDeclaration().Name()) && node.Initializer() != nil case ast.KindParameter: - return ast.IsIdentifier(node.AsParameterDeclaration().Name()) && node.AsParameterDeclaration().Initializer != nil && node.AsParameterDeclaration().DotDotDotToken == nil + return ast.IsIdentifier(node.AsParameterDeclaration().Name()) && node.Initializer() != nil && node.AsParameterDeclaration().DotDotDotToken == nil case ast.KindBindingElement: - return ast.IsIdentifier(node.AsBindingElement().Name()) && node.AsBindingElement().Initializer != nil && node.AsBindingElement().DotDotDotToken == nil + return ast.IsIdentifier(node.AsBindingElement().Name()) && node.Initializer() != nil && node.AsBindingElement().DotDotDotToken == nil case ast.KindPropertyDeclaration: - return node.AsPropertyDeclaration().Initializer != nil + return node.Initializer() != nil case ast.KindBinaryExpression: switch node.AsBinaryExpression().OperatorToken.Kind { case ast.KindEqualsToken, ast.KindAmpersandAmpersandEqualsToken, ast.KindBarBarEqualsToken, ast.KindQuestionQuestionEqualsToken: @@ -134,7 +134,7 @@ func isNamedEvaluationAnd(emitContext *printer.EmitContext, node *ast.Node, cb f case ast.KindBinaryExpression: return isAnonymousFunctionDefinition(emitContext, node.AsBinaryExpression().Right, cb) case ast.KindExportAssignment: - return isAnonymousFunctionDefinition(emitContext, node.AsExportAssignment().Expression, cb) + return isAnonymousFunctionDefinition(emitContext, node.Expression(), cb) default: panic("Unhandled case in isNamedEvaluation") } @@ -236,7 +236,7 @@ func injectClassNamedEvaluationHelperBlockIfMissing( factory := emitContext.Factory namedEvaluationBlock := createClassNamedEvaluationHelperBlock(emitContext, assignedName, thisExpression) if node.Name() != nil { - emitContext.SetSourceMapRange(namedEvaluationBlock.Body().AsBlock().Statements.Nodes[0], node.Name().Loc) + emitContext.SetSourceMapRange(namedEvaluationBlock.Body().Statements()[0], node.Name().Loc) } insertionIndex := slices.IndexFunc(node.Members(), func(n *ast.Node) bool { diff --git a/internal/transformers/estransforms/objectrestspread.go b/internal/transformers/estransforms/objectrestspread.go index da70ebc709..b27ecb7b77 100644 --- a/internal/transformers/estransforms/objectrestspread.go +++ b/internal/transformers/estransforms/objectrestspread.go @@ -1,6 +1,7 @@ package estransforms import ( + "slices" "strconv" "github.com/microsoft/typescript-go/internal/ast" @@ -303,14 +304,14 @@ func (ch *objectRestSpreadTransformer) transformFunctionBody(node *ast.Node) *as var suffix []*ast.Node if ast.IsBlock(body) { custom := false - for i, statement := range body.AsBlock().Statements.Nodes { + for i, statement := range body.Statements() { if !custom && ast.IsPrologueDirective(statement) { prefix = append(prefix, statement) } else if ch.EmitContext().EmitFlags(statement)&printer.EFCustomPrologue != 0 { custom = true prefix = append(prefix, statement) } else { - suffix = body.AsBlock().Statements.Nodes[i:] + suffix = body.Statements()[i:] break } } @@ -324,7 +325,7 @@ func (ch *objectRestSpreadTransformer) transformFunctionBody(node *ast.Node) *as } newStatementList := ch.Factory().NewNodeList(append(append(append(prefix, extras...), newStatements...), suffix...)) - newStatementList.Loc = body.AsBlock().Statements.Loc + newStatementList.Loc = body.StatementList().Loc return ch.Factory().UpdateBlock(body.AsBlock(), newStatementList) } @@ -337,7 +338,7 @@ func (ch *objectRestSpreadTransformer) collectObjectRestAssignments(node *ast.No // In cases where a binding pattern is simply '[]' or '{}', // we usually don't want to emit a var declaration; however, in the presence // of an initializer, we must emit that expression to preserve side effects. - if len(parameter.Name().AsBindingPattern().Elements.Nodes) > 0 { + if len(parameter.Name().Elements()) > 0 { declarations := ch.flattenDestructuringBinding(flattenLevelAll, parameter, ch.Factory().NewGeneratedNameForNode(parameter), false, false) if declarations != nil { declarationList := ch.Factory().NewVariableDeclarationList(ast.NodeFlagsNone, ch.Factory().NewNodeList([]*ast.Node{})) @@ -425,11 +426,9 @@ func (ch *objectRestSpreadTransformer) visitCatchClause(node *ast.CatchClause) * } newStatement := ch.Factory().NewVariableStatement(nil, ch.Factory().NewVariableDeclarationList(ast.NodeFlagsNone, ch.Factory().NewNodeList(decls))) statements := []*ast.Node{newStatement} - if block.AsBlock().Statements != nil && len(block.AsBlock().Statements.Nodes) > 0 { - statements = append(statements, block.AsBlock().Statements.Nodes...) - } + statements = append(statements, block.Statements()...) statementList := ch.Factory().NewNodeList(statements) - statementList.Loc = block.AsBlock().Statements.Loc + statementList.Loc = block.StatementList().Loc block = ch.Factory().UpdateBlock(block.AsBlock(), statementList) } @@ -483,7 +482,7 @@ func (ch *objectRestSpreadTransformer) flattenDestructuringBinding(level flatten if ast.IsVariableDeclaration(node) { initializer := getInitializerOfBindingOrAssignmentElement(node) - if initializer != nil && (ast.IsIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.AsIdentifier().Text) || bindingOrAssignmentElementContainsNonLiteralComputedName(node)) { + if initializer != nil && (ast.IsIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.Text()) || bindingOrAssignmentElementContainsNonLiteralComputedName(node)) { // If the right-hand value of the assignment is also an assignment target then // we need to cache the right-hand value. initializer = ch.ensureIdentifier(ch.Visitor().VisitNode(initializer), false, initializer.Loc) @@ -541,14 +540,14 @@ func (ch *objectRestSpreadTransformer) visitForOftatement(node *ast.ForInOrOfSta statements = append(statements, res) } if ast.IsBlock(node.Statement) { - for _, statement := range node.Statement.AsBlock().Statements.Nodes { + for _, statement := range node.Statement.Statements() { visited := ch.Visitor().VisitEachChild(statement) if visited != nil { statements = append(statements, visited) } } bodyLocation = node.Statement.Loc - statementsLocation = node.Statement.AsBlock().Statements.Loc + statementsLocation = node.Statement.StatementList().Loc } else if node.Statement != nil { statements = append(statements, ch.Visitor().VisitEachChild(node.Statement)) bodyLocation = node.Statement.Loc @@ -639,7 +638,7 @@ func (ch *objectRestSpreadTransformer) flattenDestructuringAssignment(node *ast. if value != nil { value = ch.Visitor().VisitNode(value) - if ast.IsIdentifier(value) && bindingOrAssignmentElementAssignsToName(node.AsNode(), value.AsIdentifier().Text) || bindingOrAssignmentElementContainsNonLiteralComputedName(node.AsNode()) { + if ast.IsIdentifier(value) && bindingOrAssignmentElementAssignsToName(node.AsNode(), value.Text()) || bindingOrAssignmentElementContainsNonLiteralComputedName(node.AsNode()) { // If the right-hand value of the assignment is also an assignment target then // we need to cache the right-hand value. value = ch.ensureIdentifier(value, false, location) @@ -808,7 +807,7 @@ func (ch *objectRestSpreadTransformer) flattenArrayBindingOrAssignmentPattern(pa */ func (ch *objectRestSpreadTransformer) createDestructuringPropertyAccess(value *ast.Node, propertyName *ast.Node) *ast.Node { if ast.IsComputedPropertyName(propertyName) { - argumentExpression := ch.ensureIdentifier(ch.Visitor().VisitNode(propertyName.AsComputedPropertyName().Expression), false, propertyName.Loc) + argumentExpression := ch.ensureIdentifier(ch.Visitor().VisitNode(propertyName.Expression()), false, propertyName.Loc) return ch.Factory().NewElementAccessExpression( value, nil, @@ -824,7 +823,7 @@ func (ch *objectRestSpreadTransformer) createDestructuringPropertyAccess(value * ast.NodeFlagsNone, ) } else { - name := ch.Factory().NewIdentifier(propertyName.AsIdentifier().Text) + name := ch.Factory().NewIdentifier(propertyName.Text()) return ch.Factory().NewPropertyAccessExpression( value, nil, @@ -1004,7 +1003,7 @@ func bindingOrAssignmentElementAssignsToName(element *ast.Node, name string) boo if ast.IsBindingPattern(target) || ast.IsAssignmentPattern(target) { return bindingOrAssignmentPatternAssignsToName(target, name) } else if ast.IsIdentifier(target) { - return target.AsIdentifier().Text == name + return target.Text() == name } return false } @@ -1021,7 +1020,7 @@ func bindingOrAssignmentPatternAssignsToName(pattern *ast.Node, name string) boo func bindingOrAssignmentElementContainsNonLiteralComputedName(element *ast.Node) bool { propertyName := ast.TryGetPropertyNameOfBindingOrAssignmentElement(element) - if propertyName != nil && ast.IsComputedPropertyName(propertyName) && !ast.IsLiteralExpression(propertyName.AsComputedPropertyName().Expression) { + if propertyName != nil && ast.IsComputedPropertyName(propertyName) && !ast.IsLiteralExpression(propertyName.Expression()) { return true } target := ast.GetTargetOfBindingOrAssignmentElement(element) @@ -1030,12 +1029,7 @@ func bindingOrAssignmentElementContainsNonLiteralComputedName(element *ast.Node) func bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern *ast.Node) bool { elements := ast.GetElementsOfBindingOrAssignmentPattern(pattern) - for _, element := range elements { - if bindingOrAssignmentElementContainsNonLiteralComputedName(element) { - return true - } - } - return false + return slices.ContainsFunc(elements, bindingOrAssignmentElementContainsNonLiteralComputedName) } func getInitializerOfBindingOrAssignmentElement(bindingElement *ast.Node) *ast.Node { diff --git a/internal/transformers/estransforms/usestrict.go b/internal/transformers/estransforms/usestrict.go new file mode 100644 index 0000000000..35d4abf327 --- /dev/null +++ b/internal/transformers/estransforms/usestrict.go @@ -0,0 +1,55 @@ +package estransforms + +import ( + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/transformers" +) + +func NewUseStrictTransformer(opts *transformers.TransformOptions) *transformers.Transformer { + tx := &useStrictTransformer{ + compilerOptions: opts.CompilerOptions, + getEmitModuleFormatOfFile: opts.GetEmitModuleFormatOfFile, + } + return tx.NewTransformer(tx.visit, opts.Context) +} + +type useStrictTransformer struct { + transformers.Transformer + compilerOptions *core.CompilerOptions + getEmitModuleFormatOfFile func(file ast.HasFileName) core.ModuleKind +} + +func (tx *useStrictTransformer) visit(node *ast.Node) *ast.Node { + if node.Kind != ast.KindSourceFile { + return node + } + return tx.visitSourceFile(node.AsSourceFile()) +} + +func (tx *useStrictTransformer) visitSourceFile(node *ast.SourceFile) *ast.Node { + if node.ScriptKind == core.ScriptKindJSON { + return node.AsNode() + } + + if tx.compilerOptions.GetEmitModuleKind() == core.ModuleKindPreserve { + return node.AsNode() + } + + isExternalModule := ast.IsExternalModule(node) + format := tx.getEmitModuleFormatOfFile(node) + + if isExternalModule && format >= core.ModuleKindES2015 { + return node.AsNode() + } + + if isExternalModule || + tx.compilerOptions.AlwaysStrict.DefaultIfUnknown(tx.compilerOptions.Strict).IsTrue() { + statements := tx.Factory().EnsureUseStrict(node.Statements.Nodes) + statementList := tx.Factory().NewNodeList(statements) + statementList.Loc = node.Statements.Loc + return tx.Factory().UpdateSourceFile(node, statementList, node.EndOfFileToken).AsSourceFile().AsNode() + } + + return node.AsNode() +} diff --git a/internal/transformers/estransforms/using.go b/internal/transformers/estransforms/using.go index 0178c197fb..e323a5ad6d 100644 --- a/internal/transformers/estransforms/using.go +++ b/internal/transformers/estransforms/using.go @@ -264,9 +264,9 @@ func (tx *usingDeclarationTransformer) visitForOfStatement(node *ast.ForInOrOfSt usingVarStatement := tx.Factory().NewVariableStatement(nil /*modifiers*/, usingVarList) var statement *ast.Statement if ast.IsBlock(node.Statement) { - statements := make([]*ast.Statement, 0, len(node.Statement.AsBlock().Statements.Nodes)+1) + statements := make([]*ast.Statement, 0, len(node.Statement.Statements())+1) statements = append(statements, usingVarStatement) - statements = append(statements, node.Statement.AsBlock().Statements.Nodes...) + statements = append(statements, node.Statement.Statements()...) statement = tx.Factory().UpdateBlock( node.Statement.AsBlock(), tx.Factory().NewNodeList(statements), @@ -659,7 +659,7 @@ func (tx *usingDeclarationTransformer) hoistInitializedVariable(node *ast.Variab func (tx *usingDeclarationTransformer) hoistBindingElement(node *ast.Node /*VariableDeclaration|BindingElement*/, isExportedDeclaration bool, original *ast.Node) { // NOTE: `node` has already been visited if ast.IsBindingPattern(node.Name()) { - for _, element := range node.Name().AsBindingPattern().Elements.Nodes { + for _, element := range node.Name().Elements() { if element.Name() != nil { tx.hoistBindingElement(element, isExportedDeclaration, original) } @@ -855,7 +855,7 @@ func getUsingKindOfStatements(statements []*ast.Node) usingKind { func getUsingKindOfCaseOrDefaultClauses(clauses []*ast.CaseOrDefaultClauseNode) usingKind { result := usingKindNone for _, clause := range clauses { - usingKind := getUsingKindOfStatements(clause.AsCaseOrDefaultClause().Statements.Nodes) + usingKind := getUsingKindOfStatements(clause.Statements()) if usingKind == usingKindAsync { return usingKindAsync } diff --git a/internal/transformers/jsxtransforms/jsx.go b/internal/transformers/jsxtransforms/jsx.go index 3372a23339..2654015d20 100644 --- a/internal/transformers/jsxtransforms/jsx.go +++ b/internal/transformers/jsxtransforms/jsx.go @@ -146,7 +146,7 @@ func hasKeyAfterPropsSpread(node *ast.Node) bool { for _, elem := range opener.Attributes().Properties() { if ast.IsJsxSpreadAttribute(elem) && (!ast.IsObjectLiteralExpression(elem.Expression()) || core.Some(elem.Expression().Properties(), ast.IsSpreadAssignment)) { spread = true - } else if spread && ast.IsJsxAttribute(elem) && ast.IsIdentifier(elem.Name()) && elem.Name().AsIdentifier().Text == "key" { + } else if spread && ast.IsJsxAttribute(elem) && ast.IsIdentifier(elem.Name()) && elem.Name().Text() == "key" { return true } } @@ -180,11 +180,11 @@ func (tx *JSXTransformer) insertStatementAfterCustomPrologue(to []*ast.Node, sta } func sortByImportDeclarationSource(a *ast.Node, b *ast.Node) int { - return stringutil.CompareStringsCaseSensitive(a.AsImportDeclaration().ModuleSpecifier.AsStringLiteral().Text, b.AsImportDeclaration().ModuleSpecifier.AsStringLiteral().Text) + return stringutil.CompareStringsCaseSensitive(a.ModuleSpecifier().Text(), b.ModuleSpecifier().Text()) } func getSpecifierOfRequireCall(s *ast.Node) string { - return s.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes[0].AsVariableDeclaration().Initializer.AsCallExpression().Arguments.Nodes[0].AsStringLiteral().Text + return s.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes[0].Initializer().Arguments()[0].Text() } func sortByRequireSource(a *ast.Node, b *ast.Node) int { @@ -192,11 +192,11 @@ func sortByRequireSource(a *ast.Node, b *ast.Node) int { } func sortImportSpecifiers(a *ast.Node, b *ast.Node) int { - res := stringutil.CompareStringsCaseSensitive(a.AsImportSpecifier().PropertyName.Text(), b.AsImportSpecifier().PropertyName.Text()) + res := stringutil.CompareStringsCaseSensitive(a.PropertyName().Text(), b.PropertyName().Text()) if res != 0 { return res } - return stringutil.CompareStringsCaseSensitive(a.AsImportSpecifier().Name().AsIdentifier().Text, b.AsImportSpecifier().Name().AsIdentifier().Text) + return stringutil.CompareStringsCaseSensitive(a.AsImportSpecifier().Name().Text(), b.AsImportSpecifier().Name().Text()) } func getSortedSpecifiers(m map[string]*ast.Node) []*ast.Node { @@ -254,7 +254,7 @@ func (tx *JSXTransformer) visitSourceFile(file *ast.SourceFile) *ast.Node { sorted := getSortedSpecifiers(importSpecifiersMap) asBindingElems := make([]*ast.Node, 0, len(sorted)) for _, elem := range sorted { - asBindingElems = append(asBindingElems, tx.Factory().NewBindingElement(nil, elem.AsImportSpecifier().PropertyName, elem.AsImportSpecifier().Name(), nil)) + asBindingElems = append(asBindingElems, tx.Factory().NewBindingElement(nil, elem.PropertyName(), elem.AsImportSpecifier().Name(), nil)) } s := tx.Factory().NewVariableStatement(nil, tx.Factory().NewVariableDeclarationList(ast.NodeFlagsConst, tx.Factory().NewNodeList([]*ast.Node{tx.Factory().NewVariableDeclaration( tx.Factory().NewBindingPattern(ast.KindObjectBindingPattern, tx.Factory().NewNodeList(asBindingElems)), @@ -319,8 +319,9 @@ func (tx *JSXTransformer) convertJsxChildrenToChildrenPropObject(children []*ast } func (tx *JSXTransformer) transformJsxChildToExpression(node *ast.Node) *ast.Node { + prev := tx.inJsxChild tx.setInChild(true) - defer tx.setInChild(false) + defer tx.setInChild(prev) return tx.Visitor().Visit(node) } @@ -371,9 +372,9 @@ func (tx *JSXTransformer) visitJsxOpeningLikeElementJSX(element *ast.Node, child childrenProp = tx.convertJsxChildrenToChildrenPropAssignment(children.Nodes) } var keyAttr *ast.Node - attrs := element.Attributes().AsJsxAttributes().Properties.Nodes + attrs := element.Attributes().Properties() for i, p := range attrs { - if p.Kind == ast.KindJsxAttribute && p.AsJsxAttribute().Name() != nil && ast.IsIdentifier(p.AsJsxAttribute().Name()) && p.AsJsxAttribute().Name().AsIdentifier().Text == "key" { + if p.Kind == ast.KindJsxAttribute && p.AsJsxAttribute().Name() != nil && ast.IsIdentifier(p.AsJsxAttribute().Name()) && p.AsJsxAttribute().Name().Text() == "key" { keyAttr = p attrs = slices.Clone(attrs) attrs = slices.Delete(attrs, i, i+1) @@ -531,10 +532,10 @@ func (tx *JSXTransformer) transformJsxAttributeInitializer(node *ast.Node) *ast. return res } if node.Kind == ast.KindJsxExpression { - if node.AsJsxExpression().Expression == nil { + if node.Expression() == nil { return tx.Factory().NewTrueExpression() } - return tx.Visitor().Visit(node.AsJsxExpression().Expression) + return tx.Visitor().Visit(node.Expression()) } if ast.IsJsxElement(node) || ast.IsJsxSelfClosingElement(node) || ast.IsJsxFragment(node) { tx.setInChild(false) @@ -641,7 +642,7 @@ func (tx *JSXTransformer) createJsxFactoryExpressionFromEntityName(e *ast.Node, right := tx.Factory().NewIdentifier(e.AsQualifiedName().Right.Text()) return tx.Factory().NewPropertyAccessExpression(left, nil, right, ast.NodeFlagsNone) } - return tx.createReactNamespace(e.AsIdentifier().Text, parent) + return tx.createReactNamespace(e.Text(), parent) } func (tx *JSXTransformer) createJsxPsuedoFactoryExpression(parent *ast.Node, e *ast.Node, target string) *ast.Node { @@ -688,14 +689,18 @@ func (tx *JSXTransformer) visitJsxOpeningLikeElementCreateElement(element *ast.N for _, c := range children.Nodes { res := tx.transformJsxChildToExpression(c) if res != nil { - if len(children.Nodes) > 1 { - tx.EmitContext().AddEmitFlags(res, printer.EFStartOnNewLine) - } newChildren = append(newChildren, res) } } } + // Add StartOnNewLine flag only if there are multiple actual children (after filtering) + if len(newChildren) > 1 { + for _, child := range newChildren { + tx.EmitContext().AddEmitFlags(child, printer.EFStartOnNewLine) + } + } + args := make([]*ast.Expression, 0, len(newChildren)+2) args = append(args, tagName) args = append(args, objectProperties) @@ -725,14 +730,18 @@ func (tx *JSXTransformer) visitJsxOpeningFragmentCreateElement(fragment *ast.Jsx for _, c := range children.Nodes { res := tx.transformJsxChildToExpression(c) if res != nil { - if len(children.Nodes) > 1 { - tx.EmitContext().AddEmitFlags(res, printer.EFStartOnNewLine) - } newChildren = append(newChildren, res) } } } + // Add StartOnNewLine flag only if there are multiple actual children (after filtering) + if len(newChildren) > 1 { + for _, child := range newChildren { + tx.EmitContext().AddEmitFlags(child, printer.EFStartOnNewLine) + } + } + args := make([]*ast.Expression, 0, len(newChildren)+2) args = append(args, tagName) args = append(args, tx.Factory().NewKeywordExpression(ast.KindNullKeyword)) diff --git a/internal/transformers/moduletransforms/commonjsmodule.go b/internal/transformers/moduletransforms/commonjsmodule.go index 8f39ecdd78..6664aa820e 100644 --- a/internal/transformers/moduletransforms/commonjsmodule.go +++ b/internal/transformers/moduletransforms/commonjsmodule.go @@ -247,7 +247,7 @@ func (tx *CommonJSModuleTransformer) visitSourceFile(node *ast.SourceFile) *ast. func (tx *CommonJSModuleTransformer) shouldEmitUnderscoreUnderscoreESModule() bool { if tspath.FileExtensionIsOneOf(tx.currentSourceFile.FileName(), tspath.SupportedJSExtensionsFlat) && tx.currentSourceFile.CommonJSModuleIndicator != nil && - (tx.currentSourceFile.ExternalModuleIndicator == nil /*|| tx.currentSourceFile.ExternalModuleIndicator == true*/) { // !!! + (tx.currentSourceFile.ExternalModuleIndicator == nil || tx.currentSourceFile.ExternalModuleIndicator.Kind == ast.KindSourceFile) { return false } if tx.currentModuleInfo.exportEquals == nil && ast.IsExternalModule(tx.currentSourceFile) { @@ -297,12 +297,6 @@ func (tx *CommonJSModuleTransformer) transformCommonJSModule(node *ast.SourceFil prologue, rest := tx.Factory().SplitStandardPrologue(node.Statements.Nodes) statements := slices.Clone(prologue) - // ensure "use strict" if not present - if ast.IsExternalModule(tx.currentSourceFile) || - tx.compilerOptions.AlwaysStrict.DefaultIfUnknown(tx.compilerOptions.Strict).IsTrue() { - statements = tx.Factory().EnsureUseStrict(statements) - } - // emit custom prologues from other transformations custom, rest := tx.Factory().SplitCustomPrologue(rest) statements = append(statements, core.FirstResult(tx.topLevelVisitor.VisitSlice(custom))...) @@ -437,7 +431,7 @@ func (tx *CommonJSModuleTransformer) appendExportsOfImportDeclaration(statements statements = tx.appendExportsOfDeclaration(statements, namedBindings, seen, false /*liveBinding*/) case ast.KindNamedImports: - for _, importBinding := range namedBindings.AsNamedImports().Elements.Nodes { + for _, importBinding := range namedBindings.Elements() { statements = tx.appendExportsOfDeclaration(statements, importBinding, seen, true /*liveBinding*/) } } @@ -480,7 +474,7 @@ func (tx *CommonJSModuleTransformer) appendExportsOfBindingElement(statements [] } if ast.IsBindingPattern(decl.Name()) { - for _, element := range decl.Name().AsBindingPattern().Elements.Nodes { + for _, element := range decl.Name().Elements() { e := element.AsBindingElement() if e.DotDotDotToken == nil && e.Name() == nil { statements = tx.appendExportsOfBindingElement(statements, element, isForInOrOfInitializer) @@ -850,7 +844,7 @@ func (tx *CommonJSModuleTransformer) visitTopLevelExportDeclaration(node *ast.Ex tx.EmitContext().AssignCommentAndSourceMapRanges(varStatement, node.AsNode()) statements = append(statements, varStatement) - for _, specifier := range node.ExportClause.AsNamedExports().Elements.Nodes { + for _, specifier := range node.ExportClause.Elements() { specifierName := specifier.PropertyNameOrName() exportNeedsImportDefault := tx.compilerOptions.GetESModuleInterop() && tx.EmitContext().EmitFlags(node.AsNode())&printer.EFNeverApplyImportHelper == 0 && diff --git a/internal/transformers/moduletransforms/commonjsmodule_test.go b/internal/transformers/moduletransforms/commonjsmodule_test.go deleted file mode 100644 index de4de7dc45..0000000000 --- a/internal/transformers/moduletransforms/commonjsmodule_test.go +++ /dev/null @@ -1,1057 +0,0 @@ -package moduletransforms_test - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/binder" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/printer" - "github.com/microsoft/typescript-go/internal/testutil/emittestutil" - "github.com/microsoft/typescript-go/internal/testutil/parsetestutil" - "github.com/microsoft/typescript-go/internal/transformers" - "github.com/microsoft/typescript-go/internal/transformers/moduletransforms" - "github.com/microsoft/typescript-go/internal/transformers/tstransforms" -) - -func fakeGetEmitModuleFormatOfFile(file ast.HasFileName) core.ModuleKind { - return core.ModuleKindNone -} - -func TestCommonJSModuleTransformer(t *testing.T) { - t.Parallel() - data := []struct { - title string - input string - output string - other string - jsx bool - options *core.CompilerOptions - }{ - // ImportDeclaration - { - title: "ImportDeclaration#1", - input: `import "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("other");`, - }, - { - title: "ImportDeclaration#2", - input: `import * as a from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("other");`, - }, - { - title: "ImportDeclaration#3", - input: `import { a } from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other");`, - }, - { - title: "ImportDeclaration#4", - input: `import a from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other");`, - }, - { - title: "ImportDeclaration#5", - input: `import a, * as b from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other"), b = other_1;`, - }, - { - title: "ImportDeclaration#6", - input: `import { a } from "other" -export { a }`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -const other_1 = require("other"); -Object.defineProperty(exports, "a", { enumerable: true, get: function () { return other_1.a; } });`, - }, - { - title: "ImportDeclaration#7", - input: `import * as a from "other"`, - output: `"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -const a = __importStar(require("other"));`, - options: &core.CompilerOptions{ESModuleInterop: core.TSTrue}, - }, - { - title: "ImportDeclaration#8", - input: `import * as a from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -const a = tslib_1.__importStar(require("other"));`, - options: &core.CompilerOptions{ESModuleInterop: core.TSTrue, ImportHelpers: core.TSTrue}, - }, - - // ImportEqualsDeclaration - { - title: "ImportEqualsDeclaration#1", - input: `import a = require("other");`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("other");`, - }, - { - title: "ImportEqualsDeclaration#2", - input: `export import a = require("other");`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = require("other");`, - }, - - // ExportDeclaration - { - title: "ExportDeclaration#1", - input: `export { a } from "other";`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -const other_1 = require("other"); -Object.defineProperty(exports, "a", { enumerable: true, get: function () { return other_1.a; } });`, - }, - { - title: "ExportDeclaration#2", - input: `export * as a from "other";`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = require("other");`, - }, - { - title: "ExportDeclaration#3", - input: `export * from "other";`, - output: `"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("other"), exports);`, - }, - { - title: "ExportDeclaration#4", - input: `export * as a from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -const tslib_1 = require("tslib"); -exports.a = tslib_1.__importStar(require("other"));`, - options: &core.CompilerOptions{ESModuleInterop: core.TSTrue, ImportHelpers: core.TSTrue}, - }, - { - title: "ExportDeclaration#5", - input: `export * from "other"`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("other"), exports);`, - options: &core.CompilerOptions{ESModuleInterop: core.TSTrue, ImportHelpers: core.TSTrue}, - }, - - // ExportAssignment - { - title: "ExportAssignment#1", - input: `var a = 0; -export default a;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var a = 0; -exports.default = a;`, - }, - { - title: "ExportAssignment#2", - input: `var a = 0; -export = a;`, - output: `"use strict"; -var a = 0; -module.exports = a;`, - }, - - // FunctionDeclaration - { - title: "FunctionDeclaration#1", - input: `export function f() {}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.f = f; -function f() { }`, - }, - { - title: "FunctionDeclaration#2", - input: `export default function f() {}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = f; -function f() { }`, - }, - { - title: "FunctionDeclaration#3", - input: `export default function () {}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = default_1; -function default_1() { }`, - }, - { - title: "FunctionDeclaration#4", - input: `function f() {} -export { f };`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.f = f; -function f() { }`, - }, - - // ClassDeclaration - { - title: "ClassDeclaration#1", - input: `export class C {}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.C = void 0; -class C { -} -exports.C = C;`, - }, - { - title: "ClassDeclaration#2", - input: `export default class C {}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class C { -} -exports.default = C;`, - }, - { - title: "ClassDeclaration#3", - input: `export default class {}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class default_1 { -} -exports.default = default_1;`, - }, - { - title: "ClassDeclaration#4", - input: `class C {} -export { C };`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.C = void 0; -class C { -} -exports.C = C;`, - }, - - // VariableStatement - { - title: "VariableStatement#1", - input: `export var x = y;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -exports.x = y;`, - }, - { - title: "VariableStatement#2", - input: `export var { x } = y;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -({ x: exports.x } = y);`, - }, - { - title: "VariableStatement#3", - input: `export var [x] = y;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -[exports.x] = y;`, - }, - { - title: "VariableStatement#4", - input: `var x; -export { x }; -x || (x = 1);`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -x || (exports.x = x = 1);`, - }, - { - title: "VariableStatement#5 (from enum)", - input: `export enum E { A }`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.E = void 0; -var E; -(function (E) { - E[E["A"] = 0] = "A"; -})(E || (exports.E = E = {}));`, - }, - - // ForStatement - { - title: "ForStatement#1", - input: `export { x }; -for (var x = 0; ; ) ;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x = 0; -exports.x = x; -for (;;) - ;`, - }, - - // ForInStatement - { - title: "ForInStatement#1", - input: `export { x }; -for (var x in {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -for (var x in {}) { - exports.x = x; - ; -}`, - }, - - // ForOfStatement - { - title: "ForOfStatement#1", - input: `export { x }; -for (var x of {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -for (var x of {}) { - exports.x = x; - ; -}`, - }, - - // DoStatement - { - title: "DoStatement#1", - input: `export { x }; -do { - var x = 0; -} while (false);`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -do { - var x = 0; - exports.x = x; -} while (false);`, - }, - - // WhileStatement - { - title: "WhileStatement#1", - input: `export { x }; -while (true) { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -while (true) { - var x = 0; - exports.x = x; -}`, - }, - - // LabeledStatement - { - title: "LabeledStatement#1", - input: `export { x }; -label: { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -label: { - var x = 0; - exports.x = x; -}`, - }, - - // WithStatement - { - title: "WithStatement#1", - input: `export { x }; -with ({}) { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -with ({}) { - var x = 0; - exports.x = x; -}`, - }, - - // IfStatement - { - title: "IfStatement#1", - input: `export { x }; -if (y) { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -if (y) { - var x = 0; - exports.x = x; -}`, - }, - { - title: "IfStatement#2", - input: `export { x }; -if (y) { -} -else { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -if (y) { -} -else { - var x = 0; - exports.x = x; -}`, - }, - - // SwitchStatement - { - title: "SwitchStatement#1", - input: `export { x }; -switch (y) { - case 0: - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -switch (y) { - case 0: - var x = 0; - exports.x = x; -}`, - }, - { - title: "SwitchStatement#2", - input: `export { x }; -switch (y) { - default: - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -switch (y) { - default: - var x = 0; - exports.x = x; -}`, - }, - - // TryStatement - { - title: "TryStatement#1", - input: `export { x }; -try { - var x = 0; -} -catch { -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -try { - var x = 0; - exports.x = x; -} -catch { -}`, - }, - { - title: "TryStatement#2", - input: `export { x }; -try { -} -catch { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -try { -} -catch { - var x = 0; - exports.x = x; -}`, - }, - { - title: "TryStatement#3", - input: `export { x }; -try { -} -finally { - var x = 0; -}`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -try { -} -finally { - var x = 0; - exports.x = x; -}`, - }, - - // DestructuringAssignment - { - title: "DestructuringAssignment#1", - input: `var x; -export { x }; -({ x: x } = {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -({ x: { set value(value) { exports.x = x = value; } }.value } = {});`, - }, - { - title: "DestructuringAssignment#2", - input: `var x; -export { x }; -({ x: x = 1 } = {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -({ x: { set value(value) { exports.x = x = value; } }.value = 1 } = {});`, - }, - { - title: "DestructuringAssignment#3", - input: `var x; -export { x }; -({ x } = {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -({ x: { set value(value) { exports.x = x = value; } }.value } = {});`, - }, - { - title: "DestructuringAssignment#4", - input: `var x; -export { x }; -({ x = 1 } = {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -({ x: { set value(value) { exports.x = x = value; } }.value = 1 } = {});`, - }, - { - title: "DestructuringAssignment#5", - input: `var x; -export { x }; -({ ...x } = {});`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -({ ...{ set value(value) { exports.x = x = value; } }.value } = {});`, - }, - { - title: "DestructuringAssignment#6", - input: `var x; -export { x }; -[x] = [];`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -[{ set value(value) { exports.x = x = value; } }.value] = [];`, - }, - { - title: "DestructuringAssignment#7", - input: `var x; -export { x }; -[x = 1] = [];`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -[{ set value(value) { exports.x = x = value; } }.value = 1] = [];`, - }, - { - title: "DestructuringAssignment#8", - input: `var x; -export { x }; -[...x] = [];`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -[...{ set value(value) { exports.x = x = value; } }.value] = [];`, - }, - { - title: "DestructuringAssignment#9", - input: `var x; -export { x }; -[{ x: x }] = [];`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -var x; -[{ x: { set value(value) { exports.x = x = value; } }.value }] = [];`, - }, - - // AssignmentExpression - { - title: "AssignmentExpression#1", - input: `export var a; -a = 1;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = 1;`, - }, - { - title: "AssignmentExpression#2", - input: `var a; -export { a }; -a = 1;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a; -exports.a = a = 1;`, - }, - { - title: "AssignmentExpression#3", - input: `var a; -export { a, a as b }; -a = 1;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.b = exports.a = void 0; -var a; -exports.b = exports.a = a = 1;`, - }, - - // PrefixUnaryExpression - { - title: "PrefixUnaryExpression#1", - input: `export var a = 0; -++a;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = 0; -++exports.a;`, - }, - { - title: "PrefixUnaryExpression#2", - input: `var a = 0; -export { a } -++a;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0; -exports.a = a; -exports.a = ++a;`, - }, - - // PostfixUnaryExpression - { - title: "PostfixUnaryExpression#1", - input: `export var a = 0; -a++;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = 0; -exports.a++;`, - }, - { - title: "PostfixUnaryExpression#2", - input: `var a = 0; -export { a } -a++;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0; -exports.a = a; -exports.a = (a++, a);`, - }, - { - title: "PostfixUnaryExpression#3", - input: `var a = 0, b; -export { a } -b = a++;`, - output: `"use strict"; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0, b; -exports.a = a; -b = (exports.a = (_a = a++, a), _a);`, - }, - { - title: "PostfixUnaryExpression#4", - input: `var a = 0; -export { a } -(a++);`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0; -exports.a = a; -(exports.a = (a++, a));`, - }, - { - title: "PostfixUnaryExpression#5", - input: `var a = 0; -export { a } -a++, 0;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0; -exports.a = a; -exports.a = (a++, a), 0;`, - }, - { - title: "PostfixUnaryExpression#6", - input: `var a = 0, b; -export { a } -b = (a++, 0);`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0, b; -exports.a = a; -b = (exports.a = (a++, a), 0);`, - }, - { - title: "PostfixUnaryExpression#7", - input: `var a = 0, b; -export { a } -b = (0, a++);`, - output: `"use strict"; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -var a = 0, b; -exports.a = a; -b = (0, exports.a = (_a = a++, a), _a);`, - }, - - // ShortHandPropertyAssignment - { - title: "ShorthandPropertyAssignment#1", - input: `import { a } from "other" -({ a })`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other"); -({ a: other_1.a });`, - }, - { - title: "ShorthandPropertyAssignment#2", - input: `import { a } from "other" -({ - a, -})`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other"); -({ - a: other_1.a, -});`, - }, - - // CallExpression - { - title: "CallExpression#1", - input: `import { a } from "other" -a()`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other"); -(0, other_1.a)();`, - }, - { - title: "CallExpression#2", - input: `export var a = (0, function() {}); -a()`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = (0, function () { }); -(0, exports.a)();`, - }, - { - title: "CallExpression#3", - input: `export{}; -import("./other.ts");`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => require("./other.js"));`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "CallExpression#4", - input: `export{}; -import(x);`, - output: `"use strict"; -var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) { - if (typeof path === "string" && /^\.\.?\//.test(path)) { - return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { - return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); - }); - } - return path; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve(` + "`" + `${__rewriteRelativeImportExtension(x)}` + "`" + `).then(s => require(s));`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "CallExpression#5", - input: `export{}; -import(x);`, - output: `"use strict"; -var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) { - if (typeof path === "string" && /^\.\.?\//.test(path)) { - return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { - return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); - }); - } - return path; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve(` + "`" + `${__rewriteRelativeImportExtension(x, true)}` + "`" + `).then(s => require(s));`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue, Jsx: core.JsxEmitPreserve}, - }, - { - title: "CallExpression#6", - input: `export{}; -import(x);`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -Promise.resolve(` + "`" + `${tslib_1.__rewriteRelativeImportExtension(x)}` + "`" + `).then(s => require(s));`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue, ImportHelpers: core.TSTrue}, - }, - { - title: "CallExpression#7", - input: `export {}; -a?.()`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -a?.();`, - }, - - // TaggedTemplateExpression - { - title: "TaggedTemplateExpression#1", - input: "import { a } from \"other\"\n" + - "a``", - output: "\"use strict\";\n" + - "Object.defineProperty(exports, \"__esModule\", { value: true });\n" + - "const other_1 = require(\"other\");\n" + - "(0, other_1.a) ``;", - }, - { - title: "TaggedTemplateExpression#1", - input: "export var a = (0, function() {});" + - "a``", - output: "\"use strict\";\n" + - "Object.defineProperty(exports, \"__esModule\", { value: true });\n" + - "exports.a = void 0;\n" + - "exports.a = (0, function () { });\n" + - "(0, exports.a) ``;", - }, - - // Identifier - { - title: "Identifier#1", - input: `import { a } from "other" -a;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other"); -other_1.a;`, - }, - { - title: "Identifier#2", - input: `export var a = 0; -a;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = 0; -exports.a;`, - }, - { - title: "Identifier#3 (from enum)", - input: `export enum E { A } -E.A`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.E = void 0; -var E; -(function (E) { - E[E["A"] = 0] = "A"; -})(E || (exports.E = E = {})); -E.A;`, - }, - { - title: "Identifier#4 (preserve location)", - input: `import { a } from "other"; -x || - a`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const other_1 = require("other"); -x || - other_1.a;`, - }, - { - title: "Identifier#5 (from import specifier)", - input: `import { and } from "./_namespaces/ts.js"; -const isNotOverloadAndNotAccessor = and(isNotOverload, isNotAccessor); -`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const ts_js_1 = require("./_namespaces/ts.js"); -const isNotOverloadAndNotAccessor = (0, ts_js_1.and)(isNotOverload, isNotAccessor);`, - }, - - { - title: "Identifier#6 (in template literal)", - input: `export var x = 1; -` + "`" + `${x}` + "`" + `;`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -exports.x = 1; -` + "`" + `${exports.x}` + "`" + `;`, - }, - - { - title: "Other", - input: `export const a = class { - p = 10; -};`, - output: `"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -const a = class { - p = 10; -}; -exports.a = a;`, - }, - } - for _, rec := range data { - t.Run(rec.title, func(t *testing.T) { - t.Parallel() - - compilerOptions := rec.options - if compilerOptions == nil { - compilerOptions = &core.CompilerOptions{} - } - - compilerOptions.Module = core.ModuleKindCommonJS - - file := parsetestutil.ParseTypeScript(rec.input, rec.jsx) - parsetestutil.CheckDiagnostics(t, file) - binder.BindSourceFile(file) - - var other *ast.SourceFile - if len(rec.other) > 0 { - other = parsetestutil.ParseTypeScript(rec.other, rec.jsx) - parsetestutil.CheckDiagnostics(t, other) - binder.BindSourceFile(other) - } - - emitContext := printer.NewEmitContext() - resolver := binder.NewReferenceResolver(compilerOptions, binder.ReferenceResolverHooks{}) - opts := transformers.TransformOptions{CompilerOptions: compilerOptions, Context: emitContext, Resolver: resolver, GetEmitModuleFormatOfFile: fakeGetEmitModuleFormatOfFile} - file = tstransforms.NewRuntimeSyntaxTransformer(&opts).TransformSourceFile(file) - file = moduletransforms.NewCommonJSModuleTransformer(&opts).TransformSourceFile(file) - emittestutil.CheckEmit(t, emitContext, file, rec.output) - }) - } -} diff --git a/internal/transformers/moduletransforms/esmodule_test.go b/internal/transformers/moduletransforms/esmodule_test.go deleted file mode 100644 index a9be38f3c2..0000000000 --- a/internal/transformers/moduletransforms/esmodule_test.go +++ /dev/null @@ -1,249 +0,0 @@ -package moduletransforms_test - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/binder" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/printer" - "github.com/microsoft/typescript-go/internal/testutil/emittestutil" - "github.com/microsoft/typescript-go/internal/testutil/parsetestutil" - "github.com/microsoft/typescript-go/internal/transformers" - "github.com/microsoft/typescript-go/internal/transformers/moduletransforms" - "github.com/microsoft/typescript-go/internal/transformers/tstransforms" -) - -func TestESModuleTransformer(t *testing.T) { - t.Parallel() - data := []struct { - title string - input string - output string - other string - jsx bool - options *core.CompilerOptions - }{ - // ImportDeclaration - { - title: "ImportDeclaration#1", - input: `import "other"`, - output: `import "other";`, - }, - { - title: "ImportDeclaration#2", - input: `import "./other.ts"`, - output: `import "./other.js";`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "ImportDeclaration#3", - input: `import "./other.tsx"`, - output: `import "./other.js";`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "ImportDeclaration#4", - input: `import "./other.tsx"`, - output: `import "./other.jsx";`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue, Jsx: core.JsxEmitPreserve}, - }, - - // ImportEqualsDeclaration - { - title: "ImportEqualsDeclaration#1", - input: `import x = require("other")`, - output: `export {};`, - }, - { - title: "ImportEqualsDeclaration#2", - input: `import x = require("other")`, - output: `import { createRequire as _createRequire } from "module"; -const __require = _createRequire(import.meta.url); -const x = __require("other");`, - options: &core.CompilerOptions{Module: core.ModuleKindNode16}, - }, - { - title: "ImportEqualsDeclaration#3", - input: `import x = require("./other.ts")`, - output: `import { createRequire as _createRequire } from "module"; -const __require = _createRequire(import.meta.url); -const x = __require("./other.js");`, - options: &core.CompilerOptions{Module: core.ModuleKindNode16, RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "ImportEqualsDeclaration#4", - input: `import x = require("./other.tsx")`, - output: `import { createRequire as _createRequire } from "module"; -const __require = _createRequire(import.meta.url); -const x = __require("./other.js");`, - options: &core.CompilerOptions{Module: core.ModuleKindNode16, RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "ImportEqualsDeclaration#5", - input: `import x = require("./other.tsx")`, - output: `import { createRequire as _createRequire } from "module"; -const __require = _createRequire(import.meta.url); -const x = __require("./other.jsx");`, - options: &core.CompilerOptions{Module: core.ModuleKindNode16, RewriteRelativeImportExtensions: core.TSTrue, Jsx: core.JsxEmitPreserve}, - }, - { - title: "ImportEqualsDeclaration#6", - input: `export import x = require("other")`, - output: `import { createRequire as _createRequire } from "module"; -const __require = _createRequire(import.meta.url); -const x = __require("other"); -export { x };`, - options: &core.CompilerOptions{Module: core.ModuleKindNode16}, - }, - - // ExportAssignment - { - title: "ExportAssignment#1", - input: `export = x`, - output: `export {};`, - }, - { - title: "ExportAssignment#2", - input: `export = x`, - output: `module.exports = x;`, - options: &core.CompilerOptions{Module: core.ModuleKindPreserve}, - }, - - // ExportDeclaration - { - title: "ExportDeclaration#1", - input: `export * from "other";`, - output: `export * from "other";`, - }, - { - title: "ExportDeclaration#2", - input: `export * from "./other.ts";`, - output: `export * from "./other.js";`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "ExportDeclaration#3", - input: `export * as x from "other";`, - output: `export * as x from "other";`, - options: &core.CompilerOptions{Module: core.ModuleKindESNext}, - }, - { - title: "ExportDeclaration#4", - input: `export { x } from "other";`, - output: `export { x } from "other";`, - }, - { - title: "ExportDeclaration#5", - input: `export * as x from "other";`, - output: `import * as x_1 from "other"; -export { x_1 as x };`, - }, - { - title: "ExportDeclaration#6", - input: `export * as default from "other";`, - output: `import * as default_1 from "other"; -export default default_1;`, - }, - - // CallExpression - { - title: "CallExpression#1", - input: `import("other");`, - output: `import("other");`, - }, - { - title: "CallExpression#2", - input: `import(x);`, - output: `import(x);`, - }, - { - title: "CallExpression#3", - input: `export {}; -import("./other.ts");`, - output: `export {}; -import("./other.js");`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "CallExpression#4", - input: `export {}; -import(x);`, - output: `var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) { - if (typeof path === "string" && /^\.\.?\//.test(path)) { - return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { - return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); - }); - } - return path; -}; -export {}; -import(__rewriteRelativeImportExtension(x));`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue}, - }, - { - title: "CallExpression#5", - input: `export {}; -import(x);`, - output: `var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) { - if (typeof path === "string" && /^\.\.?\//.test(path)) { - return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { - return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); - }); - } - return path; -}; -export {}; -import(__rewriteRelativeImportExtension(x, true));`, - options: &core.CompilerOptions{RewriteRelativeImportExtensions: core.TSTrue, Jsx: core.JsxEmitPreserve}, - }, - { - title: "CallExpression#6", - input: `export {}; -import(x);`, - output: `import { __rewriteRelativeImportExtension } from "tslib"; -export {}; -import(__rewriteRelativeImportExtension(x));`, - options: &core.CompilerOptions{Module: core.ModuleKindESNext, RewriteRelativeImportExtensions: core.TSTrue, ImportHelpers: core.TSTrue}, - }, - { - title: "CallExpression#7", - input: `export {}; -import(x); -var __rewriteRelativeImportExtension;`, - output: `import { __rewriteRelativeImportExtension as __rewriteRelativeImportExtension_1 } from "tslib"; -export {}; -import(__rewriteRelativeImportExtension_1(x)); -var __rewriteRelativeImportExtension;`, - options: &core.CompilerOptions{Module: core.ModuleKindESNext, RewriteRelativeImportExtensions: core.TSTrue, ImportHelpers: core.TSTrue}, - }, - } - for _, rec := range data { - t.Run(rec.title, func(t *testing.T) { - t.Parallel() - - compilerOptions := rec.options - if compilerOptions == nil { - compilerOptions = &core.CompilerOptions{} - } - - file := parsetestutil.ParseTypeScript(rec.input, rec.jsx) - parsetestutil.CheckDiagnostics(t, file) - binder.BindSourceFile(file) - - var other *ast.SourceFile - if len(rec.other) > 0 { - other = parsetestutil.ParseTypeScript(rec.other, rec.jsx) - parsetestutil.CheckDiagnostics(t, other) - binder.BindSourceFile(other) - } - - emitContext := printer.NewEmitContext() - resolver := binder.NewReferenceResolver(compilerOptions, binder.ReferenceResolverHooks{}) - opts := transformers.TransformOptions{CompilerOptions: compilerOptions, Context: emitContext, Resolver: resolver, GetEmitModuleFormatOfFile: fakeGetEmitModuleFormatOfFile} - file = tstransforms.NewRuntimeSyntaxTransformer(&opts).TransformSourceFile(file) - file = moduletransforms.NewESModuleTransformer(&opts).TransformSourceFile(file) - emittestutil.CheckEmit(t, emitContext, file, rec.output) - }) - } -} diff --git a/internal/transformers/moduletransforms/externalmoduleinfo.go b/internal/transformers/moduletransforms/externalmoduleinfo.go index 5e85d015c3..ce065652d9 100644 --- a/internal/transformers/moduletransforms/externalmoduleinfo.go +++ b/internal/transformers/moduletransforms/externalmoduleinfo.go @@ -173,7 +173,7 @@ func (c *externalModuleInfoCollector) addExportedName(name *ast.ModuleExportName } func (c *externalModuleInfoCollector) addExportedNamesForExportDeclaration(node *ast.ExportDeclaration) { - for _, specifier := range node.ExportClause.AsNamedExports().Elements.Nodes { + for _, specifier := range node.ExportClause.Elements() { specifierNameText := specifier.Name().Text() if c.addUniqueExport(specifierNameText) { name := specifier.PropertyNameOrName() @@ -228,7 +228,7 @@ func (c *externalModuleInfoCollector) addExportedFunctionDeclaration(node *ast.F func (c *externalModuleInfoCollector) collectExportedVariableInfo(decl *ast.Node /*VariableDeclaration | BindingElement*/) { if ast.IsBindingPattern(decl.Name()) { - for _, element := range decl.Name().AsBindingPattern().Elements.Nodes { + for _, element := range decl.Name().Elements() { e := element.AsBindingElement() if e.Name() != nil { c.collectExportedVariableInfo(element) @@ -338,19 +338,7 @@ func isNamedDefaultReference(e *ast.Node /*ImportSpecifier | ExportSpecifier*/) } func containsDefaultReference(node *ast.Node /*NamedImportBindings | NamedExportBindings*/) bool { - if node == nil { - return false - } - var elements *ast.NodeList - switch { - case ast.IsNamedImports(node): - elements = node.AsNamedImports().Elements - case ast.IsNamedExports(node): - elements = node.AsNamedExports().Elements - default: - return false - } - return core.Some(elements.Nodes, isNamedDefaultReference) + return node != nil && (ast.IsNamedImports(node) || ast.IsNamedExports(node)) && core.Some(node.Elements(), isNamedDefaultReference) } func getExportNeedsImportStarHelper(node *ast.ExportDeclaration) bool { diff --git a/internal/transformers/tstransforms/importelision_test.go b/internal/transformers/tstransforms/importelision_test.go index 3c401006a1..b3dd33598b 100644 --- a/internal/transformers/tstransforms/importelision_test.go +++ b/internal/transformers/tstransforms/importelision_test.go @@ -225,7 +225,7 @@ func TestImportElision(t *testing.T) { compilerOptions := &core.CompilerOptions{} - c := checker.NewChecker(&fakeProgram{ + c, _ := checker.NewChecker(&fakeProgram{ singleThreaded: true, compilerOptions: compilerOptions, files: files, diff --git a/internal/transformers/tstransforms/runtimesyntax.go b/internal/transformers/tstransforms/runtimesyntax.go index 44f0b542ad..8c3ad6a817 100644 --- a/internal/transformers/tstransforms/runtimesyntax.go +++ b/internal/transformers/tstransforms/runtimesyntax.go @@ -137,7 +137,7 @@ func (tx *RuntimeSyntaxTransformer) recordDeclarationInScope(node *ast.Node) { } return case ast.KindArrayBindingPattern, ast.KindObjectBindingPattern: - for _, element := range node.AsBindingPattern().Elements.Nodes { + for _, element := range node.Elements() { tx.recordDeclarationInScope(element) } return @@ -191,9 +191,9 @@ func (tx *RuntimeSyntaxTransformer) getExpressionForPropertyName(member *ast.Enu case ast.KindIdentifier: return tx.Factory().NewStringLiteralFromNode(name) case ast.KindStringLiteral: - return tx.Factory().NewStringLiteral(name.AsStringLiteral().Text) + return tx.Factory().NewStringLiteral(name.Text()) case ast.KindNumericLiteral: - return tx.Factory().NewNumericLiteral(name.AsNumericLiteral().Text) + return tx.Factory().NewNumericLiteral(name.Text()) default: return name } @@ -928,7 +928,7 @@ func findSuperStatementIndexPath(statements []*ast.Statement, start int) []int { indices[0] = i return indices } else if ast.IsTryStatement(statement) { - return slices.Insert(findSuperStatementIndexPath(statement.AsTryStatement().TryBlock.AsBlock().Statements.Nodes, 0), 0, i) + return slices.Insert(findSuperStatementIndexPath(statement.AsTryStatement().TryBlock.Statements(), 0), 0, i) } } return nil @@ -1148,7 +1148,7 @@ func (tx *RuntimeSyntaxTransformer) shouldEmitModuleDeclaration(node *ast.Module // If we can't find a parse tree node, assume the node is instantiated. return true } - return isInstantiatedModule(node.AsNode(), tx.compilerOptions.ShouldPreserveConstEnums()) + return ast.IsInstantiatedModule(node.AsNode(), tx.compilerOptions.ShouldPreserveConstEnums()) } func getInnermostModuleDeclarationFromDottedModule(moduleDeclaration *ast.ModuleDeclaration) *ast.ModuleDeclaration { diff --git a/internal/transformers/tstransforms/typeeraser.go b/internal/transformers/tstransforms/typeeraser.go index f2aadbed97..f17962f6d4 100644 --- a/internal/transformers/tstransforms/typeeraser.go +++ b/internal/transformers/tstransforms/typeeraser.go @@ -109,7 +109,7 @@ func (tx *TypeEraserTransformer) visit(node *ast.Node) *ast.Node { case ast.KindModuleDeclaration: if !ast.IsIdentifier(node.Name()) || - !isInstantiatedModule(node, tx.compilerOptions.ShouldPreserveConstEnums()) || + !ast.IsInstantiatedModule(node, tx.compilerOptions.ShouldPreserveConstEnums()) || getInnermostModuleDeclarationFromDottedModule(node.AsModuleDeclaration()).Body == nil { // TypeScript module declarations are elided if they are not instantiated or have no body return tx.elide(node) @@ -121,7 +121,7 @@ func (tx *TypeEraserTransformer) visit(node *ast.Node) *ast.Node { return tx.Factory().UpdateExpressionWithTypeArguments(n, tx.Visitor().VisitNode(n.Expression), nil) case ast.KindPropertyDeclaration: - if ast.HasSyntacticModifier(node, ast.ModifierFlagsAmbient) { + if ast.HasSyntacticModifier(node, ast.ModifierFlagsAmbient|ast.ModifierFlagsAbstract) { // TypeScript `declare` fields are elided return nil } diff --git a/internal/transformers/tstransforms/utilities.go b/internal/transformers/tstransforms/utilities.go index ead7be4bb8..9e0f04f17f 100644 --- a/internal/transformers/tstransforms/utilities.go +++ b/internal/transformers/tstransforms/utilities.go @@ -33,9 +33,3 @@ func constantExpression(value any, factory *printer.NodeFactory) *ast.Expression } return nil } - -func isInstantiatedModule(node *ast.ModuleDeclarationNode, preserveConstEnums bool) bool { - moduleState := ast.GetModuleInstanceState(node) - return moduleState == ast.ModuleInstanceStateInstantiated || - (preserveConstEnums && moduleState == ast.ModuleInstanceStateConstEnumOnly) -} diff --git a/internal/transformers/utilities.go b/internal/transformers/utilities.go index 96bb72c525..ceb629aa40 100644 --- a/internal/transformers/utilities.go +++ b/internal/transformers/utilities.go @@ -79,36 +79,30 @@ func IsIdentifierReference(name *ast.IdentifierNode, parent *ast.Node) bool { // only an `Initializer()` child that can be `Identifier` would be an instance of `IdentifierReference` return parent.Initializer() == name case ast.KindForStatement: - return parent.AsForStatement().Initializer == name || + return parent.Initializer() == name || parent.AsForStatement().Condition == name || parent.AsForStatement().Incrementor == name case ast.KindForInStatement, ast.KindForOfStatement: - return parent.AsForInOrOfStatement().Initializer == name || - parent.AsForInOrOfStatement().Expression == name + return parent.Initializer() == name || + parent.Expression() == name case ast.KindImportEqualsDeclaration: return parent.AsImportEqualsDeclaration().ModuleReference == name case ast.KindArrowFunction: - return parent.AsArrowFunction().Body == name + return parent.Body() == name case ast.KindConditionalExpression: return parent.AsConditionalExpression().Condition == name || parent.AsConditionalExpression().WhenTrue == name || parent.AsConditionalExpression().WhenFalse == name - case ast.KindCallExpression: - return parent.AsCallExpression().Expression == name || - slices.Contains(parent.AsCallExpression().Arguments.Nodes, name) - case ast.KindNewExpression: - return parent.AsNewExpression().Expression == name || - parent.AsNewExpression().Arguments.Nodes != nil && - slices.Contains(parent.AsNewExpression().Arguments.Nodes, name) + case ast.KindCallExpression, ast.KindNewExpression: + return parent.Expression() == name || + slices.Contains(parent.Arguments(), name) case ast.KindTaggedTemplateExpression: return parent.AsTaggedTemplateExpression().Tag == name case ast.KindImportAttribute: return parent.AsImportAttribute().Value == name - case ast.KindJsxOpeningElement: - return parent.AsJsxOpeningElement().TagName == name - case ast.KindJsxClosingElement: - return parent.AsJsxClosingElement().TagName == name + case ast.KindJsxOpeningElement, ast.KindJsxClosingElement: + return parent.TagName() == name default: return false } @@ -259,8 +253,8 @@ func IsOriginalNodeSingleLine(emitContext *printer.EmitContext, node *ast.Node) if source == nil { return false } - startLine, _ := scanner.GetECMALineAndCharacterOfPosition(source, original.Loc.Pos()) - endLine, _ := scanner.GetECMALineAndCharacterOfPosition(source, original.Loc.End()) + startLine := scanner.GetECMALineOfPosition(source, original.Loc.Pos()) + endLine := scanner.GetECMALineOfPosition(source, original.Loc.End()) return startLine == endLine } diff --git a/internal/tsoptions/commandlineoption.go b/internal/tsoptions/commandlineoption.go index 6377c316c3..ca771fdd11 100644 --- a/internal/tsoptions/commandlineoption.go +++ b/internal/tsoptions/commandlineoption.go @@ -35,8 +35,8 @@ type CommandLineOption struct { // used in output in serializing and generate tsconfig Category *diagnostics.Message - // a flag indicating whether `validateJsonOptionValue` should perform extra checks - extraValidation bool + // What kind of extra validation `validateJsonOptionValue` should do + extraValidation extraValidation // true or undefined // used for configDirTemplateSubstitutionOptions @@ -65,6 +65,14 @@ type CommandLineOption struct { ElementOptions CommandLineOptionNameMap } +type extraValidation string + +const ( + extraValidationNone extraValidation = "" + extraValidationSpec extraValidation = "spec" + extraValidationLocale extraValidation = "locale" +) + func (o *CommandLineOption) DeprecatedKeys() *collections.Set[string] { if o.Kind != CommandLineOptionTypeEnum { return nil @@ -149,13 +157,13 @@ var commandLineOptionElements = map[string]*CommandLineOption{ Name: "excludeDirectory", Kind: CommandLineOptionTypeString, IsFilePath: true, - extraValidation: true, + extraValidation: extraValidationSpec, }, "excludeFiles": { Name: "excludeFile", Kind: CommandLineOptionTypeString, IsFilePath: true, - extraValidation: true, + extraValidation: extraValidationSpec, }, // Test infra options "libFiles": { diff --git a/internal/tsoptions/commandlineparser.go b/internal/tsoptions/commandlineparser.go index 4fccbf62ca..36f0c307b1 100644 --- a/internal/tsoptions/commandlineparser.go +++ b/internal/tsoptions/commandlineparser.go @@ -46,7 +46,7 @@ func ParseCommandLine( commandLine = []string{} } parser := parseCommandLineWorker(CompilerOptionsDidYouMeanDiagnostics, commandLine, host.FS()) - optionsWithAbsolutePaths := convertToOptionsWithAbsolutePaths(parser.options, CommandLineCompilerOptionsMap, host.GetCurrentDirectory()) + optionsWithAbsolutePaths := convertToOptionsWithAbsolutePaths(parser.options.Clone(), CommandLineCompilerOptionsMap, host.GetCurrentDirectory()) compilerOptions := convertMapToOptions(optionsWithAbsolutePaths, &compilerOptionsParser{&core.CompilerOptions{}}).CompilerOptions watchOptions := convertMapToOptions(optionsWithAbsolutePaths, &watchOptionsParser{&core.WatchOptions{}}).WatchOptions result := NewParsedCommandLine(compilerOptions, parser.fileNames, tspath.ComparePathsOptions{ diff --git a/internal/tsoptions/commandlineparser_test.go b/internal/tsoptions/commandlineparser_test.go index 9caf562d17..9cfd3be97b 100644 --- a/internal/tsoptions/commandlineparser_test.go +++ b/internal/tsoptions/commandlineparser_test.go @@ -190,7 +190,7 @@ func (f commandLineSubScenario) assertParseResult(t *testing.T) { // assert.DeepEqual(t, tsBaseline.watchoptions, newParsedWatchOptions) var formattedErrors strings.Builder - diagnosticwriter.WriteFormatDiagnostics(&formattedErrors, parsed.Errors, &diagnosticwriter.FormattingOptions{NewLine: "\n"}) + diagnosticwriter.WriteFormatDiagnostics(&formattedErrors, diagnosticwriter.FromASTDiagnostics(parsed.Errors), &diagnosticwriter.FormattingOptions{NewLine: "\n"}) newBaselineErrors := formattedErrors.String() // !!! @@ -281,7 +281,7 @@ func (f commandLineSubScenario) assertBuildParseResult(t *testing.T) { // assert.DeepEqual(t, tsBaseline.watchoptions, newParsedWatchOptions) var formattedErrors strings.Builder - diagnosticwriter.WriteFormatDiagnostics(&formattedErrors, parsed.Errors, &diagnosticwriter.FormattingOptions{NewLine: "\n"}) + diagnosticwriter.WriteFormatDiagnostics(&formattedErrors, diagnosticwriter.FromASTDiagnostics(parsed.Errors), &diagnosticwriter.FormattingOptions{NewLine: "\n"}) newBaselineErrors := formattedErrors.String() // !!! diff --git a/internal/tsoptions/declsbuild.go b/internal/tsoptions/declsbuild.go index dff42a7b8e..19726e85b8 100644 --- a/internal/tsoptions/declsbuild.go +++ b/internal/tsoptions/declsbuild.go @@ -6,8 +6,6 @@ import ( "github.com/microsoft/typescript-go/internal/diagnostics" ) -var BuildOpts = slices.Concat(commonOptionsWithBuild, optionsForBuild) - var TscBuildOption = CommandLineOption{ Name: "build", Kind: "boolean", @@ -18,7 +16,7 @@ var TscBuildOption = CommandLineOption{ DefaultValueDescription: false, } -var optionsForBuild = []*CommandLineOption{ +var OptionsForBuild = []*CommandLineOption{ &TscBuildOption, { Name: "verbose", @@ -59,3 +57,5 @@ var optionsForBuild = []*CommandLineOption{ DefaultValueDescription: false, }, } + +var BuildOpts = slices.Concat(commonOptionsWithBuild, OptionsForBuild) diff --git a/internal/tsoptions/declscompiler.go b/internal/tsoptions/declscompiler.go index ec730ea048..65c54a2718 100644 --- a/internal/tsoptions/declscompiler.go +++ b/internal/tsoptions/declscompiler.go @@ -211,6 +211,7 @@ var commonOptionsWithBuild = []*CommandLineOption{ IsCommandLineOnly: true, Description: diagnostics.Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit, DefaultValueDescription: diagnostics.Platform_specific, + extraValidation: extraValidationLocale, }, { @@ -233,6 +234,13 @@ var commonOptionsWithBuild = []*CommandLineOption{ Category: diagnostics.Command_line_Options, Description: diagnostics.Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory, }, + { + Name: "checkers", + Kind: CommandLineOptionTypeNumber, + Category: diagnostics.Command_line_Options, + Description: diagnostics.Set_the_number_of_checkers_per_project, + DefaultValueDescription: diagnostics.X_4_unless_singleThreaded_is_passed, + }, } var optionsForCompiler = []*CommandLineOption{ @@ -290,6 +298,15 @@ var optionsForCompiler = []*CommandLineOption{ Description: diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing, DefaultValueDescription: false, }, + { + Name: "ignoreConfig", + Kind: CommandLineOptionTypeBoolean, + ShowInSimplifiedHelpView: true, + Category: diagnostics.Command_line_Options, + IsCommandLineOnly: true, + Description: diagnostics.Ignore_the_tsconfig_found_and_build_with_commandline_options_and_files, + DefaultValueDescription: false, + }, // Basic // targetOptionDeclaration, @@ -699,7 +716,7 @@ var optionsForCompiler = []*CommandLineOption{ AffectsModuleResolution: true, Category: diagnostics.Modules, Description: diagnostics.Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier, - DefaultValueDescription: diagnostics.X_module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node, + DefaultValueDescription: diagnostics.X_nodenext_if_module_is_nodenext_node16_if_module_is_node16_or_node18_otherwise_bundler, }, { Name: "baseUrl", diff --git a/internal/tsoptions/declswatch.go b/internal/tsoptions/declswatch.go index 0e7d81d793..b190a6641c 100644 --- a/internal/tsoptions/declswatch.go +++ b/internal/tsoptions/declswatch.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/diagnostics" ) -var optionsForWatch = []*CommandLineOption{ +var OptionsForWatch = []*CommandLineOption{ { Name: "watchInterval", Kind: CommandLineOptionTypeNumber, diff --git a/internal/tsoptions/diagnostics.go b/internal/tsoptions/diagnostics.go index 9aec10d96e..73936da069 100644 --- a/internal/tsoptions/diagnostics.go +++ b/internal/tsoptions/diagnostics.go @@ -46,7 +46,7 @@ func getParseCommandLineWorkerDiagnostics(decls []*CommandLineOption) *ParseComm var watchOptionsDidYouMeanDiagnostics = &ParseCommandLineWorkerDiagnostics{ didYouMean: DidYouMeanOptionsDiagnostics{ // no alternateMode - OptionDeclarations: optionsForWatch, + OptionDeclarations: OptionsForWatch, UnknownOptionDiagnostic: diagnostics.Unknown_watch_option_0, UnknownDidYouMeanDiagnostic: diagnostics.Unknown_watch_option_0_Did_you_mean_1, }, diff --git a/internal/tsoptions/enummaps.go b/internal/tsoptions/enummaps.go index b47e9739e3..723613a360 100644 --- a/internal/tsoptions/enummaps.go +++ b/internal/tsoptions/enummaps.go @@ -155,9 +155,9 @@ var moduleResolutionOptionMap = collections.NewOrderedMapFromList([]collections. {Key: "node16", Value: core.ModuleResolutionKindNode16}, {Key: "nodenext", Value: core.ModuleResolutionKindNodeNext}, {Key: "bundler", Value: core.ModuleResolutionKindBundler}, - {Key: "node", Value: core.ModuleResolutionKindBundler}, // TODO: remove when node is fully deprecated -- this is helpful for testing porting - {Key: "classic", Value: core.ModuleResolutionKindBundler}, // TODO: remove when fully deprecated - {Key: "node10", Value: core.ModuleResolutionKindBundler}, // TODO: remove when fully deprecated + {Key: "classic", Value: core.ModuleResolutionKindClassic}, + {Key: "node", Value: core.ModuleResolutionKindNode10}, + {Key: "node10", Value: core.ModuleResolutionKindNode10}, }) var targetOptionMap = collections.NewOrderedMapFromList([]collections.MapEntry[string, any]{ diff --git a/internal/tsoptions/namemap.go b/internal/tsoptions/namemap.go index 31a8b98d48..6cc2785e79 100644 --- a/internal/tsoptions/namemap.go +++ b/internal/tsoptions/namemap.go @@ -9,7 +9,7 @@ import ( var ( CompilerNameMap = GetNameMapFromList(OptionsDeclarations) BuildNameMap = GetNameMapFromList(BuildOpts) - WatchNameMap = GetNameMapFromList(optionsForWatch) + WatchNameMap = GetNameMapFromList(OptionsForWatch) ) func GetNameMapFromList(optDecls []*CommandLineOption) *NameMap { diff --git a/internal/tsoptions/parsedbuildcommandline.go b/internal/tsoptions/parsedbuildcommandline.go index 8a777b8c15..f0e4ad55ca 100644 --- a/internal/tsoptions/parsedbuildcommandline.go +++ b/internal/tsoptions/parsedbuildcommandline.go @@ -5,6 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -19,6 +20,9 @@ type ParsedBuildCommandLine struct { resolvedProjectPaths []string resolvedProjectPathsOnce sync.Once + + locale locale.Locale + localeOnce sync.Once } func (p *ParsedBuildCommandLine) ResolvedProjectPaths() []string { @@ -31,3 +35,10 @@ func (p *ParsedBuildCommandLine) ResolvedProjectPaths() []string { }) return p.resolvedProjectPaths } + +func (p *ParsedBuildCommandLine) Locale() locale.Locale { + p.localeOnce.Do(func() { + p.locale, _ = locale.Parse(p.CompilerOptions.Locale) + }) + return p.locale +} diff --git a/internal/tsoptions/parsedcommandline.go b/internal/tsoptions/parsedcommandline.go index e60649300b..a00e80854a 100644 --- a/internal/tsoptions/parsedcommandline.go +++ b/internal/tsoptions/parsedcommandline.go @@ -10,6 +10,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/glob" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/tspath" @@ -49,6 +50,9 @@ type ParsedCommandLine struct { literalFileNamesLen int fileNamesByPath map[tspath.Path]string // maps file names to their paths, used for quick lookups fileNamesByPathOnce sync.Once + + locale locale.Locale + localeOnce sync.Once } func NewParsedCommandLine( @@ -379,3 +383,10 @@ func (p *ParsedCommandLine) ReloadFileNamesOfParsedCommandLine(fs vfs.FS) *Parse } return &parsedCommandLine } + +func (p *ParsedCommandLine) Locale() locale.Locale { + p.localeOnce.Do(func() { + p.locale, _ = locale.Parse(p.CompilerOptions().Locale) + }) + return p.locale +} diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index bf16518be2..279f40f4ea 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -11,7 +11,7 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -func parseTristate(value any) core.Tristate { +func ParseTristate(value any) core.Tristate { if value == nil { return core.TSUnknown } @@ -25,7 +25,7 @@ func parseTristate(value any) core.Tristate { } } -func parseStringArray(value any) []string { +func ParseStringArray(value any) []string { if arr, ok := value.([]any); ok { if arr == nil { return nil @@ -45,14 +45,14 @@ func parseStringMap(value any) *collections.OrderedMap[string, []string] { if m, ok := value.(*collections.OrderedMap[string, any]); ok { result := collections.NewOrderedMapWithSizeHint[string, []string](m.Size()) for k, v := range m.Entries() { - result.Set(k, parseStringArray(v)) + result.Set(k, ParseStringArray(v)) } return result } return nil } -func parseString(value any) string { +func ParseString(value any) string { if str, ok := value.(string); ok { return str } @@ -186,119 +186,121 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption } switch key { case "allowJs": - allOptions.AllowJs = parseTristate(value) + allOptions.AllowJs = ParseTristate(value) case "allowImportingTsExtensions": - allOptions.AllowImportingTsExtensions = parseTristate(value) + allOptions.AllowImportingTsExtensions = ParseTristate(value) case "allowSyntheticDefaultImports": - allOptions.AllowSyntheticDefaultImports = parseTristate(value) + allOptions.AllowSyntheticDefaultImports = ParseTristate(value) case "allowNonTsExtensions": - allOptions.AllowNonTsExtensions = parseTristate(value) + allOptions.AllowNonTsExtensions = ParseTristate(value) case "allowUmdGlobalAccess": - allOptions.AllowUmdGlobalAccess = parseTristate(value) + allOptions.AllowUmdGlobalAccess = ParseTristate(value) case "allowUnreachableCode": - allOptions.AllowUnreachableCode = parseTristate(value) + allOptions.AllowUnreachableCode = ParseTristate(value) case "allowUnusedLabels": - allOptions.AllowUnusedLabels = parseTristate(value) + allOptions.AllowUnusedLabels = ParseTristate(value) case "allowArbitraryExtensions": - allOptions.AllowArbitraryExtensions = parseTristate(value) + allOptions.AllowArbitraryExtensions = ParseTristate(value) case "alwaysStrict": - allOptions.AlwaysStrict = parseTristate(value) + allOptions.AlwaysStrict = ParseTristate(value) case "assumeChangesOnlyAffectDirectDependencies": - allOptions.AssumeChangesOnlyAffectDirectDependencies = parseTristate(value) + allOptions.AssumeChangesOnlyAffectDirectDependencies = ParseTristate(value) case "baseUrl": - allOptions.BaseUrl = parseString(value) + allOptions.BaseUrl = ParseString(value) case "build": - allOptions.Build = parseTristate(value) + allOptions.Build = ParseTristate(value) case "checkJs": - allOptions.CheckJs = parseTristate(value) + allOptions.CheckJs = ParseTristate(value) case "customConditions": - allOptions.CustomConditions = parseStringArray(value) + allOptions.CustomConditions = ParseStringArray(value) case "composite": - allOptions.Composite = parseTristate(value) + allOptions.Composite = ParseTristate(value) case "declarationDir": - allOptions.DeclarationDir = parseString(value) + allOptions.DeclarationDir = ParseString(value) case "diagnostics": - allOptions.Diagnostics = parseTristate(value) + allOptions.Diagnostics = ParseTristate(value) case "disableSizeLimit": - allOptions.DisableSizeLimit = parseTristate(value) + allOptions.DisableSizeLimit = ParseTristate(value) case "disableSourceOfProjectReferenceRedirect": - allOptions.DisableSourceOfProjectReferenceRedirect = parseTristate(value) + allOptions.DisableSourceOfProjectReferenceRedirect = ParseTristate(value) case "disableSolutionSearching": - allOptions.DisableSolutionSearching = parseTristate(value) + allOptions.DisableSolutionSearching = ParseTristate(value) case "disableReferencedProjectLoad": - allOptions.DisableReferencedProjectLoad = parseTristate(value) + allOptions.DisableReferencedProjectLoad = ParseTristate(value) case "declarationMap": - allOptions.DeclarationMap = parseTristate(value) + allOptions.DeclarationMap = ParseTristate(value) case "declaration": - allOptions.Declaration = parseTristate(value) + allOptions.Declaration = ParseTristate(value) case "downlevelIteration": - allOptions.DownlevelIteration = parseTristate(value) + allOptions.DownlevelIteration = ParseTristate(value) case "erasableSyntaxOnly": - allOptions.ErasableSyntaxOnly = parseTristate(value) + allOptions.ErasableSyntaxOnly = ParseTristate(value) case "emitDeclarationOnly": - allOptions.EmitDeclarationOnly = parseTristate(value) + allOptions.EmitDeclarationOnly = ParseTristate(value) case "extendedDiagnostics": - allOptions.ExtendedDiagnostics = parseTristate(value) + allOptions.ExtendedDiagnostics = ParseTristate(value) case "emitDecoratorMetadata": - allOptions.EmitDecoratorMetadata = parseTristate(value) + allOptions.EmitDecoratorMetadata = ParseTristate(value) case "emitBOM": - allOptions.EmitBOM = parseTristate(value) + allOptions.EmitBOM = ParseTristate(value) case "esModuleInterop": - allOptions.ESModuleInterop = parseTristate(value) + allOptions.ESModuleInterop = ParseTristate(value) case "exactOptionalPropertyTypes": - allOptions.ExactOptionalPropertyTypes = parseTristate(value) + allOptions.ExactOptionalPropertyTypes = ParseTristate(value) case "explainFiles": - allOptions.ExplainFiles = parseTristate(value) + allOptions.ExplainFiles = ParseTristate(value) case "experimentalDecorators": - allOptions.ExperimentalDecorators = parseTristate(value) + allOptions.ExperimentalDecorators = ParseTristate(value) case "forceConsistentCasingInFileNames": - allOptions.ForceConsistentCasingInFileNames = parseTristate(value) + allOptions.ForceConsistentCasingInFileNames = ParseTristate(value) case "generateCpuProfile": - allOptions.GenerateCpuProfile = parseString(value) + allOptions.GenerateCpuProfile = ParseString(value) case "generateTrace": - allOptions.GenerateTrace = parseString(value) + allOptions.GenerateTrace = ParseString(value) case "isolatedModules": - allOptions.IsolatedModules = parseTristate(value) + allOptions.IsolatedModules = ParseTristate(value) + case "ignoreConfig": + allOptions.IgnoreConfig = ParseTristate(value) case "ignoreDeprecations": - allOptions.IgnoreDeprecations = parseString(value) + allOptions.IgnoreDeprecations = ParseString(value) case "importHelpers": - allOptions.ImportHelpers = parseTristate(value) + allOptions.ImportHelpers = ParseTristate(value) case "incremental": - allOptions.Incremental = parseTristate(value) + allOptions.Incremental = ParseTristate(value) case "init": - allOptions.Init = parseTristate(value) + allOptions.Init = ParseTristate(value) case "inlineSourceMap": - allOptions.InlineSourceMap = parseTristate(value) + allOptions.InlineSourceMap = ParseTristate(value) case "inlineSources": - allOptions.InlineSources = parseTristate(value) + allOptions.InlineSources = ParseTristate(value) case "isolatedDeclarations": - allOptions.IsolatedDeclarations = parseTristate(value) + allOptions.IsolatedDeclarations = ParseTristate(value) case "jsx": allOptions.Jsx = floatOrInt32ToFlag[core.JsxEmit](value) case "jsxFactory": - allOptions.JsxFactory = parseString(value) + allOptions.JsxFactory = ParseString(value) case "jsxFragmentFactory": - allOptions.JsxFragmentFactory = parseString(value) + allOptions.JsxFragmentFactory = ParseString(value) case "jsxImportSource": - allOptions.JsxImportSource = parseString(value) + allOptions.JsxImportSource = ParseString(value) case "lib": if _, ok := value.([]string); ok { allOptions.Lib = value.([]string) } else { - allOptions.Lib = parseStringArray(value) + allOptions.Lib = ParseStringArray(value) } case "libReplacement": - allOptions.LibReplacement = parseTristate(value) + allOptions.LibReplacement = ParseTristate(value) case "listEmittedFiles": - allOptions.ListEmittedFiles = parseTristate(value) + allOptions.ListEmittedFiles = ParseTristate(value) case "listFiles": - allOptions.ListFiles = parseTristate(value) + allOptions.ListFiles = ParseTristate(value) case "listFilesOnly": - allOptions.ListFilesOnly = parseTristate(value) + allOptions.ListFilesOnly = ParseTristate(value) case "locale": - allOptions.Locale = parseString(value) + allOptions.Locale = ParseString(value) case "mapRoot": - allOptions.MapRoot = parseString(value) + allOptions.MapRoot = ParseString(value) case "module": allOptions.Module = floatOrInt32ToFlag[core.ModuleKind](value) case "moduleDetectionKind": @@ -306,143 +308,145 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption case "moduleResolution": allOptions.ModuleResolution = floatOrInt32ToFlag[core.ModuleResolutionKind](value) case "moduleSuffixes": - allOptions.ModuleSuffixes = parseStringArray(value) + allOptions.ModuleSuffixes = ParseStringArray(value) case "moduleDetection": allOptions.ModuleDetection = floatOrInt32ToFlag[core.ModuleDetectionKind](value) case "noCheck": - allOptions.NoCheck = parseTristate(value) + allOptions.NoCheck = ParseTristate(value) case "noFallthroughCasesInSwitch": - allOptions.NoFallthroughCasesInSwitch = parseTristate(value) + allOptions.NoFallthroughCasesInSwitch = ParseTristate(value) case "noEmitForJsFiles": - allOptions.NoEmitForJsFiles = parseTristate(value) + allOptions.NoEmitForJsFiles = ParseTristate(value) case "noErrorTruncation": - allOptions.NoErrorTruncation = parseTristate(value) + allOptions.NoErrorTruncation = ParseTristate(value) case "noImplicitAny": - allOptions.NoImplicitAny = parseTristate(value) + allOptions.NoImplicitAny = ParseTristate(value) case "noImplicitThis": - allOptions.NoImplicitThis = parseTristate(value) + allOptions.NoImplicitThis = ParseTristate(value) case "noLib": - allOptions.NoLib = parseTristate(value) + allOptions.NoLib = ParseTristate(value) case "noPropertyAccessFromIndexSignature": - allOptions.NoPropertyAccessFromIndexSignature = parseTristate(value) + allOptions.NoPropertyAccessFromIndexSignature = ParseTristate(value) case "noUncheckedIndexedAccess": - allOptions.NoUncheckedIndexedAccess = parseTristate(value) + allOptions.NoUncheckedIndexedAccess = ParseTristate(value) case "noEmitHelpers": - allOptions.NoEmitHelpers = parseTristate(value) + allOptions.NoEmitHelpers = ParseTristate(value) case "noEmitOnError": - allOptions.NoEmitOnError = parseTristate(value) + allOptions.NoEmitOnError = ParseTristate(value) case "noImplicitReturns": - allOptions.NoImplicitReturns = parseTristate(value) + allOptions.NoImplicitReturns = ParseTristate(value) case "noUnusedLocals": - allOptions.NoUnusedLocals = parseTristate(value) + allOptions.NoUnusedLocals = ParseTristate(value) case "noUnusedParameters": - allOptions.NoUnusedParameters = parseTristate(value) + allOptions.NoUnusedParameters = ParseTristate(value) case "noImplicitOverride": - allOptions.NoImplicitOverride = parseTristate(value) + allOptions.NoImplicitOverride = ParseTristate(value) case "noUncheckedSideEffectImports": - allOptions.NoUncheckedSideEffectImports = parseTristate(value) + allOptions.NoUncheckedSideEffectImports = ParseTristate(value) case "outFile": - allOptions.OutFile = parseString(value) + allOptions.OutFile = ParseString(value) case "noResolve": - allOptions.NoResolve = parseTristate(value) + allOptions.NoResolve = ParseTristate(value) case "paths": allOptions.Paths = parseStringMap(value) case "preserveWatchOutput": - allOptions.PreserveWatchOutput = parseTristate(value) + allOptions.PreserveWatchOutput = ParseTristate(value) case "preserveConstEnums": - allOptions.PreserveConstEnums = parseTristate(value) + allOptions.PreserveConstEnums = ParseTristate(value) case "preserveSymlinks": - allOptions.PreserveSymlinks = parseTristate(value) + allOptions.PreserveSymlinks = ParseTristate(value) case "project": - allOptions.Project = parseString(value) + allOptions.Project = ParseString(value) case "pretty": - allOptions.Pretty = parseTristate(value) + allOptions.Pretty = ParseTristate(value) case "resolveJsonModule": - allOptions.ResolveJsonModule = parseTristate(value) + allOptions.ResolveJsonModule = ParseTristate(value) case "resolvePackageJsonExports": - allOptions.ResolvePackageJsonExports = parseTristate(value) + allOptions.ResolvePackageJsonExports = ParseTristate(value) case "resolvePackageJsonImports": - allOptions.ResolvePackageJsonImports = parseTristate(value) + allOptions.ResolvePackageJsonImports = ParseTristate(value) case "reactNamespace": - allOptions.ReactNamespace = parseString(value) + allOptions.ReactNamespace = ParseString(value) case "rewriteRelativeImportExtensions": - allOptions.RewriteRelativeImportExtensions = parseTristate(value) + allOptions.RewriteRelativeImportExtensions = ParseTristate(value) case "rootDir": - allOptions.RootDir = parseString(value) + allOptions.RootDir = ParseString(value) case "rootDirs": - allOptions.RootDirs = parseStringArray(value) + allOptions.RootDirs = ParseStringArray(value) case "removeComments": - allOptions.RemoveComments = parseTristate(value) + allOptions.RemoveComments = ParseTristate(value) case "strict": - allOptions.Strict = parseTristate(value) + allOptions.Strict = ParseTristate(value) case "strictBindCallApply": - allOptions.StrictBindCallApply = parseTristate(value) + allOptions.StrictBindCallApply = ParseTristate(value) case "strictBuiltinIteratorReturn": - allOptions.StrictBuiltinIteratorReturn = parseTristate(value) + allOptions.StrictBuiltinIteratorReturn = ParseTristate(value) case "strictFunctionTypes": - allOptions.StrictFunctionTypes = parseTristate(value) + allOptions.StrictFunctionTypes = ParseTristate(value) case "strictNullChecks": - allOptions.StrictNullChecks = parseTristate(value) + allOptions.StrictNullChecks = ParseTristate(value) case "strictPropertyInitialization": - allOptions.StrictPropertyInitialization = parseTristate(value) + allOptions.StrictPropertyInitialization = ParseTristate(value) case "skipDefaultLibCheck": - allOptions.SkipDefaultLibCheck = parseTristate(value) + allOptions.SkipDefaultLibCheck = ParseTristate(value) case "sourceMap": - allOptions.SourceMap = parseTristate(value) + allOptions.SourceMap = ParseTristate(value) case "sourceRoot": - allOptions.SourceRoot = parseString(value) + allOptions.SourceRoot = ParseString(value) case "stripInternal": - allOptions.StripInternal = parseTristate(value) + allOptions.StripInternal = ParseTristate(value) case "suppressOutputPathCheck": - allOptions.SuppressOutputPathCheck = parseTristate(value) + allOptions.SuppressOutputPathCheck = ParseTristate(value) case "target": allOptions.Target = floatOrInt32ToFlag[core.ScriptTarget](value) case "traceResolution": - allOptions.TraceResolution = parseTristate(value) + allOptions.TraceResolution = ParseTristate(value) case "tsBuildInfoFile": - allOptions.TsBuildInfoFile = parseString(value) + allOptions.TsBuildInfoFile = ParseString(value) case "typeRoots": - allOptions.TypeRoots = parseStringArray(value) + allOptions.TypeRoots = ParseStringArray(value) case "types": - allOptions.Types = parseStringArray(value) + allOptions.Types = ParseStringArray(value) case "useDefineForClassFields": - allOptions.UseDefineForClassFields = parseTristate(value) + allOptions.UseDefineForClassFields = ParseTristate(value) case "useUnknownInCatchVariables": - allOptions.UseUnknownInCatchVariables = parseTristate(value) + allOptions.UseUnknownInCatchVariables = ParseTristate(value) case "verbatimModuleSyntax": - allOptions.VerbatimModuleSyntax = parseTristate(value) + allOptions.VerbatimModuleSyntax = ParseTristate(value) case "version": - allOptions.Version = parseTristate(value) + allOptions.Version = ParseTristate(value) case "help": - allOptions.Help = parseTristate(value) + allOptions.Help = ParseTristate(value) case "all": - allOptions.All = parseTristate(value) + allOptions.All = ParseTristate(value) case "maxNodeModuleJsDepth": allOptions.MaxNodeModuleJsDepth = parseNumber(value) case "skipLibCheck": - allOptions.SkipLibCheck = parseTristate(value) + allOptions.SkipLibCheck = ParseTristate(value) case "noEmit": - allOptions.NoEmit = parseTristate(value) + allOptions.NoEmit = ParseTristate(value) case "showConfig": - allOptions.ShowConfig = parseTristate(value) + allOptions.ShowConfig = ParseTristate(value) case "configFilePath": - allOptions.ConfigFilePath = parseString(value) + allOptions.ConfigFilePath = ParseString(value) case "noDtsResolution": - allOptions.NoDtsResolution = parseTristate(value) + allOptions.NoDtsResolution = ParseTristate(value) case "pathsBasePath": - allOptions.PathsBasePath = parseString(value) + allOptions.PathsBasePath = ParseString(value) case "outDir": - allOptions.OutDir = parseString(value) + allOptions.OutDir = ParseString(value) case "newLine": allOptions.NewLine = floatOrInt32ToFlag[core.NewLineKind](value) case "watch": - allOptions.Watch = parseTristate(value) + allOptions.Watch = ParseTristate(value) case "pprofDir": - allOptions.PprofDir = parseString(value) + allOptions.PprofDir = ParseString(value) case "singleThreaded": - allOptions.SingleThreaded = parseTristate(value) + allOptions.SingleThreaded = ParseTristate(value) case "quiet": - allOptions.Quiet = parseTristate(value) + allOptions.Quiet = ParseTristate(value) + case "checkers": + allOptions.Checkers = parseNumber(value) default: // different than any key above return false @@ -477,11 +481,11 @@ func ParseWatchOptions(key string, value any, allOptions *core.WatchOptions) []* allOptions.FallbackPolling = value.(core.PollingKind) } case "synchronousWatchDirectory": - allOptions.SyncWatchDir = parseTristate(value) + allOptions.SyncWatchDir = ParseTristate(value) case "excludeDirectories": - allOptions.ExcludeDir = parseStringArray(value) + allOptions.ExcludeDir = ParseStringArray(value) case "excludeFiles": - allOptions.ExcludeFiles = parseStringArray(value) + allOptions.ExcludeFiles = ParseStringArray(value) } return nil } @@ -495,13 +499,13 @@ func ParseTypeAcquisition(key string, value any, allOptions *core.TypeAcquisitio } switch key { case "enable": - allOptions.Enable = parseTristate(value) + allOptions.Enable = ParseTristate(value) case "include": - allOptions.Include = parseStringArray(value) + allOptions.Include = ParseStringArray(value) case "exclude": - allOptions.Exclude = parseStringArray(value) + allOptions.Exclude = ParseStringArray(value) case "disableFilenameBasedTypeAcquisition": - allOptions.DisableFilenameBasedTypeAcquisition = parseTristate(value) + allOptions.DisableFilenameBasedTypeAcquisition = ParseTristate(value) } return nil } @@ -519,15 +523,15 @@ func ParseBuildOptions(key string, value any, allOptions *core.BuildOptions) []* } switch key { case "clean": - allOptions.Clean = parseTristate(value) + allOptions.Clean = ParseTristate(value) case "dry": - allOptions.Dry = parseTristate(value) + allOptions.Dry = ParseTristate(value) case "force": - allOptions.Force = parseTristate(value) + allOptions.Force = ParseTristate(value) case "stopBuildOnErrors": - allOptions.StopBuildOnErrors = parseTristate(value) + allOptions.StopBuildOnErrors = ParseTristate(value) case "verbose": - allOptions.Verbose = parseTristate(value) + allOptions.Verbose = ParseTristate(value) } return nil } diff --git a/internal/tsoptions/tsconfigparsing.go b/internal/tsoptions/tsconfigparsing.go index 9ccef5af8d..140c4a78fd 100644 --- a/internal/tsoptions/tsconfigparsing.go +++ b/internal/tsoptions/tsconfigparsing.go @@ -14,6 +14,7 @@ import ( "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/jsnum" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/tspath" @@ -292,7 +293,7 @@ func convertConfigFileToObject( ) (any, []*ast.Diagnostic) { var rootExpression *ast.Expression if len(sourceFile.Statements.Nodes) > 0 { - rootExpression = sourceFile.Statements.Nodes[0].AsExpressionStatement().Expression + rootExpression = sourceFile.Statements.Nodes[0].Expression() } if rootExpression != nil && rootExpression.Kind != ast.KindObjectLiteralExpression { baseFileName := "tsconfig.json" @@ -304,7 +305,7 @@ func convertConfigFileToObject( // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that // array is a well-formed configuration object, made into an array element by stray characters. if ast.IsArrayLiteralExpression(rootExpression) { - firstObject := core.Find(rootExpression.AsArrayLiteralExpression().Elements.Nodes, ast.IsObjectLiteralExpression) + firstObject := core.Find(rootExpression.Elements(), ast.IsObjectLiteralExpression) if firstObject != nil { return convertToJson(sourceFile, firstObject, true /*returnValue*/, jsonConversionNotifier) } @@ -359,13 +360,22 @@ func validateJsonOptionValue( if val == nil { return nil, nil } - errors := []*ast.Diagnostic{} - if opt.extraValidation { - diag := specToDiagnostic(val.(string), false) - if diag != nil { + + var errors []*ast.Diagnostic + + switch opt.extraValidation { + case extraValidationSpec: + if diag := specToDiagnostic(val.(string), false); diag != nil { errors = append(errors, CreateDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, valueExpression, diag)) - return nil, errors } + case extraValidationLocale: + if _, ok := locale.Parse(val.(string)); !ok { + errors = append(errors, CreateDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, valueExpression, diagnostics.Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1, "en", "ja-jp")) + } + } + + if len(errors) > 0 { + return nil, errors } return val, nil } @@ -383,7 +393,7 @@ func convertJsonOptionOfListType( if values, ok := values.([]any); ok { mappedValues := core.MapIndex(values, func(v any, index int) any { if valueExpression != nil { - expression = valueExpression.AsArrayLiteralExpression().Elements.Nodes[index] + expression = valueExpression.Elements()[index] } result, err := convertJsonOption(option.Elements(), v, basePath, propertyAssignment, expression, sourceFile) errors = append(errors, err...) @@ -493,7 +503,7 @@ func getExtendsConfigPathOrArray( for index, fileName := range value.([]any) { var expression *ast.Expression = nil if valueExpression != nil { - expression = valueExpression.AsArrayLiteralExpression().Elements.Nodes[index] + expression = valueExpression.Elements()[index] } if reflect.TypeOf(fileName).Kind() == reflect.String { val, err := getExtendsConfigPath(fileName.(string), host, newBase, expression, sourceFile) @@ -785,17 +795,17 @@ func convertPropertyValueToJson(sourceFile *ast.SourceFile, valueExpression *ast case ast.KindStringLiteral: if !isDoubleQuotedString(valueExpression) { - return valueExpression.AsStringLiteral().Text, []*ast.Diagnostic{ast.NewDiagnostic(sourceFile, valueExpression.Loc, diagnostics.String_literal_with_double_quotes_expected)} + return valueExpression.Text(), []*ast.Diagnostic{ast.NewDiagnostic(sourceFile, valueExpression.Loc, diagnostics.String_literal_with_double_quotes_expected)} } - return valueExpression.AsStringLiteral().Text, nil + return valueExpression.Text(), nil case ast.KindNumericLiteral: - return float64(jsnum.FromString(valueExpression.AsNumericLiteral().Text)), nil + return float64(jsnum.FromString(valueExpression.Text())), nil case ast.KindPrefixUnaryExpression: if valueExpression.AsPrefixUnaryExpression().Operator != ast.KindMinusToken || valueExpression.AsPrefixUnaryExpression().Operand.Kind != ast.KindNumericLiteral { break // not valid JSON syntax } - return float64(-jsnum.FromString(valueExpression.AsPrefixUnaryExpression().Operand.AsNumericLiteral().Text)), nil + return float64(-jsnum.FromString(valueExpression.AsPrefixUnaryExpression().Operand.Text())), nil case ast.KindObjectLiteralExpression: objectLiteralExpression := valueExpression.AsObjectLiteralExpression() // Currently having element option declaration in the tsconfig with type "object" @@ -808,7 +818,7 @@ func convertPropertyValueToJson(sourceFile *ast.SourceFile, valueExpression *ast case ast.KindArrayLiteralExpression: result, errors := convertArrayLiteralExpressionToJson( sourceFile, - valueExpression.AsArrayLiteralExpression().Elements.Nodes, + valueExpression.Elements(), option, returnValue, ) @@ -837,7 +847,7 @@ func ParseJsonConfigFileContent(json any, host ParseConfigHost, basePath string, func convertToObject(sourceFile *ast.SourceFile) (any, []*ast.Diagnostic) { var rootExpression *ast.Expression if len(sourceFile.Statements.Nodes) != 0 { - rootExpression = sourceFile.Statements.Nodes[0].AsExpressionStatement().Expression + rootExpression = sourceFile.Statements.Nodes[0].Expression() } return convertToJson(sourceFile, rootExpression, true /*returnValue*/, nil /*jsonConversionNotifier*/) } @@ -1288,7 +1298,7 @@ func parseJsonConfigFileContentWorker( projectReferences = []*core.ProjectReference{} for _, reference := range newReferencesOfRaw.sliceValue { for _, ref := range parseProjectReference(reference) { - if reflect.TypeOf(ref.Path).Kind() != reflect.String { + if ref.Path == "" { if sourceFile == nil { errors = append(errors, ast.NewCompilerDiagnostic(diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string")) } @@ -1425,7 +1435,7 @@ func ForEachTsConfigPropArray[T any](tsConfigSourceFile *ast.SourceFile, propKey func CreateDiagnosticAtReferenceSyntax(config *ParsedCommandLine, index int, message *diagnostics.Message, args ...any) *ast.Diagnostic { return ForEachTsConfigPropArray(config.ConfigFile.SourceFile, "references", func(property *ast.PropertyAssignment) *ast.Diagnostic { if ast.IsArrayLiteralExpression(property.Initializer) { - value := property.Initializer.AsArrayLiteralExpression().Elements.Nodes + value := property.Initializer.Elements() if len(value) > index { return CreateDiagnosticForNodeInSourceFile(config.ConfigFile.SourceFile, value[index], message, args...) } @@ -1437,8 +1447,8 @@ func CreateDiagnosticAtReferenceSyntax(config *ParsedCommandLine, index int, mes func GetCallbackForFindingPropertyAssignmentByValue(value string) func(property *ast.PropertyAssignment) *ast.Node { return func(property *ast.PropertyAssignment) *ast.Node { if ast.IsArrayLiteralExpression(property.Initializer) { - return core.Find(property.Initializer.AsArrayLiteralExpression().Elements.Nodes, func(element *ast.Node) bool { - return ast.IsStringLiteral(element) && element.AsStringLiteral().Text == value + return core.Find(property.Initializer.Elements(), func(element *ast.Node) bool { + return ast.IsStringLiteral(element) && element.Text() == value }) } return nil @@ -1467,7 +1477,7 @@ func ForEachPropertyAssignment[T any](objectLiteral *ast.ObjectLiteralExpression func getTsConfigObjectLiteralExpression(tsConfigSourceFile *ast.SourceFile) *ast.ObjectLiteralExpression { if tsConfigSourceFile != nil && tsConfigSourceFile.Statements != nil && len(tsConfigSourceFile.Statements.Nodes) > 0 { - expression := tsConfigSourceFile.Statements.Nodes[0].AsExpressionStatement().Expression + expression := tsConfigSourceFile.Statements.Nodes[0].Expression() return expression.AsObjectLiteralExpression() } return nil diff --git a/internal/tsoptions/tsconfigparsing_test.go b/internal/tsoptions/tsconfigparsing_test.go index 4f57b5068f..d25fb144cb 100644 --- a/internal/tsoptions/tsconfigparsing_test.go +++ b/internal/tsoptions/tsconfigparsing_test.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "io/fs" + "maps" "path/filepath" "strings" "testing" @@ -13,6 +14,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnosticwriter" "github.com/microsoft/typescript-go/internal/jsonutil" + "github.com/microsoft/typescript-go/internal/locale" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/repo" "github.com/microsoft/typescript-go/internal/testutil/baseline" @@ -136,7 +138,7 @@ func TestParseConfigFileTextToJson(t *testing.T) { assert.NilError(t, writeJsonReadableText(&baselineContent, parsed), "Failed to write JSON text") baselineContent.WriteString("\n") baselineContent.WriteString("Errors::\n") - diagnosticwriter.FormatDiagnosticsWithColorAndContext(&baselineContent, errors, &diagnosticwriter.FormattingOptions{ + diagnosticwriter.FormatDiagnosticsWithColorAndContext(&baselineContent, diagnosticwriter.FromASTDiagnostics(errors), &diagnosticwriter.FormattingOptions{ NewLine: "\n", ComparePathsOptions: tspath.ComparePathsOptions{ CurrentDirectory: "/", @@ -835,9 +837,7 @@ func baselineParseConfigWith(t *testing.T, baselineFileName string, noSubmoduleB } configFileName := tspath.CombinePaths(basePath, config.configFileName) allFileLists := make(map[string]string, len(config.allFileList)+1) - for file, content := range config.allFileList { - allFileLists[file] = content - } + maps.Copy(allFileLists, config.allFileList) allFileLists[configFileName] = config.jsonText host := tsoptionstest.NewVFSParseConfigHost(allFileLists, config.basePath, true /*useCaseSensitiveFileNames*/) parsedConfigFileContent := getParsed(config, host, basePath) @@ -864,7 +864,7 @@ func baselineParseConfigWith(t *testing.T, baselineFileName string, noSubmoduleB baselineContent.WriteString("FileNames::\n") baselineContent.WriteString(strings.Join(parsedConfigFileContent.ParsedConfig.FileNames, ",") + "\n") baselineContent.WriteString("Errors::\n") - diagnosticwriter.FormatDiagnosticsWithColorAndContext(&baselineContent, parsedConfigFileContent.Errors, &diagnosticwriter.FormattingOptions{ + diagnosticwriter.FormatDiagnosticsWithColorAndContext(&baselineContent, diagnosticwriter.FromASTDiagnostics(parsedConfigFileContent.Errors), &diagnosticwriter.FormattingOptions{ NewLine: "\r\n", ComparePathsOptions: tspath.ComparePathsOptions{ CurrentDirectory: basePath, @@ -1026,7 +1026,7 @@ func TestParseSrcCompiler(t *testing.T) { if len(parsed.Diagnostics()) > 0 { for _, error := range parsed.Diagnostics() { - t.Log(error.Message()) + t.Log(error.Localize(locale.Default)) } t.FailNow() } @@ -1048,7 +1048,7 @@ func TestParseSrcCompiler(t *testing.T) { if len(parseConfigFileContent.Errors) > 0 { for _, error := range parseConfigFileContent.Errors { - t.Log(error.Message()) + t.Log(error.Localize(locale.Default)) } t.FailNow() } diff --git a/internal/tspath/extension.go b/internal/tspath/extension.go index cc30d48a66..1b4422e791 100644 --- a/internal/tspath/extension.go +++ b/internal/tspath/extension.go @@ -51,7 +51,7 @@ func RemoveFileExtension(path string) string { } } // Otherwise just remove single dot extension, if any - return path[:len(path)-len(filepath.Ext(path))] + return path[:len(path)-len(filepath.Ext(path))] //nolint:forbidigo } func TryGetExtensionFromPath(p string) string { diff --git a/internal/tspath/path.go b/internal/tspath/path.go index fae3423721..de09221507 100644 --- a/internal/tspath/path.go +++ b/internal/tspath/path.go @@ -1127,3 +1127,7 @@ func getCommonParentsWorker(componentGroups [][]string, minComponents int, optio return [][]string{componentGroups[0][:maxDepth]} } + +func CompareNumberOfDirectorySeparators(path1, path2 string) int { + return cmp.Compare(strings.Count(path1, "/"), strings.Count(path2, "/")) +} diff --git a/internal/vfs/internal/internal.go b/internal/vfs/internal/internal.go index c761e20388..fd841de9bb 100644 --- a/internal/vfs/internal/internal.go +++ b/internal/vfs/internal/internal.go @@ -13,8 +13,8 @@ import ( ) type Common struct { - RootFor func(root string) fs.FS - Realpath func(path string) string + RootFor func(root string) fs.FS + IsReparsePoint func(path string) bool } func RootLength(p string) int { @@ -93,12 +93,12 @@ func (vfs *Common) GetAccessibleEntries(path string) (result vfs.Entries) { continue } - if entryType&fs.ModeIrregular != 0 && vfs.Realpath != nil { - // Could be a Windows junction. Try Realpath. - // TODO(jakebailey): use syscall.Win32FileAttributeData instead + if entryType&fs.ModeIrregular != 0 && vfs.IsReparsePoint != nil { + // Could be a Windows junction or other reparse point. + // Check using the OS-specific helper. fullPath := path + "/" + entry.Name() - if realpath := vfs.Realpath(fullPath); fullPath != realpath { - if stat := vfs.Stat(realpath); stat != nil { + if vfs.IsReparsePoint(fullPath) { + if stat := vfs.Stat(fullPath); stat != nil { addToResult(entry.Name(), stat.Mode()) } } diff --git a/internal/vfs/osvfs/helpers_test.go b/internal/vfs/osvfs/helpers_test.go new file mode 100644 index 0000000000..c1d4126f7e --- /dev/null +++ b/internal/vfs/osvfs/helpers_test.go @@ -0,0 +1,27 @@ +package osvfs + +import ( + "os" + "os/exec" + "runtime" + "strings" + "testing" + + "gotest.tools/v3/assert" +) + +func mklink(tb testing.TB, target, link string, isDir bool) { + tb.Helper() + + if runtime.GOOS == "windows" && isDir { + // Don't use os.Symlink on Windows, as it creates a "real" symlink, not a junction. + assert.NilError(tb, exec.Command("cmd", "/c", "mklink", "/J", link, target).Run()) + } else { + err := os.Symlink(target, link) + if err != nil && !isDir && runtime.GOOS == "windows" && strings.Contains(err.Error(), "A required privilege is not held by the client") { + tb.Log(err) + tb.Skip("file symlink support is not enabled without elevation or developer mode") + } + assert.NilError(tb, err) + } +} diff --git a/internal/vfs/osvfs/os.go b/internal/vfs/osvfs/os.go index d811d6ff71..81468db06d 100644 --- a/internal/vfs/osvfs/os.go +++ b/internal/vfs/osvfs/os.go @@ -21,8 +21,8 @@ func FS() vfs.FS { var osVFS vfs.FS = &osFS{ common: internal.Common{ - RootFor: os.DirFS, - Realpath: osFSRealpath, + RootFor: os.DirFS, + IsReparsePoint: isReparsePoint, }, } diff --git a/internal/vfs/osvfs/realpath_test.go b/internal/vfs/osvfs/realpath_test.go index e0f01c3173..b97911c6ea 100644 --- a/internal/vfs/osvfs/realpath_test.go +++ b/internal/vfs/osvfs/realpath_test.go @@ -4,8 +4,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" - "strings" "testing" "github.com/microsoft/typescript-go/internal/tspath" @@ -54,22 +52,6 @@ func setupSymlinks(tb testing.TB) (targetFile, linkFile string) { return targetFile, linkFile } -func mklink(tb testing.TB, target, link string, isDir bool) { - tb.Helper() - - if runtime.GOOS == "windows" && isDir { - // Don't use os.Symlink on Windows, as it creates a "real" symlink, not a junction. - assert.NilError(tb, exec.Command("cmd", "/c", "mklink", "/J", link, target).Run()) - } else { - err := os.Symlink(target, link) - if err != nil && !isDir && runtime.GOOS == "windows" && strings.Contains(err.Error(), "A required privilege is not held by the client") { - tb.Log(err) - tb.Skip("file symlink support is not enabled without elevation or developer mode") - } - assert.NilError(tb, err) - } -} - func BenchmarkRealpath(b *testing.B) { targetFile, linkFile := setupSymlinks(b) diff --git a/internal/vfs/osvfs/reparsepoint_other.go b/internal/vfs/osvfs/reparsepoint_other.go new file mode 100644 index 0000000000..1206b6bc36 --- /dev/null +++ b/internal/vfs/osvfs/reparsepoint_other.go @@ -0,0 +1,6 @@ +//go:build !windows + +package osvfs + +// Only Windows has reparse points; leave this nil for other OSes. +var isReparsePoint func(path string) bool diff --git a/internal/vfs/osvfs/reparsepoint_windows.go b/internal/vfs/osvfs/reparsepoint_windows.go new file mode 100644 index 0000000000..12a1e59cb0 --- /dev/null +++ b/internal/vfs/osvfs/reparsepoint_windows.go @@ -0,0 +1,29 @@ +package osvfs + +import ( + "syscall" + "unsafe" +) + +func isReparsePoint(path string) bool { + if len(path) >= 248 { + path = `\\?\` + path + } + + pathUTF16, err := syscall.UTF16PtrFromString(path) + if err != nil { + return false + } + + var data syscall.Win32FileAttributeData + err = syscall.GetFileAttributesEx( + pathUTF16, + syscall.GetFileExInfoStandard, + (*byte)(unsafe.Pointer(&data)), + ) + if err != nil { + return false + } + + return data.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0 +} diff --git a/internal/vfs/osvfs/reparsepoint_windows_test.go b/internal/vfs/osvfs/reparsepoint_windows_test.go new file mode 100644 index 0000000000..c1dba9ecd8 --- /dev/null +++ b/internal/vfs/osvfs/reparsepoint_windows_test.go @@ -0,0 +1,169 @@ +package osvfs + +import ( + "os" + "os/exec" + "path/filepath" + "testing" + + "gotest.tools/v3/assert" +) + +func TestIsReparsePoint(t *testing.T) { + t.Parallel() + + tmp := t.TempDir() + + t.Run("regular file", func(t *testing.T) { + t.Parallel() + file := filepath.Join(tmp, "regular.txt") + assert.NilError(t, os.WriteFile(file, []byte("hello"), 0o666)) + assert.Equal(t, isReparsePoint(file), false) + }) + + t.Run("regular directory", func(t *testing.T) { + t.Parallel() + dir := filepath.Join(tmp, "regular-dir") + assert.NilError(t, os.MkdirAll(dir, 0o777)) + assert.Equal(t, isReparsePoint(dir), false) + }) + + t.Run("junction point", func(t *testing.T) { + t.Parallel() + target := filepath.Join(tmp, "junction-target") + link := filepath.Join(tmp, "junction-link") + assert.NilError(t, os.MkdirAll(target, 0o777)) + mklink(t, target, link, true) + assert.Equal(t, isReparsePoint(link), true) + }) + + t.Run("file symlink", func(t *testing.T) { + t.Parallel() + target := filepath.Join(tmp, "symlink-target.txt") + link := filepath.Join(tmp, "symlink-link.txt") + assert.NilError(t, os.WriteFile(target, []byte("hello"), 0o666)) + mklink(t, target, link, false) + assert.Equal(t, isReparsePoint(link), true) + }) + + t.Run("directory symlink", func(t *testing.T) { + t.Parallel() + target := filepath.Join(tmp, "dir-symlink-target") + link := filepath.Join(tmp, "dir-symlink-link") + assert.NilError(t, os.MkdirAll(target, 0o777)) + mklink(t, target, link, false) + assert.Equal(t, isReparsePoint(link), true) + }) + + t.Run("nonexistent path", func(t *testing.T) { + t.Parallel() + nonexistent := filepath.Join(tmp, "does-not-exist") + assert.Equal(t, isReparsePoint(nonexistent), false) + }) + + t.Run("empty path", func(t *testing.T) { + t.Parallel() + assert.Equal(t, isReparsePoint(""), false) + }) + + t.Run("invalid path with null byte", func(t *testing.T) { + t.Parallel() + assert.Equal(t, isReparsePoint("invalid\x00path"), false) + }) +} + +func TestIsReparsePointLongPath(t *testing.T) { + t.Parallel() + + tmp := t.TempDir() + + // Create a deeply nested path that exceeds 248 characters + longPathBase := tmp + pathComponent := "very_long_directory_name_to_exceed_max_path_limit_abcdefghijklmnopqrstuvwxyz" + + for len(longPathBase) < 250 { + longPathBase = filepath.Join(longPathBase, pathComponent) + } + + target := filepath.Join(longPathBase, "target") + link := filepath.Join(longPathBase, "link") + + // Use \\?\ prefix to enable long path support for mklink + longTarget := `\\?\` + target + longLink := `\\?\` + link + + assert.NilError(t, os.MkdirAll(longTarget, 0o777)) + assert.NilError(t, exec.Command("cmd", "/c", "mklink", "/J", longLink, longTarget).Run()) + + // With long path support enabled, this should work even for paths >= 248 chars + assert.Equal(t, isReparsePoint(link), true) +} + +func TestIsReparsePointNestedInSymlink(t *testing.T) { + t.Parallel() + + tmp := t.TempDir() + + // Create a structure: target/inner-target, link -> target, then check link/inner-link + target := filepath.Join(tmp, "target") + innerTarget := filepath.Join(target, "inner-target") + assert.NilError(t, os.MkdirAll(innerTarget, 0o777)) + + link := filepath.Join(tmp, "link") + mklink(t, target, link, true) + + // Create a junction inside the target + innerLink := filepath.Join(target, "inner-link") + mklink(t, innerTarget, innerLink, true) + + // Check the junction through the symlink path + nestedPath := filepath.Join(link, "inner-link") + assert.Equal(t, isReparsePoint(nestedPath), true) +} + +func TestIsReparsePointRelativePath(t *testing.T) { //nolint:paralleltest // Cannot use t.Parallel() with t.Chdir() + tmp := t.TempDir() + t.Chdir(tmp) + + target := "target-rel" + link := "link-rel" + assert.NilError(t, os.MkdirAll(target, 0o777)) + mklink(t, target, link, true) + + assert.Equal(t, isReparsePoint(link), true) + assert.Equal(t, isReparsePoint(target), false) +} + +func BenchmarkIsSymlinkOrJunction(b *testing.B) { + tmp := b.TempDir() + + regularFile := filepath.Join(tmp, "regular.txt") + assert.NilError(b, os.WriteFile(regularFile, []byte("hello"), 0o666)) + + target := filepath.Join(tmp, "target") + link := filepath.Join(tmp, "link") + assert.NilError(b, os.MkdirAll(target, 0o777)) + assert.NilError(b, exec.Command("cmd", "/c", "mklink", "/J", link, target).Run()) + + b.Run("regular file", func(b *testing.B) { + b.ReportAllocs() + for b.Loop() { + isReparsePoint(regularFile) + } + }) + + b.Run("junction", func(b *testing.B) { + b.ReportAllocs() + for b.Loop() { + isReparsePoint(link) + } + }) + + b.Run("nonexistent", func(b *testing.B) { + b.ReportAllocs() + nonexistent := filepath.Join(tmp, "does-not-exist") + for b.Loop() { + isReparsePoint(nonexistent) + } + }) +} diff --git a/internal/vfs/utilities.go b/internal/vfs/utilities.go index d86a7f0d10..34a5ed38ee 100644 --- a/internal/vfs/utilities.go +++ b/internal/vfs/utilities.go @@ -24,15 +24,15 @@ type FileMatcherPatterns struct { basePaths []string } -type usage string +type Usage string const ( - usageFiles usage = "files" - usageDirectories usage = "directories" - usageExclude usage = "exclude" + usageFiles Usage = "files" + usageDirectories Usage = "directories" + usageExclude Usage = "exclude" ) -func GetRegularExpressionsForWildcards(specs []string, basePath string, usage usage) []string { +func GetRegularExpressionsForWildcards(specs []string, basePath string, usage Usage) []string { if len(specs) == 0 { return nil } @@ -41,7 +41,7 @@ func GetRegularExpressionsForWildcards(specs []string, basePath string, usage us }) } -func GetRegularExpressionForWildcard(specs []string, basePath string, usage usage) string { +func GetRegularExpressionForWildcard(specs []string, basePath string, usage Usage) string { patterns := GetRegularExpressionsForWildcards(specs, basePath, usage) if len(patterns) == 0 { return "" @@ -138,7 +138,7 @@ var excludeMatcher = WildcardMatcher{ }, } -var wildcardMatchers = map[usage]WildcardMatcher{ +var wildcardMatchers = map[Usage]WildcardMatcher{ usageFiles: filesMatcher, usageDirectories: directoriesMatcher, usageExclude: excludeMatcher, @@ -147,7 +147,7 @@ var wildcardMatchers = map[usage]WildcardMatcher{ func GetPatternFromSpec( spec string, basePath string, - usage usage, + usage Usage, ) string { pattern := getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]) if pattern == "" { @@ -160,7 +160,7 @@ func GetPatternFromSpec( func getSubPatternFromSpec( spec string, basePath string, - usage usage, + usage Usage, matcher WildcardMatcher, ) string { matcher = wildcardMatchers[usage] @@ -314,11 +314,10 @@ var ( ) func GetRegexFromPattern(pattern string, useCaseSensitiveFileNames bool) *regexp2.Regexp { - flags := regexp2.ECMAScript + opts := regexp2.RegexOptions(regexp2.ECMAScript) if !useCaseSensitiveFileNames { - flags |= regexp2.IgnoreCase + opts |= regexp2.IgnoreCase } - opts := regexp2.RegexOptions(flags) key := regexp2CacheKey{pattern, opts} diff --git a/internal/vfs/vfstest/vfstest_test.go b/internal/vfs/vfstest/vfstest_test.go index 0e2337fb84..7ce7e520a0 100644 --- a/internal/vfs/vfstest/vfstest_test.go +++ b/internal/vfs/vfstest/vfstest_test.go @@ -274,10 +274,7 @@ func TestStress(t *testing.T) { var wg sync.WaitGroup for range runtime.GOMAXPROCS(0) { - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { randomOps := slices.Clone(ops) rand.Shuffle(len(randomOps), func(i, j int) { randomOps[i], randomOps[j] = randomOps[j], randomOps[i] @@ -286,8 +283,9 @@ func TestStress(t *testing.T) { for i := range 10000 { randomOps[i%len(randomOps)]() } - }() + }) } + wg.Wait() } func TestParentDirFile(t *testing.T) { diff --git a/package-lock.json b/package-lock.json index adb5f8575c..54b39f6c56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,8 +20,8 @@ "chokidar": "^4.0.3", "dprint": "^0.50.2", "execa": "^9.6.0", - "glob": "^10.4.5", - "hereby": "^1.11.0", + "glob": "^10.5.0", + "hereby": "^1.11.1", "p-limit": "^6.2.0", "picocolors": "^1.1.1", "typescript": "^5.9.3", @@ -36,8 +36,8 @@ }, "devDependencies": { "@types/vscode": "^1.100.0", - "@vscode/vsce": "^3.6.2", - "esbuild": "^0.25.10" + "@vscode/vsce": "^3.7.0", + "esbuild": "^0.27.0" }, "engines": { "vscode": "^1.100.0" @@ -129,9 +129,9 @@ } }, "node_modules/@azure/core-rest-pipeline": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.22.1.tgz", - "integrity": "sha512-UVZlVLfLyz6g3Hy7GNDpooMQonUygH7ghdiSASOOHy97fKj/mPLqgDX7aidOijn+sCMU+WU8NjlPlNTgnvbcGA==", + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.22.2.tgz", + "integrity": "sha512-MzHym+wOi8CLUlKCQu12de0nwcq9k9Kuv43j4Wa++CsCpJwps2eeBQwD2Bu8snkxTtDKDx4GwjuR9E8yC8LNrg==", "dev": true, "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -173,9 +173,9 @@ } }, "node_modules/@azure/identity": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.12.0.tgz", - "integrity": "sha512-6vuh2R3Cte6SD6azNalLCjIDoryGdcvDVEV7IDRPtm5lHX5ffkDlIalaoOp5YJU08e4ipjJENel20kSMDLAcug==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.0.tgz", + "integrity": "sha512-uWC0fssc+hs1TGGVkkghiaFkkS7NkTxfnCH+Hdg+yTehTpMcehpok4PgUKKdyCH+9ldu6FhiHRv84Ntqj1vVcw==", "dev": true, "dependencies": { "@azure/abort-controller": "^2.0.0", @@ -208,33 +208,33 @@ } }, "node_modules/@azure/msal-browser": { - "version": "4.24.1", - "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-4.24.1.tgz", - "integrity": "sha512-e4sp8ihJIyZQvN0ZM1MMuKlEiiLWUS9V9+kxsVAc6K8MtpXHui8VINmKUxXH0OOksLhFDpdq4sGW1w6uYp431A==", + "version": "4.26.1", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-4.26.1.tgz", + "integrity": "sha512-GGCIsZXxyNm5QcQZ4maA9q+9UWmM+/87G+ybvPkrE32el1URSa9WYt0t67ks3/P0gspZX9RoEqyLqJ/X/JDnBQ==", "dev": true, "dependencies": { - "@azure/msal-common": "15.13.0" + "@azure/msal-common": "15.13.1" }, "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-common": { - "version": "15.13.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-15.13.0.tgz", - "integrity": "sha512-8oF6nj02qX7eE/6+wFT5NluXRHc05AgdCC3fJnkjiJooq8u7BcLmxaYYSwc2AfEkWRMRi6Eyvvbeqk4U4412Ag==", + "version": "15.13.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-15.13.1.tgz", + "integrity": "sha512-vQYQcG4J43UWgo1lj7LcmdsGUKWYo28RfEvDQAEMmQIMjSFufvb+pS0FJ3KXmrPmnWlt1vHDl3oip6mIDUQ4uA==", "dev": true, "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-node": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-3.8.0.tgz", - "integrity": "sha512-23BXm82Mp5XnRhrcd4mrHa0xuUNRp96ivu3nRatrfdAqjoeWAGyD0eEAafxAOHAEWWmdlyFK4ELFcdziXyw2sA==", + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-3.8.2.tgz", + "integrity": "sha512-dQrex2LiXwlCe9WuBHnCsY+xxLyuMXSd2SDEYJuhqB7cE8u6QafiC1xy8j8eBjGO30AsRi2M6amH0ZKk7vJpjA==", "dev": true, "dependencies": { - "@azure/msal-common": "15.13.0", + "@azure/msal-common": "15.13.1", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, @@ -257,9 +257,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", - "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", "dev": true, "engines": { "node": ">=6.9.0" @@ -383,9 +383,9 @@ ] }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.10.tgz", - "integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.0.tgz", + "integrity": "sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A==", "cpu": [ "ppc64" ], @@ -399,9 +399,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.10.tgz", - "integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.0.tgz", + "integrity": "sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ==", "cpu": [ "arm" ], @@ -415,9 +415,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.10.tgz", - "integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.0.tgz", + "integrity": "sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ==", "cpu": [ "arm64" ], @@ -431,9 +431,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.10.tgz", - "integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.0.tgz", + "integrity": "sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q==", "cpu": [ "x64" ], @@ -447,9 +447,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.10.tgz", - "integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.0.tgz", + "integrity": "sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg==", "cpu": [ "arm64" ], @@ -463,9 +463,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.10.tgz", - "integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.0.tgz", + "integrity": "sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g==", "cpu": [ "x64" ], @@ -479,9 +479,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.10.tgz", - "integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.0.tgz", + "integrity": "sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw==", "cpu": [ "arm64" ], @@ -495,9 +495,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.10.tgz", - "integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.0.tgz", + "integrity": "sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g==", "cpu": [ "x64" ], @@ -511,9 +511,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.10.tgz", - "integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.0.tgz", + "integrity": "sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ==", "cpu": [ "arm" ], @@ -527,9 +527,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.10.tgz", - "integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.0.tgz", + "integrity": "sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ==", "cpu": [ "arm64" ], @@ -543,9 +543,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.10.tgz", - "integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.0.tgz", + "integrity": "sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw==", "cpu": [ "ia32" ], @@ -559,9 +559,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.10.tgz", - "integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.0.tgz", + "integrity": "sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg==", "cpu": [ "loong64" ], @@ -575,9 +575,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.10.tgz", - "integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.0.tgz", + "integrity": "sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg==", "cpu": [ "mips64el" ], @@ -591,9 +591,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.10.tgz", - "integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.0.tgz", + "integrity": "sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA==", "cpu": [ "ppc64" ], @@ -607,9 +607,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.10.tgz", - "integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.0.tgz", + "integrity": "sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ==", "cpu": [ "riscv64" ], @@ -623,9 +623,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.10.tgz", - "integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.0.tgz", + "integrity": "sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w==", "cpu": [ "s390x" ], @@ -639,9 +639,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.10.tgz", - "integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.0.tgz", + "integrity": "sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw==", "cpu": [ "x64" ], @@ -655,9 +655,9 @@ } }, "node_modules/@esbuild/netbsd-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.10.tgz", - "integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.0.tgz", + "integrity": "sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w==", "cpu": [ "arm64" ], @@ -671,9 +671,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.10.tgz", - "integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.0.tgz", + "integrity": "sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA==", "cpu": [ "x64" ], @@ -687,9 +687,9 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.10.tgz", - "integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.0.tgz", + "integrity": "sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ==", "cpu": [ "arm64" ], @@ -703,9 +703,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.10.tgz", - "integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.0.tgz", + "integrity": "sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A==", "cpu": [ "x64" ], @@ -719,9 +719,9 @@ } }, "node_modules/@esbuild/openharmony-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.10.tgz", - "integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.0.tgz", + "integrity": "sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA==", "cpu": [ "arm64" ], @@ -734,10 +734,26 @@ "node": ">=18" } }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.0.tgz", + "integrity": "sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/win32-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.10.tgz", - "integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.0.tgz", + "integrity": "sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg==", "cpu": [ "arm64" ], @@ -751,9 +767,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.10.tgz", - "integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.0.tgz", + "integrity": "sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ==", "cpu": [ "ia32" ], @@ -767,9 +783,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.10.tgz", - "integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.0.tgz", + "integrity": "sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg==", "cpu": [ "x64" ], @@ -1045,24 +1061,24 @@ } }, "node_modules/@textlint/ast-node-types": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-15.2.2.tgz", - "integrity": "sha512-9ByYNzWV8tpz6BFaRzeRzIov8dkbSZu9q7IWqEIfmRuLWb2qbI/5gTvKcoWT1HYs4XM7IZ8TKSXcuPvMb6eorA==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-15.4.0.tgz", + "integrity": "sha512-IqY8i7IOGuvy05wZxISB7Me1ZyrvhaQGgx6DavfQjH3cfwpPFdDbDYmMXMuSv2xLS1kDB1kYKBV7fL2Vi16lRA==", "dev": true }, "node_modules/@textlint/linter-formatter": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/linter-formatter/-/linter-formatter-15.2.2.tgz", - "integrity": "sha512-oMVaMJ3exFvXhCj3AqmCbLaeYrTNLqaJnLJMIlmnRM3/kZdxvku4OYdaDzgtlI194cVxamOY5AbHBBVnY79kEg==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/linter-formatter/-/linter-formatter-15.4.0.tgz", + "integrity": "sha512-rfqOZmnI1Wwc/Pa4LK+vagvVPmvxf9oRsBRqIOB04DwhucingZyAIJI/TyG18DIDYbP2aFXBZ3oOvyAxHe/8PQ==", "dev": true, "dependencies": { "@azu/format-text": "^1.0.2", "@azu/style-format": "^1.0.1", - "@textlint/module-interop": "15.2.2", - "@textlint/resolver": "15.2.2", - "@textlint/types": "15.2.2", + "@textlint/module-interop": "15.4.0", + "@textlint/resolver": "15.4.0", + "@textlint/types": "15.4.0", "chalk": "^4.1.2", - "debug": "^4.4.1", + "debug": "^4.4.3", "js-yaml": "^3.14.1", "lodash": "^4.17.21", "pluralize": "^2.0.0", @@ -1190,24 +1206,24 @@ } }, "node_modules/@textlint/module-interop": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/module-interop/-/module-interop-15.2.2.tgz", - "integrity": "sha512-2rmNcWrcqhuR84Iio1WRzlc4tEoOMHd6T7urjtKNNefpTt1owrTJ9WuOe60yD3FrTW0J/R0ux5wxUbP/eaeFOA==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/module-interop/-/module-interop-15.4.0.tgz", + "integrity": "sha512-uGf+SFIfzOLCbZI0gp+2NLsrkSArsvEWulPP6lJuKp7yRHadmy7Xf/YHORe46qhNyyxc8PiAfiixHJSaHGUrGg==", "dev": true }, "node_modules/@textlint/resolver": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/resolver/-/resolver-15.2.2.tgz", - "integrity": "sha512-4hGWjmHt0y+5NAkoYZ8FvEkj8Mez9TqfbTm3BPjoV32cIfEixl2poTOgapn1rfm73905GSO3P1jiWjmgvii13Q==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/resolver/-/resolver-15.4.0.tgz", + "integrity": "sha512-Vh/QceKZQHFJFG4GxxIsKM1Xhwv93mbtKHmFE5/ybal1mIKHdqF03Z9Guaqt6Sx/AeNUshq0hkMOEhEyEWnehQ==", "dev": true }, "node_modules/@textlint/types": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/types/-/types-15.2.2.tgz", - "integrity": "sha512-X2BHGAR3yXJsCAjwYEDBIk9qUDWcH4pW61ISfmtejau+tVqKtnbbvEZnMTb6mWgKU1BvTmftd5DmB1XVDUtY3g==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/types/-/types-15.4.0.tgz", + "integrity": "sha512-ZMwJgw/xjxJufOD+IB7I2Enl9Si4Hxo04B76RwUZ5cKBKzOPcmd6WvGe2F7jqdgmTdGnfMU+Bo/joQrjPNIWqg==", "dev": true, "dependencies": { - "@textlint/ast-node-types": "15.2.2" + "@textlint/ast-node-types": "15.4.0" } }, "node_modules/@types/adm-zip": { @@ -1220,12 +1236,12 @@ } }, "node_modules/@types/node": { - "version": "24.6.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.6.1.tgz", - "integrity": "sha512-ljvjjs3DNXummeIaooB4cLBKg2U6SPI6Hjra/9rRIy7CpM0HpLtG9HptkMKAb4HYWy5S7HUvJEuWgr/y0U8SHw==", + "version": "24.10.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", + "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "dev": true, "dependencies": { - "undici-types": "~7.13.0" + "undici-types": "~7.16.0" } }, "node_modules/@types/normalize-package-data": { @@ -1241,9 +1257,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.104.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.104.0.tgz", - "integrity": "sha512-0KwoU2rZ2ecsTGFxo4K1+f+AErRsYW0fsp6A0zufzGuhyczc2IoKqYqcwXidKXmy2u8YB2GsYsOtiI9Izx3Tig==", + "version": "1.106.1", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.106.1.tgz", + "integrity": "sha512-R/HV8u2h8CAddSbX8cjpdd7B8/GnE4UjgjpuGuHcbp1xV6yh4OeqU4L1pKjlwujCrSFS0MOpwJAIs/NexMB1fQ==", "dev": true }, "node_modules/@types/which": { @@ -1263,7 +1279,7 @@ "node_modules/@typescript/libsyncrpc": { "version": "0.0.0", "resolved": "git+ssh://git@github.com/microsoft/libsyncrpc.git#95d8cfcdd52a33169677fbc3b338a745accd7fdb", - "integrity": "sha512-+cxoBpDD+MOdgpnUEIdkxskwV2rKFQwgxHyWTR4mH0ScXbWcRUQGQdP/J7dgVyjXUMZd+eCIY1ism7EdLIyKwg==", + "integrity": "sha512-r5WzumdSiLEdvSPkDJxIF7aTWuI6oq/zpihBoexnk9C6E2lfukcZBlBJMCeiicMWkIj506c1K7m+YOuPbmB5Ng==", "license": "MIT", "engines": { "node": ">= 10.16.0 < 11 || >= 11.8.0 < 12 || >= 12.0.0" @@ -1274,9 +1290,9 @@ "link": true }, "node_modules/@typespec/ts-http-runtime": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.1.tgz", - "integrity": "sha512-SnbaqayTVFEA6/tYumdF0UmybY0KHyKwGPBXnyckFlrrKdhWFrL3a2HIPXHjht5ZOElKGcXfD2D63P36btb+ww==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz", + "integrity": "sha512-IlqQ/Gv22xUC1r/WQm4StLkYQmaaTsXAhUVsNE0+xiyf0yRFiH5++q78U3bw6bLKDCTmh0uqKB9eG9+Bt75Dkg==", "dev": true, "dependencies": { "http-proxy-agent": "^7.0.0", @@ -1288,9 +1304,9 @@ } }, "node_modules/@vscode/vsce": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.6.2.tgz", - "integrity": "sha512-gvBfarWF+Ii20ESqjA3dpnPJpQJ8fFJYtcWtjwbRADommCzGg1emtmb34E+DKKhECYvaVyAl+TF9lWS/3GSPvg==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.7.0.tgz", + "integrity": "sha512-LY9r2T4joszRjz4d92ZPl6LTBUPS4IWH9gG/3JUv+1QyBJrveZlcVISuiaq0EOpmcgFh0GgVgKD4rD/21Tu8sA==", "dev": true, "dependencies": { "@azure/identity": "^4.1.0", @@ -1334,16 +1350,16 @@ } }, "node_modules/@vscode/vsce-sign": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/@vscode/vsce-sign/-/vsce-sign-2.0.8.tgz", - "integrity": "sha512-H7p8E11cZMj6mt8xIi3QXZ7dSU/2MH3Y7c+5JfUhHAV4xfaPNc8ozwLVK282c6ah596KoIJIdPUlNHV7Qs/5JA==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@vscode/vsce-sign/-/vsce-sign-2.0.9.tgz", + "integrity": "sha512-8IvaRvtFyzUnGGl3f5+1Cnor3LqaUWvhaUjAYO8Y39OUYlOf3cRd+dowuQYLpZcP3uwSG+mURwjEBOSq4SOJ0g==", "dev": true, "hasInstallScript": true, "optionalDependencies": { "@vscode/vsce-sign-alpine-arm64": "2.0.6", "@vscode/vsce-sign-alpine-x64": "2.0.6", - "@vscode/vsce-sign-darwin-arm64": "2.0.2", - "@vscode/vsce-sign-darwin-x64": "2.0.2", + "@vscode/vsce-sign-darwin-arm64": "2.0.6", + "@vscode/vsce-sign-darwin-x64": "2.0.6", "@vscode/vsce-sign-linux-arm": "2.0.6", "@vscode/vsce-sign-linux-arm64": "2.0.6", "@vscode/vsce-sign-linux-x64": "2.0.6", @@ -1378,9 +1394,9 @@ ] }, "node_modules/@vscode/vsce-sign-darwin-arm64": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-arm64/-/vsce-sign-darwin-arm64-2.0.2.tgz", - "integrity": "sha512-rz8F4pMcxPj8fjKAJIfkUT8ycG9CjIp888VY/6pq6cuI2qEzQ0+b5p3xb74CJnBbSC0p2eRVoe+WgNCAxCLtzQ==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-arm64/-/vsce-sign-darwin-arm64-2.0.6.tgz", + "integrity": "sha512-5HMHaJRIQuozm/XQIiJiA0W9uhdblwwl2ZNDSSAeXGO9YhB9MH5C4KIHOmvyjUnKy4UCuiP43VKpIxW1VWP4tQ==", "cpu": [ "arm64" ], @@ -1391,9 +1407,9 @@ ] }, "node_modules/@vscode/vsce-sign-darwin-x64": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-x64/-/vsce-sign-darwin-x64-2.0.2.tgz", - "integrity": "sha512-MCjPrQ5MY/QVoZ6n0D92jcRb7eYvxAujG/AH2yM6lI0BspvJQxp0o9s5oiAM9r32r9tkLpiy5s2icsbwefAQIw==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-x64/-/vsce-sign-darwin-x64-2.0.6.tgz", + "integrity": "sha512-25GsUbTAiNfHSuRItoQafXOIpxlYj+IXb4/qarrXu7kmbH94jlm5sdWSCKrrREs8+GsXF1b+l3OB7VJy5jsykw==", "cpu": [ "x64" ], @@ -1528,14 +1544,14 @@ "dev": true }, "node_modules/@vscode/vsce/node_modules/glob": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", - "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.1.0.tgz", + "integrity": "sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==", "dev": true, "dependencies": { "foreground-child": "^3.3.1", "jackspeak": "^4.1.1", - "minimatch": "^10.0.3", + "minimatch": "^10.1.1", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" @@ -1551,9 +1567,9 @@ } }, "node_modules/@vscode/vsce/node_modules/glob/node_modules/minimatch": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", - "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz", + "integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==", "dev": true, "dependencies": { "@isaacs/brace-expansion": "^5.0.0" @@ -1611,9 +1627,9 @@ } }, "node_modules/@vscode/vsce/node_modules/path-scurry": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", - "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz", + "integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==", "dev": true, "dependencies": { "lru-cache": "^11.0.0", @@ -1673,9 +1689,9 @@ } }, "node_modules/ansi-escapes": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.1.1.tgz", - "integrity": "sha512-Zhl0ErHcSRUaVfGUeUdDuLgpkEo8KIFjB4Y9uAc46ScOpdDiU1Dbyplh7qWJeJ/ZHpbyMSM26+X3BySgnIz40Q==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.2.0.tgz", + "integrity": "sha512-g6LhBsl+GBPRWGWsBtutpzBYuIIdBkLEvad5C/va/74Db018+5TZiyA26cZJAr3Rft5lprVqOIPxf5Vid6tqAw==", "dev": true, "dependencies": { "environment": "^1.0.0" @@ -2173,9 +2189,9 @@ } }, "node_modules/default-browser": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", - "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.4.0.tgz", + "integrity": "sha512-XDuvSq38Hr1MdN47EDvYtx3U0MTqpCEn+F6ft8z2vYDzMrvQhVp0ui9oQdqW3MvK3vqUETglt1tVGgjLuJ5izg==", "dev": true, "dependencies": { "bundle-name": "^4.1.0", @@ -2189,9 +2205,9 @@ } }, "node_modules/default-browser-id": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", - "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", "dev": true, "engines": { "node": ">=18" @@ -2222,9 +2238,9 @@ } }, "node_modules/detect-libc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.1.tgz", - "integrity": "sha512-ecqj/sy1jcK1uWrwpR67UhYrIFQ+5WlGxth34WquCbamhFA6hkkwiu37o6J5xCHdo1oixJRfVRw+ywV+Hq/0Aw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", "dev": true, "optional": true, "engines": { @@ -2451,9 +2467,9 @@ } }, "node_modules/esbuild": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz", - "integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.0.tgz", + "integrity": "sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==", "dev": true, "hasInstallScript": true, "bin": { @@ -2463,32 +2479,32 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.25.10", - "@esbuild/android-arm": "0.25.10", - "@esbuild/android-arm64": "0.25.10", - "@esbuild/android-x64": "0.25.10", - "@esbuild/darwin-arm64": "0.25.10", - "@esbuild/darwin-x64": "0.25.10", - "@esbuild/freebsd-arm64": "0.25.10", - "@esbuild/freebsd-x64": "0.25.10", - "@esbuild/linux-arm": "0.25.10", - "@esbuild/linux-arm64": "0.25.10", - "@esbuild/linux-ia32": "0.25.10", - "@esbuild/linux-loong64": "0.25.10", - "@esbuild/linux-mips64el": "0.25.10", - "@esbuild/linux-ppc64": "0.25.10", - "@esbuild/linux-riscv64": "0.25.10", - "@esbuild/linux-s390x": "0.25.10", - "@esbuild/linux-x64": "0.25.10", - "@esbuild/netbsd-arm64": "0.25.10", - "@esbuild/netbsd-x64": "0.25.10", - "@esbuild/openbsd-arm64": "0.25.10", - "@esbuild/openbsd-x64": "0.25.10", - "@esbuild/openharmony-arm64": "0.25.10", - "@esbuild/sunos-x64": "0.25.10", - "@esbuild/win32-arm64": "0.25.10", - "@esbuild/win32-ia32": "0.25.10", - "@esbuild/win32-x64": "0.25.10" + "@esbuild/aix-ppc64": "0.27.0", + "@esbuild/android-arm": "0.27.0", + "@esbuild/android-arm64": "0.27.0", + "@esbuild/android-x64": "0.27.0", + "@esbuild/darwin-arm64": "0.27.0", + "@esbuild/darwin-x64": "0.27.0", + "@esbuild/freebsd-arm64": "0.27.0", + "@esbuild/freebsd-x64": "0.27.0", + "@esbuild/linux-arm": "0.27.0", + "@esbuild/linux-arm64": "0.27.0", + "@esbuild/linux-ia32": "0.27.0", + "@esbuild/linux-loong64": "0.27.0", + "@esbuild/linux-mips64el": "0.27.0", + "@esbuild/linux-ppc64": "0.27.0", + "@esbuild/linux-riscv64": "0.27.0", + "@esbuild/linux-s390x": "0.27.0", + "@esbuild/linux-x64": "0.27.0", + "@esbuild/netbsd-arm64": "0.27.0", + "@esbuild/netbsd-x64": "0.27.0", + "@esbuild/openbsd-arm64": "0.27.0", + "@esbuild/openbsd-x64": "0.27.0", + "@esbuild/openharmony-arm64": "0.27.0", + "@esbuild/sunos-x64": "0.27.0", + "@esbuild/win32-arm64": "0.27.0", + "@esbuild/win32-ia32": "0.27.0", + "@esbuild/win32-x64": "0.27.0" } }, "node_modules/escape-string-regexp": { @@ -2658,9 +2674,9 @@ } }, "node_modules/form-data": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", - "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "dev": true, "dependencies": { "asynckit": "^0.4.0", @@ -2764,9 +2780,9 @@ "optional": true }, "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", "dev": true, "dependencies": { "foreground-child": "^3.1.0", @@ -2894,9 +2910,9 @@ } }, "node_modules/hereby": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.0.tgz", - "integrity": "sha512-Tdp03ueQL3w5eZCrQVW4POBDxg9ldjNyFrZYWt6ndMha5agyRUO8b+irOEG3B1RSS9/2LxSjjyG6DSxITouJzA==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.1.tgz", + "integrity": "sha512-3tcp92aUN6mSmWslo/EIoz3AAKa9GPmiJ3g0ZgXC8NGZPyh4J3T+JoGfD4JTiL31SW+pFliKKHu1uxa7nwDv0g==", "dev": true, "dependencies": { "command-line-usage": "^6.1.3", @@ -3268,9 +3284,9 @@ "dev": true }, "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, "dependencies": { "argparse": "^1.0.7", @@ -3619,9 +3635,9 @@ "link": true }, "node_modules/node-abi": { - "version": "3.77.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.77.0.tgz", - "integrity": "sha512-DSmt0OEcLoK4i3NuscSbGjOf3bqiDEutejqENSplMSFA/gmB8mkED9G4pKWnPl7MDU4rSHebKPHeitpDfyH0cQ==", + "version": "3.85.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.85.0.tgz", + "integrity": "sha512-zsFhmbkAzwhTft6nd3VxcG0cvJsT70rL+BIGHWVq5fi6MwGrHwzqKaxXE+Hl2GmnGItnDKPPkO5/LQqjVkIdFg==", "dev": true, "optional": true, "dependencies": { @@ -3639,16 +3655,16 @@ "optional": true }, "node_modules/node-sarif-builder": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/node-sarif-builder/-/node-sarif-builder-3.2.0.tgz", - "integrity": "sha512-kVIOdynrF2CRodHZeP/97Rh1syTUHBNiw17hUCIVhlhEsWlfJm19MuO56s4MdKbr22xWx6mzMnNAgXzVlIYM9Q==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/node-sarif-builder/-/node-sarif-builder-3.3.0.tgz", + "integrity": "sha512-8taRy2nQs1xNs8iO2F0XbkZJEliiijpKgFVcyiwKjJ2+3X59LVI3wY84qRdJwRDpIo5GK8wvb1pxcJ+JVu3jrg==", "dev": true, "dependencies": { "@types/sarif": "^2.1.7", "fs-extra": "^11.1.1" }, "engines": { - "node": ">=18" + "node": ">=20" } }, "node_modules/normalize-package-data": { @@ -3773,9 +3789,9 @@ } }, "node_modules/p-map": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.3.tgz", - "integrity": "sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4.tgz", + "integrity": "sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ==", "dev": true, "engines": { "node": ">=18" @@ -4088,9 +4104,9 @@ "dev": true }, "node_modules/rc-config-loader/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, "dependencies": { "argparse": "^2.0.1" @@ -4260,9 +4276,9 @@ "dev": true }, "node_modules/sax": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", - "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.3.tgz", + "integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==", "dev": true }, "node_modules/secretlint": { @@ -4287,9 +4303,9 @@ } }, "node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", "bin": { "semver": "bin/semver.js" }, @@ -4999,9 +5015,9 @@ } }, "node_modules/undici-types": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.13.0.tgz", - "integrity": "sha512-Ov2Rr9Sx+fRgagJ5AX0qvItZG/JKKoBRAVITs1zk7IqZGTJUwgUr7qoYBpWwakpWilTZFM98rG/AFRocu10iIQ==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true }, "node_modules/unicorn-magic": { @@ -5355,9 +5371,9 @@ } }, "node_modules/yocto-queue": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.1.tgz", - "integrity": "sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.2.tgz", + "integrity": "sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==", "dev": true, "engines": { "node": ">=12.20" @@ -5431,9 +5447,9 @@ } }, "@azure/core-rest-pipeline": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.22.1.tgz", - "integrity": "sha512-UVZlVLfLyz6g3Hy7GNDpooMQonUygH7ghdiSASOOHy97fKj/mPLqgDX7aidOijn+sCMU+WU8NjlPlNTgnvbcGA==", + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.22.2.tgz", + "integrity": "sha512-MzHym+wOi8CLUlKCQu12de0nwcq9k9Kuv43j4Wa++CsCpJwps2eeBQwD2Bu8snkxTtDKDx4GwjuR9E8yC8LNrg==", "dev": true, "requires": { "@azure/abort-controller": "^2.1.2", @@ -5466,9 +5482,9 @@ } }, "@azure/identity": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.12.0.tgz", - "integrity": "sha512-6vuh2R3Cte6SD6azNalLCjIDoryGdcvDVEV7IDRPtm5lHX5ffkDlIalaoOp5YJU08e4ipjJENel20kSMDLAcug==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.0.tgz", + "integrity": "sha512-uWC0fssc+hs1TGGVkkghiaFkkS7NkTxfnCH+Hdg+yTehTpMcehpok4PgUKKdyCH+9ldu6FhiHRv84Ntqj1vVcw==", "dev": true, "requires": { "@azure/abort-controller": "^2.0.0", @@ -5495,27 +5511,27 @@ } }, "@azure/msal-browser": { - "version": "4.24.1", - "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-4.24.1.tgz", - "integrity": "sha512-e4sp8ihJIyZQvN0ZM1MMuKlEiiLWUS9V9+kxsVAc6K8MtpXHui8VINmKUxXH0OOksLhFDpdq4sGW1w6uYp431A==", + "version": "4.26.1", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-4.26.1.tgz", + "integrity": "sha512-GGCIsZXxyNm5QcQZ4maA9q+9UWmM+/87G+ybvPkrE32el1URSa9WYt0t67ks3/P0gspZX9RoEqyLqJ/X/JDnBQ==", "dev": true, "requires": { - "@azure/msal-common": "15.13.0" + "@azure/msal-common": "15.13.1" } }, "@azure/msal-common": { - "version": "15.13.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-15.13.0.tgz", - "integrity": "sha512-8oF6nj02qX7eE/6+wFT5NluXRHc05AgdCC3fJnkjiJooq8u7BcLmxaYYSwc2AfEkWRMRi6Eyvvbeqk4U4412Ag==", + "version": "15.13.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-15.13.1.tgz", + "integrity": "sha512-vQYQcG4J43UWgo1lj7LcmdsGUKWYo28RfEvDQAEMmQIMjSFufvb+pS0FJ3KXmrPmnWlt1vHDl3oip6mIDUQ4uA==", "dev": true }, "@azure/msal-node": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-3.8.0.tgz", - "integrity": "sha512-23BXm82Mp5XnRhrcd4mrHa0xuUNRp96ivu3nRatrfdAqjoeWAGyD0eEAafxAOHAEWWmdlyFK4ELFcdziXyw2sA==", + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-3.8.2.tgz", + "integrity": "sha512-dQrex2LiXwlCe9WuBHnCsY+xxLyuMXSd2SDEYJuhqB7cE8u6QafiC1xy8j8eBjGO30AsRi2M6amH0ZKk7vJpjA==", "dev": true, "requires": { - "@azure/msal-common": "15.13.0", + "@azure/msal-common": "15.13.1", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" } @@ -5532,9 +5548,9 @@ } }, "@babel/helper-validator-identifier": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", - "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", "dev": true }, "@dprint/darwin-arm64": { @@ -5601,177 +5617,184 @@ "optional": true }, "@esbuild/aix-ppc64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.10.tgz", - "integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.0.tgz", + "integrity": "sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A==", "dev": true, "optional": true }, "@esbuild/android-arm": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.10.tgz", - "integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.0.tgz", + "integrity": "sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ==", "dev": true, "optional": true }, "@esbuild/android-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.10.tgz", - "integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.0.tgz", + "integrity": "sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ==", "dev": true, "optional": true }, "@esbuild/android-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.10.tgz", - "integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.0.tgz", + "integrity": "sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q==", "dev": true, "optional": true }, "@esbuild/darwin-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.10.tgz", - "integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.0.tgz", + "integrity": "sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg==", "dev": true, "optional": true }, "@esbuild/darwin-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.10.tgz", - "integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.0.tgz", + "integrity": "sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g==", "dev": true, "optional": true }, "@esbuild/freebsd-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.10.tgz", - "integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.0.tgz", + "integrity": "sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw==", "dev": true, "optional": true }, "@esbuild/freebsd-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.10.tgz", - "integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.0.tgz", + "integrity": "sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g==", "dev": true, "optional": true }, "@esbuild/linux-arm": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.10.tgz", - "integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.0.tgz", + "integrity": "sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ==", "dev": true, "optional": true }, "@esbuild/linux-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.10.tgz", - "integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.0.tgz", + "integrity": "sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ==", "dev": true, "optional": true }, "@esbuild/linux-ia32": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.10.tgz", - "integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.0.tgz", + "integrity": "sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw==", "dev": true, "optional": true }, "@esbuild/linux-loong64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.10.tgz", - "integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.0.tgz", + "integrity": "sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg==", "dev": true, "optional": true }, "@esbuild/linux-mips64el": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.10.tgz", - "integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.0.tgz", + "integrity": "sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg==", "dev": true, "optional": true }, "@esbuild/linux-ppc64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.10.tgz", - "integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.0.tgz", + "integrity": "sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA==", "dev": true, "optional": true }, "@esbuild/linux-riscv64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.10.tgz", - "integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.0.tgz", + "integrity": "sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ==", "dev": true, "optional": true }, "@esbuild/linux-s390x": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.10.tgz", - "integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.0.tgz", + "integrity": "sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w==", "dev": true, "optional": true }, "@esbuild/linux-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.10.tgz", - "integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.0.tgz", + "integrity": "sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw==", "dev": true, "optional": true }, "@esbuild/netbsd-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.10.tgz", - "integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.0.tgz", + "integrity": "sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w==", "dev": true, "optional": true }, "@esbuild/netbsd-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.10.tgz", - "integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.0.tgz", + "integrity": "sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA==", "dev": true, "optional": true }, "@esbuild/openbsd-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.10.tgz", - "integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.0.tgz", + "integrity": "sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ==", "dev": true, "optional": true }, "@esbuild/openbsd-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.10.tgz", - "integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.0.tgz", + "integrity": "sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A==", "dev": true, "optional": true }, "@esbuild/openharmony-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.10.tgz", - "integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.0.tgz", + "integrity": "sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA==", + "dev": true, + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.0.tgz", + "integrity": "sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA==", "dev": true, "optional": true }, "@esbuild/win32-arm64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.10.tgz", - "integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.0.tgz", + "integrity": "sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg==", "dev": true, "optional": true }, "@esbuild/win32-ia32": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.10.tgz", - "integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.0.tgz", + "integrity": "sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ==", "dev": true, "optional": true }, "@esbuild/win32-x64": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.10.tgz", - "integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.0.tgz", + "integrity": "sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg==", "dev": true, "optional": true }, @@ -5980,24 +6003,24 @@ "dev": true }, "@textlint/ast-node-types": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-15.2.2.tgz", - "integrity": "sha512-9ByYNzWV8tpz6BFaRzeRzIov8dkbSZu9q7IWqEIfmRuLWb2qbI/5gTvKcoWT1HYs4XM7IZ8TKSXcuPvMb6eorA==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-15.4.0.tgz", + "integrity": "sha512-IqY8i7IOGuvy05wZxISB7Me1ZyrvhaQGgx6DavfQjH3cfwpPFdDbDYmMXMuSv2xLS1kDB1kYKBV7fL2Vi16lRA==", "dev": true }, "@textlint/linter-formatter": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/linter-formatter/-/linter-formatter-15.2.2.tgz", - "integrity": "sha512-oMVaMJ3exFvXhCj3AqmCbLaeYrTNLqaJnLJMIlmnRM3/kZdxvku4OYdaDzgtlI194cVxamOY5AbHBBVnY79kEg==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/linter-formatter/-/linter-formatter-15.4.0.tgz", + "integrity": "sha512-rfqOZmnI1Wwc/Pa4LK+vagvVPmvxf9oRsBRqIOB04DwhucingZyAIJI/TyG18DIDYbP2aFXBZ3oOvyAxHe/8PQ==", "dev": true, "requires": { "@azu/format-text": "^1.0.2", "@azu/style-format": "^1.0.1", - "@textlint/module-interop": "15.2.2", - "@textlint/resolver": "15.2.2", - "@textlint/types": "15.2.2", + "@textlint/module-interop": "15.4.0", + "@textlint/resolver": "15.4.0", + "@textlint/types": "15.4.0", "chalk": "^4.1.2", - "debug": "^4.4.1", + "debug": "^4.4.3", "js-yaml": "^3.14.1", "lodash": "^4.17.21", "pluralize": "^2.0.0", @@ -6097,24 +6120,24 @@ } }, "@textlint/module-interop": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/module-interop/-/module-interop-15.2.2.tgz", - "integrity": "sha512-2rmNcWrcqhuR84Iio1WRzlc4tEoOMHd6T7urjtKNNefpTt1owrTJ9WuOe60yD3FrTW0J/R0ux5wxUbP/eaeFOA==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/module-interop/-/module-interop-15.4.0.tgz", + "integrity": "sha512-uGf+SFIfzOLCbZI0gp+2NLsrkSArsvEWulPP6lJuKp7yRHadmy7Xf/YHORe46qhNyyxc8PiAfiixHJSaHGUrGg==", "dev": true }, "@textlint/resolver": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/resolver/-/resolver-15.2.2.tgz", - "integrity": "sha512-4hGWjmHt0y+5NAkoYZ8FvEkj8Mez9TqfbTm3BPjoV32cIfEixl2poTOgapn1rfm73905GSO3P1jiWjmgvii13Q==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/resolver/-/resolver-15.4.0.tgz", + "integrity": "sha512-Vh/QceKZQHFJFG4GxxIsKM1Xhwv93mbtKHmFE5/ybal1mIKHdqF03Z9Guaqt6Sx/AeNUshq0hkMOEhEyEWnehQ==", "dev": true }, "@textlint/types": { - "version": "15.2.2", - "resolved": "https://registry.npmjs.org/@textlint/types/-/types-15.2.2.tgz", - "integrity": "sha512-X2BHGAR3yXJsCAjwYEDBIk9qUDWcH4pW61ISfmtejau+tVqKtnbbvEZnMTb6mWgKU1BvTmftd5DmB1XVDUtY3g==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@textlint/types/-/types-15.4.0.tgz", + "integrity": "sha512-ZMwJgw/xjxJufOD+IB7I2Enl9Si4Hxo04B76RwUZ5cKBKzOPcmd6WvGe2F7jqdgmTdGnfMU+Bo/joQrjPNIWqg==", "dev": true, "requires": { - "@textlint/ast-node-types": "15.2.2" + "@textlint/ast-node-types": "15.4.0" } }, "@types/adm-zip": { @@ -6127,12 +6150,12 @@ } }, "@types/node": { - "version": "24.6.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.6.1.tgz", - "integrity": "sha512-ljvjjs3DNXummeIaooB4cLBKg2U6SPI6Hjra/9rRIy7CpM0HpLtG9HptkMKAb4HYWy5S7HUvJEuWgr/y0U8SHw==", + "version": "24.10.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", + "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "dev": true, "requires": { - "undici-types": "~7.13.0" + "undici-types": "~7.16.0" } }, "@types/normalize-package-data": { @@ -6148,9 +6171,9 @@ "dev": true }, "@types/vscode": { - "version": "1.104.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.104.0.tgz", - "integrity": "sha512-0KwoU2rZ2ecsTGFxo4K1+f+AErRsYW0fsp6A0zufzGuhyczc2IoKqYqcwXidKXmy2u8YB2GsYsOtiI9Izx3Tig==", + "version": "1.106.1", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.106.1.tgz", + "integrity": "sha512-R/HV8u2h8CAddSbX8cjpdd7B8/GnE4UjgjpuGuHcbp1xV6yh4OeqU4L1pKjlwujCrSFS0MOpwJAIs/NexMB1fQ==", "dev": true }, "@types/which": { @@ -6172,16 +6195,16 @@ }, "@typescript/libsyncrpc": { "version": "git+ssh://git@github.com/microsoft/libsyncrpc.git#95d8cfcdd52a33169677fbc3b338a745accd7fdb", - "integrity": "sha512-+cxoBpDD+MOdgpnUEIdkxskwV2rKFQwgxHyWTR4mH0ScXbWcRUQGQdP/J7dgVyjXUMZd+eCIY1ism7EdLIyKwg==", + "integrity": "sha512-r5WzumdSiLEdvSPkDJxIF7aTWuI6oq/zpihBoexnk9C6E2lfukcZBlBJMCeiicMWkIj506c1K7m+YOuPbmB5Ng==", "from": "@typescript/libsyncrpc@github:microsoft/libsyncrpc#95d8cfcdd52a33169677fbc3b338a745accd7fdb" }, "@typescript/native-preview": { "version": "file:_packages/native-preview" }, "@typespec/ts-http-runtime": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.1.tgz", - "integrity": "sha512-SnbaqayTVFEA6/tYumdF0UmybY0KHyKwGPBXnyckFlrrKdhWFrL3a2HIPXHjht5ZOElKGcXfD2D63P36btb+ww==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz", + "integrity": "sha512-IlqQ/Gv22xUC1r/WQm4StLkYQmaaTsXAhUVsNE0+xiyf0yRFiH5++q78U3bw6bLKDCTmh0uqKB9eG9+Bt75Dkg==", "dev": true, "requires": { "http-proxy-agent": "^7.0.0", @@ -6190,9 +6213,9 @@ } }, "@vscode/vsce": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.6.2.tgz", - "integrity": "sha512-gvBfarWF+Ii20ESqjA3dpnPJpQJ8fFJYtcWtjwbRADommCzGg1emtmb34E+DKKhECYvaVyAl+TF9lWS/3GSPvg==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.7.0.tgz", + "integrity": "sha512-LY9r2T4joszRjz4d92ZPl6LTBUPS4IWH9gG/3JUv+1QyBJrveZlcVISuiaq0EOpmcgFh0GgVgKD4rD/21Tu8sA==", "dev": true, "requires": { "@azure/identity": "^4.1.0", @@ -6272,23 +6295,23 @@ "dev": true }, "glob": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", - "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.1.0.tgz", + "integrity": "sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==", "dev": true, "requires": { "foreground-child": "^3.3.1", "jackspeak": "^4.1.1", - "minimatch": "^10.0.3", + "minimatch": "^10.1.1", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" }, "dependencies": { "minimatch": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", - "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz", + "integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==", "dev": true, "requires": { "@isaacs/brace-expansion": "^5.0.0" @@ -6327,9 +6350,9 @@ } }, "path-scurry": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", - "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz", + "integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==", "dev": true, "requires": { "lru-cache": "^11.0.0", @@ -6348,15 +6371,15 @@ } }, "@vscode/vsce-sign": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/@vscode/vsce-sign/-/vsce-sign-2.0.8.tgz", - "integrity": "sha512-H7p8E11cZMj6mt8xIi3QXZ7dSU/2MH3Y7c+5JfUhHAV4xfaPNc8ozwLVK282c6ah596KoIJIdPUlNHV7Qs/5JA==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@vscode/vsce-sign/-/vsce-sign-2.0.9.tgz", + "integrity": "sha512-8IvaRvtFyzUnGGl3f5+1Cnor3LqaUWvhaUjAYO8Y39OUYlOf3cRd+dowuQYLpZcP3uwSG+mURwjEBOSq4SOJ0g==", "dev": true, "requires": { "@vscode/vsce-sign-alpine-arm64": "2.0.6", "@vscode/vsce-sign-alpine-x64": "2.0.6", - "@vscode/vsce-sign-darwin-arm64": "2.0.2", - "@vscode/vsce-sign-darwin-x64": "2.0.2", + "@vscode/vsce-sign-darwin-arm64": "2.0.6", + "@vscode/vsce-sign-darwin-x64": "2.0.6", "@vscode/vsce-sign-linux-arm": "2.0.6", "@vscode/vsce-sign-linux-arm64": "2.0.6", "@vscode/vsce-sign-linux-x64": "2.0.6", @@ -6379,16 +6402,16 @@ "optional": true }, "@vscode/vsce-sign-darwin-arm64": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-arm64/-/vsce-sign-darwin-arm64-2.0.2.tgz", - "integrity": "sha512-rz8F4pMcxPj8fjKAJIfkUT8ycG9CjIp888VY/6pq6cuI2qEzQ0+b5p3xb74CJnBbSC0p2eRVoe+WgNCAxCLtzQ==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-arm64/-/vsce-sign-darwin-arm64-2.0.6.tgz", + "integrity": "sha512-5HMHaJRIQuozm/XQIiJiA0W9uhdblwwl2ZNDSSAeXGO9YhB9MH5C4KIHOmvyjUnKy4UCuiP43VKpIxW1VWP4tQ==", "dev": true, "optional": true }, "@vscode/vsce-sign-darwin-x64": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-x64/-/vsce-sign-darwin-x64-2.0.2.tgz", - "integrity": "sha512-MCjPrQ5MY/QVoZ6n0D92jcRb7eYvxAujG/AH2yM6lI0BspvJQxp0o9s5oiAM9r32r9tkLpiy5s2icsbwefAQIw==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-x64/-/vsce-sign-darwin-x64-2.0.6.tgz", + "integrity": "sha512-25GsUbTAiNfHSuRItoQafXOIpxlYj+IXb4/qarrXu7kmbH94jlm5sdWSCKrrREs8+GsXF1b+l3OB7VJy5jsykw==", "dev": true, "optional": true }, @@ -6452,9 +6475,9 @@ } }, "ansi-escapes": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.1.1.tgz", - "integrity": "sha512-Zhl0ErHcSRUaVfGUeUdDuLgpkEo8KIFjB4Y9uAc46ScOpdDiU1Dbyplh7qWJeJ/ZHpbyMSM26+X3BySgnIz40Q==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.2.0.tgz", + "integrity": "sha512-g6LhBsl+GBPRWGWsBtutpzBYuIIdBkLEvad5C/va/74Db018+5TZiyA26cZJAr3Rft5lprVqOIPxf5Vid6tqAw==", "dev": true, "requires": { "environment": "^1.0.0" @@ -6813,9 +6836,9 @@ "dev": true }, "default-browser": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", - "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.4.0.tgz", + "integrity": "sha512-XDuvSq38Hr1MdN47EDvYtx3U0MTqpCEn+F6ft8z2vYDzMrvQhVp0ui9oQdqW3MvK3vqUETglt1tVGgjLuJ5izg==", "dev": true, "requires": { "bundle-name": "^4.1.0", @@ -6823,9 +6846,9 @@ } }, "default-browser-id": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", - "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", "dev": true }, "define-lazy-prop": { @@ -6841,9 +6864,9 @@ "dev": true }, "detect-libc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.1.tgz", - "integrity": "sha512-ecqj/sy1jcK1uWrwpR67UhYrIFQ+5WlGxth34WquCbamhFA6hkkwiu37o6J5xCHdo1oixJRfVRw+ywV+Hq/0Aw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", "dev": true, "optional": true }, @@ -7008,37 +7031,37 @@ } }, "esbuild": { - "version": "0.25.10", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz", - "integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==", - "dev": true, - "requires": { - "@esbuild/aix-ppc64": "0.25.10", - "@esbuild/android-arm": "0.25.10", - "@esbuild/android-arm64": "0.25.10", - "@esbuild/android-x64": "0.25.10", - "@esbuild/darwin-arm64": "0.25.10", - "@esbuild/darwin-x64": "0.25.10", - "@esbuild/freebsd-arm64": "0.25.10", - "@esbuild/freebsd-x64": "0.25.10", - "@esbuild/linux-arm": "0.25.10", - "@esbuild/linux-arm64": "0.25.10", - "@esbuild/linux-ia32": "0.25.10", - "@esbuild/linux-loong64": "0.25.10", - "@esbuild/linux-mips64el": "0.25.10", - "@esbuild/linux-ppc64": "0.25.10", - "@esbuild/linux-riscv64": "0.25.10", - "@esbuild/linux-s390x": "0.25.10", - "@esbuild/linux-x64": "0.25.10", - "@esbuild/netbsd-arm64": "0.25.10", - "@esbuild/netbsd-x64": "0.25.10", - "@esbuild/openbsd-arm64": "0.25.10", - "@esbuild/openbsd-x64": "0.25.10", - "@esbuild/openharmony-arm64": "0.25.10", - "@esbuild/sunos-x64": "0.25.10", - "@esbuild/win32-arm64": "0.25.10", - "@esbuild/win32-ia32": "0.25.10", - "@esbuild/win32-x64": "0.25.10" + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.0.tgz", + "integrity": "sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==", + "dev": true, + "requires": { + "@esbuild/aix-ppc64": "0.27.0", + "@esbuild/android-arm": "0.27.0", + "@esbuild/android-arm64": "0.27.0", + "@esbuild/android-x64": "0.27.0", + "@esbuild/darwin-arm64": "0.27.0", + "@esbuild/darwin-x64": "0.27.0", + "@esbuild/freebsd-arm64": "0.27.0", + "@esbuild/freebsd-x64": "0.27.0", + "@esbuild/linux-arm": "0.27.0", + "@esbuild/linux-arm64": "0.27.0", + "@esbuild/linux-ia32": "0.27.0", + "@esbuild/linux-loong64": "0.27.0", + "@esbuild/linux-mips64el": "0.27.0", + "@esbuild/linux-ppc64": "0.27.0", + "@esbuild/linux-riscv64": "0.27.0", + "@esbuild/linux-s390x": "0.27.0", + "@esbuild/linux-x64": "0.27.0", + "@esbuild/netbsd-arm64": "0.27.0", + "@esbuild/netbsd-x64": "0.27.0", + "@esbuild/openbsd-arm64": "0.27.0", + "@esbuild/openbsd-x64": "0.27.0", + "@esbuild/openharmony-arm64": "0.27.0", + "@esbuild/sunos-x64": "0.27.0", + "@esbuild/win32-arm64": "0.27.0", + "@esbuild/win32-ia32": "0.27.0", + "@esbuild/win32-x64": "0.27.0" } }, "escape-string-regexp": { @@ -7158,9 +7181,9 @@ } }, "form-data": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", - "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "dev": true, "requires": { "asynckit": "^0.4.0", @@ -7240,9 +7263,9 @@ "optional": true }, "glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", "dev": true, "requires": { "foreground-child": "^3.1.0", @@ -7327,9 +7350,9 @@ } }, "hereby": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.0.tgz", - "integrity": "sha512-Tdp03ueQL3w5eZCrQVW4POBDxg9ldjNyFrZYWt6ndMha5agyRUO8b+irOEG3B1RSS9/2LxSjjyG6DSxITouJzA==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.1.tgz", + "integrity": "sha512-3tcp92aUN6mSmWslo/EIoz3AAKa9GPmiJ3g0ZgXC8NGZPyh4J3T+JoGfD4JTiL31SW+pFliKKHu1uxa7nwDv0g==", "dev": true, "requires": { "command-line-usage": "^6.1.3", @@ -7567,9 +7590,9 @@ "dev": true }, "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -7858,15 +7881,15 @@ "version": "file:_extension", "requires": { "@types/vscode": "^1.100.0", - "@vscode/vsce": "^3.6.2", - "esbuild": "^0.25.10", + "@vscode/vsce": "^3.7.0", + "esbuild": "^0.27.0", "vscode-languageclient": "^9.0.1" } }, "node-abi": { - "version": "3.77.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.77.0.tgz", - "integrity": "sha512-DSmt0OEcLoK4i3NuscSbGjOf3bqiDEutejqENSplMSFA/gmB8mkED9G4pKWnPl7MDU4rSHebKPHeitpDfyH0cQ==", + "version": "3.85.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.85.0.tgz", + "integrity": "sha512-zsFhmbkAzwhTft6nd3VxcG0cvJsT70rL+BIGHWVq5fi6MwGrHwzqKaxXE+Hl2GmnGItnDKPPkO5/LQqjVkIdFg==", "dev": true, "optional": true, "requires": { @@ -7881,9 +7904,9 @@ "optional": true }, "node-sarif-builder": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/node-sarif-builder/-/node-sarif-builder-3.2.0.tgz", - "integrity": "sha512-kVIOdynrF2CRodHZeP/97Rh1syTUHBNiw17hUCIVhlhEsWlfJm19MuO56s4MdKbr22xWx6mzMnNAgXzVlIYM9Q==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/node-sarif-builder/-/node-sarif-builder-3.3.0.tgz", + "integrity": "sha512-8taRy2nQs1xNs8iO2F0XbkZJEliiijpKgFVcyiwKjJ2+3X59LVI3wY84qRdJwRDpIo5GK8wvb1pxcJ+JVu3jrg==", "dev": true, "requires": { "@types/sarif": "^2.1.7", @@ -7977,9 +8000,9 @@ } }, "p-map": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.3.tgz", - "integrity": "sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4.tgz", + "integrity": "sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ==", "dev": true }, "package-json-from-dist": { @@ -8198,9 +8221,9 @@ "dev": true }, "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, "requires": { "argparse": "^2.0.1" @@ -8302,9 +8325,9 @@ "dev": true }, "sax": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", - "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.3.tgz", + "integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==", "dev": true }, "secretlint": { @@ -8323,9 +8346,9 @@ } }, "semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==" + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==" }, "shebang-command": { "version": "2.0.0", @@ -8837,9 +8860,9 @@ "dev": true }, "undici-types": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.13.0.tgz", - "integrity": "sha512-Ov2Rr9Sx+fRgagJ5AX0qvItZG/JKKoBRAVITs1zk7IqZGTJUwgUr7qoYBpWwakpWilTZFM98rG/AFRocu10iIQ==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true }, "unicorn-magic": { @@ -9108,9 +9131,9 @@ } }, "yocto-queue": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.1.tgz", - "integrity": "sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.2.tgz", + "integrity": "sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==", "dev": true }, "yoctocolors": { diff --git a/package.json b/package.json index 1372eda040..45cb9dabd2 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "chokidar": "^4.0.3", "dprint": "^0.50.2", "execa": "^9.6.0", - "glob": "^10.4.5", - "hereby": "^1.11.0", + "glob": "^10.5.0", + "hereby": "^1.11.1", "p-limit": "^6.2.0", "picocolors": "^1.1.1", "typescript": "^5.9.3", diff --git a/testdata/baselines/reference/api/encodeSourceFileWithUnicodeEscapes.txt b/testdata/baselines/reference/api/encodeSourceFileWithUnicodeEscapes.txt new file mode 100644 index 0000000000..93102c786a --- /dev/null +++ b/testdata/baselines/reference/api/encodeSourceFileWithUnicodeEscapes.txt @@ -0,0 +1,27 @@ +KindSourceFile [0, 98), i=1, next=0 + NodeList [0, 98), i=2, next=27 + KindVariableStatement [0, 15), i=3, next=9 + KindVariableDeclarationList [0, 14), i=4, next=0 + NodeList [3, 14), i=5, next=0 + KindVariableDeclaration [3, 14), i=6, next=0 + KindIdentifier "a" [3, 5), i=7, next=8 + KindStringLiteral "😃" [7, 14), i=8, next=0 + KindVariableStatement [15, 39), i=9, next=15 + KindVariableDeclarationList [15, 38), i=10, next=0 + NodeList [19, 38), i=11, next=0 + KindVariableDeclaration [19, 38), i=12, next=0 + KindIdentifier "b" [19, 21), i=13, next=14 + KindStringLiteral "😃" [23, 38), i=14, next=0 + KindVariableStatement [39, 69), i=15, next=21 + KindVariableDeclarationList [39, 68), i=16, next=0 + NodeList [43, 68), i=17, next=0 + KindVariableDeclaration [43, 68), i=18, next=0 + KindIdentifier "c" [43, 45), i=19, next=20 + KindStringLiteral "īŋŊ😃" [47, 68), i=20, next=0 + KindVariableStatement [69, 98), i=21, next=0 + KindVariableDeclarationList [69, 98), i=22, next=0 + NodeList [73, 98), i=23, next=0 + KindVariableDeclaration [73, 98), i=24, next=0 + KindIdentifier "d" [73, 75), i=25, next=26 + KindStringLiteral "īŋŊ😃" [77, 98), i=26, next=0 + KindEndOfFile [98, 98), i=27, next=0 diff --git a/testdata/baselines/reference/compiler/allowSyntheticDefaultImports9.js b/testdata/baselines/reference/compiler/allowSyntheticDefaultImports9.js index 14cdb26657..cc99033f91 100644 --- a/testdata/baselines/reference/compiler/allowSyntheticDefaultImports9.js +++ b/testdata/baselines/reference/compiler/allowSyntheticDefaultImports9.js @@ -12,7 +12,10 @@ Foo.foo(); //// [a.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); b_1.default.bar(); b_1.default.foo(); diff --git a/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.errors.txt b/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.errors.txt new file mode 100644 index 0000000000..39b13ba38a --- /dev/null +++ b/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.errors.txt @@ -0,0 +1,23 @@ +assertsPredicateParameterMismatch.ts(7,12): error TS1225: Cannot find parameter 'condition'. + + +==== assertsPredicateParameterMismatch.ts (1 errors) ==== + // This test verifies that the checker doesn't panic when an assertion predicate + // references a parameter name that doesn't match any actual function parameter. + // This specifically tests the code path in isReachableFlowNodeWorker. + + function assertCondition( + _condition: boolean + ): asserts condition { // "condition" doesn't match parameter "_condition" + ~~~~~~~~~ +!!! error TS1225: Cannot find parameter 'condition'. + if (!_condition) { + throw new Error('Condition failed'); + } + } + + function test(): void { + assertCondition(false); + console.log("unreachable"); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.symbols b/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.symbols new file mode 100644 index 0000000000..bbeb60ccf3 --- /dev/null +++ b/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/assertsPredicateParameterMismatch.ts] //// + +=== assertsPredicateParameterMismatch.ts === +// This test verifies that the checker doesn't panic when an assertion predicate +// references a parameter name that doesn't match any actual function parameter. +// This specifically tests the code path in isReachableFlowNodeWorker. + +function assertCondition( +>assertCondition : Symbol(assertCondition, Decl(assertsPredicateParameterMismatch.ts, 0, 0)) + + _condition: boolean +>_condition : Symbol(_condition, Decl(assertsPredicateParameterMismatch.ts, 4, 25)) + +): asserts condition { // "condition" doesn't match parameter "_condition" + if (!_condition) { +>_condition : Symbol(_condition, Decl(assertsPredicateParameterMismatch.ts, 4, 25)) + + throw new Error('Condition failed'); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +function test(): void { +>test : Symbol(test, Decl(assertsPredicateParameterMismatch.ts, 10, 1)) + + assertCondition(false); +>assertCondition : Symbol(assertCondition, Decl(assertsPredicateParameterMismatch.ts, 0, 0)) + + console.log("unreachable"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +} + diff --git a/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.types b/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.types new file mode 100644 index 0000000000..1f05e06e53 --- /dev/null +++ b/testdata/baselines/reference/compiler/assertsPredicateParameterMismatch.types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/assertsPredicateParameterMismatch.ts] //// + +=== assertsPredicateParameterMismatch.ts === +// This test verifies that the checker doesn't panic when an assertion predicate +// references a parameter name that doesn't match any actual function parameter. +// This specifically tests the code path in isReachableFlowNodeWorker. + +function assertCondition( +>assertCondition : (_condition: boolean) => asserts condition + + _condition: boolean +>_condition : boolean + +): asserts condition { // "condition" doesn't match parameter "_condition" + if (!_condition) { +>!_condition : boolean +>_condition : boolean + + throw new Error('Condition failed'); +>new Error('Condition failed') : Error +>Error : ErrorConstructor +>'Condition failed' : "Condition failed" + } +} + +function test(): void { +>test : () => void + + assertCondition(false); +>assertCondition(false) : void +>assertCondition : (_condition: boolean) => asserts condition +>false : false + + console.log("unreachable"); +>console.log("unreachable") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"unreachable" : "unreachable" +} + diff --git a/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js b/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js index e76b2fcda6..a62af024ff 100644 --- a/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js +++ b/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js @@ -16,11 +16,11 @@ export function foo(): ({ a, b }: { a: string, b: string }) => void { //// [other.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.foo = foo; /** * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eu aliquet lectus, nec rhoncus metus. Donec dapibus consectetur risus vitae porta. Aenean nisi neque, dignissim quis varius vel, volutpat vel tellus. Praesent lacinia molestie est, vel convallis odio ornare id. Pellentesque quis purus ante. Morbi a nisl justo. Etiam malesuada ipsum sem, fringilla rhoncus turpis ullamcorper et. Aenean laoreet, nisl id tempus pellentesque, elit elit congue felis, sit amet luctus nulla orci sit amet velit. Praesent non tincidunt nisi, at tempor eros. Quisque tincidunt euismod posuere. Ut blandit mauris elit, a porttitor orci aliquam ac. Duis imperdiet gravida ultrices. In. */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; function foo() { return () => { }; } diff --git a/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments.js b/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments.js index dba1b5d4e4..0121bc1021 100644 --- a/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments.js +++ b/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments.js @@ -6,8 +6,6 @@ var unrelated; /** @typedef {number} B */ //// [emitEndOfFileJSDocComments.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** @typedef {number} A */ var unrelated; /** @typedef {number} B */ diff --git a/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js b/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js index 890f9d0031..1d50133ea3 100644 --- a/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js +++ b/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js @@ -22,8 +22,6 @@ function test(param) { //// [emitEndOfFileJSDocComments2.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** @typedef {number} A */ /** * JSDoc comment for function diff --git a/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.errors.txt b/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.errors.txt new file mode 100644 index 0000000000..ba2c3dacd2 --- /dev/null +++ b/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.errors.txt @@ -0,0 +1,23 @@ +index.ts(2,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. +index.ts(3,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. + + +==== index.ts (2 errors) ==== + // These should still error because they are in a TypeScript file + import bar = require("./bar.cjs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. + import foo = require("./foo.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. + +==== bar.cjs (0 errors) ==== + module.exports = { + a: 1, + } + +==== foo.js (0 errors) ==== + module.exports = { + b: 2, + } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.symbols b/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.symbols new file mode 100644 index 0000000000..7aac5d5b51 --- /dev/null +++ b/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.symbols @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/erasableSyntaxOnlyJS.ts] //// + +=== index.ts === +// These should still error because they are in a TypeScript file +import bar = require("./bar.cjs"); +>bar : Symbol(bar, Decl(index.ts, 0, 0)) + +import foo = require("./foo.js"); +>foo : Symbol(foo, Decl(index.ts, 1, 34)) + +=== bar.cjs === +module.exports = { +>module.exports : Symbol(export=, Decl(bar.cjs, 0, 0)) +>module : Symbol("bar", Decl(bar.cjs, 0, 0)) +>exports : Symbol(export=, Decl(bar.cjs, 0, 0)) + + a: 1, +>a : Symbol(a, Decl(bar.cjs, 0, 18)) +} + +=== foo.js === +module.exports = { +>module.exports : Symbol(export=, Decl(foo.js, 0, 0)) +>module : Symbol("foo", Decl(foo.js, 0, 0)) +>exports : Symbol(export=, Decl(foo.js, 0, 0)) + + b: 2, +>b : Symbol(b, Decl(foo.js, 0, 18)) +} + diff --git a/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.types b/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.types new file mode 100644 index 0000000000..d765d1238f --- /dev/null +++ b/testdata/baselines/reference/compiler/erasableSyntaxOnlyJS.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/erasableSyntaxOnlyJS.ts] //// + +=== index.ts === +// These should still error because they are in a TypeScript file +import bar = require("./bar.cjs"); +>bar : { a: number; } + +import foo = require("./foo.js"); +>foo : { b: number; } + +=== bar.cjs === +module.exports = { +>module.exports = { a: 1,} : { a: number; } +>module.exports : { a: number; } +>module : { "export=": { a: number; }; } +>exports : { a: number; } +>{ a: 1,} : { a: number; } + + a: 1, +>a : number +>1 : 1 +} + +=== foo.js === +module.exports = { +>module.exports = { b: 2,} : { b: number; } +>module.exports : { b: number; } +>module : { "export=": { b: number; }; } +>exports : { b: number; } +>{ b: 2,} : { b: number; } + + b: 2, +>b : number +>2 : 2 +} + diff --git a/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.symbols b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.symbols new file mode 100644 index 0000000000..9c655b0125 --- /dev/null +++ b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.symbols @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/explicitMembersBeforeInherited.ts] //// + +=== explicitMembersBeforeInherited.ts === +// https://github.com/microsoft/typescript-go/issues/1968 + +type IndentationTree = TopNode | VirtualNode | LineNode | BlankNode; +>IndentationTree : Symbol(IndentationTree, Decl(explicitMembersBeforeInherited.ts, 0, 0)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>TopNode : Symbol(TopNode, Decl(explicitMembersBeforeInherited.ts, 11, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>VirtualNode : Symbol(VirtualNode, Decl(explicitMembersBeforeInherited.ts, 7, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>LineNode : Symbol(LineNode, Decl(explicitMembersBeforeInherited.ts, 15, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>BlankNode : Symbol(BlankNode, Decl(explicitMembersBeforeInherited.ts, 19, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) + +type IndentationSubTree = Exclude, TopNode>; +>IndentationSubTree : Symbol(IndentationSubTree, Decl(explicitMembersBeforeInherited.ts, 2, 83)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 3, 24)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>IndentationTree : Symbol(IndentationTree, Decl(explicitMembersBeforeInherited.ts, 0, 0)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 3, 24)) +>TopNode : Symbol(TopNode, Decl(explicitMembersBeforeInherited.ts, 11, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 3, 24)) + +interface NodeBase { +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 5, 19)) + + subs: IndentationSubTree[]; +>subs : Symbol(NodeBase.subs, Decl(explicitMembersBeforeInherited.ts, 5, 23)) +>IndentationSubTree : Symbol(IndentationSubTree, Decl(explicitMembersBeforeInherited.ts, 2, 83)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 5, 19)) +} + +interface VirtualNode extends NodeBase { +>VirtualNode : Symbol(VirtualNode, Decl(explicitMembersBeforeInherited.ts, 7, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 9, 22)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 9, 22)) + + type: 'virtual'; +>type : Symbol(VirtualNode.type, Decl(explicitMembersBeforeInherited.ts, 9, 46)) +} + +interface TopNode extends NodeBase { +>TopNode : Symbol(TopNode, Decl(explicitMembersBeforeInherited.ts, 11, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 13, 18)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 13, 18)) + + type: 'top'; +>type : Symbol(TopNode.type, Decl(explicitMembersBeforeInherited.ts, 13, 42)) +} + +interface LineNode extends NodeBase { +>LineNode : Symbol(LineNode, Decl(explicitMembersBeforeInherited.ts, 15, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 17, 19)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 17, 19)) + + type: 'line'; +>type : Symbol(LineNode.type, Decl(explicitMembersBeforeInherited.ts, 17, 43)) +} + +interface BlankNode extends NodeBase { +>BlankNode : Symbol(BlankNode, Decl(explicitMembersBeforeInherited.ts, 19, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 21, 20)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 21, 20)) + + type: 'blank'; +>type : Symbol(BlankNode.type, Decl(explicitMembersBeforeInherited.ts, 21, 44)) +} + diff --git a/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.types b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.types new file mode 100644 index 0000000000..10ec1583c3 --- /dev/null +++ b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/explicitMembersBeforeInherited.ts] //// + +=== explicitMembersBeforeInherited.ts === +// https://github.com/microsoft/typescript-go/issues/1968 + +type IndentationTree = TopNode | VirtualNode | LineNode | BlankNode; +>IndentationTree : IndentationTree + +type IndentationSubTree = Exclude, TopNode>; +>IndentationSubTree : IndentationSubTree + +interface NodeBase { + subs: IndentationSubTree[]; +>subs : IndentationSubTree[] +} + +interface VirtualNode extends NodeBase { + type: 'virtual'; +>type : "virtual" +} + +interface TopNode extends NodeBase { + type: 'top'; +>type : "top" +} + +interface LineNode extends NodeBase { + type: 'line'; +>type : "line" +} + +interface BlankNode extends NodeBase { + type: 'blank'; +>type : "blank" +} + diff --git a/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt new file mode 100644 index 0000000000..39c8d40771 --- /dev/null +++ b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt @@ -0,0 +1,14 @@ +t.ts(2,14): error TS1379: An import alias cannot reference a declaration that was exported using 'export type'. + + +==== t.ts (1 errors) ==== + import a = require("./a"); + import foo = a.Foo + ~~~~~ +!!! error TS1379: An import alias cannot reference a declaration that was exported using 'export type'. +!!! related TS1377 a.ts:2:15: 'Foo' was exported here. + +==== a.ts (0 errors) ==== + type Foo = { x: number } + export type { Foo }; + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols new file mode 100644 index 0000000000..fa41228c5e --- /dev/null +++ b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/importAliasTypeOnlyExport.ts] //// + +=== t.ts === +import a = require("./a"); +>a : Symbol(a, Decl(t.ts, 0, 0)) + +import foo = a.Foo +>foo : Symbol(foo, Decl(t.ts, 0, 26)) +>a : Symbol(a, Decl(t.ts, 0, 0)) +>Foo : Symbol(a.Foo, Decl(a.ts, 1, 13)) + +=== a.ts === +type Foo = { x: number } +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) +>x : Symbol(x, Decl(a.ts, 0, 12)) + +export type { Foo }; +>Foo : Symbol(Foo, Decl(a.ts, 1, 13)) + diff --git a/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types new file mode 100644 index 0000000000..73e51f003e --- /dev/null +++ b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/importAliasTypeOnlyExport.ts] //// + +=== t.ts === +import a = require("./a"); +>a : typeof a + +import foo = a.Foo +>foo : any +>a : typeof a +>Foo : foo + +=== a.ts === +type Foo = { x: number } +>Foo : Foo +>x : number + +export type { Foo }; +>Foo : Foo + diff --git a/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.js b/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.js new file mode 100644 index 0000000000..8f3f16b17c --- /dev/null +++ b/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.js @@ -0,0 +1,295 @@ +//// [tests/cases/compiler/incrementalConcurrentSafeAliasFollowing.ts] //// + +//// [a.tsbuildinfo] +{ + "version": "TEST", + "root": [ [ 8, 9 ] ], + "fileNames": [ + "lib.d.ts", + "lib.es5.d.ts", + "lib.dom.d.ts", + "lib.webworker.importscripts.d.ts", + "lib.scripthost.d.ts", + "lib.decorators.d.ts", + "lib.decorators.legacy.d.ts", + "./.src/file2.ts", + "./.src/file1.ts" + ], + "fileInfos": [ + "8aa2344ef67b04dfd9aa23b0f29ffb31", + { + "version": "71cf8049ea8d435bcdf47408dac2525c", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + }, + { + "version": "9cf691967d2e0b0210f5864fdf1ad87a", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + }, + { + "version": "eb49c11101339d745cfc83e213607152", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + }, + { + "version": "a4fa81fccf6300a830a36517b5beb51f", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + }, + { + "version": "45c91c5f844a9ee1df11d1b71c484b0e", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + }, + { + "version": "39e009135c77d60baa790854b51d2195", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + }, + "ed441e10e1833cd4635f7c61645b7ee7", + "553372ff8498789eb6e91ea68f08e47a" + ], + "fileIdsList": [ [ 8 ] ], + "options": { + "newLine": 1, + "noErrorTruncation": true, + "skipDefaultLibCheck": true, + "tsBuildInfoFile": "./a.tsbuildinfo" + }, + "referencedMap": [ [ 9, 1 ] ] +} +//// [file1.ts] +// need an out of date but present buildinfo, chained export aliases, +// and enough files that the same checker is used for multiple files +// to trigger the race from typescript-go/#1470 +import {b} from "./file2.js" + +export type {b as c} +//// [file2.ts] +const a = 1 + +export type {a as b} +//// [file0.ts] +import {c} from "./file1.js" + +export type {c as d} +//// [file3.ts] +import {b} from "./file2.js" + +export type {b as e} +//// [file4.ts] +import {b} from "./file2.js" + +export type {b as f} +//// [file5.ts] +import {b} from "./file2.js" + +export type {b as g} +//// [file6.ts] +import {b} from "./file2.js" + +export type {b as h} +//// [file7.ts] +import {b} from "./file2.js" + +export type {b as i} +//// [file8.ts] +import {b} from "./file2.js" + +export type {b as j} +//// [file9.ts] +import {b} from "./file2.js" + +export type {b as k} +//// [file10.ts] +import {b} from "./file2.js" + +export type {b as l} +//// [file11.ts] +import {b} from "./file2.js" + +export type {b as m} +//// [file12.ts] +import {b} from "./file2.js" + +export type {b as n} +//// [file13.ts] +import {b} from "./file2.js" + +export type {b as o} +//// [file14.ts] +import {b} from "./file2.js" + +export type {b as p} +//// [file15.ts] +import {b} from "./file2.js" + +export type {b as q} +//// [barrel.ts] +export * from "./file0.js" +export * from "./file1.js" +export * from "./file2.js" +export * from "./file3.js" +export * from "./file4.js" +export * from "./file5.js" +export * from "./file6.js" +export * from "./file7.js" +export * from "./file8.js" +export * from "./file9.js" +export * from "./file10.js" +export * from "./file11.js" +export * from "./file12.js" +export * from "./file13.js" +export * from "./file14.js" +export * from "./file15.js" + +//// [file2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const a = 1; +//// [file1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file0.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file13.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file14.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file15.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [barrel.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./file0.js"), exports); +__exportStar(require("./file1.js"), exports); +__exportStar(require("./file2.js"), exports); +__exportStar(require("./file3.js"), exports); +__exportStar(require("./file4.js"), exports); +__exportStar(require("./file5.js"), exports); +__exportStar(require("./file6.js"), exports); +__exportStar(require("./file7.js"), exports); +__exportStar(require("./file8.js"), exports); +__exportStar(require("./file9.js"), exports); +__exportStar(require("./file10.js"), exports); +__exportStar(require("./file11.js"), exports); +__exportStar(require("./file12.js"), exports); +__exportStar(require("./file13.js"), exports); +__exportStar(require("./file14.js"), exports); +__exportStar(require("./file15.js"), exports); + + +//// [file2.d.ts] +declare const a = 1; +export type { a as b }; +//// [file1.d.ts] +import { b } from "./file2.js"; +export type { b as c }; +//// [file0.d.ts] +import { c } from "./file1.js"; +export type { c as d }; +//// [file3.d.ts] +import { b } from "./file2.js"; +export type { b as e }; +//// [file4.d.ts] +import { b } from "./file2.js"; +export type { b as f }; +//// [file5.d.ts] +import { b } from "./file2.js"; +export type { b as g }; +//// [file6.d.ts] +import { b } from "./file2.js"; +export type { b as h }; +//// [file7.d.ts] +import { b } from "./file2.js"; +export type { b as i }; +//// [file8.d.ts] +import { b } from "./file2.js"; +export type { b as j }; +//// [file9.d.ts] +import { b } from "./file2.js"; +export type { b as k }; +//// [file10.d.ts] +import { b } from "./file2.js"; +export type { b as l }; +//// [file11.d.ts] +import { b } from "./file2.js"; +export type { b as m }; +//// [file12.d.ts] +import { b } from "./file2.js"; +export type { b as n }; +//// [file13.d.ts] +import { b } from "./file2.js"; +export type { b as o }; +//// [file14.d.ts] +import { b } from "./file2.js"; +export type { b as p }; +//// [file15.d.ts] +import { b } from "./file2.js"; +export type { b as q }; +//// [barrel.d.ts] +export * from "./file0.js"; +export * from "./file1.js"; +export * from "./file2.js"; +export * from "./file3.js"; +export * from "./file4.js"; +export * from "./file5.js"; +export * from "./file6.js"; +export * from "./file7.js"; +export * from "./file8.js"; +export * from "./file9.js"; +export * from "./file10.js"; +export * from "./file11.js"; +export * from "./file12.js"; +export * from "./file13.js"; +export * from "./file14.js"; +export * from "./file15.js"; diff --git a/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.symbols b/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.symbols new file mode 100644 index 0000000000..b6ca4ff7d0 --- /dev/null +++ b/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.symbols @@ -0,0 +1,151 @@ +//// [tests/cases/compiler/incrementalConcurrentSafeAliasFollowing.ts] //// + +=== file1.ts === +// need an out of date but present buildinfo, chained export aliases, +// and enough files that the same checker is used for multiple files +// to trigger the race from typescript-go/#1470 +import {b} from "./file2.js" +>b : Symbol(b, Decl(file1.ts, 3, 8)) + +export type {b as c} +>b : Symbol(b, Decl(file1.ts, 3, 8)) +>c : Symbol(c, Decl(file1.ts, 5, 13)) + +=== file2.ts === +const a = 1 +>a : Symbol(a, Decl(file2.ts, 0, 5)) + +export type {a as b} +>a : Symbol(a, Decl(file2.ts, 0, 5)) +>b : Symbol(b, Decl(file2.ts, 2, 13)) + +=== file0.ts === +import {c} from "./file1.js" +>c : Symbol(c, Decl(file0.ts, 0, 8)) + +export type {c as d} +>c : Symbol(c, Decl(file0.ts, 0, 8)) +>d : Symbol(d, Decl(file0.ts, 2, 13)) + +=== file3.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file3.ts, 0, 8)) + +export type {b as e} +>b : Symbol(b, Decl(file3.ts, 0, 8)) +>e : Symbol(e, Decl(file3.ts, 2, 13)) + +=== file4.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file4.ts, 0, 8)) + +export type {b as f} +>b : Symbol(b, Decl(file4.ts, 0, 8)) +>f : Symbol(f, Decl(file4.ts, 2, 13)) + +=== file5.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file5.ts, 0, 8)) + +export type {b as g} +>b : Symbol(b, Decl(file5.ts, 0, 8)) +>g : Symbol(g, Decl(file5.ts, 2, 13)) + +=== file6.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file6.ts, 0, 8)) + +export type {b as h} +>b : Symbol(b, Decl(file6.ts, 0, 8)) +>h : Symbol(h, Decl(file6.ts, 2, 13)) + +=== file7.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file7.ts, 0, 8)) + +export type {b as i} +>b : Symbol(b, Decl(file7.ts, 0, 8)) +>i : Symbol(i, Decl(file7.ts, 2, 13)) + +=== file8.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file8.ts, 0, 8)) + +export type {b as j} +>b : Symbol(b, Decl(file8.ts, 0, 8)) +>j : Symbol(j, Decl(file8.ts, 2, 13)) + +=== file9.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file9.ts, 0, 8)) + +export type {b as k} +>b : Symbol(b, Decl(file9.ts, 0, 8)) +>k : Symbol(k, Decl(file9.ts, 2, 13)) + +=== file10.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file10.ts, 0, 8)) + +export type {b as l} +>b : Symbol(b, Decl(file10.ts, 0, 8)) +>l : Symbol(l, Decl(file10.ts, 2, 13)) + +=== file11.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file11.ts, 0, 8)) + +export type {b as m} +>b : Symbol(b, Decl(file11.ts, 0, 8)) +>m : Symbol(m, Decl(file11.ts, 2, 13)) + +=== file12.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file12.ts, 0, 8)) + +export type {b as n} +>b : Symbol(b, Decl(file12.ts, 0, 8)) +>n : Symbol(n, Decl(file12.ts, 2, 13)) + +=== file13.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file13.ts, 0, 8)) + +export type {b as o} +>b : Symbol(b, Decl(file13.ts, 0, 8)) +>o : Symbol(o, Decl(file13.ts, 2, 13)) + +=== file14.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file14.ts, 0, 8)) + +export type {b as p} +>b : Symbol(b, Decl(file14.ts, 0, 8)) +>p : Symbol(p, Decl(file14.ts, 2, 13)) + +=== file15.ts === +import {b} from "./file2.js" +>b : Symbol(b, Decl(file15.ts, 0, 8)) + +export type {b as q} +>b : Symbol(b, Decl(file15.ts, 0, 8)) +>q : Symbol(q, Decl(file15.ts, 2, 13)) + +=== barrel.ts === + +export * from "./file0.js" +export * from "./file1.js" +export * from "./file2.js" +export * from "./file3.js" +export * from "./file4.js" +export * from "./file5.js" +export * from "./file6.js" +export * from "./file7.js" +export * from "./file8.js" +export * from "./file9.js" +export * from "./file10.js" +export * from "./file11.js" +export * from "./file12.js" +export * from "./file13.js" +export * from "./file14.js" +export * from "./file15.js" diff --git a/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.types b/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.types new file mode 100644 index 0000000000..b2b0234037 --- /dev/null +++ b/testdata/baselines/reference/compiler/incrementalConcurrentSafeAliasFollowing.types @@ -0,0 +1,152 @@ +//// [tests/cases/compiler/incrementalConcurrentSafeAliasFollowing.ts] //// + +=== file1.ts === +// need an out of date but present buildinfo, chained export aliases, +// and enough files that the same checker is used for multiple files +// to trigger the race from typescript-go/#1470 +import {b} from "./file2.js" +>b : 1 + +export type {b as c} +>b : 1 +>c : any + +=== file2.ts === +const a = 1 +>a : 1 +>1 : 1 + +export type {a as b} +>a : 1 +>b : any + +=== file0.ts === +import {c} from "./file1.js" +>c : 1 + +export type {c as d} +>c : 1 +>d : any + +=== file3.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as e} +>b : 1 +>e : any + +=== file4.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as f} +>b : 1 +>f : any + +=== file5.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as g} +>b : 1 +>g : any + +=== file6.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as h} +>b : 1 +>h : any + +=== file7.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as i} +>b : 1 +>i : any + +=== file8.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as j} +>b : 1 +>j : any + +=== file9.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as k} +>b : 1 +>k : any + +=== file10.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as l} +>b : 1 +>l : any + +=== file11.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as m} +>b : 1 +>m : any + +=== file12.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as n} +>b : 1 +>n : any + +=== file13.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as o} +>b : 1 +>o : any + +=== file14.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as p} +>b : 1 +>p : any + +=== file15.ts === +import {b} from "./file2.js" +>b : 1 + +export type {b as q} +>b : 1 +>q : any + +=== barrel.ts === + +export * from "./file0.js" +export * from "./file1.js" +export * from "./file2.js" +export * from "./file3.js" +export * from "./file4.js" +export * from "./file5.js" +export * from "./file6.js" +export * from "./file7.js" +export * from "./file8.js" +export * from "./file9.js" +export * from "./file10.js" +export * from "./file11.js" +export * from "./file12.js" +export * from "./file13.js" +export * from "./file14.js" +export * from "./file15.js" diff --git a/testdata/baselines/reference/compiler/invalidJsdocType.errors.txt b/testdata/baselines/reference/compiler/invalidJsdocType.errors.txt new file mode 100644 index 0000000000..e122d03076 --- /dev/null +++ b/testdata/baselines/reference/compiler/invalidJsdocType.errors.txt @@ -0,0 +1,8 @@ +a.js(1,12): error TS1110: Type expected. + + +==== a.js (1 errors) ==== + /** @type {@import("a").Type} */ + ~ +!!! error TS1110: Type expected. + let x; \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/invalidJsdocType.symbols b/testdata/baselines/reference/compiler/invalidJsdocType.symbols new file mode 100644 index 0000000000..0f8b4e2b0a --- /dev/null +++ b/testdata/baselines/reference/compiler/invalidJsdocType.symbols @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/invalidJsdocType.ts] //// + +=== a.js === +/** @type {@import("a").Type} */ +let x; +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/testdata/baselines/reference/compiler/invalidJsdocType.types b/testdata/baselines/reference/compiler/invalidJsdocType.types new file mode 100644 index 0000000000..50b41486a2 --- /dev/null +++ b/testdata/baselines/reference/compiler/invalidJsdocType.types @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/invalidJsdocType.ts] //// + +=== a.js === +/** @type {@import("a").Type} */ +let x; +>x : any + diff --git a/testdata/baselines/reference/compiler/invocationErrorRecovery.errors.txt b/testdata/baselines/reference/compiler/invocationErrorRecovery.errors.txt new file mode 100644 index 0000000000..aaabcef494 --- /dev/null +++ b/testdata/baselines/reference/compiler/invocationErrorRecovery.errors.txt @@ -0,0 +1,16 @@ +index.ts(2,1): error TS2349: This expression is not callable. + Type '{ default: () => void; }' has no call signatures. + + +==== foo.d.ts (0 errors) ==== + declare function foo(): void; + declare namespace foo {} + export = foo; +==== index.ts (1 errors) ==== + import * as foo from "./foo"; + foo() + ~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type '{ default: () => void; }' has no call signatures. +!!! related TS7038 index.ts:1:1: Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead. + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/invocationErrorRecovery.symbols b/testdata/baselines/reference/compiler/invocationErrorRecovery.symbols new file mode 100644 index 0000000000..4dfa6b4fd9 --- /dev/null +++ b/testdata/baselines/reference/compiler/invocationErrorRecovery.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/invocationErrorRecovery.ts] //// + +=== foo.d.ts === +declare function foo(): void; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +declare namespace foo {} +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +export = foo; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +=== index.ts === +import * as foo from "./foo"; +>foo : Symbol(foo, Decl(index.ts, 0, 6)) + +foo() +>foo : Symbol(foo, Decl(index.ts, 0, 6)) + diff --git a/testdata/baselines/reference/compiler/invocationErrorRecovery.types b/testdata/baselines/reference/compiler/invocationErrorRecovery.types new file mode 100644 index 0000000000..5bdbe9b0e7 --- /dev/null +++ b/testdata/baselines/reference/compiler/invocationErrorRecovery.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/invocationErrorRecovery.ts] //// + +=== foo.d.ts === +declare function foo(): void; +>foo : () => void + +declare namespace foo {} +export = foo; +>foo : () => void + +=== index.ts === +import * as foo from "./foo"; +>foo : { default: () => void; } + +foo() +>foo() : any +>foo : { default: () => void; } + diff --git a/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js new file mode 100644 index 0000000000..76829952bc --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/jsDeclarationExportDefaultAssignmentCrash.ts] //// + +//// [index.js] +exports.default = () => { + return 1234; +} + + +//// [index.js] +export var default = () => { + return 1234; +}; +exports.default = () => { + return 1234; +}; + + +//// [index.d.ts] +declare const _default: () => number; +export default _default; diff --git a/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.symbols b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.symbols new file mode 100644 index 0000000000..d6854289de --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.symbols @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsDeclarationExportDefaultAssignmentCrash.ts] //// + +=== index.js === +exports.default = () => { +>exports.default : Symbol(default, Decl(index.js, 0, 0)) +>exports : Symbol("index", Decl(index.js, 0, 0)) +>default : Symbol(default, Decl(index.js, 0, 0)) + + return 1234; +} + diff --git a/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.types b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.types new file mode 100644 index 0000000000..91e2e5fc03 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.types @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/jsDeclarationExportDefaultAssignmentCrash.ts] //// + +=== index.js === +exports.default = () => { +>exports.default = () => { return 1234;} : () => number +>exports.default : () => number +>exports : typeof import("index") +>default : () => number +>() => { return 1234;} : () => number + + return 1234; +>1234 : 1234 +} + diff --git a/testdata/baselines/reference/compiler/jsDocCallbackExport1.js b/testdata/baselines/reference/compiler/jsDocCallbackExport1.js new file mode 100644 index 0000000000..eac66bbf52 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDocCallbackExport1.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/jsDocCallbackExport1.ts] //// + +//// [x.js] +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +function f1() {} + + + + +//// [x.d.ts] +type Foo = (x: string) => number; +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +declare function f1(): void; diff --git a/testdata/baselines/reference/compiler/jsDocCallbackExport1.symbols b/testdata/baselines/reference/compiler/jsDocCallbackExport1.symbols new file mode 100644 index 0000000000..bcf7834faf --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDocCallbackExport1.symbols @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsDocCallbackExport1.ts] //// + +=== x.js === +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +function f1() {} +>f1 : Symbol(f1, Decl(x.js, 0, 0)) + diff --git a/testdata/baselines/reference/compiler/jsDocCallbackExport1.types b/testdata/baselines/reference/compiler/jsDocCallbackExport1.types new file mode 100644 index 0000000000..f5d648222c --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDocCallbackExport1.types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsDocCallbackExport1.ts] //// + +=== x.js === +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +function f1() {} +>f1 : () => void + diff --git a/testdata/baselines/reference/compiler/jsDocCallbackExport2.js b/testdata/baselines/reference/compiler/jsDocCallbackExport2.js new file mode 100644 index 0000000000..8a894ce57d --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDocCallbackExport2.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/jsDocCallbackExport2.ts] //// + +//// [x.js] +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +export function f1() {} + + + + +//// [x.d.ts] +export type Foo = (x: string) => number; +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +export declare function f1(): void; diff --git a/testdata/baselines/reference/compiler/jsDocCallbackExport2.symbols b/testdata/baselines/reference/compiler/jsDocCallbackExport2.symbols new file mode 100644 index 0000000000..cccf7626e6 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDocCallbackExport2.symbols @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsDocCallbackExport2.ts] //// + +=== x.js === +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +export function f1() {} +>f1 : Symbol(f1, Decl(x.js, 0, 0)) + diff --git a/testdata/baselines/reference/compiler/jsDocCallbackExport2.types b/testdata/baselines/reference/compiler/jsDocCallbackExport2.types new file mode 100644 index 0000000000..2a6b035028 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsDocCallbackExport2.types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsDocCallbackExport2.ts] //// + +=== x.js === +/** + * @callback Foo + * @param {string} x + * @returns {number} + */ +export function f1() {} +>f1 : () => void + diff --git a/testdata/baselines/reference/compiler/jsxNestedIndentation.js b/testdata/baselines/reference/compiler/jsxNestedIndentation.js new file mode 100644 index 0000000000..05db37de72 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsxNestedIndentation.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/jsxNestedIndentation.tsx] //// + +//// [jsxNestedIndentation.tsx] +declare var React: any; +declare function Child(props: { children?: any }): any; +function Test() { + return + + + + +} + + +//// [jsxNestedIndentation.js] +"use strict"; +function Test() { + return React.createElement(Child, null, + React.createElement(Child, null, + React.createElement(Child, null))); +} diff --git a/testdata/baselines/reference/compiler/jsxNestedIndentation.symbols b/testdata/baselines/reference/compiler/jsxNestedIndentation.symbols new file mode 100644 index 0000000000..630e254a6c --- /dev/null +++ b/testdata/baselines/reference/compiler/jsxNestedIndentation.symbols @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/jsxNestedIndentation.tsx] //// + +=== jsxNestedIndentation.tsx === +declare var React: any; +>React : Symbol(React, Decl(jsxNestedIndentation.tsx, 0, 11)) + +declare function Child(props: { children?: any }): any; +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) +>props : Symbol(props, Decl(jsxNestedIndentation.tsx, 1, 23)) +>children : Symbol(children, Decl(jsxNestedIndentation.tsx, 1, 31)) + +function Test() { +>Test : Symbol(Test, Decl(jsxNestedIndentation.tsx, 1, 55)) + + return +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) +} + diff --git a/testdata/baselines/reference/compiler/jsxNestedIndentation.types b/testdata/baselines/reference/compiler/jsxNestedIndentation.types new file mode 100644 index 0000000000..f910202c49 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsxNestedIndentation.types @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/jsxNestedIndentation.tsx] //// + +=== jsxNestedIndentation.tsx === +declare var React: any; +>React : any + +declare function Child(props: { children?: any }): any; +>Child : (props: { children?: any; }) => any +>props : { children?: any; } +>children : any + +function Test() { +>Test : () => any + + return +> : any +>Child : (props: { children?: any; }) => any + + +> : any +>Child : (props: { children?: any; }) => any + + +> : any +>Child : (props: { children?: any; }) => any +>Child : (props: { children?: any; }) => any + + +>Child : (props: { children?: any; }) => any + + +>Child : (props: { children?: any; }) => any +} + diff --git a/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js b/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js index a179ad9931..107acc3fb6 100644 --- a/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js +++ b/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js @@ -34,7 +34,9 @@ export const InlineUnicodeChar = () => { }; export const StandaloneUnicodeChar = () => { // This should reproduce the issue - unicode character on its own line - return (_jsxs("div", { children: [_jsx("span", { children: "\u26A0" }), "\u26A0"] })); + return (_jsxs("div", { children: [ + _jsx("span", { children: "\u26A0" }), + "\u26A0"] })); }; export const MultipleUnicodeChars = () => { // Test multiple unicode characters diff --git a/testdata/baselines/reference/compiler/nestedJSDocImportType.errors.txt b/testdata/baselines/reference/compiler/nestedJSDocImportType.errors.txt new file mode 100644 index 0000000000..d3012728fc --- /dev/null +++ b/testdata/baselines/reference/compiler/nestedJSDocImportType.errors.txt @@ -0,0 +1,16 @@ +b.js(3,24): error TS2306: File 'a.js' is not a module. + + +==== a.js (0 errors) ==== + /** @typedef {string} A */ + +==== b.js (1 errors) ==== + module.exports = { + create() { + /** @param {import("./a").A} x */ + ~~~~~ +!!! error TS2306: File 'a.js' is not a module. + function f(x) {} + return f("hi"); + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/panicSatisfiesOnExportEqualsDeclaration.symbols b/testdata/baselines/reference/compiler/panicSatisfiesOnExportEqualsDeclaration.symbols index 8ebafccf77..7b8a395a97 100644 --- a/testdata/baselines/reference/compiler/panicSatisfiesOnExportEqualsDeclaration.symbols +++ b/testdata/baselines/reference/compiler/panicSatisfiesOnExportEqualsDeclaration.symbols @@ -6,6 +6,6 @@ */ module.exports = {}; >module.exports : Symbol(export=, Decl(panicSatisfiesOnExportEqualsDeclaration.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("panicSatisfiesOnExportEqualsDeclaration", Decl(panicSatisfiesOnExportEqualsDeclaration.js, 0, 0)) >exports : Symbol(export=, Decl(panicSatisfiesOnExportEqualsDeclaration.js, 0, 0)) diff --git a/testdata/baselines/reference/compiler/reachabilityChecks10.errors.txt b/testdata/baselines/reference/compiler/reachabilityChecks10.errors.txt new file mode 100644 index 0000000000..2b26eae20f --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks10.errors.txt @@ -0,0 +1,11 @@ +reachabilityChecks10.ts(2,1): error TS7027: Unreachable code detected. + + +==== reachabilityChecks10.ts (1 errors) ==== + throw new Error("") + console.log("1") + ~~~~~~~~~~~~~~~~ + console.log("2") + ~~~~~~~~~~~~~~~~ +!!! error TS7027: Unreachable code detected. + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/reachabilityChecks10.symbols b/testdata/baselines/reference/compiler/reachabilityChecks10.symbols new file mode 100644 index 0000000000..6ecc554153 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks10.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/reachabilityChecks10.ts] //// + +=== reachabilityChecks10.ts === +throw new Error("") +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +console.log("1") +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + +console.log("2") +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/testdata/baselines/reference/compiler/reachabilityChecks10.types b/testdata/baselines/reference/compiler/reachabilityChecks10.types new file mode 100644 index 0000000000..d57914a480 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks10.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/reachabilityChecks10.ts] //// + +=== reachabilityChecks10.ts === +throw new Error("") +>new Error("") : Error +>Error : ErrorConstructor +>"" : "" + +console.log("1") +>console.log("1") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"1" : "1" + +console.log("2") +>console.log("2") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"2" : "2" + diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt b/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt new file mode 100644 index 0000000000..b4497ee464 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt @@ -0,0 +1,104 @@ +reachabilityChecks11.ts(6,5): error TS7027: Unreachable code detected. +reachabilityChecks11.ts(18,5): error TS7027: Unreachable code detected. +reachabilityChecks11.ts(30,5): error TS7027: Unreachable code detected. +reachabilityChecks11.ts(47,5): error TS7027: Unreachable code detected. +reachabilityChecks11.ts(60,5): error TS7027: Unreachable code detected. +reachabilityChecks11.ts(69,5): error TS7027: Unreachable code detected. + + +==== reachabilityChecks11.ts (6 errors) ==== + // while (true); + var x = 1; + + module A { + while (true); + let x; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } + + module A1 { + do {} while(true); + module A { + interface F {} + } + } + + module A2 { + while (true); + module A { + ~~~~~~~~~~ + var x = 1; + ~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + + module A3 { + while (true); + type T = string; + } + + module A4 { + while (true); + module A { + ~~~~~~~~~~ + const enum E { X } + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + + function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; + } + + function f2() { + return; + class A { + ~~~~~~~~~ + } + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + + module B { + for (; ;); + module C { + } + } + + function f3() { + do { + } while (true); + enum E { + ~~~~~~~~ + X = 1 + ~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + + function f4() { + if (true) { + throw new Error(); + } + const enum E { + ~~~~~~~~~~~~~~ + X = 1 + ~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS7027: Unreachable code detected. + } + + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.js b/testdata/baselines/reference/compiler/reachabilityChecks11.js new file mode 100644 index 0000000000..1e69b95ff9 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.js @@ -0,0 +1,153 @@ +//// [tests/cases/compiler/reachabilityChecks11.ts] //// + +//// [reachabilityChecks11.ts] +// while (true); +var x = 1; + +module A { + while (true); + let x; +} + +module A1 { + do {} while(true); + module A { + interface F {} + } +} + +module A2 { + while (true); + module A { + var x = 1; + } +} + +module A3 { + while (true); + type T = string; +} + +module A4 { + while (true); + module A { + const enum E { X } + } +} + +function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; +} + +function f2() { + return; + class A { + } +} + +module B { + for (; ;); + module C { + } +} + +function f3() { + do { + } while (true); + enum E { + X = 1 + } +} + +function f4() { + if (true) { + throw new Error(); + } + const enum E { + X = 1 + } +} + + + +//// [reachabilityChecks11.js] +// while (true); +var x = 1; +var A; +(function (A) { + while (true) + ; + let x; +})(A || (A = {})); +var A1; +(function (A1) { + do { } while (true); +})(A1 || (A1 = {})); +var A2; +(function (A2) { + while (true) + ; + let A; + (function (A) { + var x = 1; + })(A || (A = {})); +})(A2 || (A2 = {})); +var A3; +(function (A3) { + while (true) + ; +})(A3 || (A3 = {})); +var A4; +(function (A4) { + while (true) + ; + let A; + (function (A) { + let E; + (function (E) { + E[E["X"] = 0] = "X"; + })(E || (E = {})); + })(A || (A = {})); +})(A4 || (A4 = {})); +function f1(x) { + if (x) { + return; + } + else { + throw new Error("123"); + } + var x; +} +function f2() { + return; + class A { + } +} +var B; +(function (B) { + for (;;) + ; +})(B || (B = {})); +function f3() { + do { + } while (true); + let E; + (function (E) { + E[E["X"] = 1] = "X"; + })(E || (E = {})); +} +function f4() { + if (true) { + throw new Error(); + } + let E; + (function (E) { + E[E["X"] = 1] = "X"; + })(E || (E = {})); +} diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.symbols b/testdata/baselines/reference/compiler/reachabilityChecks11.symbols new file mode 100644 index 0000000000..450ccad803 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.symbols @@ -0,0 +1,124 @@ +//// [tests/cases/compiler/reachabilityChecks11.ts] //// + +=== reachabilityChecks11.ts === +// while (true); +var x = 1; +>x : Symbol(x, Decl(reachabilityChecks11.ts, 1, 3)) + +module A { +>A : Symbol(A, Decl(reachabilityChecks11.ts, 1, 10)) + + while (true); + let x; +>x : Symbol(x, Decl(reachabilityChecks11.ts, 5, 7)) +} + +module A1 { +>A1 : Symbol(A1, Decl(reachabilityChecks11.ts, 6, 1)) + + do {} while(true); + module A { +>A : Symbol(A, Decl(reachabilityChecks11.ts, 9, 22)) + + interface F {} +>F : Symbol(F, Decl(reachabilityChecks11.ts, 10, 14)) + } +} + +module A2 { +>A2 : Symbol(A2, Decl(reachabilityChecks11.ts, 13, 1)) + + while (true); + module A { +>A : Symbol(A, Decl(reachabilityChecks11.ts, 16, 17)) + + var x = 1; +>x : Symbol(x, Decl(reachabilityChecks11.ts, 18, 11)) + } +} + +module A3 { +>A3 : Symbol(A3, Decl(reachabilityChecks11.ts, 20, 1)) + + while (true); + type T = string; +>T : Symbol(T, Decl(reachabilityChecks11.ts, 23, 17)) +} + +module A4 { +>A4 : Symbol(A4, Decl(reachabilityChecks11.ts, 25, 1)) + + while (true); + module A { +>A : Symbol(A, Decl(reachabilityChecks11.ts, 28, 17)) + + const enum E { X } +>E : Symbol(E, Decl(reachabilityChecks11.ts, 29, 14)) +>X : Symbol(E.X, Decl(reachabilityChecks11.ts, 30, 22)) + } +} + +function f1(x) { +>f1 : Symbol(f1, Decl(reachabilityChecks11.ts, 32, 1)) +>x : Symbol(x, Decl(reachabilityChecks11.ts, 34, 12), Decl(reachabilityChecks11.ts, 41, 7)) + + if (x) { +>x : Symbol(x, Decl(reachabilityChecks11.ts, 34, 12), Decl(reachabilityChecks11.ts, 41, 7)) + + return; + } + else { + throw new Error("123"); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + var x; +>x : Symbol(x, Decl(reachabilityChecks11.ts, 34, 12), Decl(reachabilityChecks11.ts, 41, 7)) +} + +function f2() { +>f2 : Symbol(f2, Decl(reachabilityChecks11.ts, 42, 1)) + + return; + class A { +>A : Symbol(A, Decl(reachabilityChecks11.ts, 45, 11)) + } +} + +module B { +>B : Symbol(B, Decl(reachabilityChecks11.ts, 48, 1)) + + for (; ;); + module C { +>C : Symbol(C, Decl(reachabilityChecks11.ts, 51, 14)) + } +} + +function f3() { +>f3 : Symbol(f3, Decl(reachabilityChecks11.ts, 54, 1)) + + do { + } while (true); + enum E { +>E : Symbol(E, Decl(reachabilityChecks11.ts, 58, 19)) + + X = 1 +>X : Symbol(E.X, Decl(reachabilityChecks11.ts, 59, 12)) + } +} + +function f4() { +>f4 : Symbol(f4, Decl(reachabilityChecks11.ts, 62, 1)) + + if (true) { + throw new Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + const enum E { +>E : Symbol(E, Decl(reachabilityChecks11.ts, 67, 5)) + + X = 1 +>X : Symbol(E.X, Decl(reachabilityChecks11.ts, 68, 18)) + } +} + + diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.types b/testdata/baselines/reference/compiler/reachabilityChecks11.types new file mode 100644 index 0000000000..10cf27d433 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.types @@ -0,0 +1,139 @@ +//// [tests/cases/compiler/reachabilityChecks11.ts] //// + +=== reachabilityChecks11.ts === +// while (true); +var x = 1; +>x : number +>1 : 1 + +module A { +>A : typeof A + + while (true); +>true : true + + let x; +>x : any +} + +module A1 { +>A1 : typeof A1 + + do {} while(true); +>true : true + + module A { + interface F {} + } +} + +module A2 { +>A2 : typeof A2 + + while (true); +>true : true + + module A { +>A : typeof A + + var x = 1; +>x : number +>1 : 1 + } +} + +module A3 { +>A3 : typeof A3 + + while (true); +>true : true + + type T = string; +>T : string +} + +module A4 { +>A4 : typeof A4 + + while (true); +>true : true + + module A { + const enum E { X } +>E : E +>X : E.X + } +} + +function f1(x) { +>f1 : (x: any) => void +>x : any + + if (x) { +>x : any + + return; + } + else { + throw new Error("123"); +>new Error("123") : Error +>Error : ErrorConstructor +>"123" : "123" + } + var x; +>x : any +} + +function f2() { +>f2 : () => void + + return; + class A { +>A : A + } +} + +module B { +>B : typeof B + + for (; ;); + module C { + } +} + +function f3() { +>f3 : () => void + + do { + } while (true); +>true : true + + enum E { +>E : E + + X = 1 +>X : E.X +>1 : 1 + } +} + +function f4() { +>f4 : () => void + + if (true) { +>true : true + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor + } + const enum E { +>E : E + + X = 1 +>X : E.X +>1 : 1 + } +} + + diff --git a/testdata/baselines/reference/compiler/reachabilityChecks9.errors.txt b/testdata/baselines/reference/compiler/reachabilityChecks9.errors.txt new file mode 100644 index 0000000000..75b9cf98da --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks9.errors.txt @@ -0,0 +1,37 @@ +reachabilityChecks9.ts(7,7): error TS7027: Unreachable code detected. +reachabilityChecks9.ts(20,7): error TS7027: Unreachable code detected. + + +==== reachabilityChecks9.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/55562 + + function g(str: string) { + switch (str) { + case "a": + return; + console.log("1"); + ~~~~~~~~~~~~~~~~~ + console.log("2"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7027: Unreachable code detected. + case "b": + console.log("3"); + } + } + + function h(str: string) { + switch (str) { + case "a": + console.log("1"); + default: + return; + console.log("2"); + ~~~~~~~~~~~~~~~~~ + console.log("3"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7027: Unreachable code detected. + case "b": + console.log("4"); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/reachabilityChecks9.symbols b/testdata/baselines/reference/compiler/reachabilityChecks9.symbols new file mode 100644 index 0000000000..d50f997b9a --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks9.symbols @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/reachabilityChecks9.ts] //// + +=== reachabilityChecks9.ts === +// https://github.com/microsoft/TypeScript/issues/55562 + +function g(str: string) { +>g : Symbol(g, Decl(reachabilityChecks9.ts, 0, 0)) +>str : Symbol(str, Decl(reachabilityChecks9.ts, 2, 11)) + + switch (str) { +>str : Symbol(str, Decl(reachabilityChecks9.ts, 2, 11)) + + case "a": + return; + console.log("1"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + + console.log("2"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + + case "b": + console.log("3"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + } +} + +function h(str: string) { +>h : Symbol(h, Decl(reachabilityChecks9.ts, 11, 1)) +>str : Symbol(str, Decl(reachabilityChecks9.ts, 13, 11)) + + switch (str) { +>str : Symbol(str, Decl(reachabilityChecks9.ts, 13, 11)) + + case "a": + console.log("1"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + + default: + return; + console.log("2"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + + console.log("3"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + + case "b": + console.log("4"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + } +} + diff --git a/testdata/baselines/reference/compiler/reachabilityChecks9.types b/testdata/baselines/reference/compiler/reachabilityChecks9.types new file mode 100644 index 0000000000..8bced2f44c --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecks9.types @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/reachabilityChecks9.ts] //// + +=== reachabilityChecks9.ts === +// https://github.com/microsoft/TypeScript/issues/55562 + +function g(str: string) { +>g : (str: string) => void +>str : string + + switch (str) { +>str : string + + case "a": +>"a" : "a" + + return; + console.log("1"); +>console.log("1") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"1" : "1" + + console.log("2"); +>console.log("2") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"2" : "2" + + case "b": +>"b" : "b" + + console.log("3"); +>console.log("3") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"3" : "3" + } +} + +function h(str: string) { +>h : (str: string) => void +>str : string + + switch (str) { +>str : string + + case "a": +>"a" : "a" + + console.log("1"); +>console.log("1") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"1" : "1" + + default: + return; + console.log("2"); +>console.log("2") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"2" : "2" + + console.log("3"); +>console.log("3") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"3" : "3" + + case "b": +>"b" : "b" + + console.log("4"); +>console.log("4") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"4" : "4" + } +} + diff --git a/testdata/baselines/reference/compiler/reachabilityChecksIgnored.js b/testdata/baselines/reference/compiler/reachabilityChecksIgnored.js new file mode 100644 index 0000000000..7635105d49 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecksIgnored.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/reachabilityChecksIgnored.ts] //// + +//// [reachabilityChecksIgnored.ts] +function a() { + throw new Error(""); + + // @ts-ignore + console.log("unreachable"); +} + +function b() { + throw new Error(""); + + // @ts-expect-error + console.log("unreachable"); +} + + +//// [reachabilityChecksIgnored.js] +function a() { + throw new Error(""); + // @ts-ignore + console.log("unreachable"); +} +function b() { + throw new Error(""); + // @ts-expect-error + console.log("unreachable"); +} diff --git a/testdata/baselines/reference/compiler/reachabilityChecksIgnored.symbols b/testdata/baselines/reference/compiler/reachabilityChecksIgnored.symbols new file mode 100644 index 0000000000..04eccd0375 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecksIgnored.symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/reachabilityChecksIgnored.ts] //// + +=== reachabilityChecksIgnored.ts === +function a() { +>a : Symbol(a, Decl(reachabilityChecksIgnored.ts, 0, 0)) + + throw new Error(""); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // @ts-ignore + console.log("unreachable"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +} + +function b() { +>b : Symbol(b, Decl(reachabilityChecksIgnored.ts, 5, 1)) + + throw new Error(""); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // @ts-expect-error + console.log("unreachable"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +} + diff --git a/testdata/baselines/reference/compiler/reachabilityChecksIgnored.types b/testdata/baselines/reference/compiler/reachabilityChecksIgnored.types new file mode 100644 index 0000000000..838060e048 --- /dev/null +++ b/testdata/baselines/reference/compiler/reachabilityChecksIgnored.types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/reachabilityChecksIgnored.ts] //// + +=== reachabilityChecksIgnored.ts === +function a() { +>a : () => void + + throw new Error(""); +>new Error("") : Error +>Error : ErrorConstructor +>"" : "" + + // @ts-ignore + console.log("unreachable"); +>console.log("unreachable") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"unreachable" : "unreachable" +} + +function b() { +>b : () => void + + throw new Error(""); +>new Error("") : Error +>Error : ErrorConstructor +>"" : "" + + // @ts-expect-error + console.log("unreachable"); +>console.log("unreachable") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"unreachable" : "unreachable" +} + diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).js b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).js deleted file mode 100644 index da264d8e4c..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).js +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/settingsSimpleTest.ts] //// - -//// [settingsSimpleTest.ts] -export {}; -const x: string = undefined; - -//// [settingsSimpleTest.js] -const x = undefined; -export {}; - - -//// [settingsSimpleTest.d.ts] -export {}; diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).symbols b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).symbols deleted file mode 100644 index fb50091854..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).symbols +++ /dev/null @@ -1,8 +0,0 @@ -//// [tests/cases/compiler/settingsSimpleTest.ts] //// - -=== settingsSimpleTest.ts === -export {}; -const x: string = undefined; ->x : Symbol(x, Decl(settingsSimpleTest.ts, 1, 5)) ->undefined : Symbol(undefined) - diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).types b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).types deleted file mode 100644 index 2c05c492b6..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=false).types +++ /dev/null @@ -1,8 +0,0 @@ -//// [tests/cases/compiler/settingsSimpleTest.ts] //// - -=== settingsSimpleTest.ts === -export {}; -const x: string = undefined; ->x : string ->undefined : undefined - diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).errors.txt b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).errors.txt deleted file mode 100644 index 1c2471e7a6..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -settingsSimpleTest.ts(2,7): error TS2322: Type 'undefined' is not assignable to type 'string'. - - -==== settingsSimpleTest.ts (1 errors) ==== - export {}; - const x: string = undefined; - ~ -!!! error TS2322: Type 'undefined' is not assignable to type 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).js b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).js deleted file mode 100644 index da264d8e4c..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).js +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/settingsSimpleTest.ts] //// - -//// [settingsSimpleTest.ts] -export {}; -const x: string = undefined; - -//// [settingsSimpleTest.js] -const x = undefined; -export {}; - - -//// [settingsSimpleTest.d.ts] -export {}; diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).symbols b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).symbols deleted file mode 100644 index fb50091854..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).symbols +++ /dev/null @@ -1,8 +0,0 @@ -//// [tests/cases/compiler/settingsSimpleTest.ts] //// - -=== settingsSimpleTest.ts === -export {}; -const x: string = undefined; ->x : Symbol(x, Decl(settingsSimpleTest.ts, 1, 5)) ->undefined : Symbol(undefined) - diff --git a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).types b/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).types deleted file mode 100644 index 2c05c492b6..0000000000 --- a/testdata/baselines/reference/compiler/settingsSimpleTest(strict=true).types +++ /dev/null @@ -1,8 +0,0 @@ -//// [tests/cases/compiler/settingsSimpleTest.ts] //// - -=== settingsSimpleTest.ts === -export {}; -const x: string = undefined; ->x : string ->undefined : undefined - diff --git a/testdata/baselines/reference/compiler/typePredicateParameterMismatch.errors.txt b/testdata/baselines/reference/compiler/typePredicateParameterMismatch.errors.txt new file mode 100644 index 0000000000..6c3037be78 --- /dev/null +++ b/testdata/baselines/reference/compiler/typePredicateParameterMismatch.errors.txt @@ -0,0 +1,25 @@ +typePredicateParameterMismatch.ts(10,4): error TS1225: Cannot find parameter 'value'. + + +==== typePredicateParameterMismatch.ts (1 errors) ==== + // This test verifies that the checker doesn't panic when a type predicate + // references a parameter name that doesn't match any actual function parameter. + + type TypeA = { kind: 'a' }; + type TypeB = { kind: 'b' }; + type UnionType = TypeA | TypeB; + + function isTypeA( + _value: UnionType + ): value is TypeA { // "value" doesn't match parameter "_value" + ~~~~~ +!!! error TS1225: Cannot find parameter 'value'. + return true; + } + + function test(input: UnionType): void { + if (isTypeA(input)) { + console.log(input.kind); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/typePredicateParameterMismatch.symbols b/testdata/baselines/reference/compiler/typePredicateParameterMismatch.symbols new file mode 100644 index 0000000000..6efd825513 --- /dev/null +++ b/testdata/baselines/reference/compiler/typePredicateParameterMismatch.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/typePredicateParameterMismatch.ts] //// + +=== typePredicateParameterMismatch.ts === +// This test verifies that the checker doesn't panic when a type predicate +// references a parameter name that doesn't match any actual function parameter. + +type TypeA = { kind: 'a' }; +>TypeA : Symbol(TypeA, Decl(typePredicateParameterMismatch.ts, 0, 0)) +>kind : Symbol(kind, Decl(typePredicateParameterMismatch.ts, 3, 14)) + +type TypeB = { kind: 'b' }; +>TypeB : Symbol(TypeB, Decl(typePredicateParameterMismatch.ts, 3, 27)) +>kind : Symbol(kind, Decl(typePredicateParameterMismatch.ts, 4, 14)) + +type UnionType = TypeA | TypeB; +>UnionType : Symbol(UnionType, Decl(typePredicateParameterMismatch.ts, 4, 27)) +>TypeA : Symbol(TypeA, Decl(typePredicateParameterMismatch.ts, 0, 0)) +>TypeB : Symbol(TypeB, Decl(typePredicateParameterMismatch.ts, 3, 27)) + +function isTypeA( +>isTypeA : Symbol(isTypeA, Decl(typePredicateParameterMismatch.ts, 5, 31)) + + _value: UnionType +>_value : Symbol(_value, Decl(typePredicateParameterMismatch.ts, 7, 17)) +>UnionType : Symbol(UnionType, Decl(typePredicateParameterMismatch.ts, 4, 27)) + +): value is TypeA { // "value" doesn't match parameter "_value" +>TypeA : Symbol(TypeA, Decl(typePredicateParameterMismatch.ts, 0, 0)) + + return true; +} + +function test(input: UnionType): void { +>test : Symbol(test, Decl(typePredicateParameterMismatch.ts, 11, 1)) +>input : Symbol(input, Decl(typePredicateParameterMismatch.ts, 13, 14)) +>UnionType : Symbol(UnionType, Decl(typePredicateParameterMismatch.ts, 4, 27)) + + if (isTypeA(input)) { +>isTypeA : Symbol(isTypeA, Decl(typePredicateParameterMismatch.ts, 5, 31)) +>input : Symbol(input, Decl(typePredicateParameterMismatch.ts, 13, 14)) + + console.log(input.kind); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>input.kind : Symbol(kind, Decl(typePredicateParameterMismatch.ts, 3, 14), Decl(typePredicateParameterMismatch.ts, 4, 14)) +>input : Symbol(input, Decl(typePredicateParameterMismatch.ts, 13, 14)) +>kind : Symbol(kind, Decl(typePredicateParameterMismatch.ts, 3, 14), Decl(typePredicateParameterMismatch.ts, 4, 14)) + } +} + diff --git a/testdata/baselines/reference/compiler/typePredicateParameterMismatch.types b/testdata/baselines/reference/compiler/typePredicateParameterMismatch.types new file mode 100644 index 0000000000..92c77ed7e9 --- /dev/null +++ b/testdata/baselines/reference/compiler/typePredicateParameterMismatch.types @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/typePredicateParameterMismatch.ts] //// + +=== typePredicateParameterMismatch.ts === +// This test verifies that the checker doesn't panic when a type predicate +// references a parameter name that doesn't match any actual function parameter. + +type TypeA = { kind: 'a' }; +>TypeA : TypeA +>kind : "a" + +type TypeB = { kind: 'b' }; +>TypeB : TypeB +>kind : "b" + +type UnionType = TypeA | TypeB; +>UnionType : UnionType + +function isTypeA( +>isTypeA : (_value: UnionType) => value is TypeA + + _value: UnionType +>_value : UnionType + +): value is TypeA { // "value" doesn't match parameter "_value" + return true; +>true : true +} + +function test(input: UnionType): void { +>test : (input: UnionType) => void +>input : UnionType + + if (isTypeA(input)) { +>isTypeA(input) : boolean +>isTypeA : (_value: UnionType) => value is TypeA +>input : UnionType + + console.log(input.kind); +>console.log(input.kind) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>input.kind : "a" | "b" +>input : UnionType +>kind : "a" | "b" + } +} + diff --git a/testdata/baselines/reference/compiler/typedefHoisting.errors.txt b/testdata/baselines/reference/compiler/typedefHoisting.errors.txt new file mode 100644 index 0000000000..d4264baa84 --- /dev/null +++ b/testdata/baselines/reference/compiler/typedefHoisting.errors.txt @@ -0,0 +1,25 @@ +error TS5055: Cannot write file 'x.js' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +error TS5055: Cannot write file 'y.js' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. + + +!!! error TS5055: Cannot write file 'x.js' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +!!! error TS5055: Cannot write file 'y.js' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +==== x.js (0 errors) ==== + class C { + /** @import {Bar} from "./y" */ + /** @typedef {Bar[]} Bars */ + /** @type {Bars} */ + foo = ["abc", "def"] + bar(/** @type {Bar} */ x) { + return x + } + } + +==== y.js (0 errors) ==== + /** @typedef {string} Bar */ + export {} + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/typedefHoisting.js b/testdata/baselines/reference/compiler/typedefHoisting.js new file mode 100644 index 0000000000..6803d6b512 --- /dev/null +++ b/testdata/baselines/reference/compiler/typedefHoisting.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/typedefHoisting.ts] //// + +//// [x.js] +class C { + /** @import {Bar} from "./y" */ + /** @typedef {Bar[]} Bars */ + /** @type {Bars} */ + foo = ["abc", "def"] + bar(/** @type {Bar} */ x) { + return x + } +} + +//// [y.js] +/** @typedef {string} Bar */ +export {} + + + + +//// [y.d.ts] +export type Bar = string; +/** @typedef {string} Bar */ +export {}; +//// [x.d.ts] +import type { Bar } from "./y"; +type Bars = Bar[]; +declare class C { + /** @import {Bar} from "./y" */ + /** @typedef {Bar[]} Bars */ + /** @type {Bars} */ + foo: Bars; + bar(/** @type {Bar} */ x: Bar): string; +} diff --git a/testdata/baselines/reference/compiler/typedefHoisting.symbols b/testdata/baselines/reference/compiler/typedefHoisting.symbols new file mode 100644 index 0000000000..7202639df6 --- /dev/null +++ b/testdata/baselines/reference/compiler/typedefHoisting.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/typedefHoisting.ts] //// + +=== x.js === +class C { +>C : Symbol(C, Decl(x.js, 0, 0)) + + /** @import {Bar} from "./y" */ + /** @typedef {Bar[]} Bars */ + /** @type {Bars} */ + foo = ["abc", "def"] +>foo : Symbol(C.foo, Decl(x.js, 0, 9)) + + bar(/** @type {Bar} */ x) { +>bar : Symbol(C.bar, Decl(x.js, 4, 24)) +>x : Symbol(x, Decl(x.js, 5, 8)) + + return x +>x : Symbol(x, Decl(x.js, 5, 8)) + } +} + +=== y.js === + +/** @typedef {string} Bar */ +export {} + diff --git a/testdata/baselines/reference/compiler/typedefHoisting.types b/testdata/baselines/reference/compiler/typedefHoisting.types new file mode 100644 index 0000000000..5b60cac604 --- /dev/null +++ b/testdata/baselines/reference/compiler/typedefHoisting.types @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/typedefHoisting.ts] //// + +=== x.js === +class C { +>C : C + + /** @import {Bar} from "./y" */ + /** @typedef {Bar[]} Bars */ + /** @type {Bars} */ + foo = ["abc", "def"] +>foo : Bars +>["abc", "def"] : string[] +>"abc" : "abc" +>"def" : "def" + + bar(/** @type {Bar} */ x) { +>bar : (x: string) => string +>x : string + + return x +>x : string + } +} + +=== y.js === + +/** @typedef {string} Bar */ +export {} + diff --git a/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.js b/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.js new file mode 100644 index 0000000000..d15d143232 --- /dev/null +++ b/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/unicodeSurrogatesInStringLiterals.ts] //// + +//// [unicodeSurrogatesInStringLiterals.ts] +// low-high surrogate pair - the "correct" case +export const highLow = "\ud83d\ude03" as const; + +// high surrogate +export const high = "\ud83d" as const; + +// low surrogate +export const low = "\ude03" as const; + +// two high surrogates +export const highHigh = "\ud83d\ud83d" as const; + +// two low surrogates +export const lowLow = "\ude03\ude03" as const; + +// swapped expected order of surrogates +export const lowHigh = "\ude03\ud83d" as const; + + +//// [unicodeSurrogatesInStringLiterals.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.lowHigh = exports.lowLow = exports.highHigh = exports.low = exports.high = exports.highLow = void 0; +// low-high surrogate pair - the "correct" case +exports.highLow = "\ud83d\ude03"; +// high surrogate +exports.high = "\ud83d"; +// low surrogate +exports.low = "\ude03"; +// two high surrogates +exports.highHigh = "\ud83d\ud83d"; +// two low surrogates +exports.lowLow = "\ude03\ude03"; +// swapped expected order of surrogates +exports.lowHigh = "\ude03\ud83d"; + + +//// [unicodeSurrogatesInStringLiterals.d.ts] +export declare const highLow: "😃"; +export declare const high: "īŋŊ"; +export declare const low: "īŋŊ"; +export declare const highHigh: "īŋŊīŋŊ"; +export declare const lowLow: "īŋŊīŋŊ"; +export declare const lowHigh: "īŋŊīŋŊ"; diff --git a/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.symbols b/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.symbols new file mode 100644 index 0000000000..df74f86bde --- /dev/null +++ b/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/unicodeSurrogatesInStringLiterals.ts] //// + +=== unicodeSurrogatesInStringLiterals.ts === +// low-high surrogate pair - the "correct" case +export const highLow = "\ud83d\ude03" as const; +>highLow : Symbol(highLow, Decl(unicodeSurrogatesInStringLiterals.ts, 1, 12)) +>const : Symbol(const) + +// high surrogate +export const high = "\ud83d" as const; +>high : Symbol(high, Decl(unicodeSurrogatesInStringLiterals.ts, 4, 12)) +>const : Symbol(const) + +// low surrogate +export const low = "\ude03" as const; +>low : Symbol(low, Decl(unicodeSurrogatesInStringLiterals.ts, 7, 12)) +>const : Symbol(const) + +// two high surrogates +export const highHigh = "\ud83d\ud83d" as const; +>highHigh : Symbol(highHigh, Decl(unicodeSurrogatesInStringLiterals.ts, 10, 12)) +>const : Symbol(const) + +// two low surrogates +export const lowLow = "\ude03\ude03" as const; +>lowLow : Symbol(lowLow, Decl(unicodeSurrogatesInStringLiterals.ts, 13, 12)) +>const : Symbol(const) + +// swapped expected order of surrogates +export const lowHigh = "\ude03\ud83d" as const; +>lowHigh : Symbol(lowHigh, Decl(unicodeSurrogatesInStringLiterals.ts, 16, 12)) +>const : Symbol(const) + diff --git a/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.types b/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.types new file mode 100644 index 0000000000..26778de70b --- /dev/null +++ b/testdata/baselines/reference/compiler/unicodeSurrogatesInStringLiterals.types @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/unicodeSurrogatesInStringLiterals.ts] //// + +=== unicodeSurrogatesInStringLiterals.ts === +// low-high surrogate pair - the "correct" case +export const highLow = "\ud83d\ude03" as const; +>highLow : "😃" +>"\ud83d\ude03" as const : "😃" +>"\ud83d\ude03" : "😃" + +// high surrogate +export const high = "\ud83d" as const; +>high : "īŋŊ" +>"\ud83d" as const : "īŋŊ" +>"\ud83d" : "īŋŊ" + +// low surrogate +export const low = "\ude03" as const; +>low : "īŋŊ" +>"\ude03" as const : "īŋŊ" +>"\ude03" : "īŋŊ" + +// two high surrogates +export const highHigh = "\ud83d\ud83d" as const; +>highHigh : "īŋŊīŋŊ" +>"\ud83d\ud83d" as const : "īŋŊīŋŊ" +>"\ud83d\ud83d" : "īŋŊīŋŊ" + +// two low surrogates +export const lowLow = "\ude03\ude03" as const; +>lowLow : "īŋŊīŋŊ" +>"\ude03\ude03" as const : "īŋŊīŋŊ" +>"\ude03\ude03" : "īŋŊīŋŊ" + +// swapped expected order of surrogates +export const lowHigh = "\ude03\ud83d" as const; +>lowHigh : "īŋŊīŋŊ" +>"\ude03\ud83d" as const : "īŋŊīŋŊ" +>"\ude03\ud83d" : "īŋŊīŋŊ" + diff --git a/testdata/baselines/reference/conformance/deepElementAccessExpressionInJS.js b/testdata/baselines/reference/conformance/deepElementAccessExpressionInJS.js index 74a48be03c..a38d407c96 100644 --- a/testdata/baselines/reference/conformance/deepElementAccessExpressionInJS.js +++ b/testdata/baselines/reference/conformance/deepElementAccessExpressionInJS.js @@ -16,6 +16,7 @@ function calculatePropertyName(index) { //// [elementAccessExpressionInJS.js] +"use strict"; if (module[calculatePropertyName(1)]) { } function calculatePropertyName(index) { diff --git a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.errors.txt b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.errors.txt deleted file mode 100644 index 45259ff67b..0000000000 --- a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -/a.js(2,11): error TS8040: A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag. -/a.js(8,11): error TS8040: A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag. -/a.js(15,11): error TS8040: A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag. - - -==== /a.js (3 errors) ==== - /** - * @type {(a: 1) => true} - ~~~~~~~~~~~~~~ -!!! error TS8040: A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag. - * @param {2} a - */ - export function conflictingParam(a) { return true } - - /** - * @type {(b: 3) => true} - ~~~~~~~~~~~~~~ -!!! error TS8040: A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag. - * @return {false} - */ - export function conflictingReturn(b) { return false } - - - /** - * @type {(c: 4) => true} - ~~~~~~~~~~~~~~ -!!! error TS8040: A JSDoc '@type' tag may not occur with a '@param' or '@returns' tag. - * @param {5} d - * @return {false} - */ - export function conflictingBoth(d) { return false } - - \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.js b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.js index 488da6a2de..5c551238dd 100644 --- a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.js +++ b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.js @@ -1,44 +1,126 @@ //// [tests/cases/conformance/jsdoc/jsdocTypeParameterTagConflict.ts] //// //// [a.js] +// @type on a function is applicable when there are no preceding @param, @return, or @template annotations +// and no @type parameter annotations. + +// @param for a parameter is applicable when there is no applicable @type annotation for the function and +// no @type annotation on the parameter. + +// @return is applicable when there is no applicable @type annotation for the function. + +// @template is applicable when there is no applicable @type annotation for the function. + /** - * @type {(a: 1) => true} - * @param {2} a + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} */ -export function conflictingParam(a) { return true } +function f1(/** @type {5}*/ a, b) { return "abc" } /** - * @type {(b: 3) => true} - * @return {false} + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} */ -export function conflictingReturn(b) { return false } +function f2(a, b) { return 42 } +/** + * @param {3} a + * @type {(a: 1, b: 2) => number} + * @param {4} b + * @return {string} + */ +function f3(a, b) { return "abc" } + +/** + * @return {string} + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + */ +function f4(a, b) { return "abc" } + +/** + * @type {(a: 1, b: 2) => number} + * @template T + * @template U + * @param {T} a + * @param {U} b + * @return {string} + */ +function f5(a, b) { return 42 } /** - * @type {(c: 4) => true} - * @param {5} d - * @return {false} + * @template T + * @type {(a: 1, b: 2) => number} + * @template U + * @param {T} a + * @param {U} b + * @return {string} */ -export function conflictingBoth(d) { return false } +function f6(a, b) { return "abc" } +/** + * @param {1} a + * @param {2} a + */ +function f7(a) {} //// [a.d.ts] /** - * @type {(a: 1) => true} - * @param {2} a + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} */ -export declare function conflictingParam(a: 2): true; +declare function f1(/** @type {5}*/ a: 5, b: 4): string; /** - * @type {(b: 3) => true} - * @return {false} + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} */ -export declare function conflictingReturn(b: 3): false; +declare function f2(a: 1, b: 2): number; /** - * @type {(c: 4) => true} - * @param {5} d - * @return {false} + * @param {3} a + * @type {(a: 1, b: 2) => number} + * @param {4} b + * @return {string} + */ +declare function f3(a: 3, b: 4): string; +/** + * @return {string} + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + */ +declare function f4(a: 3, b: 4): string; +/** + * @type {(a: 1, b: 2) => number} + * @template T + * @template U + * @param {T} a + * @param {U} b + * @return {string} + */ +declare function f5(a: 1, b: 2): number; +/** + * @template T + * @type {(a: 1, b: 2) => number} + * @template U + * @param {T} a + * @param {U} b + * @return {string} + */ +declare function f6(a: T, b: U): string; +/** + * @param {1} a + * @param {2} a */ -export declare function conflictingBoth(d: 5): false; +declare function f7(a: 1): void; diff --git a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.symbols b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.symbols index 488ac65579..168456c74f 100644 --- a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.symbols +++ b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.symbols @@ -1,30 +1,91 @@ //// [tests/cases/conformance/jsdoc/jsdocTypeParameterTagConflict.ts] //// === /a.js === +// @type on a function is applicable when there are no preceding @param, @return, or @template annotations +// and no @type parameter annotations. + +// @param for a parameter is applicable when there is no applicable @type annotation for the function and +// no @type annotation on the parameter. + +// @return is applicable when there is no applicable @type annotation for the function. + +// @template is applicable when there is no applicable @type annotation for the function. + /** - * @type {(a: 1) => true} - * @param {2} a + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} + */ +function f1(/** @type {5}*/ a, b) { return "abc" } +>f1 : Symbol(f1, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 16, 12)) +>b : Symbol(b, Decl(a.js, 16, 30)) + +/** + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} */ -export function conflictingParam(a) { return true } ->conflictingParam : Symbol(conflictingParam, Decl(a.js, 0, 0)) ->a : Symbol(a, Decl(a.js, 4, 33)) +function f2(a, b) { return 42 } +>f2 : Symbol(f2, Decl(a.js, 16, 50)) +>a : Symbol(a, Decl(a.js, 24, 12)) +>b : Symbol(b, Decl(a.js, 24, 14)) /** - * @type {(b: 3) => true} - * @return {false} + * @param {3} a + * @type {(a: 1, b: 2) => number} + * @param {4} b + * @return {string} */ -export function conflictingReturn(b) { return false } ->conflictingReturn : Symbol(conflictingReturn, Decl(a.js, 4, 51)) ->b : Symbol(b, Decl(a.js, 10, 34)) +function f3(a, b) { return "abc" } +>f3 : Symbol(f3, Decl(a.js, 24, 31)) +>a : Symbol(a, Decl(a.js, 32, 12)) +>b : Symbol(b, Decl(a.js, 32, 14)) +/** + * @return {string} + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + */ +function f4(a, b) { return "abc" } +>f4 : Symbol(f4, Decl(a.js, 32, 34)) +>a : Symbol(a, Decl(a.js, 40, 12)) +>b : Symbol(b, Decl(a.js, 40, 14)) + +/** + * @type {(a: 1, b: 2) => number} + * @template T + * @template U + * @param {T} a + * @param {U} b + * @return {string} + */ +function f5(a, b) { return 42 } +>f5 : Symbol(f5, Decl(a.js, 40, 34)) +>a : Symbol(a, Decl(a.js, 50, 12)) +>b : Symbol(b, Decl(a.js, 50, 14)) /** - * @type {(c: 4) => true} - * @param {5} d - * @return {false} + * @template T + * @type {(a: 1, b: 2) => number} + * @template U + * @param {T} a + * @param {U} b + * @return {string} */ -export function conflictingBoth(d) { return false } ->conflictingBoth : Symbol(conflictingBoth, Decl(a.js, 10, 53)) ->d : Symbol(d, Decl(a.js, 18, 32)) +function f6(a, b) { return "abc" } +>f6 : Symbol(f6, Decl(a.js, 50, 31)) +>a : Symbol(a, Decl(a.js, 60, 12)) +>b : Symbol(b, Decl(a.js, 60, 14)) +/** + * @param {1} a + * @param {2} a + */ +function f7(a) {} +>f7 : Symbol(f7, Decl(a.js, 60, 34)) +>a : Symbol(a, Decl(a.js, 66, 12)) diff --git a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.types b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.types index c011a7682c..eeeac7e45d 100644 --- a/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.types +++ b/testdata/baselines/reference/conformance/jsdocTypeParameterTagConflict.types @@ -1,33 +1,97 @@ //// [tests/cases/conformance/jsdoc/jsdocTypeParameterTagConflict.ts] //// === /a.js === +// @type on a function is applicable when there are no preceding @param, @return, or @template annotations +// and no @type parameter annotations. + +// @param for a parameter is applicable when there is no applicable @type annotation for the function and +// no @type annotation on the parameter. + +// @return is applicable when there is no applicable @type annotation for the function. + +// @template is applicable when there is no applicable @type annotation for the function. + /** - * @type {(a: 1) => true} - * @param {2} a + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} + */ +function f1(/** @type {5}*/ a, b) { return "abc" } +>f1 : (a: 5, b: 4) => string +>a : 5 +>b : 4 +>"abc" : "abc" + +/** + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + * @return {string} */ -export function conflictingParam(a) { return true } ->conflictingParam : (a: 2) => true ->a : 2 ->true : true +function f2(a, b) { return 42 } +>f2 : (a: 1, b: 2) => number +>a : 1 +>b : 2 +>42 : 42 /** - * @type {(b: 3) => true} - * @return {false} + * @param {3} a + * @type {(a: 1, b: 2) => number} + * @param {4} b + * @return {string} */ -export function conflictingReturn(b) { return false } ->conflictingReturn : (b: 3) => false ->b : 3 ->false : false +function f3(a, b) { return "abc" } +>f3 : (a: 3, b: 4) => string +>a : 3 +>b : 4 +>"abc" : "abc" +/** + * @return {string} + * @type {(a: 1, b: 2) => number} + * @param {3} a + * @param {4} b + */ +function f4(a, b) { return "abc" } +>f4 : (a: 3, b: 4) => string +>a : 3 +>b : 4 +>"abc" : "abc" + +/** + * @type {(a: 1, b: 2) => number} + * @template T + * @template U + * @param {T} a + * @param {U} b + * @return {string} + */ +function f5(a, b) { return 42 } +>f5 : (a: 1, b: 2) => number +>a : 1 +>b : 2 +>42 : 42 /** - * @type {(c: 4) => true} - * @param {5} d - * @return {false} + * @template T + * @type {(a: 1, b: 2) => number} + * @template U + * @param {T} a + * @param {U} b + * @return {string} */ -export function conflictingBoth(d) { return false } ->conflictingBoth : (d: 5) => false ->d : 5 ->false : false +function f6(a, b) { return "abc" } +>f6 : (a: T, b: U) => string +>a : T +>b : U +>"abc" : "abc" +/** + * @param {1} a + * @param {2} a + */ +function f7(a) {} +>f7 : (a: 1) => void +>a : 1 diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.js b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.js new file mode 100644 index 0000000000..16af97d07e --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts] //// + +//// [typedefModuleExportsIndirect1.js] +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +module.exports = dummy; +//// [use.js] +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c + + +//// [typedefModuleExportsIndirect1.js] +"use strict"; +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +module.exports = dummy; +//// [use.js] +"use strict"; +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c; + + +//// [typedefModuleExportsIndirect1.d.ts] +export type C = { + a: 1; + m: 1; +}; +export = dummy; +//// [use.d.ts] +type C = import('./typedefModuleExportsIndirect1').C; +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +declare var c: C; + + +//// [DtsFileErrors] + + +dist/typedefModuleExportsIndirect1.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +dist/typedefModuleExportsIndirect1.d.ts(5,10): error TS2304: Cannot find name 'dummy'. +dist/use.d.ts(1,52): error TS2694: Namespace 'unknown' has no exported member 'C'. + + +==== dist/typedefModuleExportsIndirect1.d.ts (2 errors) ==== + export type C = { + a: 1; + m: 1; + }; + export = dummy; + ~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~~~~~ +!!! error TS2304: Cannot find name 'dummy'. + +==== dist/use.d.ts (1 errors) ==== + type C = import('./typedefModuleExportsIndirect1').C; + ~ +!!! error TS2694: Namespace 'unknown' has no exported member 'C'. + /** @typedef {import('./typedefModuleExportsIndirect1').C} C */ + /** @type {C} */ + declare var c: C; + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.symbols b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.symbols new file mode 100644 index 0000000000..cc609e1896 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts] //// + +=== typedefModuleExportsIndirect1.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +>dummy : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) + +module.exports = dummy; +>module.exports : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) +>module : Symbol("typedefModuleExportsIndirect1", Decl(typedefModuleExportsIndirect1.js, 0, 0)) +>exports : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) +>dummy : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c +>c : Symbol(c, Decl(use.js, 2, 3)) + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.types b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.types new file mode 100644 index 0000000000..314c92c037 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts] //// + +=== typedefModuleExportsIndirect1.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +>dummy : 0 +>0 : 0 + +module.exports = dummy; +>module.exports = dummy : 0 +>module.exports : 0 +>module : { readonly dummy: 0; } +>exports : 0 +>dummy : 0 + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c +>c : import("typedefModuleExportsIndirect1").C + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.js b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.js new file mode 100644 index 0000000000..0d5492f3e3 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts] //// + +//// [typedefModuleExportsIndirect2.js] +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +module.exports = f; +//// [use.js] +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c + + +//// [typedefModuleExportsIndirect2.js] +"use strict"; +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function () { }; +module.exports = f; +//// [use.js] +"use strict"; +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c; + + +//// [typedefModuleExportsIndirect2.d.ts] +export type C = { + a: 1; + m: 1; +}; +export = f; +//// [use.d.ts] +type C = import('./typedefModuleExportsIndirect2').C; +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +declare var c: C; + + +//// [DtsFileErrors] + + +dist/typedefModuleExportsIndirect2.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +dist/typedefModuleExportsIndirect2.d.ts(5,10): error TS2304: Cannot find name 'f'. +dist/use.d.ts(1,52): error TS2694: Namespace 'unknown' has no exported member 'C'. + + +==== dist/typedefModuleExportsIndirect2.d.ts (2 errors) ==== + export type C = { + a: 1; + m: 1; + }; + export = f; + ~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~ +!!! error TS2304: Cannot find name 'f'. + +==== dist/use.d.ts (1 errors) ==== + type C = import('./typedefModuleExportsIndirect2').C; + ~ +!!! error TS2694: Namespace 'unknown' has no exported member 'C'. + /** @typedef {import('./typedefModuleExportsIndirect2').C} C */ + /** @type {C} */ + declare var c: C; + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.symbols b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.symbols new file mode 100644 index 0000000000..66b77d9c1b --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts] //// + +=== typedefModuleExportsIndirect2.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +>f : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) + +module.exports = f; +>module.exports : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) +>module : Symbol("typedefModuleExportsIndirect2", Decl(typedefModuleExportsIndirect2.js, 0, 0)) +>exports : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) +>f : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c +>c : Symbol(c, Decl(use.js, 2, 3)) + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.types b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.types new file mode 100644 index 0000000000..979ef24238 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts] //// + +=== typedefModuleExportsIndirect2.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +>f : () => void +>function() {} : () => void + +module.exports = f; +>module.exports = f : () => void +>module.exports : () => void +>module : { readonly f: () => void; } +>exports : () => void +>f : () => void + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c +>c : import("typedefModuleExportsIndirect2").C + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.js b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.js new file mode 100644 index 0000000000..2daa007515 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts] //// + +//// [typedefModuleExportsIndirect3.js] +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +module.exports = o; +//// [use.js] +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c + + +//// [typedefModuleExportsIndirect3.js] +"use strict"; +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +module.exports = o; +//// [use.js] +"use strict"; +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c; + + +//// [typedefModuleExportsIndirect3.d.ts] +export type C = { + a: 1; + m: 1; +}; +export = o; +//// [use.d.ts] +type C = import('./typedefModuleExportsIndirect3').C; +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +declare var c: C; + + +//// [DtsFileErrors] + + +dist/typedefModuleExportsIndirect3.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +dist/typedefModuleExportsIndirect3.d.ts(5,10): error TS2304: Cannot find name 'o'. +dist/use.d.ts(1,52): error TS2694: Namespace 'unknown' has no exported member 'C'. + + +==== dist/typedefModuleExportsIndirect3.d.ts (2 errors) ==== + export type C = { + a: 1; + m: 1; + }; + export = o; + ~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~ +!!! error TS2304: Cannot find name 'o'. + +==== dist/use.d.ts (1 errors) ==== + type C = import('./typedefModuleExportsIndirect3').C; + ~ +!!! error TS2694: Namespace 'unknown' has no exported member 'C'. + /** @typedef {import('./typedefModuleExportsIndirect3').C} C */ + /** @type {C} */ + declare var c: C; + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.symbols b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.symbols new file mode 100644 index 0000000000..0f1a451f01 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts] //// + +=== typedefModuleExportsIndirect3.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +>o : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) + +module.exports = o; +>module.exports : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) +>module : Symbol("typedefModuleExportsIndirect3", Decl(typedefModuleExportsIndirect3.js, 0, 0)) +>exports : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) +>o : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c +>c : Symbol(c, Decl(use.js, 2, 3)) + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.types b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.types new file mode 100644 index 0000000000..be9e0ac169 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts] //// + +=== typedefModuleExportsIndirect3.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +>o : {} +>{} : {} + +module.exports = o; +>module.exports = o : {} +>module.exports : {} +>module : { readonly o: {}; } +>exports : {} +>o : {} + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c +>c : import("typedefModuleExportsIndirect3").C + diff --git a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md index 1fff3fc8ff..a679c95fee 100644 --- a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md +++ b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md @@ -6,7 +6,7 @@ someVar; a/**/ ``````ts -import {someVar,anotherVar} from "./a.ts"; +import {anotherVar, someVar} from "./a.ts"; someVar; a diff --git a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md index e565df0c68..b70487e0b7 100644 --- a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md +++ b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md @@ -6,7 +6,7 @@ someVar; b/**/ ``````ts -import { aa, someVar,bb } from "./a.ts"; +import { aa, bb, someVar } from "./a.ts"; someVar; b diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc index e819cd0446..e010a5eca3 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc @@ -5,7 +5,7 @@ // prop1: string; // } // -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -17,7 +17,7 @@ // } // // class D extends C { -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc index 5176a15ed5..bdee4ee2f5 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc @@ -10,7 +10,7 @@ // // let localPublic = publicParam; // this.publicParam += " Hello!"; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -66,7 +66,7 @@ // // let localPublic = publicParam; // this.publicParam += " Hello!"; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -82,7 +82,7 @@ // // let localPublic = publicParam; // this.publicParam += " Hello!"; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc index 69914c5798..506a26e40c 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc @@ -10,7 +10,7 @@ // this.privateParam += 10; // // let localPublic = publicParam; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -29,7 +29,7 @@ // this.publicParam += " Hello!"; // // let localProtected = protectedParam; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -66,7 +66,7 @@ // this.privateParam += 10; // // let localPublic = publicParam; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -85,7 +85,7 @@ // this.publicParam += " Hello!"; // // let localProtected = protectedParam; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc index c5e2753dbe..6f6a8128a0 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc @@ -10,7 +10,7 @@ // this.privateParam += 10; // // let localPublic = publicParam; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -29,7 +29,7 @@ // this.publicParam += " Hello!"; // // let localProtected = protectedParam; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -66,7 +66,7 @@ // this.privateParam += 10; // // let localPublic = publicParam; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -85,7 +85,7 @@ // this.publicParam += " Hello!"; // // let localProtected = protectedParam; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightJSDocTypedef.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightJSDocTypedef.baseline.jsonc index 8e19a1b263..45d27cb06e 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightJSDocTypedef.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightJSDocTypedef.baseline.jsonc @@ -6,7 +6,7 @@ // * bar: number; // * }} Foo // */ -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -19,7 +19,7 @@ // * }} Foo // */ // -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightReferenceDirective.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightReferenceDirective.baseline.jsonc new file mode 100644 index 0000000000..affad0dae7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightReferenceDirective.baseline.jsonc @@ -0,0 +1,6 @@ +// === documentHighlights === +// === /a.ts === +// /// +// +// const x = 1; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightTemplateStrings.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightTemplateStrings.baseline.jsonc index e7504bc218..000c5e8db0 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightTemplateStrings.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightTemplateStrings.baseline.jsonc @@ -8,4 +8,4 @@ // return 1; // case "b": // return 2; -// // --- (line: 11) skipped --- \ No newline at end of file +// --- (line: 11) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc index 694ac0952d..ee841cc3dd 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc @@ -5,7 +5,7 @@ // } // function f(readonly p) {} // -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_40082.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_40082.baseline.jsonc index 9a74597f6d..5d0cc5cbf7 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_40082.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_40082.baseline.jsonc @@ -1,6 +1,6 @@ // === documentHighlights === // === /documentHighlights_40082.ts === // export = (state, messages) => { -// export /*HIGHLIGHTS*/default { +// export /*HIGHLIGHTS*/[|default|] { // } // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/emptyExportFindReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/emptyExportFindReferences.baseline.jsonc index d013f7427a..ededeb5e3c 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/emptyExportFindReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/emptyExportFindReferences.baseline.jsonc @@ -1,5 +1,5 @@ // === documentHighlights === // === /Foo.js === -// /*HIGHLIGHTS*/module.exports = { +// /*HIGHLIGHTS*/[|module.exports = { // -// } \ No newline at end of file +// }|] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc new file mode 100644 index 0000000000..fbd7faf736 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc @@ -0,0 +1,15 @@ +// === documentHighlights === +// === /b.ts === +// import { x } from "/*HIGHLIGHTS*/[|./a|]"; + + + +// === documentHighlights === +// === /c/sub.js === +// const a = require("/*HIGHLIGHTS*/[|../a|]"); + + + +// === documentHighlights === +// === /d.ts === +// /// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc index 3d811b7b7a..14420aa91d 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc @@ -8,7 +8,7 @@ // } // // Abstract class below should not get highlighted // abstract class Foo { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -22,7 +22,7 @@ // } // // Abstract class below should not get highlighted // abstract class Foo { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -36,7 +36,7 @@ // } // // Abstract class below should not get highlighted // abstract class Foo { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -50,7 +50,7 @@ // } // // Abstract class below should not get highlighted // abstract class Foo { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -64,4 +64,4 @@ // } // // Abstract class below should not get highlighted // abstract class Foo { -// // --- (line: 9) skipped --- \ No newline at end of file +// --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc index 08faaf8825..176fb79f21 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc @@ -32,7 +32,7 @@ // } // // abstract cannot appear here, won't get highlighted // let c = abstract class Foo { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -45,4 +45,4 @@ // } // // abstract cannot appear here, won't get highlighted // let c = abstract class Foo { -// // --- (line: 8) skipped --- \ No newline at end of file +// --- (line: 8) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc index 10c2925c08..6a48f78847 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc @@ -6,7 +6,7 @@ // } // abstract class B {} // } -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -18,7 +18,7 @@ // } // abstract class B {} // } -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc index 4934e838b1..2ed5c5bdd3 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc @@ -12,7 +12,7 @@ // await 300; // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -30,7 +30,7 @@ // await 300; // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -48,7 +48,7 @@ // await 300; // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -66,7 +66,7 @@ // await 300; // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -84,4 +84,4 @@ // await 300; // } // } -// // --- (line: 13) skipped --- \ No newline at end of file +// --- (line: 13) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc index 7b5c4730a1..4a4dcf7c02 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc @@ -8,7 +8,7 @@ // } // } // -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -22,7 +22,7 @@ // } // } // -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -36,7 +36,7 @@ // } // } // -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -50,4 +50,4 @@ // } // } // -// // --- (line: 9) skipped --- \ No newline at end of file +// --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc index 923a851a0c..94ad7b2590 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc @@ -11,7 +11,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -28,7 +28,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -45,7 +45,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -62,7 +62,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -79,4 +79,4 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- \ No newline at end of file +// --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc index 44ea7bf572..814ea2fb87 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc @@ -11,7 +11,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -28,7 +28,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -45,7 +45,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -62,7 +62,7 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -79,4 +79,4 @@ // } // // let B = class D { -// // --- (line: 12) skipped --- \ No newline at end of file +// --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc index 6e552e9a49..57a86ba00f 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc @@ -12,7 +12,7 @@ // } // // let B = class D { -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -30,7 +30,7 @@ // } // // let B = class D { -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -48,7 +48,7 @@ // } // // let B = class D { -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -66,4 +66,4 @@ // } // // let B = class D { -// // --- (line: 13) skipped --- \ No newline at end of file +// --- (line: 13) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc index d5d4cce282..dbe4c8051d 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc @@ -13,7 +13,7 @@ // } // } // function inside() { -// // --- (line: 39) skipped --- +// --- (line: 39) skipped --- @@ -32,7 +32,7 @@ // } // } // function inside() { -// // --- (line: 39) skipped --- +// --- (line: 39) skipped --- @@ -51,7 +51,7 @@ // } // } // function inside() { -// // --- (line: 39) skipped --- +// --- (line: 39) skipped --- @@ -70,7 +70,7 @@ // } // } // function inside() { -// // --- (line: 39) skipped --- +// --- (line: 39) skipped --- @@ -89,4 +89,4 @@ // } // } // function inside() { -// // --- (line: 39) skipped --- \ No newline at end of file +// --- (line: 39) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc index 0b18513ac4..ffaa22c5c0 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc @@ -28,7 +28,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -62,7 +62,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -96,7 +96,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -130,7 +130,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -164,7 +164,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -198,7 +198,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -232,7 +232,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -266,7 +266,7 @@ // } // // static bar() { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -300,4 +300,4 @@ // } // // static bar() { -// // --- (line: 29) skipped --- \ No newline at end of file +// --- (line: 29) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc index 9a0d835004..af2e5170e9 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc @@ -8,7 +8,7 @@ // if (a === undefined && r.length === 0) { // return; // } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -22,7 +22,7 @@ // if (a === undefined && r.length === 0) { // return; // } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -36,7 +36,7 @@ // if (a === undefined && r.length === 0) { // return; // } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -50,4 +50,4 @@ // if (a === undefined && r.length === 0) { // return; // } -// // --- (line: 9) skipped --- \ No newline at end of file +// --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc index dcb84d6fb3..6d13696877 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc @@ -8,7 +8,7 @@ // interface I2 { // } // } -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- // --- (line: 45) skipped --- // } @@ -31,7 +31,7 @@ // interface I2 { // } // } -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- // --- (line: 45) skipped --- // } @@ -54,7 +54,7 @@ // interface I2 { // } // } -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- // --- (line: 45) skipped --- // } diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc index e8aad750bf..aa39315422 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc @@ -8,4 +8,4 @@ // // export class C2 { // public pub1; -// // --- (line: 41) skipped --- \ No newline at end of file +// --- (line: 41) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc index fe4b8851c5..e93934e75e 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc @@ -5,7 +5,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; @@ -24,7 +24,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; @@ -43,7 +43,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; @@ -62,7 +62,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc index bc27b75743..c2215000ab 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc @@ -5,7 +5,7 @@ // public pub1; // public pub2; // private priv1; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 24) skipped --- // protected static statProt; @@ -23,7 +23,7 @@ // declare var foo; // // export class C2 { -// // --- (line: 40) skipped --- +// --- (line: 40) skipped --- // --- (line: 46) skipped --- // } @@ -42,7 +42,7 @@ // public pub1; // public pub2; // private priv1; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 24) skipped --- // protected static statProt; @@ -60,7 +60,7 @@ // declare var foo; // // export class C2 { -// // --- (line: 40) skipped --- +// --- (line: 40) skipped --- // --- (line: 46) skipped --- // } @@ -79,7 +79,7 @@ // public pub1; // public pub2; // private priv1; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 24) skipped --- // protected static statProt; @@ -97,7 +97,7 @@ // declare var foo; // // export class C2 { -// // --- (line: 40) skipped --- +// --- (line: 40) skipped --- // --- (line: 46) skipped --- // } @@ -116,7 +116,7 @@ // public pub1; // public pub2; // private priv1; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 24) skipped --- // protected static statProt; @@ -134,7 +134,7 @@ // declare var foo; // // export class C2 { -// // --- (line: 40) skipped --- +// --- (line: 40) skipped --- // --- (line: 46) skipped --- // } @@ -153,7 +153,7 @@ // public pub1; // public pub2; // private priv1; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 24) skipped --- // protected static statProt; @@ -171,7 +171,7 @@ // declare var foo; // // export class C2 { -// // --- (line: 40) skipped --- +// --- (line: 40) skipped --- // --- (line: 46) skipped --- // } diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc index a870127ec7..8002597a24 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc @@ -8,4 +8,4 @@ // public pub1; // private priv1; // protected prot1; -// // --- (line: 43) skipped --- \ No newline at end of file +// --- (line: 43) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc index f403d6f737..cb1dbbda9c 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc @@ -5,7 +5,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; @@ -24,7 +24,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; @@ -43,7 +43,7 @@ // // module m { // export class C1 { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 53) skipped --- // declare function foo(): string; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc index f8dcb8e4ee..27751a8374 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc @@ -4,7 +4,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; @@ -27,7 +27,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; @@ -50,7 +50,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; @@ -73,7 +73,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; @@ -96,7 +96,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; @@ -119,7 +119,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; @@ -142,7 +142,7 @@ // if (false) { // } // else { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 10) skipped --- // var x = undefined; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc index 1bfc0a9616..3445107591 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc @@ -7,7 +7,7 @@ // } // if (true) { // } -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -20,4 +20,4 @@ // } // if (true) { // } -// // --- (line: 8) skipped --- \ No newline at end of file +// --- (line: 8) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc index b519b05023..3a5564b744 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc @@ -11,7 +11,7 @@ // if (false) // if (true) // var x = undefined; -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -28,4 +28,4 @@ // if (false) // if (true) // var x = undefined; -// // --- (line: 12) skipped --- \ No newline at end of file +// --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc index 18d8c97660..e83646bb59 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc @@ -13,7 +13,7 @@ // // break; // continue; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -32,7 +32,7 @@ // // break; // continue; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -51,7 +51,7 @@ // // break; // continue; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -70,7 +70,7 @@ // // break; // continue; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -89,7 +89,7 @@ // // break; // continue; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -108,7 +108,7 @@ // // break; // continue; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -127,4 +127,4 @@ // // break; // continue; -// // --- (line: 14) skipped --- \ No newline at end of file +// --- (line: 14) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc index 2449c57254..286cb6d4b5 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc @@ -15,7 +15,7 @@ // // function foo() { // label3: while (true) { -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- @@ -36,7 +36,7 @@ // // function foo() { // label3: while (true) { -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- @@ -57,7 +57,7 @@ // // function foo() { // label3: while (true) { -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- @@ -78,7 +78,7 @@ // // function foo() { // label3: while (true) { -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- @@ -99,4 +99,4 @@ // // function foo() { // label3: while (true) { -// // --- (line: 19) skipped --- \ No newline at end of file +// --- (line: 19) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc index dda8ff0265..3fbfb484fd 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc @@ -12,7 +12,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -23,7 +23,7 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- @@ -41,7 +41,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -52,7 +52,7 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- @@ -70,7 +70,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -81,7 +81,7 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- @@ -99,7 +99,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -110,7 +110,7 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- @@ -128,7 +128,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -139,7 +139,7 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- @@ -157,7 +157,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -168,7 +168,7 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- @@ -186,7 +186,7 @@ // // // these cross function boundaries // break label1; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 32) skipped --- // break label4; @@ -197,4 +197,4 @@ // // switch (10) { // case 1: -// // --- (line: 41) skipped --- \ No newline at end of file +// --- (line: 41) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc index 36319f7756..2c11a4aad0 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc @@ -32,7 +32,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -70,7 +70,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -108,7 +108,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -146,7 +146,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -184,7 +184,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -222,7 +222,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -260,7 +260,7 @@ // } // } // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- @@ -298,4 +298,4 @@ // } // } // } -// // --- (line: 58) skipped --- \ No newline at end of file +// --- (line: 58) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc index 6bdbd543a4..125a07de88 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc @@ -8,7 +8,7 @@ // // constructor(export conFoo, // declare conBar, -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -22,7 +22,7 @@ // // constructor(export conFoo, // declare conBar, -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -36,7 +36,7 @@ // // constructor(export conFoo, // declare conBar, -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -50,7 +50,7 @@ // // constructor(export conFoo, // declare conBar, -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -64,7 +64,7 @@ // // constructor(export conFoo, // declare conBar, -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -78,7 +78,7 @@ // // constructor(export conFoo, // declare conBar, -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -101,7 +101,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -124,7 +124,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -147,7 +147,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -170,7 +170,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -193,7 +193,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -216,7 +216,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -233,7 +233,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -250,7 +250,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -273,7 +273,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -296,7 +296,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -313,7 +313,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -336,7 +336,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -359,7 +359,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -382,7 +382,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -399,7 +399,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -422,7 +422,7 @@ // } // } // -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -436,7 +436,7 @@ // public b; // private c; // protected d; -// // --- (line: 23) skipped --- +// --- (line: 23) skipped --- @@ -450,7 +450,7 @@ // private c; // protected d; // static public private protected e; -// // --- (line: 24) skipped --- +// --- (line: 24) skipped --- @@ -464,7 +464,7 @@ // protected d; // static public private protected e; // public static protected private f; -// // --- (line: 25) skipped --- +// --- (line: 25) skipped --- @@ -478,7 +478,7 @@ // static public private protected e; // public static protected private f; // protected static public g; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- @@ -492,7 +492,7 @@ // public static protected private f; // protected static public g; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -506,7 +506,7 @@ // public static protected private f; // protected static public g; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -520,7 +520,7 @@ // public static protected private f; // protected static public g; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -534,7 +534,7 @@ // public static protected private f; // protected static public g; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -548,7 +548,7 @@ // protected static public g; // } // static a; -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -562,7 +562,7 @@ // protected static public g; // } // static a; -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -576,7 +576,7 @@ // protected static public g; // } // static a; -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -590,7 +590,7 @@ // protected static public g; // } // static a; -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -604,7 +604,7 @@ // } // static a; // public b; -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -618,7 +618,7 @@ // } // static a; // public b; -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -632,7 +632,7 @@ // } // static a; // public b; -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -646,7 +646,7 @@ // public b; // private c; // protected d; -// // --- (line: 31) skipped --- +// --- (line: 31) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc index 3617a1c9ba..4ac62facb2 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc @@ -27,7 +27,7 @@ // protected static statProt; // } // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -60,7 +60,7 @@ // protected static statProt; // } // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -93,7 +93,7 @@ // protected static statProt; // } // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -126,7 +126,7 @@ // protected static statProt; // } // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -159,7 +159,7 @@ // protected static statProt; // } // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -192,4 +192,4 @@ // protected static statProt; // } // -// // --- (line: 28) skipped --- \ No newline at end of file +// --- (line: 28) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc index f60965a862..cb5ec4f321 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc @@ -11,7 +11,7 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- +// --- (line: 48) skipped --- @@ -28,4 +28,4 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- \ No newline at end of file +// --- (line: 48) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc index 8490faf1d0..110aa435ee 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc @@ -15,7 +15,7 @@ // this.public = 10; // this.private = 10; // this.protected = 10; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- // --- (line: 21) skipped --- // @@ -25,7 +25,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -46,7 +46,7 @@ // this.public = 10; // this.private = 10; // this.protected = 10; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- // --- (line: 21) skipped --- // @@ -56,7 +56,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -77,7 +77,7 @@ // this.public = 10; // this.private = 10; // this.protected = 10; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- // --- (line: 21) skipped --- // @@ -87,7 +87,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -108,7 +108,7 @@ // this.public = 10; // this.private = 10; // this.protected = 10; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- // --- (line: 21) skipped --- // @@ -118,7 +118,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -139,7 +139,7 @@ // this.public = 10; // this.private = 10; // this.protected = 10; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- // --- (line: 21) skipped --- // @@ -149,7 +149,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -170,7 +170,7 @@ // this.public = 10; // this.private = 10; // this.protected = 10; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- // --- (line: 21) skipped --- // @@ -180,4 +180,4 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- \ No newline at end of file +// --- (line: 29) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc index 70dd56fa8a..bb0a6e58b0 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc @@ -10,7 +10,7 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- +// --- (line: 48) skipped --- @@ -26,7 +26,7 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- +// --- (line: 48) skipped --- @@ -42,4 +42,4 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- \ No newline at end of file +// --- (line: 48) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc index f0245158d1..f4d29bb6ee 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc @@ -26,7 +26,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -58,7 +58,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -90,7 +90,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -122,7 +122,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -154,7 +154,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -186,7 +186,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -218,7 +218,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -250,7 +250,7 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- @@ -282,4 +282,4 @@ // private static statPriv; // protected static statProt; // } -// // --- (line: 27) skipped --- \ No newline at end of file +// --- (line: 27) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc index 368425ff54..4341efbd50 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc @@ -12,7 +12,7 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- +// --- (line: 48) skipped --- @@ -30,4 +30,4 @@ // public = private = protected; // } // } -// // --- (line: 48) skipped --- \ No newline at end of file +// --- (line: 48) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc index aa353f0e86..6d1400c143 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc @@ -31,4 +31,4 @@ // constructor(readonly prop2: string) { // class D { // readonly prop: string = ""; -// // --- (line: 6) skipped --- \ No newline at end of file +// --- (line: 6) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc index e1e04ea209..0150bdb2f9 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc @@ -6,7 +6,7 @@ // return; // return; // return; -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- // --- (line: 12) skipped --- // @@ -26,7 +26,7 @@ // return; // return; // return; -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- // --- (line: 12) skipped --- // @@ -46,7 +46,7 @@ // return; // return; // return; -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- // --- (line: 12) skipped --- // diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc index 6a7fa7bfdd..d6d3046f3f 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc @@ -12,7 +12,7 @@ // } // })() || true; // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -30,7 +30,7 @@ // } // })() || true; // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -48,7 +48,7 @@ // } // })() || true; // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -66,4 +66,4 @@ // } // })() || true; // } -// // --- (line: 13) skipped --- \ No newline at end of file +// --- (line: 13) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc index f8e611291b..ef1ff56046 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc @@ -8,7 +8,7 @@ // return undefined; // } // -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -22,4 +22,4 @@ // return undefined; // } // -// // --- (line: 9) skipped --- \ No newline at end of file +// --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc index 99684a437f..4573eeed5a 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc @@ -11,7 +11,7 @@ // return undefined; // } // -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- @@ -28,4 +28,4 @@ // return undefined; // } // -// // --- (line: 16) skipped --- \ No newline at end of file +// --- (line: 16) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc index 669bccd3c2..3670237fd2 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc @@ -10,7 +10,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -26,7 +26,7 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- +// --- (line: 29) skipped --- @@ -42,4 +42,4 @@ // } // // export interface I1 { -// // --- (line: 29) skipped --- \ No newline at end of file +// --- (line: 29) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc index a89f8f9810..27e5817c58 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc @@ -28,7 +28,7 @@ // } // } // -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -62,7 +62,7 @@ // } // } // -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -96,7 +96,7 @@ // } // } // -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -130,7 +130,7 @@ // } // } // -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -164,7 +164,7 @@ // } // } // -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -198,7 +198,7 @@ // } // } // -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -232,4 +232,4 @@ // } // } // -// // --- (line: 35) skipped --- \ No newline at end of file +// --- (line: 35) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc index 199a3e90e5..6e1cfb87a4 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc @@ -15,7 +15,7 @@ // } // // // Are not actually 'super' keywords. -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- @@ -36,7 +36,7 @@ // } // // // Are not actually 'super' keywords. -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- @@ -57,4 +57,4 @@ // } // // // Are not actually 'super' keywords. -// // --- (line: 47) skipped --- \ No newline at end of file +// --- (line: 47) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc index 527a1d8087..79efd5ce98 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc @@ -9,7 +9,7 @@ // }, // c: function () { // return super.a(); -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- @@ -24,7 +24,7 @@ // }, // c: function () { // return super.a(); -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc index c1812ce56f..0610a1cd99 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc @@ -4,7 +4,7 @@ // super; // } // -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- @@ -15,7 +15,7 @@ // } // // module M { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -30,7 +30,7 @@ // function f(x = super) { // super; // } -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- @@ -44,7 +44,7 @@ // super; // } // -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -58,4 +58,4 @@ // } // // class A { -// // --- (line: 12) skipped --- \ No newline at end of file +// --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc index 2f45fd199e..9de4835b56 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc @@ -14,7 +14,7 @@ // } // case 0xBEEF: // default: -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -34,7 +34,7 @@ // } // case 0xBEEF: // default: -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -54,7 +54,7 @@ // } // case 0xBEEF: // default: -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -74,7 +74,7 @@ // } // case 0xBEEF: // default: -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -94,7 +94,7 @@ // } // case 0xBEEF: // default: -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -114,4 +114,4 @@ // } // case 0xBEEF: // default: -// // --- (line: 15) skipped --- \ No newline at end of file +// --- (line: 15) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc index 2418ead776..eae6c00b15 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc @@ -5,7 +5,7 @@ // // function f() { // this; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -16,4 +16,4 @@ // // function f() { // this; -// // --- (line: 6) skipped --- \ No newline at end of file +// --- (line: 6) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc index 76d9c05eb4..6736e22a6c 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc @@ -16,7 +16,7 @@ // } // } // function inside() { -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -38,7 +38,7 @@ // } // } // function inside() { -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -60,7 +60,7 @@ // } // } // function inside() { -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -82,7 +82,7 @@ // } // } // function inside() { -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -104,7 +104,7 @@ // } // } // function inside() { -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -126,4 +126,4 @@ // } // } // function inside() { -// // --- (line: 17) skipped --- \ No newline at end of file +// --- (line: 17) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc index 8beeaf0051..92bab07661 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc @@ -11,7 +11,7 @@ // } // } // -// // --- (line: 24) skipped --- +// --- (line: 24) skipped --- @@ -28,4 +28,4 @@ // } // } // -// // --- (line: 24) skipped --- \ No newline at end of file +// --- (line: 24) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc index 71a4333334..46336ec112 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc @@ -19,7 +19,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -37,7 +37,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -62,7 +62,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -80,7 +80,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -105,7 +105,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -123,7 +123,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -148,7 +148,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -166,7 +166,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -191,7 +191,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -209,7 +209,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -234,7 +234,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -252,7 +252,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -277,7 +277,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -295,7 +295,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -320,7 +320,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -338,7 +338,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -363,7 +363,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -381,7 +381,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -406,7 +406,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -424,7 +424,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -449,7 +449,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -467,7 +467,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -492,7 +492,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -510,7 +510,7 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- +// --- (line: 82) skipped --- @@ -535,7 +535,7 @@ // } // } // function inside() { -// // --- (line: 62) skipped --- +// --- (line: 62) skipped --- // --- (line: 66) skipped --- // } @@ -553,4 +553,4 @@ // } // } // function inside() { -// // --- (line: 82) skipped --- \ No newline at end of file +// --- (line: 82) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc index 12d80173a7..122dbc0190 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc @@ -19,7 +19,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -37,7 +37,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -62,7 +62,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -80,7 +80,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -105,7 +105,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -123,7 +123,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -148,7 +148,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -166,7 +166,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -191,7 +191,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -209,7 +209,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -234,7 +234,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -252,7 +252,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -277,7 +277,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -295,7 +295,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -320,7 +320,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -338,7 +338,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -363,7 +363,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -381,7 +381,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -406,7 +406,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -424,7 +424,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -449,7 +449,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -467,7 +467,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -492,7 +492,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -510,7 +510,7 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- +// --- (line: 124) skipped --- @@ -535,7 +535,7 @@ // } // } // function inside() { -// // --- (line: 104) skipped --- +// --- (line: 104) skipped --- // --- (line: 108) skipped --- // } @@ -553,4 +553,4 @@ // } // } // function inside() { -// // --- (line: 124) skipped --- \ No newline at end of file +// --- (line: 124) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc index b554a64c91..0e343b0c7e 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc @@ -21,7 +21,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -61,7 +61,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -101,7 +101,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -141,7 +141,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -181,7 +181,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -221,7 +221,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -261,7 +261,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; @@ -301,7 +301,7 @@ // return; // return; // return; -// // --- (line: 26) skipped --- +// --- (line: 26) skipped --- // --- (line: 30) skipped --- // })() || true; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc index db010fa874..4571f7ebd7 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc @@ -9,4 +9,4 @@ // } // catch (x) { // return 100; -// // --- (line: 10) skipped --- \ No newline at end of file +// --- (line: 10) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc index 86ca2055fc..7928edb6ae 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc @@ -15,7 +15,7 @@ // } // } // catch (x) { -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- @@ -36,4 +36,4 @@ // } // } // catch (x) { -// // --- (line: 16) skipped --- \ No newline at end of file +// --- (line: 16) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc index ffe619c700..d8d97ef913 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc @@ -15,7 +15,7 @@ // })() || true; // } // -// // --- (line: 34) skipped --- +// --- (line: 34) skipped --- @@ -36,7 +36,7 @@ // })() || true; // } // -// // --- (line: 34) skipped --- +// --- (line: 34) skipped --- @@ -57,7 +57,7 @@ // })() || true; // } // -// // --- (line: 34) skipped --- +// --- (line: 34) skipped --- @@ -78,7 +78,7 @@ // })() || true; // } // -// // --- (line: 34) skipped --- +// --- (line: 34) skipped --- @@ -99,4 +99,4 @@ // })() || true; // } // -// // --- (line: 34) skipped --- \ No newline at end of file +// --- (line: 34) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc index 64af032ca9..f92bdeb5c5 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc @@ -8,4 +8,4 @@ // } // catch (x) { // throw 10; -// // --- (line: 9) skipped --- \ No newline at end of file +// --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc index 721e41c40c..791f95c434 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc @@ -6,7 +6,7 @@ // class Foo { // *memberFunction() { // return yield 1; -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -18,7 +18,7 @@ // class Foo { // *memberFunction() { // return yield 1; -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -30,4 +30,4 @@ // class Foo { // *memberFunction() { // return yield 1; -// // --- (line: 7) skipped --- \ No newline at end of file +// --- (line: 7) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc index a1f16deccb..4d12d4f3f4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc @@ -1,8 +1,6 @@ // === findAllReferences === -// === /home/src/workspaces/project/a/index.d.ts === -// declare class [|A|] { -// } -// //# sourceMappingURL=index.d.ts.map +// === /home/src/workspaces/project/a/index.ts === +// class A {}[||] // === /home/src/workspaces/project/b/b.ts === // /// diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc index 360000f99d..ee50558949 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences1.ts === // export class C { -// /*FIND ALL REFS*/public constructor() { } +// /*FIND ALL REFS*/public [|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc index ebe82fac1e..a6c3c02e0f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences2.ts === // export class C { -// /*FIND ALL REFS*/private constructor() { } +// /*FIND ALL REFS*/private [|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc index a9c98eaea2..cf4ebb836b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences4.ts === // export class C { -// /*FIND ALL REFS*/protected constructor() { } +// /*FIND ALL REFS*/protected [|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc index cf2a41e027..af501fac1d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc @@ -18,7 +18,7 @@ // === /foo.ts === // export function foo() { return "foo"; } // import("./foo") -// /*FIND ALL REFS*/var x = import("./foo") +// /*FIND ALL REFS*/var [|x|] = import("./foo") diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc index 8db971a964..dfe204ec44 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc @@ -16,7 +16,7 @@ // */ // p() { } // /** -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -28,7 +28,7 @@ // static s() { } // /** // * {@link m} -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- // --- (line: 13) skipped --- // */ @@ -45,7 +45,7 @@ // */ // q() { } // /** -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- @@ -58,7 +58,7 @@ // /** // * {@link m} // * @see {m} -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- // --- (line: 24) skipped --- // */ @@ -71,7 +71,7 @@ // */ // r() { } // } -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -93,7 +93,7 @@ // */ // c() // /** -// // --- (line: 49) skipped --- +// --- (line: 49) skipped --- @@ -107,7 +107,7 @@ // /** // * {@link a} // * @see {a} -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 45) skipped --- // */ @@ -120,7 +120,7 @@ // */ // d() // } -// // --- (line: 56) skipped --- +// --- (line: 56) skipped --- @@ -175,7 +175,7 @@ // */ // r() { } // } -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -205,4 +205,4 @@ // */ // d() // } -// // --- (line: 56) skipped --- \ No newline at end of file +// --- (line: 56) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc index 164c894c14..eba7e0c70e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc @@ -13,7 +13,7 @@ // * @see {Consider#This#show} // * {@link Consider.This.show} // * @see {NPR.Consider#This#show} -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -116,7 +116,7 @@ // export class Consider { // This = class { // show() { } -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 9) skipped --- // * {@link Consider#m} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc index 37e0a9e126..bff0714030 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc @@ -13,7 +13,7 @@ // * {@linkcode Consider#This#show} // * {@linkplain Consider.This.show} // * {@linkcode NPR.Consider#This#show} -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -116,7 +116,7 @@ // export class Consider { // This = class { // show() { } -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 9) skipped --- // * {@linkplain Consider#m} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc index fc41d645a1..90ec6e075a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc @@ -25,7 +25,7 @@ // super.method(); // } // method() { super(); } -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- // === /d.ts === // import * as a from "./a"; @@ -61,7 +61,7 @@ // super.method(); // } // method() { super(); } -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- // === /d.ts === // import * as a from "./a"; @@ -97,7 +97,7 @@ // super.method(); // } // method() { super(); } -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- // === /d.ts === // import * as a from "./a"; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc index b573d0da76..2560521003 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /foo.ts === -// /*FIND ALL REFS*/import settings from "./settings.json"; -// settings; +// /*FIND ALL REFS*/import [|settings|] from "./settings.json"; +// [|settings|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc index 63169a81fa..e6b3049cf9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc @@ -6,6 +6,10 @@ // === findAllReferences === +// === /node_modules/@types/three/index.d.ts === +// export * from "[|./three-core|]"; +// export as namespace THREE; + // === /typings/global.d.ts === // import * as _THREE from '/*FIND ALL REFS*/[|three|]'; // declare global { diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc index a0e7b903e9..4b37e613d9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findAllRefsDeclareClass.ts === -// /*FIND ALL REFS*/declare class C { +// /*FIND ALL REFS*/declare class [|C|] { // static m(): void; // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc index 459666328e..4bd7d96f89 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsEnumAsNamespace.ts === -// /*FIND ALL REFS*/enum E { A } -// let e: E.A; +// /*FIND ALL REFS*/enum [|E|] { A } +// let e: [|E|].A; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportDefaultClassConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportDefaultClassConstructor.baseline.jsonc index af95e7e1a7..4bedb5b167 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportDefaultClassConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportDefaultClassConstructor.baseline.jsonc @@ -1,5 +1,5 @@ // === findAllReferences === // === /findAllRefsExportDefaultClassConstructor.ts === // export default class { -// /*FIND ALL REFS*/constructor() {} +// /*FIND ALL REFS*/[|constructor|]() {} // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc index 3734653d91..bc114597e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc @@ -8,10 +8,10 @@ // === findAllReferences === // === /a.ts === // type T = number; -// /*FIND ALL REFS*/[|export|] = T; +// /*FIND ALL REFS*/export = [|T|]; // === /b.ts === -// import T = require("[|./a|]"); +// import [|T|] = require("./a"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc index a7e3cdedf6..f936ce1ea0 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsForDefaultExport01.ts === -// /*FIND ALL REFS*/export default class DefaultExportedClass { +// /*FIND ALL REFS*/export default class [|DefaultExportedClass|] { // } // -// var x: DefaultExportedClass; +// var x: [|DefaultExportedClass|]; // -// var y = new DefaultExportedClass; +// var y = new [|DefaultExportedClass|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc index 00007d570f..6f553cd654 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc @@ -1,10 +1,15 @@ // === findAllReferences === // === /findAllRefsForDefaultExport02.ts === -// /*FIND ALL REFS*/export default function DefaultExportedFunction() { -// return DefaultExportedFunction; +// /*FIND ALL REFS*/export default function [|DefaultExportedFunction|]() { +// return [|DefaultExportedFunction|]; // } // -// // --- (line: 5) skipped --- +// var x: typeof [|DefaultExportedFunction|]; +// +// var y = [|DefaultExportedFunction|](); +// +// namespace DefaultExportedFunction { +// } @@ -74,7 +79,7 @@ // // var y = DefaultExportedFunction(); // -// /*FIND ALL REFS*/namespace DefaultExportedFunction { +// /*FIND ALL REFS*/namespace [|DefaultExportedFunction|] { // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc new file mode 100644 index 0000000000..137945bf4a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc @@ -0,0 +1,141 @@ +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// /*FIND ALL REFS*/function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function /*FIND ALL REFS*/[|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// /*FIND ALL REFS*/export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default /*FIND ALL REFS*/[|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof /*FIND ALL REFS*/[|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = /*FIND ALL REFS*/[|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// /*FIND ALL REFS*/namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace /*FIND ALL REFS*/[|f|] { +// var local = 100; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport04.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport04.baseline.jsonc index a5fd072cef..d1fe7e8668 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport04.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport04.baseline.jsonc @@ -23,11 +23,19 @@ // === findAllReferences === // === /a.ts === // const a = 0; -// export /*FIND ALL REFS*/default a; +// export /*FIND ALL REFS*/[|default|] a; + +// === /b.ts === +// import [|a|] from "./a"; +// [|a|]; // === findAllReferences === +// === /a.ts === +// const a = 0; +// export [|default|] a; + // === /b.ts === // import /*FIND ALL REFS*/[|a|] from "./a"; // [|a|]; @@ -35,6 +43,10 @@ // === findAllReferences === +// === /a.ts === +// const a = 0; +// export [|default|] a; + // === /b.ts === // import [|a|] from "./a"; // /*FIND ALL REFS*/[|a|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport09.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport09.baseline.jsonc index 5a1931dc42..0e2d010d7d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport09.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport09.baseline.jsonc @@ -4,7 +4,7 @@ // import aDefault from "./a.js" // import * as b from "./b.js" // import bDefault from "./b.js" -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- @@ -15,7 +15,7 @@ // import * as b from "./b.js" // import bDefault from "./b.js" // -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -27,7 +27,7 @@ // import bDefault from "./b.js" // // import * as c from "./c" -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_anonymous.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_anonymous.baseline.jsonc index 5f0ee63378..8fe9cad9a2 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_anonymous.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport_anonymous.baseline.jsonc @@ -1,3 +1,6 @@ // === findAllReferences === // === /a.ts === -// export /*FIND ALL REFS*/default 1; \ No newline at end of file +// export /*FIND ALL REFS*/[|default|] 1; + +// === /b.ts === +// import [|a|] from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultKeyword.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultKeyword.baseline.jsonc index c4f30551ac..a6f9679c53 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultKeyword.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultKeyword.baseline.jsonc @@ -4,7 +4,7 @@ // // const default = 1; // -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- @@ -16,7 +16,7 @@ // // function default() {} // -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -30,7 +30,7 @@ // // class default {} // -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc index f02db6604a..ae707a8518 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /file1.ts === -// var foo = /*FIND ALL REFS*/function foo(a = foo(), b = () => foo) { -// foo(foo, foo); +// var foo = /*FIND ALL REFS*/function [|foo|](a = [|foo|](), b = () => [|foo|]) { +// [|foo|]([|foo|], [|foo|]); // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc new file mode 100644 index 0000000000..8173e6641a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc @@ -0,0 +1,33 @@ +// === findAllReferences === +// === /b.ts === +// import { x } from "/*FIND ALL REFS*/[|./a|]"; + +// === /c/sub.js === +// const a = require("[|../a|]"); + +// === /d.ts === +// /// + + + +// === findAllReferences === +// === /b.ts === +// import { x } from "[|./a|]"; + +// === /c/sub.js === +// const a = require("/*FIND ALL REFS*/[|../a|]"); + +// === /d.ts === +// /// + + + +// === findAllReferences === +// === /b.ts === +// import { x } from "[|./a|]"; + +// === /c/sub.js === +// const a = require("[|../a|]"); + +// === /d.ts === +// /// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstanceMethodInheritance.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstanceMethodInheritance.baseline.jsonc index 872fa19d94..503fb4d860 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstanceMethodInheritance.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstanceMethodInheritance.baseline.jsonc @@ -35,7 +35,7 @@ // } // // class Z extends Y{ -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- // --- (line: 16) skipped --- // x.foo(); @@ -56,7 +56,7 @@ // foo(): void{} // } // -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 17) skipped --- // y.foo(); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstancePropertyInheritance.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstancePropertyInheritance.baseline.jsonc index ef28551cd5..c50b79024f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstancePropertyInheritance.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStaticInstancePropertyInheritance.baseline.jsonc @@ -35,7 +35,7 @@ // } // // class Z extends Y{ -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- // --- (line: 16) skipped --- // x.foo; @@ -56,7 +56,7 @@ // foo:any // } // -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 17) skipped --- // y.foo; @@ -181,7 +181,7 @@ // } // // class Z extends Y{ -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- // --- (line: 16) skipped --- // x.foo; @@ -202,7 +202,7 @@ // foo:any // } // -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 17) skipped --- // y.foo; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStringLiteral.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStringLiteral.baseline.jsonc index 25e25f788a..de1934c34b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStringLiteral.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForStringLiteral.baseline.jsonc @@ -5,4 +5,4 @@ // } // /** // * @type {{ property: "foo"}} -// // --- (line: 6) skipped --- \ No newline at end of file +// --- (line: 6) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc index e63980b63d..4064c53b01 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsForVariableInExtendsClause01.ts === -// /*FIND ALL REFS*/var Base = class { }; -// class C extends Base { } +// /*FIND ALL REFS*/var [|Base|] = class { }; +// class C extends [|Base|] { } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc index 635f9d38cb..692886f089 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /findAllRefsForVariableInExtendsClause02.ts === -// /*FIND ALL REFS*/interface Base { } +// /*FIND ALL REFS*/interface [|Base|] { } // namespace n { // var Base = class { }; -// interface I extends Base { } +// interface I extends [|Base|] { } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc index d7491ce03c..69f271dfd9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc @@ -1,7 +1,10 @@ // === findAllReferences === // === /a.js === // module.exports = 0; -// /*FIND ALL REFS*/export type N = number; +// /*FIND ALL REFS*/export type [|N|] = number; + +// === /b.js === +// type T = import("./a").[|N|]; @@ -16,5 +19,9 @@ // === findAllReferences === +// === /a.js === +// module.exports = 0; +// export type [|N|] = number; + // === /b.js === -// type T = import("./a")./*FIND ALL REFS*/N; \ No newline at end of file +// type T = import("./a")./*FIND ALL REFS*/[|N|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties4.baseline.jsonc index 7574b69cc6..d3cda0e851 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties4.baseline.jsonc @@ -57,7 +57,7 @@ // } // // interface D extends C { -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties5.baseline.jsonc index 0e213dc93d..a31259b4a4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInheritedProperties5.baseline.jsonc @@ -5,7 +5,7 @@ // prop1: number; // } // -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -17,7 +17,7 @@ // } // // class D extends C { -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc index d70f81e56a..b433189590 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsInsideTemplates1.ts === -// /*FIND ALL REFS*/var x = 10; -// var y = `${ x } ${ x }` +// /*FIND ALL REFS*/var [|x|] = 10; +// var y = `${ [|x|] } ${ [|x|] }` diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc index 9d2e0aa91d..8ca4acea24 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsInsideTemplates2.ts === -// /*FIND ALL REFS*/function f(...rest: any[]) { } -// f `${ f } ${ f }` +// /*FIND ALL REFS*/function [|f|](...rest: any[]) { } +// [|f|] `${ [|f|] } ${ [|f|] }` diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc index 118d6ab98c..19b1d2ba3d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc @@ -1,10 +1,13 @@ // === findAllReferences === // === /findAllRefsInsideWithBlock.ts === -// /*FIND ALL REFS*/var x = 0; +// /*FIND ALL REFS*/var [|x|] = 0; // // with ({}) { // var y = x; // Reference of x here should not be picked -// // --- (line: 5) skipped --- +// y++; // also reference for y should be ignored +// } +// +// [|x|] = [|x|] + 1; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc index b1d0fc3619..3b50a12409 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc @@ -14,7 +14,7 @@ // // export const bar = 123; // console.log({ bar }); -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -34,7 +34,7 @@ // // export const bar = 123; // console.log({ bar }); -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -49,7 +49,7 @@ // // interface IFoo { // foo(): void; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag2.baseline.jsonc index 44d151af3a..ab47e0389f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag2.baseline.jsonc @@ -4,7 +4,7 @@ // constructor() { // this.id_ = Math.random(); // } -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // === /player.js === // import [|Component|] from './component.js'; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag3.baseline.jsonc index fe331dd151..0059cc284c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsJsDocImportTag3.baseline.jsonc @@ -4,7 +4,7 @@ // constructor() { // this.id_ = Math.random(); // } -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // === /player.js === // import { [|Component|] } from './component.js'; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc new file mode 100644 index 0000000000..8303effda7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc @@ -0,0 +1,21 @@ +// === findAllReferences === +// === /a.js === +// /*FIND ALL REFS*/const [|b|] = require("./b"); + + + +// === findAllReferences === +// === /a.js === +// const b = require("/*FIND ALL REFS*/[|./b|]"); + +// === /b.js === +// [|module.exports = 0|]; + + + +// === findAllReferences === +// === /a.js === +// const b = require("[|./b|]"); + +// === /b.js === +// /*FIND ALL REFS*/[|module.exports = 0|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsNonexistentPropertyNoCrash1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsNonexistentPropertyNoCrash1.baseline.jsonc index effe8abd26..2738cf3b9d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsNonexistentPropertyNoCrash1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsNonexistentPropertyNoCrash1.baseline.jsonc @@ -8,4 +8,4 @@ // return name[1]; // } // }, -// // --- (line: 18) skipped --- \ No newline at end of file +// --- (line: 18) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc index 8cef99ffaa..a362eb779e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc @@ -1,9 +1,16 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/function decorator(target) { +// /*FIND ALL REFS*/function [|decorator|](target) { // return target; // } -// decorator(); +// [|decorator|](); + +// === /b.ts === +// @[|decorator|] @[|decorator|]("again") +// class C { +// @[|decorator|] +// method() {} +// } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc index c27ee5460e..6fa2ed3597 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc @@ -4,11 +4,18 @@ // // } // -// /*FIND ALL REFS*/public start(){ +// /*FIND ALL REFS*/public [|start|](){ // return this; // } // -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- + +// === /findAllRefsOnDefinition.ts === +// import Second = require("./findAllRefsOnDefinition-import"); +// +// var second = new Second.Test() +// second.[|start|](); +// second.stop(); @@ -22,7 +29,7 @@ // return this; // } // -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- // === /findAllRefsOnDefinition.ts === // import Second = require("./findAllRefsOnDefinition-import"); @@ -43,7 +50,7 @@ // return this; // } // -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- // === /findAllRefsOnDefinition.ts === // import Second = require("./findAllRefsOnDefinition-import"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc index 97030d14d0..948c4ea942 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc @@ -2,11 +2,17 @@ // === /findAllRefsOnDefinition2-import.ts === // export module Test{ // -// /*FIND ALL REFS*/export interface start { } +// /*FIND ALL REFS*/export interface [|start|] { } // // export interface stop { } // } +// === /findAllRefsOnDefinition2.ts === +// import Second = require("./findAllRefsOnDefinition2-import"); +// +// var start: Second.Test.[|start|]; +// var stop: Second.Test.stop; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc index a353dee861..ff228b6549 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc @@ -1,11 +1,13 @@ // === findAllReferences === // === /findAllRefsOnPrivateParameterProperty1.ts === // class ABCD { -// constructor(private x: number, public y: number, /*FIND ALL REFS*/private z: number) { +// constructor(private x: number, public y: number, /*FIND ALL REFS*/private [|z|]: number) { // } // // func() { -// // --- (line: 6) skipped --- +// return this.[|z|]; +// } +// } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsParameterPropertyDeclaration_inheritance.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsParameterPropertyDeclaration_inheritance.baseline.jsonc index 035894ef83..598c9cedf2 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsParameterPropertyDeclaration_inheritance.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsParameterPropertyDeclaration_inheritance.baseline.jsonc @@ -21,7 +21,7 @@ // } // } // class D extends C { -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc index 450a19bbe9..573570f52e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc @@ -1,11 +1,14 @@ // === findAllReferences === // === /findAllRefsPrivateNameAccessors.ts === // class C { -// /*FIND ALL REFS*/get #foo(){ return 1; } -// set #foo(value: number){ } +// /*FIND ALL REFS*/get [|#foo|](){ return 1; } +// set [|#foo|](value: number){ } // constructor() { -// this.#foo(); -// // --- (line: 6) skipped --- +// this.[|#foo|](); +// } +// } +// class D extends C { +// --- (line: 9) skipped --- @@ -19,19 +22,21 @@ // } // } // class D extends C { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- // === findAllReferences === // === /findAllRefsPrivateNameAccessors.ts === // class C { -// get #foo(){ return 1; } -// /*FIND ALL REFS*/set #foo(value: number){ } +// get [|#foo|](){ return 1; } +// /*FIND ALL REFS*/set [|#foo|](value: number){ } // constructor() { -// this.#foo(); +// this.[|#foo|](); // } -// // --- (line: 7) skipped --- +// } +// class D extends C { +// --- (line: 9) skipped --- @@ -45,7 +50,7 @@ // } // } // class D extends C { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -59,7 +64,7 @@ // } // } // class D extends C { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -69,10 +74,10 @@ // } // } // class E { -// /*FIND ALL REFS*/get #foo(){ return 1; } -// set #foo(value: number){ } +// /*FIND ALL REFS*/get [|#foo|](){ return 1; } +// set [|#foo|](value: number){ } // constructor() { -// this.#foo(); +// this.[|#foo|](); // } // } @@ -95,13 +100,14 @@ // === findAllReferences === // === /findAllRefsPrivateNameAccessors.ts === -// --- (line: 12) skipped --- +// --- (line: 11) skipped --- +// } // } // class E { -// get #foo(){ return 1; } -// /*FIND ALL REFS*/set #foo(value: number){ } +// get [|#foo|](){ return 1; } +// /*FIND ALL REFS*/set [|#foo|](value: number){ } // constructor() { -// this.#foo(); +// this.[|#foo|](); // } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameMethods.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameMethods.baseline.jsonc index b115a88835..bd67fc9c94 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameMethods.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameMethods.baseline.jsonc @@ -7,7 +7,7 @@ // } // } // class D extends C { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -20,7 +20,7 @@ // } // } // class D extends C { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameProperties.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameProperties.baseline.jsonc index cbc205cc2d..b7538252a0 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameProperties.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameProperties.baseline.jsonc @@ -8,7 +8,7 @@ // } // } // class D extends C { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -22,7 +22,7 @@ // } // } // class D extends C { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -36,7 +36,7 @@ // } // } // class D extends C { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsThisKeyword.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsThisKeyword.baseline.jsonc index f8e13748e3..1d014bde5c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsThisKeyword.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsThisKeyword.baseline.jsonc @@ -4,7 +4,7 @@ // function f(this) { // return this; // function g(this) { return this; } -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- @@ -16,7 +16,7 @@ // function g(this) { return this; } // } // class C { -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -28,7 +28,7 @@ // function g(this) { return this; } // } // class C { -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -41,7 +41,7 @@ // } // class C { // static x() { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -54,7 +54,7 @@ // } // class C { // static x() { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -71,7 +71,7 @@ // } // constructor() { // this; -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -88,7 +88,7 @@ // } // constructor() { // this; -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc index d58e4feb85..92b33590b7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc @@ -19,6 +19,11 @@ // === findAllReferences === +// === /a.js === +// module.exports = 0; +// /** @typedef {number} [|Foo|] */ +// const dummy = 0; + // === /b.js === -// /** @type {import('./a')./*FIND ALL REFS*/Foo} */ +// /** @type {import('./a')./*FIND ALL REFS*/[|Foo|]} */ // const x = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsUnionProperty.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsUnionProperty.baseline.jsonc index 7eb77a494a..31924ba41a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsUnionProperty.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsUnionProperty.baseline.jsonc @@ -117,7 +117,7 @@ // }; // declare const t: T; // if (t.type === "a") { -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- @@ -132,7 +132,7 @@ // }; // declare const t: T; // if (t.type === "a") { -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- @@ -147,4 +147,4 @@ // }; // declare const t: T; // if (t.type === "a") { -// // --- (line: 10) skipped --- \ No newline at end of file +// --- (line: 10) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc index 275b2415e7..38bc2fe401 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames1.ts === // class Foo { -// /*FIND ALL REFS*/public _bar() { return 0; } +// /*FIND ALL REFS*/public [|_bar|]() { return 0; } // } // // var x: Foo; -// x._bar; +// x.[|_bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc index 0627485bd8..def74d86dd 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames2.ts === // class Foo { -// /*FIND ALL REFS*/public __bar() { return 0; } +// /*FIND ALL REFS*/public [|__bar|]() { return 0; } // } // // var x: Foo; -// x.__bar; +// x.[|__bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc index ba2b00295d..b1c169241e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames3.ts === // class Foo { -// /*FIND ALL REFS*/public ___bar() { return 0; } +// /*FIND ALL REFS*/public [|___bar|]() { return 0; } // } // // var x: Foo; -// x.___bar; +// x.[|___bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc index 4c995ceb99..ba04ab6467 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames4.ts === // class Foo { -// /*FIND ALL REFS*/public ____bar() { return 0; } +// /*FIND ALL REFS*/public [|____bar|]() { return 0; } // } // // var x: Foo; -// x.____bar; +// x.[|____bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc index 68b9058871..18e8118cfb 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc @@ -3,11 +3,15 @@ // class Foo { // public _bar; // public __bar; -// /*FIND ALL REFS*/public ___bar; +// /*FIND ALL REFS*/public [|___bar|]; // public ____bar; // } // -// // --- (line: 8) skipped --- +// var x: Foo; +// x._bar; +// x.__bar; +// x.[|___bar|]; +// x.____bar; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc index 5cea661dd5..371052938b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc @@ -2,11 +2,16 @@ // === /findAllRefsWithLeadingUnderscoreNames6.ts === // class Foo { // public _bar; -// /*FIND ALL REFS*/public __bar; +// /*FIND ALL REFS*/public [|__bar|]; // public ___bar; // public ____bar; // } -// // --- (line: 7) skipped --- +// +// var x: Foo; +// x._bar; +// x.[|__bar|]; +// x.___bar; +// x.____bar; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc index 761a4899a3..46abb67ad4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames7.ts === -// /*FIND ALL REFS*/function __foo() { -// __foo(); +// /*FIND ALL REFS*/function [|__foo|]() { +// [|__foo|](); // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames8.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames8.baseline.jsonc index 16510e0f5b..4e30c5fd6e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames8.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames8.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames8.ts === // (/*FIND ALL REFS*/function __foo() { -// __foo(); +// [|__foo|](); // }) diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames9.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames9.baseline.jsonc index 099cdfee54..c139980070 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames9.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames9.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames9.ts === // (/*FIND ALL REFS*/function ___foo() { -// ___foo(); +// [|___foo|](); // }) diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment.baseline.jsonc index 1666c1f148..c40b21b16c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment.baseline.jsonc @@ -16,6 +16,18 @@ // var obj1 = { name: /*FIND ALL REFS*/[|name|] }; // obj.name; +// === bundled:///libs/lib.dom.d.ts === +// --- (line: --) skipped --- +// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/name) +// */ +// /** @deprecated */ +// declare const [|name|]: void; +// /** +// * The **`Window.navigator`** read-only property returns a reference to the Navigator object, which has methods and properties about the application running the script. +// * +// --- (line: --) skipped --- +// + // === findAllReferences === @@ -26,6 +38,18 @@ // var obj1 = { name: [|name|] }; // obj.[|name|]; +// === bundled:///libs/lib.dom.d.ts === +// --- (line: --) skipped --- +// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/name) +// */ +// /** @deprecated */ +// declare const [|name|]: void; +// /** +// * The **`Window.navigator`** read-only property returns a reference to the Navigator object, which has methods and properties about the application running the script. +// * +// --- (line: --) skipped --- +// + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment2.baseline.jsonc index 4aa27d262c..2efe5a6b7f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithShorthandPropertyAssignment2.baseline.jsonc @@ -4,7 +4,7 @@ // // module M { export var dx; } // module M { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc index 41f5903eec..a39cb0e4e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc @@ -1,8 +1,12 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/export type T = 0; +// /*FIND ALL REFS*/export type [|T|] = 0; // export const T = 0; +// === /b.ts === +// const x: import("./a").[|T|] = 0; +// const x: typeof import("./a").T = 0; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc index 55c3e1d76c..2d8b8e38a2 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc @@ -1,8 +1,12 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/export type T = number; +// /*FIND ALL REFS*/export type [|T|] = number; // export type U = string; +// === /b.ts === +// const x: import("./a").[|T|] = 0; +// const x: import("./a").U = 0; + // === findAllReferences === @@ -19,7 +23,11 @@ // === findAllReferences === // === /a.ts === // export type T = number; -// /*FIND ALL REFS*/export type U = string; +// /*FIND ALL REFS*/export type [|U|] = string; + +// === /b.ts === +// const x: import("./a").T = 0; +// const x: import("./a").[|U|] = 0; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc index 33e67cb257..b1dc44da2b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /b.ts === -// /*FIND ALL REFS*/const x: typeof import("./a") = { x: 0 }; +// /*FIND ALL REFS*/const [|x|]: typeof import("./a") = { x: 0 }; // const y: typeof import("./a") = { x: 0 }; @@ -15,7 +15,7 @@ // === findAllReferences === // === /b.ts === // const x: typeof import("./a") = { x: 0 }; -// /*FIND ALL REFS*/const y: typeof import("./a") = { x: 0 }; +// /*FIND ALL REFS*/const [|y|]: typeof import("./a") = { x: 0 }; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc index 14c23a2f5f..77cd5d46e7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc @@ -1,10 +1,10 @@ // === findAllReferences === // === /a.js === // /** @enum {string} */ -// /*FIND ALL REFS*/const E = { A: "" }; -// E["A"]; +// /*FIND ALL REFS*/const [|E|] = { A: "" }; +// [|E|]["A"]; // /** @type {E} */ -// const e = E.A; +// const e = [|E|].A; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc index ec494e6888..2b80f1d44d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc @@ -1,6 +1,14 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/var x: number; +// /*FIND ALL REFS*/var [|x|]: number; + +// === /b.ts === +// /// +// [|x|]++; + +// === /c.ts === +// /// +// [|x|]++; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc index 01bbfdfb3a..98e4beca3a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc @@ -4,7 +4,7 @@ // someFunction() { this; } // } // -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- @@ -15,7 +15,7 @@ // } // // type Options = "option 1" | "option 2"; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc index a3b65b722a..aac6454a10 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /index.tsx === -// /*FIND ALL REFS*/const obj = {Component: () =>
}; -// const element = ; +// /*FIND ALL REFS*/const [|obj|] = {Component: () =>
}; +// const element = <[|obj|].Component/>; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc index d47a9cd615..45d4e9154c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfArrowFunction.ts === -// /*FIND ALL REFS*/var f = x => x + 1; -// f(12); +// /*FIND ALL REFS*/var [|f|] = x => x + 1; +// [|f|](12); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc index 66aa26aa9b..250b824282 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc @@ -1,10 +1,12 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfClass.ts === -// /*FIND ALL REFS*/class C { +// /*FIND ALL REFS*/class [|C|] { // n: number; // constructor() { // this.n = 12; -// // --- (line: 5) skipped --- +// } +// } +// let c = new [|C|](); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc index e0b28c98c1..fc51da704e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc @@ -1,10 +1,10 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfEnum.ts === -// /*FIND ALL REFS*/enum E { +// /*FIND ALL REFS*/enum [|E|] { // First, // Second // } -// let first = E.First; +// let first = [|E|].First; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc index 93a9afb726..fb25553e8f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfFunction.ts === -// /*FIND ALL REFS*/function func(x: number) { +// /*FIND ALL REFS*/function [|func|](x: number) { // } -// func(x) +// [|func|](x) diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc index 1d3cb221db..3465e29156 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterface.ts === -// /*FIND ALL REFS*/interface I { +// /*FIND ALL REFS*/interface [|I|] { // p: number; // } -// let i: I = { p: 12 }; +// let i: [|I|] = { p: 12 }; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc index 0482d27845..06b881e54c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc @@ -1,10 +1,18 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// /*FIND ALL REFS*/interface Numbers { +// /*FIND ALL REFS*/interface [|Numbers|] { // p: number; // } -// interface Numbers { -// // --- (line: 5) skipped --- +// interface [|Numbers|] { +// m: number; +// } +// class [|Numbers|] { +// f(n: number) { +// return this.p + this.m + n; +// } +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); @@ -28,14 +36,19 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// interface Numbers { +// interface [|Numbers|] { // p: number; // } -// /*FIND ALL REFS*/interface Numbers { +// /*FIND ALL REFS*/interface [|Numbers|] { // m: number; // } -// class Numbers { -// // --- (line: 8) skipped --- +// class [|Numbers|] { +// f(n: number) { +// return this.p + this.m + n; +// } +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); @@ -59,15 +72,19 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// --- (line: 3) skipped --- -// interface Numbers { +// interface [|Numbers|] { +// p: number; +// } +// interface [|Numbers|] { // m: number; // } -// /*FIND ALL REFS*/class Numbers { +// /*FIND ALL REFS*/class [|Numbers|] { // f(n: number) { // return this.p + this.m + n; // } -// // --- (line: 11) skipped --- +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc index bba65c8c91..1ea8914044 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfNamespace.ts === -// /*FIND ALL REFS*/namespace Numbers { +// /*FIND ALL REFS*/namespace [|Numbers|] { // export var n = 12; // } -// let x = Numbers.n + 1; +// let x = [|Numbers|].n + 1; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc index 588c2d0769..7dfa3f7a3b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfTypeAlias.ts === -// /*FIND ALL REFS*/type Alias= number; -// let n: Alias = 12; +// /*FIND ALL REFS*/type [|Alias|]= number; +// let n: [|Alias|] = 12; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc index 3e18059318..9ee407ef13 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc @@ -1,10 +1,22 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfVariable.ts === -// /*FIND ALL REFS*/var x = 0; -// var assignmentRightHandSide = x; -// var assignmentRightHandSide2 = 1 + x; +// /*FIND ALL REFS*/var [|x|] = 0; +// var assignmentRightHandSide = [|x|]; +// var assignmentRightHandSide2 = 1 + [|x|]; +// +// [|x|] = 1; +// [|x|] = [|x|] + [|x|]; +// +// [|x|] == 1; +// [|x|] <= 1; // -// // --- (line: 5) skipped --- +// var preIncrement = ++[|x|]; +// var postIncrement = [|x|]++; +// var preDecrement = --[|x|]; +// var postDecrement = [|x|]--; +// +// [|x|] += 1; +// [|x|] <<= 1; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossGlobalProjects.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossGlobalProjects.baseline.jsonc index d97e39c38f..9ae99a8d0c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossGlobalProjects.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossGlobalProjects.baseline.jsonc @@ -5,7 +5,7 @@ // FB(); // } // } -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -51,7 +51,7 @@ // } // // interface I { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -90,7 +90,7 @@ // } // // interface I { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossModuleProjects.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossModuleProjects.baseline.jsonc index bab15b51fa..00448c0d64 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossModuleProjects.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionAcrossModuleProjects.baseline.jsonc @@ -9,7 +9,7 @@ // } // } // -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- // --- (line: 13) skipped --- // } @@ -43,6 +43,27 @@ // FC() { }, // }; +// === /home/src/workspaces/project/a2/index.ts === +// import { NS } from "../b"; +// import { [|I|] } from "../c"; +// +// declare module "../b" { +// export namespace NS { +// export function FA(); +// } +// } +// +// declare module "../c" { +// export interface [|I|] { +// FA(); +// } +// } +// +// const ia: [|I|] = { +// FA: NS.FA, +// FC() { }, +// }; + // === /home/src/workspaces/project/c/index.ts === // export namespace NS { // export function FC() {} @@ -84,7 +105,7 @@ // } // } // -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- // --- (line: 13) skipped --- // } @@ -97,6 +118,27 @@ // === findAllReferences === +// === /home/src/workspaces/project/a/index.ts === +// import { NS } from "../b"; +// import { [|I|] } from "../c"; +// +// declare module "../b" { +// export namespace NS { +// export function FA(); +// } +// } +// +// declare module "../c" { +// export interface [|I|] { +// FA(); +// } +// } +// +// const ia: [|I|] = { +// FA: NS.FA, +// FC() { }, +// }; + // === /home/src/workspaces/project/a2/index.ts === // import { NS } from "../b"; // import { [|I|] } from "../c"; @@ -155,7 +197,7 @@ // } // // export interface I { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -194,11 +236,53 @@ // } // // export interface I { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // === findAllReferences === +// === /home/src/workspaces/project/a/index.ts === +// import { NS } from "../b"; +// import { [|I|] } from "../c"; +// +// declare module "../b" { +// export namespace NS { +// export function FA(); +// } +// } +// +// declare module "../c" { +// export interface [|I|] { +// FA(); +// } +// } +// +// const ia: [|I|] = { +// FA: NS.FA, +// FC() { }, +// }; + +// === /home/src/workspaces/project/a2/index.ts === +// import { NS } from "../b"; +// import { [|I|] } from "../c"; +// +// declare module "../b" { +// export namespace NS { +// export function FA(); +// } +// } +// +// declare module "../c" { +// export interface [|I|] { +// FA(); +// } +// } +// +// const ia: [|I|] = { +// FA: NS.FA, +// FC() { }, +// }; + // === /home/src/workspaces/project/c/index.ts === // export namespace NS { // export function FC() {} @@ -213,6 +297,22 @@ // === findAllReferences === +// === /home/src/workspaces/project/a/index.ts === +// --- (line: 14) skipped --- +// +// const ia: I = { +// FA: NS.FA, +// [|FC|]() { }, +// }; + +// === /home/src/workspaces/project/a2/index.ts === +// --- (line: 14) skipped --- +// +// const ia: I = { +// FA: NS.FA, +// [|FC|]() { }, +// }; + // === /home/src/workspaces/project/c/index.ts === // export namespace NS { // export function FC() {} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc index 662ccb87d3..db5fd49cb4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc @@ -19,9 +19,9 @@ // === findAllReferences === // === /a.js === // /** @typedef {number} T */ -// /*FIND ALL REFS*/const T = 1; +// /*FIND ALL REFS*/const [|T|] = 1; // /** @type {T} */ -// const n = T; +// const n = [|T|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc index 72f2f31da3..f67cbe6091 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /a.js === // /** @typedef {number} */ -// /*FIND ALL REFS*/const T = 1; +// /*FIND ALL REFS*/const [|T|] = 1; // /** @type {T} */ -// const n = T; +// const n = [|T|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc index 3dd7634782..31f1861768 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc @@ -2,11 +2,71 @@ // === /localGetReferences_1.ts === // // Comment Refence Test: globalVar // // References to a variable declared in global. -// /*FIND ALL REFS*/var globalVar: number = 2; +// /*FIND ALL REFS*/var [|globalVar|]: number = 2; // // class fooCls { // // References to static variable declared in a class. -// // --- (line: 7) skipped --- +// static clsSVar = 1; +// // References to a variable declared in a class. +// clsVar = 1; +// +// constructor (public clsParam: number) { +// //Increments +// [|globalVar|]++; +// this.clsVar++; +// fooCls.clsSVar++; +// // References to a class parameter. +// --- (line: 17) skipped --- + +// --- (line: 25) skipped --- +// +// //Increments +// fooCls.clsSVar++; +// [|globalVar|]++; +// modTest.modVar++; +// fnVar++; +// +// --- (line: 33) skipped --- + +// --- (line: 38) skipped --- +// export var modVar:number; +// +// //Increments +// [|globalVar|]++; +// fooCls.clsSVar++; +// modVar++; +// +// --- (line: 46) skipped --- + +// --- (line: 50) skipped --- +// static boo = foo; +// +// //Increments +// [|globalVar|]++; +// fooCls.clsSVar++; +// modVar++; +// } +// --- (line: 58) skipped --- + +// --- (line: 65) skipped --- +// +// //Arguments +// // References to a class argument. +// clsTest = new fooCls([|globalVar|]); +// // References to a function argument. +// foo([|globalVar|]); +// +// //Increments +// fooCls.clsSVar++; +// modTest.modVar++; +// [|globalVar|] = [|globalVar|] + [|globalVar|]; +// +// //ETC - Other cases +// [|globalVar|] = 3; +// // References to illegal assignment. +// foo = foo + 1; +// err = err++; +// --- (line: 83) skipped --- @@ -28,7 +88,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -38,7 +98,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -48,7 +108,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -58,7 +118,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -78,7 +138,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -88,11 +148,59 @@ // // class fooCls { // // References to static variable declared in a class. -// /*FIND ALL REFS*/static clsSVar = 1; +// /*FIND ALL REFS*/static [|clsSVar|] = 1; // // References to a variable declared in a class. // clsVar = 1; // -// // --- (line: 11) skipped --- +// constructor (public clsParam: number) { +// //Increments +// globalVar++; +// this.clsVar++; +// fooCls.[|clsSVar|]++; +// // References to a class parameter. +// this.clsParam++; +// modTest.modVar++; +// --- (line: 19) skipped --- + +// --- (line: 24) skipped --- +// var fnVar = 1; +// +// //Increments +// fooCls.[|clsSVar|]++; +// globalVar++; +// modTest.modVar++; +// fnVar++; +// --- (line: 32) skipped --- + +// --- (line: 39) skipped --- +// +// //Increments +// globalVar++; +// fooCls.[|clsSVar|]++; +// modVar++; +// +// class testCls { +// --- (line: 47) skipped --- + +// --- (line: 51) skipped --- +// +// //Increments +// globalVar++; +// fooCls.[|clsSVar|]++; +// modVar++; +// } +// +// --- (line: 59) skipped --- + +// --- (line: 70) skipped --- +// foo(globalVar); +// +// //Increments +// fooCls.[|clsSVar|]++; +// modTest.modVar++; +// globalVar = globalVar + globalVar; +// +// --- (line: 78) skipped --- @@ -114,7 +222,7 @@ // // References to a class parameter. // this.clsParam++; // modTest.modVar++; -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- // --- (line: 24) skipped --- // var fnVar = 1; @@ -124,7 +232,7 @@ // globalVar++; // modTest.modVar++; // fnVar++; -// // --- (line: 32) skipped --- +// --- (line: 32) skipped --- // --- (line: 39) skipped --- // @@ -134,7 +242,7 @@ // modVar++; // // class testCls { -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- // --- (line: 51) skipped --- // @@ -144,7 +252,7 @@ // modVar++; // } // -// // --- (line: 59) skipped --- +// --- (line: 59) skipped --- // --- (line: 70) skipped --- // foo(globalVar); @@ -154,7 +262,7 @@ // modTest.modVar++; // globalVar = globalVar + globalVar; // -// // --- (line: 78) skipped --- +// --- (line: 78) skipped --- @@ -173,7 +281,7 @@ // fooCls.clsSVar++; // // References to a class parameter. // this.clsParam++; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -183,11 +291,17 @@ // // References to a variable declared in a class. // clsVar = 1; // -// constructor (/*FIND ALL REFS*/public clsParam: number) { +// constructor (/*FIND ALL REFS*/public [|clsParam|]: number) { // //Increments // globalVar++; // this.clsVar++; -// // --- (line: 15) skipped --- +// fooCls.clsSVar++; +// // References to a class parameter. +// this.[|clsParam|]++; +// modTest.modVar++; +// } +// } +// --- (line: 21) skipped --- @@ -207,7 +321,7 @@ // modTest.modVar++; // } // } -// // --- (line: 21) skipped --- +// --- (line: 21) skipped --- @@ -229,7 +343,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -239,7 +353,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -249,7 +363,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -259,7 +373,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -279,7 +393,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -298,7 +412,7 @@ // fooCls.clsSVar++; // // References to a class parameter. // this.clsParam++; -// // --- (line: 18) skipped --- +// --- (line: 18) skipped --- @@ -320,7 +434,7 @@ // // References to a class parameter. // this.clsParam++; // modTest.modVar++; -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- // --- (line: 24) skipped --- // var fnVar = 1; @@ -330,7 +444,7 @@ // globalVar++; // modTest.modVar++; // fnVar++; -// // --- (line: 32) skipped --- +// --- (line: 32) skipped --- // --- (line: 39) skipped --- // @@ -340,7 +454,7 @@ // modVar++; // // class testCls { -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- // --- (line: 51) skipped --- // @@ -350,7 +464,7 @@ // modVar++; // } // -// // --- (line: 59) skipped --- +// --- (line: 59) skipped --- // --- (line: 70) skipped --- // foo(globalVar); @@ -360,7 +474,7 @@ // modTest.modVar++; // globalVar = globalVar + globalVar; // -// // --- (line: 78) skipped --- +// --- (line: 78) skipped --- @@ -380,7 +494,7 @@ // modTest.modVar++; // } // } -// // --- (line: 21) skipped --- +// --- (line: 21) skipped --- @@ -390,11 +504,54 @@ // } // // // References to a function parameter. -// /*FIND ALL REFS*/function foo(x: number) { +// /*FIND ALL REFS*/function [|foo|](x: number) { // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- + +// --- (line: 43) skipped --- +// modVar++; +// +// class testCls { +// static boo = [|foo|]; +// } +// +// function testFn(){ +// static boo = [|foo|]; +// +// //Increments +// globalVar++; +// fooCls.clsSVar++; +// modVar++; +// } +// +// module testMod { +// var boo = [|foo|]; +// } +// } +// +// --- (line: 64) skipped --- + +// --- (line: 67) skipped --- +// // References to a class argument. +// clsTest = new fooCls(globalVar); +// // References to a function argument. +// [|foo|](globalVar); +// +// //Increments +// fooCls.clsSVar++; +// modTest.modVar++; +// globalVar = globalVar + globalVar; +// +// //ETC - Other cases +// globalVar = 3; +// // References to illegal assignment. +// [|foo|] = [|foo|] + 1; +// err = err++; +// +// //Shadowed fn Parameter +// --- (line: 85) skipped --- @@ -408,7 +565,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -431,7 +588,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -451,7 +608,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -465,7 +622,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 30) skipped --- // fnVar++; @@ -475,7 +632,7 @@ // } // // module modTest { -// // --- (line: 38) skipped --- +// --- (line: 38) skipped --- @@ -485,11 +642,17 @@ // // References to a function parameter. // function foo(x: number) { // // References to a variable declared in a function. -// /*FIND ALL REFS*/var fnVar = 1; +// /*FIND ALL REFS*/var [|fnVar|] = 1; // // //Increments // fooCls.clsSVar++; -// // --- (line: 29) skipped --- +// globalVar++; +// modTest.modVar++; +// [|fnVar|]++; +// +// //Return +// return x++; +// --- (line: 35) skipped --- @@ -509,7 +672,7 @@ // // //Return // return x++; -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -531,7 +694,7 @@ // // References to a class parameter. // this.clsParam++; // modTest.modVar++; -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- // --- (line: 24) skipped --- // var fnVar = 1; @@ -541,7 +704,7 @@ // globalVar++; // modTest.modVar++; // fnVar++; -// // --- (line: 32) skipped --- +// --- (line: 32) skipped --- // --- (line: 39) skipped --- // @@ -551,7 +714,7 @@ // modVar++; // // class testCls { -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- // --- (line: 51) skipped --- // @@ -561,7 +724,7 @@ // modVar++; // } // -// // --- (line: 59) skipped --- +// --- (line: 59) skipped --- // --- (line: 70) skipped --- // foo(globalVar); @@ -571,7 +734,7 @@ // modTest.modVar++; // globalVar = globalVar + globalVar; // -// // --- (line: 78) skipped --- +// --- (line: 78) skipped --- @@ -593,7 +756,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -603,7 +766,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -613,7 +776,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -623,7 +786,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -643,7 +806,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -663,7 +826,7 @@ // // //Return // return x++; -// // --- (line: 35) skipped --- +// --- (line: 35) skipped --- @@ -677,7 +840,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 30) skipped --- // fnVar++; @@ -687,7 +850,7 @@ // } // // module modTest { -// // --- (line: 38) skipped --- +// --- (line: 38) skipped --- @@ -709,7 +872,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -719,7 +882,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -729,7 +892,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -739,7 +902,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -759,7 +922,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -781,7 +944,7 @@ // // References to a class parameter. // this.clsParam++; // modTest.modVar++; -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- // --- (line: 24) skipped --- // var fnVar = 1; @@ -791,7 +954,7 @@ // globalVar++; // modTest.modVar++; // fnVar++; -// // --- (line: 32) skipped --- +// --- (line: 32) skipped --- // --- (line: 39) skipped --- // @@ -801,7 +964,7 @@ // modVar++; // // class testCls { -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- // --- (line: 51) skipped --- // @@ -811,7 +974,7 @@ // modVar++; // } // -// // --- (line: 59) skipped --- +// --- (line: 59) skipped --- // --- (line: 70) skipped --- // foo(globalVar); @@ -821,7 +984,7 @@ // modTest.modVar++; // globalVar = globalVar + globalVar; // -// // --- (line: 78) skipped --- +// --- (line: 78) skipped --- @@ -835,7 +998,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -858,7 +1021,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -878,7 +1041,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -892,7 +1055,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -915,7 +1078,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -935,7 +1098,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -957,7 +1120,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -967,7 +1130,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -977,7 +1140,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -987,7 +1150,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1007,7 +1170,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1029,7 +1192,7 @@ // // References to a class parameter. // this.clsParam++; // modTest.modVar++; -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- // --- (line: 24) skipped --- // var fnVar = 1; @@ -1039,7 +1202,7 @@ // globalVar++; // modTest.modVar++; // fnVar++; -// // --- (line: 32) skipped --- +// --- (line: 32) skipped --- // --- (line: 39) skipped --- // @@ -1049,7 +1212,7 @@ // modVar++; // // class testCls { -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- // --- (line: 51) skipped --- // @@ -1059,7 +1222,7 @@ // modVar++; // } // -// // --- (line: 59) skipped --- +// --- (line: 59) skipped --- // --- (line: 70) skipped --- // foo(globalVar); @@ -1069,7 +1232,7 @@ // modTest.modVar++; // globalVar = globalVar + globalVar; // -// // --- (line: 78) skipped --- +// --- (line: 78) skipped --- @@ -1083,7 +1246,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -1106,7 +1269,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -1126,7 +1289,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -1148,7 +1311,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -1158,7 +1321,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -1168,7 +1331,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -1178,7 +1341,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1198,7 +1361,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1212,7 +1375,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -1235,7 +1398,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -1255,7 +1418,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -1277,7 +1440,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -1287,7 +1450,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -1297,7 +1460,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -1307,7 +1470,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1327,7 +1490,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1349,7 +1512,7 @@ // // References to a class parameter. // this.clsParam++; // modTest.modVar++; -// // --- (line: 19) skipped --- +// --- (line: 19) skipped --- // --- (line: 24) skipped --- // var fnVar = 1; @@ -1359,7 +1522,7 @@ // globalVar++; // modTest.modVar++; // fnVar++; -// // --- (line: 32) skipped --- +// --- (line: 32) skipped --- // --- (line: 39) skipped --- // @@ -1369,7 +1532,7 @@ // modVar++; // // class testCls { -// // --- (line: 47) skipped --- +// --- (line: 47) skipped --- // --- (line: 51) skipped --- // @@ -1379,7 +1542,7 @@ // modVar++; // } // -// // --- (line: 59) skipped --- +// --- (line: 59) skipped --- // --- (line: 70) skipped --- // foo(globalVar); @@ -1389,7 +1552,7 @@ // modTest.modVar++; // globalVar = globalVar + globalVar; // -// // --- (line: 78) skipped --- +// --- (line: 78) skipped --- @@ -1411,7 +1574,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -1421,7 +1584,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -1431,7 +1594,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -1441,7 +1604,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1461,7 +1624,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1483,7 +1646,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -1493,7 +1656,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -1503,7 +1666,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -1513,7 +1676,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1533,7 +1696,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1555,7 +1718,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -1565,7 +1728,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -1575,7 +1738,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -1585,7 +1748,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1605,7 +1768,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1627,7 +1790,7 @@ // this.clsVar++; // fooCls.clsSVar++; // // References to a class parameter. -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- // --- (line: 25) skipped --- // @@ -1637,7 +1800,7 @@ // modTest.modVar++; // fnVar++; // -// // --- (line: 33) skipped --- +// --- (line: 33) skipped --- // --- (line: 38) skipped --- // export var modVar:number; @@ -1647,7 +1810,7 @@ // fooCls.clsSVar++; // modVar++; // -// // --- (line: 46) skipped --- +// --- (line: 46) skipped --- // --- (line: 50) skipped --- // static boo = foo; @@ -1657,7 +1820,7 @@ // fooCls.clsSVar++; // modVar++; // } -// // --- (line: 58) skipped --- +// --- (line: 58) skipped --- // --- (line: 65) skipped --- // @@ -1677,7 +1840,7 @@ // // References to illegal assignment. // foo = foo + 1; // err = err++; -// // --- (line: 83) skipped --- +// --- (line: 83) skipped --- @@ -1691,7 +1854,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -1714,7 +1877,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -1734,7 +1897,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -1748,7 +1911,7 @@ // // References to a variable declared in a function. // var fnVar = 1; // -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 43) skipped --- // modVar++; @@ -1771,7 +1934,7 @@ // } // } // -// // --- (line: 64) skipped --- +// --- (line: 64) skipped --- // --- (line: 67) skipped --- // // References to a class argument. @@ -1791,7 +1954,7 @@ // err = err++; // // //Shadowed fn Parameter -// // --- (line: 85) skipped --- +// --- (line: 85) skipped --- @@ -1808,7 +1971,7 @@ // } // // //Remotes -// // --- (line: 92) skipped --- +// --- (line: 92) skipped --- @@ -1825,7 +1988,7 @@ // } // // //Remotes -// // --- (line: 92) skipped --- +// --- (line: 92) skipped --- @@ -1842,7 +2005,7 @@ // } // // //Remotes -// // --- (line: 92) skipped --- +// --- (line: 92) skipped --- @@ -1886,7 +2049,7 @@ // // References to a variable declared in global. // var globalVar: number = 2; // -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- @@ -1900,7 +2063,7 @@ // // //Shadowed fn Parameter // function shdw(globalVar: number) { -// // --- (line: 86) skipped --- +// --- (line: 86) skipped --- @@ -1914,4 +2077,4 @@ // //Shadowed fn Parameter // function shdw(globalVar: number) { // //Increments -// // --- (line: 87) skipped --- \ No newline at end of file +// --- (line: 87) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referenceInParameterPropertyDeclaration.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referenceInParameterPropertyDeclaration.baseline.jsonc index 4cc9699bb0..5c15f865f3 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referenceInParameterPropertyDeclaration.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referenceInParameterPropertyDeclaration.baseline.jsonc @@ -10,7 +10,7 @@ // // let localPublic = publicParam; // this.publicParam += " Hello!"; -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc index b70c6b36cd..752d9fb046 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc @@ -1,10 +1,15 @@ // === findAllReferences === // === /referencesForAmbients.ts === -// /*FIND ALL REFS*/declare module "foo" { +// /*FIND ALL REFS*/declare module "[|foo|]" { // var f: number; // } // -// // --- (line: 5) skipped --- +// declare module "bar" { +// export import foo = require("[|foo|]"); +// var f2: typeof foo.f; +// } +// +// --- (line: 10) skipped --- @@ -19,18 +24,23 @@ // var f2: typeof foo.f; // } // -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- // === findAllReferences === // === /referencesForAmbients.ts === // declare module "foo" { -// /*FIND ALL REFS*/var f: number; +// /*FIND ALL REFS*/var [|f|]: number; // } // // declare module "bar" { -// // --- (line: 6) skipped --- +// export import foo = require("foo"); +// var f2: typeof foo.[|f|]; +// } +// +// declare module "baz" { +// --- (line: 11) skipped --- @@ -46,7 +56,7 @@ // } // // declare module "baz" { -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -56,11 +66,15 @@ // var f: number; // } // -// /*FIND ALL REFS*/declare module "bar" { +// /*FIND ALL REFS*/declare module "[|bar|]" { // export import foo = require("foo"); // var f2: typeof foo.f; // } -// // --- (line: 9) skipped --- +// +// declare module "baz" { +// import bar = require("[|bar|]"); +// var f2: typeof bar.foo; +// } @@ -89,11 +103,14 @@ // } // // declare module "bar" { -// /*FIND ALL REFS*/export import foo = require("foo"); -// var f2: typeof foo.f; +// /*FIND ALL REFS*/export import [|foo|] = require("foo"); +// var f2: typeof [|foo|].f; // } // -// // --- (line: 10) skipped --- +// declare module "baz" { +// import bar = require("bar"); +// var f2: typeof bar.[|foo|]; +// } @@ -126,7 +143,7 @@ // var f2: typeof foo.f; // } // -// // --- (line: 10) skipped --- +// --- (line: 10) skipped --- @@ -160,7 +177,7 @@ // } // // declare module "baz" { -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -170,8 +187,8 @@ // } // // declare module "baz" { -// /*FIND ALL REFS*/import bar = require("bar"); -// var f2: typeof bar.foo; +// /*FIND ALL REFS*/import [|bar|] = require("bar"); +// var f2: typeof [|bar|].foo; // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc index 6eba7c7b66..9fdcbf41b4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc @@ -3,11 +3,18 @@ // var n = 14; // // class foo { -// /*FIND ALL REFS*/private n = 0; +// /*FIND ALL REFS*/private [|n|] = 0; // // public bar() { -// this.n = 9; -// // --- (line: 8) skipped --- +// this.[|n|] = 9; +// } +// +// constructor() { +// this.[|n|] = 4; +// } +// +// public bar2() { +// --- (line: 15) skipped --- @@ -27,7 +34,7 @@ // } // // public bar2() { -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -47,7 +54,7 @@ // } // // public bar2() { -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -67,4 +74,4 @@ // } // // public bar2() { -// // --- (line: 15) skipped --- \ No newline at end of file +// --- (line: 15) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc index e5b662d166..b1565d329a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc @@ -5,11 +5,17 @@ // class p { } // // class foo { -// constructor (/*FIND ALL REFS*/public p: any) { +// constructor (/*FIND ALL REFS*/public [|p|]: any) { // } // // public f(p) { -// // --- (line: 10) skipped --- +// this.[|p|] = p; +// } +// +// } +// +// var n = new foo(undefined); +// n.[|p|] = null; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc index 1eaba5ce64..a69a231138 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc @@ -2,35 +2,39 @@ // === /referencesForDeclarationKeywords.ts === // class Base {} // interface Implemented1 {} -// /*FIND ALL REFS*/class C1 extends Base implements Implemented1 { +// /*FIND ALL REFS*/class [|C1|] extends Base implements Implemented1 { // get e() { return 1; } // set e(v) {} // } -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- // === findAllReferences === // === /referencesForDeclarationKeywords.ts === -// class Base {} +// class [|Base|] {} // interface Implemented1 {} -// class C1 /*FIND ALL REFS*/extends Base implements Implemented1 { +// class C1 /*FIND ALL REFS*/extends [|Base|] implements Implemented1 { // get e() { return 1; } // set e(v) {} // } -// // --- (line: 7) skipped --- +// interface I1 extends [|Base|] { } +// type T = { } +// enum E { } +// namespace N { } +// --- (line: 11) skipped --- // === findAllReferences === // === /referencesForDeclarationKeywords.ts === // class Base {} -// interface Implemented1 {} -// class C1 extends Base /*FIND ALL REFS*/implements Implemented1 { +// interface [|Implemented1|] {} +// class C1 extends Base /*FIND ALL REFS*/implements [|Implemented1|] { // get e() { return 1; } // set e(v) {} // } -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -50,11 +54,12 @@ // class Base {} // interface Implemented1 {} // class C1 extends Base implements Implemented1 { -// /*FIND ALL REFS*/get e() { return 1; } -// set e(v) {} +// /*FIND ALL REFS*/get [|e|]() { return 1; } +// set [|e|](v) {} // } // interface I1 extends Base { } -// // --- (line: 8) skipped --- +// type T = { } +// --- (line: 9) skipped --- @@ -63,12 +68,12 @@ // class Base {} // interface Implemented1 {} // class C1 extends Base implements Implemented1 { -// get e() { return 1; } -// /*FIND ALL REFS*/set e(v) {} +// get [|e|]() { return 1; } +// /*FIND ALL REFS*/set [|e|](v) {} // } // interface I1 extends Base { } // type T = { } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -78,25 +83,27 @@ // get e() { return 1; } // set e(v) {} // } -// /*FIND ALL REFS*/interface I1 extends Base { } +// /*FIND ALL REFS*/interface [|I1|] extends Base { } // type T = { } // enum E { } // namespace N { } -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- // === findAllReferences === // === /referencesForDeclarationKeywords.ts === -// --- (line: 3) skipped --- +// class [|Base|] {} +// interface Implemented1 {} +// class C1 extends [|Base|] implements Implemented1 { // get e() { return 1; } // set e(v) {} // } -// interface I1 /*FIND ALL REFS*/extends Base { } +// interface I1 /*FIND ALL REFS*/extends [|Base|] { } // type T = { } // enum E { } // namespace N { } -// // --- (line: 11) skipped --- +// --- (line: 11) skipped --- @@ -116,11 +123,11 @@ // set e(v) {} // } // interface I1 extends Base { } -// /*FIND ALL REFS*/type T = { } +// /*FIND ALL REFS*/type [|T|] = { } // enum E { } // namespace N { } // module M { } -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -130,11 +137,11 @@ // } // interface I1 extends Base { } // type T = { } -// /*FIND ALL REFS*/enum E { } +// /*FIND ALL REFS*/enum [|E|] { } // namespace N { } // module M { } // function fn() {} -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- @@ -144,11 +151,11 @@ // interface I1 extends Base { } // type T = { } // enum E { } -// /*FIND ALL REFS*/namespace N { } +// /*FIND ALL REFS*/namespace [|N|] { } // module M { } // function fn() {} // var x; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- @@ -158,11 +165,11 @@ // type T = { } // enum E { } // namespace N { } -// /*FIND ALL REFS*/module M { } +// /*FIND ALL REFS*/module [|M|] { } // function fn() {} // var x; // let y; -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -172,11 +179,11 @@ // enum E { } // namespace N { } // module M { } -// /*FIND ALL REFS*/function fn() {} +// /*FIND ALL REFS*/function [|fn|]() {} // var x; // let y; // const z = 1; -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- @@ -186,11 +193,11 @@ // namespace N { } // module M { } // function fn() {} -// /*FIND ALL REFS*/var x; +// /*FIND ALL REFS*/var [|x|]; // let y; // const z = 1; // interface Implemented2 {} -// // --- (line: 17) skipped --- +// --- (line: 17) skipped --- @@ -200,7 +207,7 @@ // module M { } // function fn() {} // var x; -// /*FIND ALL REFS*/let y; +// /*FIND ALL REFS*/let [|y|]; // const z = 1; // interface Implemented2 {} // interface Implemented3 {} @@ -215,7 +222,7 @@ // function fn() {} // var x; // let y; -// /*FIND ALL REFS*/const z = 1; +// /*FIND ALL REFS*/const [|z|] = 1; // interface Implemented2 {} // interface Implemented3 {} // class C2 implements Implemented2, Implemented3 {} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExportedValues.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExportedValues.baseline.jsonc index 10c12df9c3..09b2502240 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExportedValues.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExportedValues.baseline.jsonc @@ -5,7 +5,7 @@ // // // local use // var x = variable; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc index 845f1c7ced..9e86a17195 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc @@ -1,83 +1,114 @@ // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// class C { +// class [|C|] { // static x = 1; // } -// /*FIND ALL REFS*/new C(); -// void C; -// typeof C; -// delete C.x; -// // --- (line: 8) skipped --- +// /*FIND ALL REFS*/new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; +// async function* f() { +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// class C { +// class [|C|] { // static x = 1; // } -// new C(); -// /*FIND ALL REFS*/void C; -// typeof C; -// delete C.x; +// new [|C|](); +// /*FIND ALL REFS*/void [|C|]; +// typeof [|C|]; +// delete [|C|].x; // async function* f() { -// // --- (line: 9) skipped --- +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// class C { +// class [|C|] { // static x = 1; // } -// new C(); -// void C; -// /*FIND ALL REFS*/[|typeof|] C; -// delete C.x; +// new [|C|](); +// void [|C|]; +// /*FIND ALL REFS*/typeof [|C|]; +// delete [|C|].x; // async function* f() { -// yield C; -// // --- (line: 10) skipped --- +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 5) skipped --- -// typeof C; -// delete C.x; +// class [|C|] { +// static x = 1; +// } +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; // async function* f() { -// /*FIND ALL REFS*/yield C; -// await C; +// /*FIND ALL REFS*/yield [|C|]; +// await [|C|]; // } -// "x" in C; -// undefined instanceof C; -// undefined as C; +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 6) skipped --- -// delete C.x; +// class [|C|] { +// static x = 1; +// } +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; // async function* f() { -// yield C; -// /*FIND ALL REFS*/await C; +// yield [|C|]; +// /*FIND ALL REFS*/await [|C|]; // } -// "x" in C; -// undefined instanceof C; -// undefined as C; +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 8) skipped --- -// yield C; -// await C; +// class [|C|] { +// static x = 1; // } -// "x" /*FIND ALL REFS*/in C; -// undefined instanceof C; -// undefined as C; +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; +// async function* f() { +// yield [|C|]; +// await [|C|]; +// } +// "x" /*FIND ALL REFS*/in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; @@ -102,22 +133,33 @@ // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 10) skipped --- +// class [|C|] { +// static x = 1; // } -// "x" in C; -// undefined instanceof C; -// undefined /*FIND ALL REFS*/as C; +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; +// async function* f() { +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined /*FIND ALL REFS*/as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 3) skipped --- +// class C { +// static [|x|] = 1; +// } // new C(); // void C; // typeof C; -// /*FIND ALL REFS*/delete C.x; +// /*FIND ALL REFS*/delete C.[|x|]; // async function* f() { // yield C; // await C; -// // --- (line: 11) skipped --- \ No newline at end of file +// --- (line: 11) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc index 6f1cb201fe..cdbcdc4593 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/declare module "foo" { +// /*FIND ALL REFS*/declare module "[|foo|]" { // var f: number; // } +// === /referencesForGlobals_2.ts === +// import f = require("[|foo|]"); + // === findAllReferences === @@ -19,7 +22,7 @@ // === findAllReferences === // === /referencesForGlobals_2.ts === -// /*FIND ALL REFS*/import f = require("foo"); +// /*FIND ALL REFS*/import [|f|] = require("foo"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc index 86de4ff51c..02172bb86d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /referencesForFunctionOverloads.ts === -// /*FIND ALL REFS*/function foo(x: string); -// function foo(x: string, y: number) { -// foo('', 43); +// /*FIND ALL REFS*/function [|foo|](x: string); +// function [|foo|](x: string, y: number) { +// [|foo|]('', 43); // } @@ -18,9 +18,9 @@ // === findAllReferences === // === /referencesForFunctionOverloads.ts === -// function foo(x: string); -// /*FIND ALL REFS*/function foo(x: string, y: number) { -// foo('', 43); +// function [|foo|](x: string); +// /*FIND ALL REFS*/function [|foo|](x: string, y: number) { +// [|foo|]('', 43); // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc index 54bec186f0..7942e20845 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc @@ -1,10 +1,26 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/var global = 2; +// /*FIND ALL REFS*/var [|global|] = 2; // // class foo { // constructor (public global) { } -// // --- (line: 5) skipped --- +// public f(global) { } +// public f2(global) { } +// } +// +// class bar { +// constructor () { +// var n = [|global|]; +// +// var f = new foo(''); +// f.global = ''; +// } +// } +// +// var k = [|global|]; + +// === /referencesForGlobals_2.ts === +// var m = [|global|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc index 31467511fe..d610d04261 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/class globalClass { +// /*FIND ALL REFS*/class [|globalClass|] { // public f() { } // } +// === /referencesForGlobals_2.ts === +// var c = [|globalClass|](); + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc index 79f09ba209..900a8652b7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/interface globalInterface { +// /*FIND ALL REFS*/interface [|globalInterface|] { // f(); // } +// === /referencesForGlobals_2.ts === +// var i: [|globalInterface|]; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc index 92d11768c4..0d1e16d30b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/module globalModule { +// /*FIND ALL REFS*/module [|globalModule|] { // export f() { }; // } +// === /referencesForGlobals_2.ts === +// var m = [|globalModule|]; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc index 1345e76576..1fe53ef3aa 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc @@ -4,7 +4,10 @@ // export var x; // } // -// /*FIND ALL REFS*/import globalAlias = globalModule; +// /*FIND ALL REFS*/import [|globalAlias|] = globalModule; + +// === /referencesForGlobals_2.ts === +// var m = [|globalAlias|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc index 73e1bc6410..3c0c64d7a8 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc @@ -1,10 +1,11 @@ // === findAllReferences === // === /referencesForGlobalsInExternalModule.ts === -// /*FIND ALL REFS*/var topLevelVar = 2; -// var topLevelVar2 = topLevelVar; +// /*FIND ALL REFS*/var [|topLevelVar|] = 2; +// var topLevelVar2 = [|topLevelVar|]; // // class topLevelClass { } -// // --- (line: 5) skipped --- +// var c = new topLevelClass(); +// --- (line: 6) skipped --- @@ -15,7 +16,7 @@ // // class topLevelClass { } // var c = new topLevelClass(); -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -26,7 +27,7 @@ // // class topLevelClass { } // var c = new topLevelClass(); -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -35,11 +36,12 @@ // var topLevelVar = 2; // var topLevelVar2 = topLevelVar; // -// /*FIND ALL REFS*/class topLevelClass { } -// var c = new topLevelClass(); +// /*FIND ALL REFS*/class [|topLevelClass|] { } +// var c = new [|topLevelClass|](); // // interface topLevelInterface { } -// // --- (line: 8) skipped --- +// var i: topLevelInterface; +// --- (line: 9) skipped --- @@ -53,7 +55,7 @@ // // interface topLevelInterface { } // var i: topLevelInterface; -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -67,7 +69,7 @@ // // interface topLevelInterface { } // var i: topLevelInterface; -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -77,11 +79,12 @@ // class topLevelClass { } // var c = new topLevelClass(); // -// /*FIND ALL REFS*/interface topLevelInterface { } -// var i: topLevelInterface; +// /*FIND ALL REFS*/interface [|topLevelInterface|] { } +// var i: [|topLevelInterface|]; // // module topLevelModule { -// // --- (line: 11) skipped --- +// export var x; +// --- (line: 12) skipped --- @@ -96,7 +99,7 @@ // // module topLevelModule { // export var x; -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -111,7 +114,7 @@ // // module topLevelModule { // export var x; -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -121,10 +124,10 @@ // interface topLevelInterface { } // var i: topLevelInterface; // -// /*FIND ALL REFS*/module topLevelModule { +// /*FIND ALL REFS*/module [|topLevelModule|] { // export var x; // } -// var x = topLevelModule.x; +// var x = [|topLevelModule|].x; // // export = x; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc index 81aaedb024..bd03e117e5 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc @@ -4,8 +4,8 @@ // function $(s: string): any; // export = $; // } -// /*FIND ALL REFS*/import $ = require("jquery"); -// $("a"); +// /*FIND ALL REFS*/import [|$|] = require("jquery"); +// [|$|]("a"); // import $ = require("jquery"); @@ -40,7 +40,7 @@ // } // import $ = require("jquery"); // $("a"); -// /*FIND ALL REFS*/import $ = require("jquery"); +// /*FIND ALL REFS*/import [|$|] = require("jquery"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForInheritedProperties9.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForInheritedProperties9.baseline.jsonc index fa5cd78b48..d35f31e906 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForInheritedProperties9.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForInheritedProperties9.baseline.jsonc @@ -5,7 +5,7 @@ // } // // class C extends D { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForLabel5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForLabel5.baseline.jsonc index 4b0e54b03e..b495a48255 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForLabel5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForLabel5.baseline.jsonc @@ -19,7 +19,7 @@ // function blah() { // label: while (true) { // if (false) break label; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc index 9a876c8f4b..f1cc995e1e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc @@ -1,10 +1,17 @@ // === findAllReferences === // === /referencesForMergedDeclarations.ts === -// /*FIND ALL REFS*/interface Foo { +// /*FIND ALL REFS*/interface [|Foo|] { // } // // module Foo { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- + +// --- (line: 8) skipped --- +// } +// +// var f1: Foo.Bar; +// var f2: [|Foo|]; +// Foo.bind(this); @@ -14,7 +21,7 @@ // } // // module Foo { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 8) skipped --- // } @@ -30,11 +37,16 @@ // interface Foo { // } // -// /*FIND ALL REFS*/module Foo { +// /*FIND ALL REFS*/module [|Foo|] { // export interface Bar { } // } // -// // --- (line: 8) skipped --- +// function Foo(): void { +// } +// +// var f1: [|Foo|].Bar; +// var f2: Foo; +// Foo.bind(this); @@ -62,12 +74,12 @@ // export interface Bar { } // } // -// /*FIND ALL REFS*/function Foo(): void { +// /*FIND ALL REFS*/function [|Foo|](): void { // } // // var f1: Foo.Bar; // var f2: Foo; -// Foo.bind(this); +// [|Foo|].bind(this); @@ -110,7 +122,7 @@ // } // // module Foo { -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 8) skipped --- // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc index 377113b9d1..fa095d184e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc @@ -4,10 +4,10 @@ // // function ATest() { } // -// /*FIND ALL REFS*/import alias = ATest; // definition +// /*FIND ALL REFS*/import [|alias|] = ATest; // definition // -// var a: alias.Bar; // namespace -// alias.call(this); // value +// var a: [|alias|].Bar; // namespace +// [|alias|].call(this); // value diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc index 1fc1969780..a49154eaa7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc @@ -26,7 +26,7 @@ // static staticMethod() { } // method() { } // } -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // --- (line: 8) skipped --- // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc index fc54de7f4b..5896510ddb 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc @@ -1,10 +1,24 @@ // === findAllReferences === // === /referencesForMergedDeclarations4.ts === -// /*FIND ALL REFS*/class testClass { +// /*FIND ALL REFS*/class [|testClass|] { // static staticMethod() { } // method() { } // } -// // --- (line: 5) skipped --- +// +// module [|testClass|] { +// export interface Bar { +// +// } +// export var s = 0; +// } +// +// var c1: [|testClass|]; +// var c2: [|testClass|].Bar; +// [|testClass|].staticMethod(); +// [|testClass|].prototype.method(); +// [|testClass|].bind(this); +// [|testClass|].s; +// new [|testClass|](); @@ -34,16 +48,25 @@ // === findAllReferences === // === /referencesForMergedDeclarations4.ts === -// class testClass { +// class [|testClass|] { // static staticMethod() { } // method() { } // } // -// /*FIND ALL REFS*/module testClass { +// /*FIND ALL REFS*/module [|testClass|] { // export interface Bar { // // } -// // --- (line: 10) skipped --- +// export var s = 0; +// } +// +// var c1: [|testClass|]; +// var c2: [|testClass|].Bar; +// [|testClass|].staticMethod(); +// [|testClass|].prototype.method(); +// [|testClass|].bind(this); +// [|testClass|].s; +// new [|testClass|](); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc index f7f9fd6965..7746adb1e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc @@ -1,11 +1,14 @@ // === findAllReferences === // === /referencesForMergedDeclarations6.ts === // interface Foo { } -// /*FIND ALL REFS*/module Foo { +// /*FIND ALL REFS*/module [|Foo|] { // export interface Bar { } // export module Bar { export interface Baz { } } // export function Bar() { } -// // --- (line: 6) skipped --- +// } +// +// // module +// import a1 = [|Foo|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations7.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations7.baseline.jsonc index 5f4172f80a..b42cbb5171 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations7.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations7.baseline.jsonc @@ -6,7 +6,7 @@ // export module Bar { export interface Baz { } } // export function Bar() { } // } -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc index ce8d974534..01b41d14f3 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc @@ -3,12 +3,12 @@ // interface Foo { } // module Foo { // export interface Bar { } -// /*FIND ALL REFS*/export module Bar { export interface Baz { } } +// /*FIND ALL REFS*/export module [|Bar|] { export interface Baz { } } // export function Bar() { } // } // // // module -// import a3 = Foo.Bar.Baz; +// import a3 = Foo.[|Bar|].Baz; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc index b4505a6fce..2ff0b6c60c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc @@ -1,31 +1,31 @@ // === findAllReferences === // === /referencesForModifiers.ts === -// /*FIND ALL REFS*/declare abstract class C1 { +// /*FIND ALL REFS*/declare abstract class [|C1|] { // static a; // readonly b; // public c; -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // === findAllReferences === // === /referencesForModifiers.ts === -// declare /*FIND ALL REFS*/abstract class C1 { +// declare /*FIND ALL REFS*/abstract class [|C1|] { // static a; // readonly b; // public c; -// // --- (line: 5) skipped --- +// --- (line: 5) skipped --- // === findAllReferences === // === /referencesForModifiers.ts === // declare abstract class C1 { -// /*FIND ALL REFS*/static a; +// /*FIND ALL REFS*/static [|a|]; // readonly b; // public c; // protected d; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- @@ -33,11 +33,11 @@ // === /referencesForModifiers.ts === // declare abstract class C1 { // static a; -// /*FIND ALL REFS*/readonly b; +// /*FIND ALL REFS*/readonly [|b|]; // public c; // protected d; // private e; -// // --- (line: 7) skipped --- +// --- (line: 7) skipped --- @@ -46,11 +46,11 @@ // declare abstract class C1 { // static a; // readonly b; -// /*FIND ALL REFS*/public c; +// /*FIND ALL REFS*/public [|c|]; // protected d; // private e; // } -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -60,11 +60,11 @@ // static a; // readonly b; // public c; -// /*FIND ALL REFS*/protected d; +// /*FIND ALL REFS*/protected [|d|]; // private e; // } // const enum E { -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- @@ -75,7 +75,7 @@ // readonly b; // public c; // protected d; -// /*FIND ALL REFS*/private e; +// /*FIND ALL REFS*/private [|e|]; // } // const enum E { // } @@ -90,7 +90,7 @@ // protected d; // private e; // } -// /*FIND ALL REFS*/const enum E { +// /*FIND ALL REFS*/const enum [|E|] { // } // async function fn() {} // export default class C2 {} @@ -103,7 +103,7 @@ // } // const enum E { // } -// /*FIND ALL REFS*/async function fn() {} +// /*FIND ALL REFS*/async function [|fn|]() {} // export default class C2 {} @@ -114,7 +114,7 @@ // const enum E { // } // async function fn() {} -// /*FIND ALL REFS*/export default class C2 {} +// /*FIND ALL REFS*/export default class [|C2|] {} @@ -124,4 +124,4 @@ // const enum E { // } // async function fn() {} -// export /*FIND ALL REFS*/default class C2 {} \ No newline at end of file +// export /*FIND ALL REFS*/[|default|] class C2 {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForNoContext.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForNoContext.baseline.jsonc index e164a992da..751b4c9e69 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForNoContext.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForNoContext.baseline.jsonc @@ -7,7 +7,7 @@ // // //Increments // modVar++; -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- @@ -21,7 +21,7 @@ // } // // function testFn(){ -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForOverrides.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForOverrides.baseline.jsonc index 8925d5d0da..4a9fdc9a98 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForOverrides.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForOverrides.baseline.jsonc @@ -11,7 +11,7 @@ // } // } // } -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- // --- (line: 58) skipped --- // @@ -21,7 +21,7 @@ // // var y: SimpleInterfaceTest.IBar = null; // y.ifoo(); -// // --- (line: 66) skipped --- +// --- (line: 66) skipped --- @@ -38,7 +38,7 @@ // } // } // -// // --- (line: 22) skipped --- +// --- (line: 22) skipped --- // --- (line: 61) skipped --- // x.foo(); @@ -48,7 +48,7 @@ // // var w: SimpleClassInterfaceTest.Bar = null; // w.icfoo(); -// // --- (line: 69) skipped --- +// --- (line: 69) skipped --- @@ -65,7 +65,7 @@ // } // } // } -// // --- (line: 31) skipped --- +// --- (line: 31) skipped --- // --- (line: 64) skipped --- // y.ifoo(); @@ -75,7 +75,7 @@ // // var z = new Test.BarBlah(); // z.field = ""; -// // --- (line: 72) skipped --- +// --- (line: 72) skipped --- @@ -111,7 +111,7 @@ // } // } // -// // --- (line: 60) skipped --- +// --- (line: 60) skipped --- // --- (line: 67) skipped --- // w.icfoo(); @@ -134,7 +134,7 @@ // } // // export interface IBlah extends IBase { -// // --- (line: 39) skipped --- +// --- (line: 39) skipped --- // --- (line: 43) skipped --- // } @@ -149,7 +149,7 @@ // } // // export class BarBlah extends Bar { -// // --- (line: 56) skipped --- +// --- (line: 56) skipped --- // --- (line: 68) skipped --- // diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc new file mode 100644 index 0000000000..bc4a02ea61 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc @@ -0,0 +1,526 @@ +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// /*FIND ALL REFS*/import [|A|] = require("./a"); +// namespace N { } +// import N2 = N; +// +// --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = /*FIND ALL REFS*/require("[|./a|]"); +// namespace N { } +// import N2 = N; +// +// --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = require("./a"); +// namespace N { } +// /*FIND ALL REFS*/import [|N2|] = N; +// +// // import ... from ... +// import type B from "./b"; +// --- (line: 8) skipped --- + + + +// === findAllReferences === +// === /b.ts === +// export default class [|B|] {} + +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// /*FIND ALL REFS*/import type [|B|] from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /b.ts === +// export default class [|B|] {} + +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import /*FIND ALL REFS*/type [|B|] from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import type B /*FIND ALL REFS*/from "[|./b|]"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// /*FIND ALL REFS*/import type * as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import /*FIND ALL REFS*/type * as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * /*FIND ALL REFS*/as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * as C /*FIND ALL REFS*/from "[|./c|]"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /d.ts === +// export class [|D|] {} + +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// /*FIND ALL REFS*/import type { [|D|] } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /d.ts === +// export class [|D|] {} + +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import /*FIND ALL REFS*/type { [|D|] } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } /*FIND ALL REFS*/from "[|./d|]"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// /*FIND ALL REFS*/import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import /*FIND ALL REFS*/type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } /*FIND ALL REFS*/from "[|./e|]"; +// +// // import "module" +// import "./f"; +// --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 /*FIND ALL REFS*/as [|e3|] } from "./e"; +// +// // import "module" +// import "./f"; +// --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 9) skipped --- +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// /*FIND ALL REFS*/import "[|./f|]"; +// +// // export ... from ... +// export type * from "./g"; +// --- (line: 17) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// /*FIND ALL REFS*/export type * from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// export /*FIND ALL REFS*/type * from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// export type * /*FIND ALL REFS*/from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// /*FIND ALL REFS*/export type * as [|H|] from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export /*FIND ALL REFS*/type * as [|H|] from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export type * /*FIND ALL REFS*/as [|H|] from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export type * as H /*FIND ALL REFS*/from "[|./h|]"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// /*FIND ALL REFS*/export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// export /*FIND ALL REFS*/type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } /*FIND ALL REFS*/from "[|./i|]"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// /*FIND ALL REFS*/export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export /*FIND ALL REFS*/type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } /*FIND ALL REFS*/from "[|./j|]"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 /*FIND ALL REFS*/as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 16) skipped --- +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type [|Z1|] = 1; +// /*FIND ALL REFS*/export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 16) skipped --- +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type [|Z1|] = 1; +// export /*FIND ALL REFS*/type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// /*FIND ALL REFS*/export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export /*FIND ALL REFS*/type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 /*FIND ALL REFS*/as z4 }; + + + +// === findAllReferences === +// === /main2.ts === +// const [|x|] = {}; +// /*FIND ALL REFS*/export = [|x|]; + + + +// === findAllReferences === +// === /main3.ts === +// const [|y|] = {}; +// /*FIND ALL REFS*/export default [|y|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc index d51eb433e8..05be2ced9c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc @@ -3,11 +3,29 @@ // var n = 43; // // class foo { -// /*FIND ALL REFS*/static n = ''; +// /*FIND ALL REFS*/static [|n|] = ''; // // public bar() { -// foo.n = "'"; -// // --- (line: 8) skipped --- +// foo.[|n|] = "'"; +// if(foo.[|n|]) { +// var x = foo.[|n|]; +// } +// } +// } +// +// class foo2 { +// private x = foo.[|n|]; +// constructor() { +// foo.[|n|] = x; +// } +// +// function b(n) { +// n = foo.[|n|]; +// } +// } + +// === /referencesOnStatic_2.ts === +// var q = foo.[|n|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc index 84334b385e..eb76a14cc8 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc @@ -7,7 +7,7 @@ // static bar: Foo; // // public foo(): void { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- // --- (line: 14) skipped --- // // instance function @@ -17,7 +17,7 @@ // // // static function // MixedStaticsClassTest.Foo.foo(); -// // --- (line: 22) skipped --- +// --- (line: 22) skipped --- @@ -27,11 +27,19 @@ // module MixedStaticsClassTest { // export class Foo { // bar: Foo; -// /*FIND ALL REFS*/static bar: Foo; +// /*FIND ALL REFS*/static [|bar|]: Foo; // // public foo(): void { // } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- + +// --- (line: 18) skipped --- +// +// // static function +// MixedStaticsClassTest.Foo.foo(); +// MixedStaticsClassTest.Foo.[|bar|]; +// } +// } @@ -45,7 +53,7 @@ // // public foo(): void { // } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- // --- (line: 18) skipped --- // @@ -63,11 +71,21 @@ // bar: Foo; // static bar: Foo; // -// /*FIND ALL REFS*/public foo(): void { +// /*FIND ALL REFS*/public [|foo|](): void { // } // public static foo(): void { // } -// // --- (line: 11) skipped --- +// } +// } +// +// function test() { +// // instance function +// var x = new MixedStaticsClassTest.Foo(); +// x.[|foo|](); +// x.bar; +// +// // static function +// --- (line: 21) skipped --- @@ -91,7 +109,7 @@ // x.bar; // // // static function -// // --- (line: 21) skipped --- +// --- (line: 21) skipped --- @@ -101,11 +119,20 @@ // // public foo(): void { // } -// /*FIND ALL REFS*/public static foo(): void { +// /*FIND ALL REFS*/public static [|foo|](): void { // } // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- + +// --- (line: 17) skipped --- +// x.bar; +// +// // static function +// MixedStaticsClassTest.Foo.[|foo|](); +// MixedStaticsClassTest.Foo.bar; +// } +// } @@ -119,7 +146,7 @@ // } // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- // --- (line: 17) skipped --- // x.bar; @@ -152,7 +179,7 @@ // x.bar; // // // static function -// // --- (line: 21) skipped --- +// --- (line: 21) skipped --- @@ -165,7 +192,7 @@ // static bar: Foo; // // public foo(): void { -// // --- (line: 8) skipped --- +// --- (line: 8) skipped --- // --- (line: 14) skipped --- // // instance function @@ -175,7 +202,7 @@ // // // static function // MixedStaticsClassTest.Foo.foo(); -// // --- (line: 22) skipped --- +// --- (line: 22) skipped --- @@ -189,7 +216,7 @@ // } // } // } -// // --- (line: 13) skipped --- +// --- (line: 13) skipped --- // --- (line: 17) skipped --- // x.bar; @@ -212,7 +239,7 @@ // // public foo(): void { // } -// // --- (line: 9) skipped --- +// --- (line: 9) skipped --- // --- (line: 18) skipped --- // diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc index 3a61f5954d..d2ff4badc6 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc @@ -1,12 +1,12 @@ // === findAllReferences === // === /referencesForStringLiteralPropertyNames3.ts === // class Foo2 { -// /*FIND ALL REFS*/get "42"() { return 0; } -// set 42(n) { } +// /*FIND ALL REFS*/get "[|42|]"() { return 0; } +// set [|42|](n) { } // } // // var y: Foo2; -// y[42]; +// y[[|42|]]; @@ -25,12 +25,12 @@ // === findAllReferences === // === /referencesForStringLiteralPropertyNames3.ts === // class Foo2 { -// get "42"() { return 0; } -// /*FIND ALL REFS*/set 42(n) { } +// get "[|42|]"() { return 0; } +// /*FIND ALL REFS*/set [|42|](n) { } // } // // var y: Foo2; -// y[42]; +// y[[|42|]]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc index e458b9c5e7..343a4a0883 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /referencesForTypeKeywords.ts === -// interface I {} -// function f() {} +// interface [|I|] {} +// function f() {} // type A1 = T extends U ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; @@ -14,7 +14,7 @@ // === /referencesForTypeKeywords.ts === // interface I {} // function f() {} -// type A1 = T /*FIND ALL REFS*/extends U ? 1 : 0; +// type A1 = T /*FIND ALL REFS*/extends [|U|] ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; // type A4 = keyof T; @@ -27,7 +27,7 @@ // interface I {} // function f() {} // type A1 = T extends U ? 1 : 0; -// type A2 = T extends /*FIND ALL REFS*/[|infer|] U ? 1 : 0; +// type A2 = T extends /*FIND ALL REFS*/infer [|U|] ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; // type A4 = keyof T; // type A5 = readonly T[]; @@ -40,7 +40,7 @@ // function f() {} // type A1 = T extends U ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; -// type A3 = { [P /*FIND ALL REFS*/in keyof T]: 1 }; +// type A3 = { [[|P|] /*FIND ALL REFS*/in keyof T]: 1 }; // type A4 = keyof T; // type A5 = readonly T[]; @@ -52,8 +52,8 @@ // function f() {} // type A1 = T extends U ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; -// type A3 = { [P in [|keyof|] T]: 1 }; -// type A4 = /*FIND ALL REFS*/[|keyof|] T; +// type A3 = { [P in keyof T]: 1 }; +// type A4<[|T|]> = /*FIND ALL REFS*/keyof [|T|]; // type A5 = readonly T[]; @@ -64,4 +64,4 @@ // type A2 = T extends infer U ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; // type A4 = keyof T; -// type A5 = /*FIND ALL REFS*/[|readonly|] T[]; \ No newline at end of file +// type A5<[|T|]> = /*FIND ALL REFS*/readonly [|T|][]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForUnionProperties.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForUnionProperties.baseline.jsonc index 5a0d495a21..cbf119c6ba 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForUnionProperties.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForUnionProperties.baseline.jsonc @@ -5,7 +5,7 @@ // } // // interface Base { -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 17) skipped --- // diff --git a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc index 2515a755e4..52195127bf 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc @@ -15,7 +15,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -33,7 +33,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -43,7 +43,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -53,7 +53,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -63,7 +63,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -84,7 +84,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -102,7 +102,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -112,7 +112,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -122,7 +122,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -132,7 +132,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -155,7 +155,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -171,7 +171,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -181,7 +181,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -191,7 +191,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -201,7 +201,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -224,7 +224,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -240,7 +240,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -250,7 +250,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -260,7 +260,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -270,7 +270,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -291,7 +291,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -309,7 +309,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -319,7 +319,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -329,7 +329,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -339,7 +339,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -353,7 +353,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -371,7 +371,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -381,7 +381,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -391,7 +391,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -401,7 +401,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -424,7 +424,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -440,7 +440,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -450,7 +450,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -460,7 +460,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -470,7 +470,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -493,7 +493,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -509,7 +509,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -519,7 +519,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -529,7 +529,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -539,7 +539,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -562,7 +562,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -578,7 +578,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -588,7 +588,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -598,7 +598,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -608,7 +608,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -631,7 +631,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -647,7 +647,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -657,7 +657,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -667,7 +667,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -677,17 +677,76 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 85) skipped --- +// var remoteclsTest: remotefooCls; +// +// //Arguments +// remoteclsTest = new remotefooCls([|remoteglobalVar|]); +// remotefoo([|remoteglobalVar|]); +// +// //Increments +// remotefooCls.remoteclsSVar++; +// remotemodTest.remotemodVar++; +// [|remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; +// +// //ETC - Other cases +// [|remoteglobalVar|] = 3; +// +// //Find References misses method param +// var +// --- (line: 102) skipped --- + // === /remoteGetReferences_2.ts === -// /*FIND ALL REFS*/var remoteglobalVar: number = 2; +// /*FIND ALL REFS*/var [|remoteglobalVar|]: number = 2; // // class remotefooCls { // //Declare -// // --- (line: 5) skipped --- +// remoteclsVar = 1; +// static remoteclsSVar = 1; +// +// constructor(public remoteclsParam: number) { +// //Increments +// [|remoteglobalVar|]++; +// this.remoteclsVar++; +// remotefooCls.remoteclsSVar++; +// this.remoteclsParam++; +// --- (line: 14) skipped --- + +// --- (line: 20) skipped --- +// +// //Increments +// remotefooCls.remoteclsSVar++; +// [|remoteglobalVar|]++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// +// --- (line: 28) skipped --- + +// --- (line: 33) skipped --- +// export var remotemodVar: number; +// +// //Increments +// [|remoteglobalVar|]++; +// remotefooCls.remoteclsSVar++; +// remotemodVar++; +// +// --- (line: 41) skipped --- + +// --- (line: 45) skipped --- +// static remoteboo = remotefoo; +// +// //Increments +// [|remoteglobalVar|]++; +// remotefooCls.remoteclsSVar++; +// remotemodVar++; +// } +// --- (line: 53) skipped --- @@ -710,7 +769,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var /*FIND ALL REFS*/[|remoteglobalVar|]: number = 2; @@ -726,7 +785,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -736,7 +795,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -746,7 +805,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -756,19 +815,76 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 82) skipped --- +// +// //Remotes +// //Type test +// var remoteclsTest: [|remotefooCls|]; +// +// //Arguments +// remoteclsTest = new [|remotefooCls|](remoteglobalVar); +// remotefoo(remoteglobalVar); +// +// //Increments +// [|remotefooCls|].remoteclsSVar++; +// remotemodTest.remotemodVar++; +// remoteglobalVar = remoteglobalVar + remoteglobalVar; +// +// --- (line: 97) skipped --- + // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; // -// /*FIND ALL REFS*/class remotefooCls { +// /*FIND ALL REFS*/class [|remotefooCls|] { // //Declare // remoteclsVar = 1; // static remoteclsSVar = 1; -// // --- (line: 7) skipped --- +// +// constructor(public remoteclsParam: number) { +// //Increments +// remoteglobalVar++; +// this.remoteclsVar++; +// [|remotefooCls|].remoteclsSVar++; +// this.remoteclsParam++; +// remotemodTest.remotemodVar++; +// } +// --- (line: 16) skipped --- + +// --- (line: 19) skipped --- +// var remotefnVar = 1; +// +// //Increments +// [|remotefooCls|].remoteclsSVar++; +// remoteglobalVar++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// --- (line: 27) skipped --- + +// --- (line: 34) skipped --- +// +// //Increments +// remoteglobalVar++; +// [|remotefooCls|].remoteclsSVar++; +// remotemodVar++; +// +// class remotetestCls { +// --- (line: 42) skipped --- + +// --- (line: 46) skipped --- +// +// //Increments +// remoteglobalVar++; +// [|remotefooCls|].remoteclsSVar++; +// remotemodVar++; +// } +// +// --- (line: 54) skipped --- @@ -789,7 +905,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -807,7 +923,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -817,7 +933,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -827,7 +943,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -837,7 +953,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -857,22 +973,69 @@ // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; // remotemodTest.remotemodVar++; -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 89) skipped --- +// remotefoo(remoteglobalVar); +// +// //Increments +// remotefooCls.[|remoteclsSVar|]++; +// remotemodTest.remotemodVar++; +// remoteglobalVar = remoteglobalVar + remoteglobalVar; +// +// --- (line: 97) skipped --- + // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; // // class remotefooCls { // //Declare // remoteclsVar = 1; -// /*FIND ALL REFS*/static remoteclsSVar = 1; +// /*FIND ALL REFS*/static [|remoteclsSVar|] = 1; // // constructor(public remoteclsParam: number) { // //Increments -// // --- (line: 10) skipped --- +// remoteglobalVar++; +// this.remoteclsVar++; +// remotefooCls.[|remoteclsSVar|]++; +// this.remoteclsParam++; +// remotemodTest.remotemodVar++; +// } +// --- (line: 16) skipped --- + +// --- (line: 19) skipped --- +// var remotefnVar = 1; +// +// //Increments +// remotefooCls.[|remoteclsSVar|]++; +// remoteglobalVar++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// --- (line: 27) skipped --- + +// --- (line: 34) skipped --- +// +// //Increments +// remoteglobalVar++; +// remotefooCls.[|remoteclsSVar|]++; +// remotemodVar++; +// +// class remotetestCls { +// --- (line: 42) skipped --- + +// --- (line: 46) skipped --- +// +// //Increments +// remoteglobalVar++; +// remotefooCls.[|remoteclsSVar|]++; +// remotemodVar++; +// } +// +// --- (line: 54) skipped --- @@ -886,7 +1049,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -904,7 +1067,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -914,7 +1077,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -924,7 +1087,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -934,7 +1097,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -957,7 +1120,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -973,7 +1136,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -983,7 +1146,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -993,7 +1156,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -1003,7 +1166,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -1023,7 +1186,7 @@ // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; // remotemodTest.remotemodVar++; -// // --- (line: 15) skipped --- +// --- (line: 15) skipped --- @@ -1044,7 +1207,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1062,7 +1225,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1072,7 +1235,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1082,7 +1245,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1092,7 +1255,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1106,7 +1269,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1124,7 +1287,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1134,7 +1297,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1144,7 +1307,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1154,7 +1317,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1175,7 +1338,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1193,7 +1356,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1203,7 +1366,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1213,7 +1376,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1223,7 +1386,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1237,7 +1400,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1255,7 +1418,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1265,7 +1428,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1275,7 +1438,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1285,7 +1448,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1308,7 +1471,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -1324,7 +1487,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -1334,7 +1497,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -1344,7 +1507,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -1354,7 +1517,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -1377,7 +1540,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -1393,7 +1556,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -1403,7 +1566,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -1413,7 +1576,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -1423,7 +1586,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -1444,7 +1607,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1462,7 +1625,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1472,7 +1635,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1482,7 +1645,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1492,7 +1655,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1506,7 +1669,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1524,7 +1687,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1534,7 +1697,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1544,7 +1707,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1554,7 +1717,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1577,7 +1740,7 @@ // // //Find References misses method param // var -// // --- (line: 102) skipped --- +// --- (line: 102) skipped --- // === /remoteGetReferences_2.ts === // var [|remoteglobalVar|]: number = 2; @@ -1593,7 +1756,7 @@ // this.remoteclsVar++; // remotefooCls.remoteclsSVar++; // this.remoteclsParam++; -// // --- (line: 14) skipped --- +// --- (line: 14) skipped --- // --- (line: 20) skipped --- // @@ -1603,7 +1766,7 @@ // remotemodTest.remotemodVar++; // remotefnVar++; // -// // --- (line: 28) skipped --- +// --- (line: 28) skipped --- // --- (line: 33) skipped --- // export var remotemodVar: number; @@ -1613,7 +1776,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // -// // --- (line: 41) skipped --- +// --- (line: 41) skipped --- // --- (line: 45) skipped --- // static remoteboo = remotefoo; @@ -1623,7 +1786,7 @@ // remotefooCls.remoteclsSVar++; // remotemodVar++; // } -// // --- (line: 53) skipped --- +// --- (line: 53) skipped --- @@ -1644,7 +1807,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1662,7 +1825,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1672,7 +1835,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1682,7 +1845,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1692,7 +1855,7 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- +// --- (line: 54) skipped --- @@ -1706,7 +1869,7 @@ // remotemodTest.remotemodVar++; // remoteglobalVar = remoteglobalVar + remoteglobalVar; // -// // --- (line: 97) skipped --- +// --- (line: 97) skipped --- // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; @@ -1724,7 +1887,7 @@ // this.remoteclsParam++; // remotemodTest.remotemodVar++; // } -// // --- (line: 16) skipped --- +// --- (line: 16) skipped --- // --- (line: 19) skipped --- // var remotefnVar = 1; @@ -1734,7 +1897,7 @@ // remoteglobalVar++; // remotemodTest.remotemodVar++; // remotefnVar++; -// // --- (line: 27) skipped --- +// --- (line: 27) skipped --- // --- (line: 34) skipped --- // @@ -1744,7 +1907,7 @@ // remotemodVar++; // // class remotetestCls { -// // --- (line: 42) skipped --- +// --- (line: 42) skipped --- // --- (line: 46) skipped --- // @@ -1754,4 +1917,4 @@ // remotemodVar++; // } // -// // --- (line: 54) skipped --- \ No newline at end of file +// --- (line: 54) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals.baseline.jsonc index 28ba24f606..683be0695a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameImportOfExportEquals.baseline.jsonc @@ -11,7 +11,7 @@ // export { N }; // Renaming N here would rename // } // declare module "b" { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -28,7 +28,7 @@ // export { N }; // Renaming N here would rename // } // declare module "b" { -// // --- (line: 12) skipped --- +// --- (line: 12) skipped --- @@ -58,7 +58,7 @@ // } // declare module "mod" { // export = N; -// // --- (line: 6) skipped --- +// --- (line: 6) skipped --- // --- (line: 9) skipped --- // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences10.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences10.baseline.jsonc index 66169b1bef..ae62ad6be9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences10.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences10.baseline.jsonc @@ -8,4 +8,13 @@ // } // interface LinkProps extends ClickableProps { // goTo: string; -// // --- (line: 16) skipped --- \ No newline at end of file +// } +// declare function MainButton(buttonProps: ButtonProps): JSX.Element; +// declare function MainButton(linkProps: LinkProps): JSX.Element; +// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; +// let opt = ; +// let opt = ; +// let opt = {}} />; +// let opt = {}} ignore-prop />; +// let opt = ; +// let opt = ; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences2.baseline.jsonc index fe81dcc1af..bbc44e1a5c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences2.baseline.jsonc @@ -8,4 +8,6 @@ // isOpen?: boolean; // }; // span: { n: string; }; -// // --- (line: 9) skipped --- \ No newline at end of file +// } +// } +// var x =
; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences3.baseline.jsonc index 8cfb85cc27..6512cb7d90 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences3.baseline.jsonc @@ -9,4 +9,4 @@ // } // // -// var x = ; \ No newline at end of file +// var x = ; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc index a65332382e..2fb055c836 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc @@ -4,11 +4,14 @@ // } // interface ElementAttributesProperty { props } // } -// /*FIND ALL REFS*/class MyClass { +// /*FIND ALL REFS*/class [|MyClass|] { // props: { // name?: string; // size?: number; -// // --- (line: 11) skipped --- +// } +// +// +// var x = <[|MyClass|] name='hello'>; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc index 8c15f502a3..c7fa566bf2 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc @@ -4,12 +4,12 @@ // propString: string // optional?: boolean // } -// /*FIND ALL REFS*/declare function Opt(attributes: OptionPropBag): JSX.Element; -// let opt = ; -// let opt1 = ; -// let opt2 = ; -// let opt3 = ; -// let opt4 = ; +// /*FIND ALL REFS*/declare function [|Opt|](attributes: OptionPropBag): JSX.Element; +// let opt = <[|Opt|] />; +// let opt1 = <[|Opt|] propx={100} propString />; +// let opt2 = <[|Opt|] propx={100} optional/>; +// let opt3 = <[|Opt|] wrong />; +// let opt4 = <[|Opt|] propx={100} propString="hi" />; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences7.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences7.baseline.jsonc index ec6919e839..d0c6c2635a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences7.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences7.baseline.jsonc @@ -8,4 +8,8 @@ // propString: string // optional?: boolean // } -// // --- (line: 12) skipped --- \ No newline at end of file +// declare function Opt(attributes: OptionPropBag): JSX.Element; +// let opt = ; +// let opt1 = ; +// let opt2 = ; +// let opt3 = ; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc index 4cce5cf782..dac2cf2682 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc @@ -4,11 +4,15 @@ // interface LinkProps extends ClickableProps { // goTo: string; // } -// /*FIND ALL REFS*/declare function MainButton(buttonProps: ButtonProps): JSX.Element; -// declare function MainButton(linkProps: LinkProps): JSX.Element; -// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; -// let opt = ; -// // --- (line: 21) skipped --- +// /*FIND ALL REFS*/declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; +// declare function [|MainButton|](linkProps: LinkProps): JSX.Element; +// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; +// let opt = <[|MainButton|] />; +// let opt = <[|MainButton|] children="chidlren" />; +// let opt = <[|MainButton|] onClick={()=>{}} />; +// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; +// let opt = <[|MainButton|] goTo="goTo" />; +// let opt = <[|MainButton|] wrong />; @@ -32,15 +36,19 @@ // === findAllReferences === // === /file.tsx === -// --- (line: 14) skipped --- +// --- (line: 13) skipped --- +// interface LinkProps extends ClickableProps { // goTo: string; // } -// declare function MainButton(buttonProps: ButtonProps): JSX.Element; -// /*FIND ALL REFS*/declare function MainButton(linkProps: LinkProps): JSX.Element; -// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; -// let opt = ; -// let opt = ; -// // --- (line: 22) skipped --- +// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; +// /*FIND ALL REFS*/declare function [|MainButton|](linkProps: LinkProps): JSX.Element; +// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; +// let opt = <[|MainButton|] />; +// let opt = <[|MainButton|] children="chidlren" />; +// let opt = <[|MainButton|] onClick={()=>{}} />; +// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; +// let opt = <[|MainButton|] goTo="goTo" />; +// let opt = <[|MainButton|] wrong />; @@ -64,15 +72,19 @@ // === findAllReferences === // === /file.tsx === -// --- (line: 15) skipped --- +// --- (line: 13) skipped --- +// interface LinkProps extends ClickableProps { +// goTo: string; // } -// declare function MainButton(buttonProps: ButtonProps): JSX.Element; -// declare function MainButton(linkProps: LinkProps): JSX.Element; -// /*FIND ALL REFS*/declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; -// let opt = ; -// let opt = ; -// let opt = {}} />; -// // --- (line: 23) skipped --- +// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; +// declare function [|MainButton|](linkProps: LinkProps): JSX.Element; +// /*FIND ALL REFS*/declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; +// let opt = <[|MainButton|] />; +// let opt = <[|MainButton|] children="chidlren" />; +// let opt = <[|MainButton|] onClick={()=>{}} />; +// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; +// let opt = <[|MainButton|] goTo="goTo" />; +// let opt = <[|MainButton|] wrong />; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences9.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences9.baseline.jsonc index 41f35bf02e..0f7118fa54 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences9.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences9.baseline.jsonc @@ -8,4 +8,11 @@ // } // declare function MainButton(buttonProps: ButtonProps): JSX.Element; // declare function MainButton(linkProps: LinkProps): JSX.Element; -// // --- (line: 19) skipped --- \ No newline at end of file +// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; +// let opt = ; +// let opt = ; +// let opt = {}} />; +// let opt = {}} ignore-prop />; +// let opt = ; +// let opt = ; +// let opt = ; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc index f93c9e0604..590e0bcf5c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc @@ -4,8 +4,8 @@ // function SFC2(prop: { x: boolean }) { // return

World

; // } -// /*FIND ALL REFS*/var SFCComp = SFC1 || SFC2; -// +// /*FIND ALL REFS*/var [|SFCComp|] = SFC1 || SFC2; +// <[|SFCComp|] x={ "hi" } /> diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc index fa4cc25d78..b02df6df6e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc @@ -4,8 +4,8 @@ // } // private method() { } // } -// /*FIND ALL REFS*/var RCComp = RC1 || RC2; -// +// /*FIND ALL REFS*/var [|RCComp|] = RC1 || RC2; +// <[|RCComp|] /> diff --git a/testdata/baselines/reference/fourslash/goToDefinition/definition.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/definition.baseline.jsonc deleted file mode 100644 index 90392f6142..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/definition.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// [|export class Foo {}|] - -// === /b.ts === -// import n = require('./a/*GOTO DEF*/'); -// var x = new n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/definition01.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/definition01.baseline.jsonc deleted file mode 100644 index 90392f6142..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/definition01.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// [|export class Foo {}|] - -// === /b.ts === -// import n = require('./a/*GOTO DEF*/'); -// var x = new n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/findAllRefsForDefaultExport.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/findAllRefsForDefaultExport.baseline.jsonc deleted file mode 100644 index 4b94a0a31b..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/findAllRefsForDefaultExport.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export default function [|f|]() {} - -// === /b.ts === -// import g from "./a"; -// /*GOTO DEF*/g(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionAcrossMultipleProjects.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionAcrossMultipleProjects.baseline.jsonc deleted file mode 100644 index 5759a9945b..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionAcrossMultipleProjects.baseline.jsonc +++ /dev/null @@ -1,19 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// var [|x|]: number; - -// === /b.ts === -// var [|x|]: number; - -// === /c.ts === -// var [|x|]: number; - -// === /d.ts === -// var [|x|]: number; - -// === /e.ts === -// /// -// /// -// /// -// /// -// /*GOTO DEF*/x++; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionCSSPatternAmbientModule.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionCSSPatternAmbientModule.baseline.jsonc deleted file mode 100644 index 3a900298ab..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionCSSPatternAmbientModule.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === goToDefinition === -// === /types.ts === -// declare module [|"*.css"|] { -// const styles: any; -// export = styles; -// } - -// === /index.ts === -// import styles from /*GOTO DEF*/"./index.css"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionClassConstructors.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionClassConstructors.baseline.jsonc deleted file mode 100644 index 9d9d23db29..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionClassConstructors.baseline.jsonc +++ /dev/null @@ -1,63 +0,0 @@ -// === goToDefinition === -// === /definitions.ts === -// export class Base { -// [|constructor(protected readonly cArg: string) {}|] -// } -// -// export class [|Derived|] extends Base { -// readonly email = this.cArg.getByLabel('Email') -// readonly password = this.cArg.getByLabel('Password') -// } - -// === /main.ts === -// import { Derived } from './definitions' -// const derived = new /*GOTO DEF*/Derived(cArg) - - - -// === goToDefinition === -// === /defInSameFile.ts === -// import { Base } from './definitions' -// class [|SameFile|] extends Base { -// readonly name: string = 'SameFile' -// } -// const SameFile = new /*GOTO DEF*/SameFile(cArg) -// const wrapper = new Base(cArg) - -// === /definitions.ts === -// export class Base { -// [|constructor(protected readonly cArg: string) {}|] -// } -// -// export class Derived extends Base { -// // --- (line: 6) skipped --- - - - -// === goToDefinition === -// === /hasConstructor.ts === -// import { Base } from './definitions' -// class [|HasConstructor|] extends Base { -// [|constructor() {}|] -// readonly name: string = ''; -// } -// const hasConstructor = new /*GOTO DEF*/HasConstructor(cArg) - - - -// === goToDefinition === -// === /definitions.ts === -// export class [|Base|] { -// [|constructor(protected readonly cArg: string) {}|] -// } -// -// export class Derived extends Base { -// // --- (line: 6) skipped --- - -// === /defInSameFile.ts === -// import { Base } from './definitions' -// class SameFile extends Base { -// readonly name: string = 'SameFile' -// } -// const SameFile = new SameFile(cArg) -// const wrapper = new /*GOTO DEF*/Base(cArg) \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDecorator.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDecorator.baseline.jsonc deleted file mode 100644 index 0ebd8c5a1e..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDecorator.baseline.jsonc +++ /dev/null @@ -1,33 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// function [|decorator|](target) { -// return target; -// } -// function decoratorFactory(...args) { -// return target => target; -// } - -// === /b.ts === -// @/*GOTO DEF*/decorator -// class C { -// @decoratorFactory(a, "22", true) -// method() {} -// } - - - -// === goToDefinition === -// === /a.ts === -// function decorator(target) { -// return target; -// } -// function [|decoratorFactory|](...args) { -// return target => target; -// } - -// === /b.ts === -// @decorator -// class C { -// @decora/*GOTO DEF*/torFactory(a, "22", true) -// method() {} -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport2.baseline.jsonc deleted file mode 100644 index bf6e1646d3..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport2.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /foo.ts === -// export function [|bar|]() { return "bar"; } -// var x = import("./foo"); -// x.then(foo => { -// foo.b/*GOTO DEF*/ar(); -// }) \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc deleted file mode 100644 index 80f46261ba..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc +++ /dev/null @@ -1,4 +0,0 @@ -// === goToDefinition === -// === /foo.ts === -// export function bar() { return "bar"; } -// import('./foo').then(({ [|ba/*GOTO DEF*/r|] }) => undefined); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc deleted file mode 100644 index 80f46261ba..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc +++ /dev/null @@ -1,4 +0,0 @@ -// === goToDefinition === -// === /foo.ts === -// export function bar() { return "bar"; } -// import('./foo').then(({ [|ba/*GOTO DEF*/r|] }) => undefined); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExpandoElementAccess.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExpandoElementAccess.baseline.jsonc deleted file mode 100644 index d4ecb56a09..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExpandoElementAccess.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionExpandoElementAccess.ts === -// function f() {} -// f[[|"x"|]] = 0; -// f[/*GOTO DEF*/[|"x"|]] = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName.baseline.jsonc deleted file mode 100644 index 90392f6142..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// [|export class Foo {}|] - -// === /b.ts === -// import n = require('./a/*GOTO DEF*/'); -// var x = new n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName2.baseline.jsonc deleted file mode 100644 index 4453ae5b73..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName2.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// [|class Foo {} -// export var x = 0;|] - -// === /b.ts === -// import n = require('./a/*GOTO DEF*/'); -// var x = new n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName3.baseline.jsonc deleted file mode 100644 index 28f4ba1fd3..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName3.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// declare module [|"e"|] { -// class Foo { } -// } - -// === /b.ts === -// import n = require('e/*GOTO DEF*/'); -// var x = new n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName5.baseline.jsonc deleted file mode 100644 index a9336821ec..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName5.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// declare module [|"external/*GOTO DEF*/"|] { -// class Foo { } -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName6.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName6.baseline.jsonc deleted file mode 100644 index 236ff22c0f..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName6.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// declare module [|"e"|] { -// class Foo { } -// } - -// === /b.ts === -// import * from 'e/*GOTO DEF*/'; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName7.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName7.baseline.jsonc deleted file mode 100644 index ebcad5e2ab..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName7.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// declare module [|"e"|] { -// class Foo { } -// } - -// === /b.ts === -// import {Foo, Bar} from 'e/*GOTO DEF*/'; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName8.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName8.baseline.jsonc deleted file mode 100644 index 8d0abed4ba..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName8.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// declare module [|"e"|] { -// class Foo { } -// } - -// === /b.ts === -// export {Foo, Bar} from 'e/*GOTO DEF*/'; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName9.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName9.baseline.jsonc deleted file mode 100644 index bc11061813..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionExternalModuleName9.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// declare module [|"e"|] { -// class Foo { } -// } - -// === /b.ts === -// export * from 'e/*GOTO DEF*/'; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionFunctionOverloads.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionFunctionOverloads.baseline.jsonc deleted file mode 100644 index d7038b1f61..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionFunctionOverloads.baseline.jsonc +++ /dev/null @@ -1,45 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionFunctionOverloads.ts === -// function [|functionOverload|](value: number); -// function functionOverload(value: string); -// function functionOverload() {} -// -// /*GOTO DEF*/functionOverload(123); -// functionOverload("123"); -// functionOverload({}); - - - -// === goToDefinition === -// === /goToDefinitionFunctionOverloads.ts === -// function functionOverload(value: number); -// function [|functionOverload|](value: string); -// function functionOverload() {} -// -// functionOverload(123); -// /*GOTO DEF*/functionOverload("123"); -// functionOverload({}); - - - -// === goToDefinition === -// === /goToDefinitionFunctionOverloads.ts === -// function [|functionOverload|](value: number); -// function functionOverload(value: string); -// function functionOverload() {} -// -// functionOverload(123); -// functionOverload("123"); -// /*GOTO DEF*/functionOverload({}); - - - -// === goToDefinition === -// === /goToDefinitionFunctionOverloads.ts === -// function /*GOTO DEF*/[|functionOverload|](value: number); -// function [|functionOverload|](value: string); -// function [|functionOverload|]() {} -// -// functionOverload(123); -// functionOverload("123"); -// functionOverload({}); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionFunctionOverloadsInClass.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionFunctionOverloadsInClass.baseline.jsonc deleted file mode 100644 index 1acfdd2dfc..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionFunctionOverloadsInClass.baseline.jsonc +++ /dev/null @@ -1,25 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionFunctionOverloadsInClass.ts === -// class clsInOverload { -// static [|fnOverload|](); -// static /*GOTO DEF*/[|fnOverload|](foo: string); -// static [|fnOverload|](foo: any) { } -// public fnOverload(): any; -// public fnOverload(foo: string); -// public fnOverload(foo: any) { return "foo" } -// // --- (line: 8) skipped --- - - - -// === goToDefinition === -// === /goToDefinitionFunctionOverloadsInClass.ts === -// class clsInOverload { -// static fnOverload(); -// static fnOverload(foo: string); -// static fnOverload(foo: any) { } -// public /*GOTO DEF*/[|fnOverload|](): any; -// public [|fnOverload|](foo: string); -// public [|fnOverload|](foo: any) { return "foo" } -// -// constructor() { } -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImport1.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImport1.baseline.jsonc deleted file mode 100644 index b9281b2a4d..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImport1.baseline.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -// === goToDefinition === -// === /b.ts === -// [|export const foo = 1;|] - -// === /a.ts === -// import { foo } from "./b/*GOTO DEF*/"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames.baseline.jsonc deleted file mode 100644 index 5aa9446edb..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames.baseline.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export module Module { -// } -// export class [|Class|] { -// private f; -// } -// export interface Interface { -// x; -// } - -// === /b.ts === -// export {/*GOTO DEF*/Class} from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames10.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames10.baseline.jsonc deleted file mode 100644 index 91440f77d1..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames10.baseline.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -// === goToDefinition === -// === /a.js === -// class Class { -// f; -// } -// module.exports.[|Class|] = Class; - -// === /b.js === -// const { Class } = require("./a"); -// /*GOTO DEF*/Class; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames2.baseline.jsonc deleted file mode 100644 index e78479c07d..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames2.baseline.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export module Module { -// } -// export class [|Class|] { -// private f; -// } -// export interface Interface { -// x; -// } - -// === /b.ts === -// import {/*GOTO DEF*/Class} from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames3.baseline.jsonc deleted file mode 100644 index e203d7d28d..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames3.baseline.jsonc +++ /dev/null @@ -1,31 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export module Module { -// } -// export class [|Class|] { -// private f; -// } -// export interface Interface { -// x; -// } - -// === /e.ts === -// import {M, C, I} from "./d"; -// var c = new /*GOTO DEF*/C(); - - - -// === goToDefinition === -// === /a.ts === -// export module Module { -// } -// export class [|Class|] { -// private f; -// } -// export interface Interface { -// x; -// } - -// === /e.ts === -// import {M, /*GOTO DEF*/C, I} from "./d"; -// var c = new C(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames4.baseline.jsonc deleted file mode 100644 index 55509a2511..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames4.baseline.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export module Module { -// } -// export class [|Class|] { -// private f; -// } -// export interface Interface { -// x; -// } - -// === /b.ts === -// import {Class as /*GOTO DEF*/ClassAlias} from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames5.baseline.jsonc deleted file mode 100644 index 0c0a65ec64..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames5.baseline.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export module Module { -// } -// export class [|Class|] { -// private f; -// } -// export interface Interface { -// x; -// } - -// === /b.ts === -// export {Class as /*GOTO DEF*/ClassAlias} from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames7.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames7.baseline.jsonc deleted file mode 100644 index 204b6ef767..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames7.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// class [|Class|] { -// private f; -// } -// export default Class; - -// === /b.ts === -// import /*GOTO DEF*/defaultExport from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames8.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames8.baseline.jsonc deleted file mode 100644 index 438a28cd46..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames8.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === goToDefinition === -// === /a.js === -// class [|Class|] { -// private f; -// } -// export { Class }; - -// === /b.js === -// import { /*GOTO DEF*/Class } from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames9.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames9.baseline.jsonc deleted file mode 100644 index 54c06f70e2..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionImportedNames9.baseline.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -// === goToDefinition === -// === /a.js === -// class [|Class|] { -// f; -// } -// export { Class }; - -// === /b.js === -// const { Class } = require("./a"); -// /*GOTO DEF*/Class; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionInstanceof2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionInstanceof2.baseline.jsonc deleted file mode 100644 index 899d642468..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionInstanceof2.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /main.ts === -// class C { -// static [|[Symbol.hasInstance]|](value: unknown): boolean { return true; } -// } -// declare var obj: any; -// obj /*GOTO DEF*/instanceof C; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsDocImportTag4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsDocImportTag4.baseline.jsonc deleted file mode 100644 index ec17a66f3c..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsDocImportTag4.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /b.ts === -// export interface [|A|] { } - -// === /a.js === -// /** -// * @import { A/*GOTO DEF*/ } from "./b"; -// */ \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsDocImportTag5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsDocImportTag5.baseline.jsonc deleted file mode 100644 index 7e27cfb656..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsDocImportTag5.baseline.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -// === goToDefinition === -// === /b.ts === -// export interface [|A|] { } - -// === /a.js === -// /** -// * @import { A } from "./b"; -// */ -// -// /** -// * @param { A/*GOTO DEF*/ } a -// */ -// function f(a) {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsModuleName.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsModuleName.baseline.jsonc deleted file mode 100644 index b8416519af..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsModuleName.baseline.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -// === goToDefinition === -// === /foo.js === -// [|module.exports = {};|] - -// === /bar.js === -// var x = require(/*GOTO DEF*/"./foo"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsxNotSet.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsxNotSet.baseline.jsonc deleted file mode 100644 index dd6576d397..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionJsxNotSet.baseline.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -// === goToDefinition === -// === /foo.jsx === -// const [|Foo|] = () => ( -//
foo
-// ); -// export default Foo; - -// === /bar.jsx === -// import Foo from './foo'; -// const a = \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMember.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMember.baseline.jsonc deleted file mode 100644 index 73c5325d09..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMember.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// class A { -// private [|z|]/*GOTO DEF*/: string; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionModifiers.baseline.jsonc deleted file mode 100644 index 25bd1b90c5..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionModifiers.baseline.jsonc +++ /dev/null @@ -1,199 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// /*GOTO DEF*/export class [|A|] { -// -// private z: string; -// -// // --- (line: 5) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// export class [|A|]/*GOTO DEF*/ { -// -// private z: string; -// -// // --- (line: 5) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// export class A { -// -// /*GOTO DEF*/private [|z|]: string; -// -// readonly x: string; -// -// // --- (line: 7) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// export class A { -// -// private [|z|]/*GOTO DEF*/: string; -// -// readonly x: string; -// -// // --- (line: 7) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// export class A { -// -// private z: string; -// -// /*GOTO DEF*/readonly [|x|]: string; -// -// async a() { } -// -// // --- (line: 9) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// export class A { -// -// private z: string; -// -// readonly [|x|]/*GOTO DEF*/: string; -// -// async a() { } -// -// // --- (line: 9) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 3) skipped --- -// -// readonly x: string; -// -// /*GOTO DEF*/async [|a|]() { } -// -// override b() {} -// -// // --- (line: 11) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 3) skipped --- -// -// readonly x: string; -// -// async [|a|]/*GOTO DEF*/() { } -// -// override b() {} -// -// // --- (line: 11) skipped --- - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 5) skipped --- -// -// async a() { } -// -// /*GOTO DEF*/override [|b|]() {} -// -// public async c() { } -// } -// -// export function foo() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 5) skipped --- -// -// async a() { } -// -// override [|b|]/*GOTO DEF*/() {} -// -// public async c() { } -// } -// -// export function foo() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 7) skipped --- -// -// override b() {} -// -// /*GOTO DEF*/public async [|c|]() { } -// } -// -// export function foo() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 7) skipped --- -// -// override b() {} -// -// public/*GOTO DEF*/ async [|c|]() { } -// } -// -// export function foo() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 7) skipped --- -// -// override b() {} -// -// public as/*GOTO DEF*/ync [|c|]() { } -// } -// -// export function foo() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 7) skipped --- -// -// override b() {} -// -// public async [|c|]/*GOTO DEF*/() { } -// } -// -// export function foo() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 10) skipped --- -// public async c() { } -// } -// -// exp/*GOTO DEF*/ort function [|foo|]() { } - - - -// === goToDefinition === -// === /a.ts === -// --- (line: 10) skipped --- -// public async c() { } -// } -// -// export function [|foo|]/*GOTO DEF*/() { } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMultipleDefinitions.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMultipleDefinitions.baseline.jsonc deleted file mode 100644 index 34a3582173..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMultipleDefinitions.baseline.jsonc +++ /dev/null @@ -1,32 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// interface [|IFoo|] { -// instance1: number; -// } - -// === /b.ts === -// interface [|IFoo|] { -// instance2: number; -// } -// -// interface [|IFoo|] { -// instance3: number; -// } -// -// var ifoo: IFo/*GOTO DEF*/o; - - - -// === goToDefinition === -// === /c.ts === -// module [|Module|] { -// export class c1 { } -// } - -// === /d.ts === -// module [|Module|] { -// export class c2 { } -// } - -// === /e.ts === -// Modul/*GOTO DEF*/e; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionObjectSpread.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionObjectSpread.baseline.jsonc deleted file mode 100644 index 857f644752..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionObjectSpread.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionObjectSpread.ts === -// interface A1 { [|a|]: number }; -// interface A2 { [|a|]?: number }; -// let a1: A1; -// let a2: A2; -// let a12 = { ...a1, ...a2 }; -// a12.a/*GOTO DEF*/; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember17.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember17.baseline.jsonc deleted file mode 100644 index 912ebcd379..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember17.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember17.ts === -// --- (line: 4) skipped --- -// } -// -// export class MySqlVarBinary extends MySqlColumn { -// static /*GOTO DEF*/override readonly [|[entityKind]|]: string = "MySqlVarBinary"; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember18.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember18.baseline.jsonc deleted file mode 100644 index 82fd630b90..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember18.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember18.ts === -// --- (line: 4) skipped --- -// } -// -// export class MySqlVarBinary extends MySqlColumn { -// /*GOTO DEF*/override readonly [|[entityKind]|]: string = "MySqlVarBinary"; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember19.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember19.baseline.jsonc deleted file mode 100644 index 9a6e7362bf..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember19.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember19.ts === -// --- (line: 4) skipped --- -// } -// -// export class B extends A { -// static /*GOTO DEF*/override readonly [|[prop]|] = "B"; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember20.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember20.baseline.jsonc deleted file mode 100644 index 0583541163..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember20.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember20.ts === -// --- (line: 4) skipped --- -// } -// -// export class B extends A { -// /*GOTO DEF*/override readonly [|[prop]|] = "B"; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember21.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember21.baseline.jsonc deleted file mode 100644 index eb4779aae4..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember21.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember21.ts === -// const prop = "foo" as const; -// -// abstract class A {} -// -// export class B extends A { -// static /*GOTO DEF*/override readonly [|[prop]|] = "B"; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember23.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember23.baseline.jsonc deleted file mode 100644 index 7ca46d1935..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember23.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember23.ts === -// --- (line: 4) skipped --- -// } -// -// export class B extends A { -// static /*GOTO DEF*/override [|[prop]|]() {} -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember7.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember7.baseline.jsonc deleted file mode 100644 index c3bd341438..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember7.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionOverriddenMember7.ts === -// class Foo { -// /*GOTO DEF*/override [|m|]() {} -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember8.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember8.baseline.jsonc deleted file mode 100644 index fc104d7433..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionOverriddenMember8.baseline.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// export class A { -// [|m|]() {} -// } - -// === /b.ts === -// import { A } from "./a"; -// class B extends A { -// /*GOTO DEF*/override m() {} -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionPartialImplementation.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionPartialImplementation.baseline.jsonc deleted file mode 100644 index 97d4a0e865..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionPartialImplementation.baseline.jsonc +++ /dev/null @@ -1,16 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionPartialImplementation_1.ts === -// module A { -// export interface [|IA|] { -// y: string; -// } -// } - -// === /goToDefinitionPartialImplementation_2.ts === -// module A { -// export interface [|IA|] { -// x: number; -// } -// -// var x: /*GOTO DEF*/IA; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionReturn1.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionReturn1.baseline.jsonc deleted file mode 100644 index de684a61f8..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionReturn1.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionReturn1.ts === -// function [|foo|]() { -// /*GOTO DEF*/return 10; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionShorthandProperty01.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionShorthandProperty01.baseline.jsonc deleted file mode 100644 index b447aab88a..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionShorthandProperty01.baseline.jsonc +++ /dev/null @@ -1,41 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionShorthandProperty01.ts === -// var name = "hello"; -// var id = 100000; -// declare var id; -// var obj = {/*GOTO DEF*/name, id}; -// obj.name; -// obj.id; - - - -// === goToDefinition === -// === /goToDefinitionShorthandProperty01.ts === -// var name = "hello"; -// var [|id|] = 100000; -// declare var [|id|]; -// var obj = {name, /*GOTO DEF*/id}; -// obj.name; -// obj.id; - - - -// === goToDefinition === -// === /goToDefinitionShorthandProperty01.ts === -// var name = "hello"; -// var id = 100000; -// declare var id; -// var obj = {[|name|], id}; -// obj./*GOTO DEF*/name; -// obj.id; - - - -// === goToDefinition === -// === /goToDefinitionShorthandProperty01.ts === -// var name = "hello"; -// var id = 100000; -// declare var id; -// var obj = {name, [|id|]}; -// obj.name; -// obj./*GOTO DEF*/id; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc deleted file mode 100644 index 9af12dce90..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc +++ /dev/null @@ -1,17 +0,0 @@ -// === goToDefinition === -// === /a.js === -// [|module.exports = function [|f|]() {}|] - -// === /b.js === -// const f = require("./a"); -// /*GOTO DEF*/f(); - - - -// === goToDefinition === -// === /a.js === -// [|module.exports = function [|f|]() {}|] - -// === /bar.ts === -// import f = require("./a"); -// /*GOTO DEF*/f(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSimple.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSimple.baseline.jsonc deleted file mode 100644 index 78b467b720..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSimple.baseline.jsonc +++ /dev/null @@ -1,17 +0,0 @@ -// === goToDefinition === -// === /Definition.ts === -// class [|c|] { } - -// === /Consumption.ts === -// var n = new /*GOTO DEF*/c(); -// var n = new c(); - - - -// === goToDefinition === -// === /Definition.ts === -// class [|c|] { } - -// === /Consumption.ts === -// var n = new c(); -// var n = new c/*GOTO DEF*/(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSwitchCase5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSwitchCase5.baseline.jsonc deleted file mode 100644 index 656f1d3f24..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSwitchCase5.baseline.jsonc +++ /dev/null @@ -1,3 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionSwitchCase5.ts === -// export /*GOTO DEF*/default {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSwitchCase7.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSwitchCase7.baseline.jsonc deleted file mode 100644 index 14f21d4768..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionSwitchCase7.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionSwitchCase7.ts === -// switch (null) { -// case null: -// export /*GOTO DEF*/default 123; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeOnlyImport.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeOnlyImport.baseline.jsonc deleted file mode 100644 index f6994cecfe..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeOnlyImport.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// enum [|SyntaxKind|] { SourceFile } -// export type { SyntaxKind } - -// === /c.ts === -// import type { SyntaxKind } from './b'; -// let kind: /*GOTO DEF*/SyntaxKind; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment.baseline.jsonc deleted file mode 100644 index 234342516d..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment.baseline.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -// === goToDefinition === -// === /foo.js === -// const Bar; -// const [|Foo|] = [|Bar|] = function () {} -// Foo.prototype.bar = function() {} -// new Foo/*GOTO DEF*/(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment1.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment1.baseline.jsonc deleted file mode 100644 index 30aca9d564..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment1.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /foo.js === -// const [|Foo|] = module.[|exports|] = function () {} -// Foo.prototype.bar = function() {} -// new Foo/*GOTO DEF*/(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment2.baseline.jsonc deleted file mode 100644 index 8e94c0fc30..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment2.baseline.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -// === goToDefinition === -// === /foo.ts === -// const Bar; -// const [|Foo|] = [|Bar|] = function () {} -// Foo.prototype.bar = function() {} -// new Foo/*GOTO DEF*/(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment3.baseline.jsonc deleted file mode 100644 index d826f639e3..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionVariableAssignment3.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /foo.ts === -// const [|Foo|] = module.[|exports|] = function () {} -// Foo.prototype.bar = function() {} -// new Foo/*GOTO DEF*/(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc deleted file mode 100644 index a3f9d8721b..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -// === goToDefinition === -// === /goToDefinitionYield4.ts === -// function* gen() { -// class C { [|[/*GOTO DEF*/yield 10]|]() {} } -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinition_untypedModule.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinition_untypedModule.baseline.jsonc deleted file mode 100644 index 087f06c4d9..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinition_untypedModule.baseline.jsonc +++ /dev/null @@ -1,4 +0,0 @@ -// === goToDefinition === -// === /a.ts === -// import { [|f|] } from "foo"; -// /*GOTO DEF*/f(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToModuleAliasDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToModuleAliasDefinition.baseline.jsonc deleted file mode 100644 index 398dffba0c..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToModuleAliasDefinition.baseline.jsonc +++ /dev/null @@ -1,4 +0,0 @@ -// === goToDefinition === -// === /b.ts === -// import [|n|] = require('a'); -// var x = new /*GOTO DEF*/n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc deleted file mode 100644 index 2cde751515..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc +++ /dev/null @@ -1,18 +0,0 @@ -// === goToDefinition === -// === /gotoDefinitionInObjectBindingPattern2.ts === -// var p0 = ({[|a/*GOTO DEF*/a|]}) => {console.log(aa)}; -// function f2({ a1, b1 }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} - - - -// === goToDefinition === -// === /gotoDefinitionInObjectBindingPattern2.ts === -// var p0 = ({aa}) => {console.log(aa)}; -// function f2({ [|a/*GOTO DEF*/1|], b1 }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} - - - -// === goToDefinition === -// === /gotoDefinitionInObjectBindingPattern2.ts === -// var p0 = ({aa}) => {console.log(aa)}; -// function f2({ a1, [|b/*GOTO DEF*/1|] }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/importTypeNodeGoToDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/importTypeNodeGoToDefinition.baseline.jsonc deleted file mode 100644 index f551165273..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/importTypeNodeGoToDefinition.baseline.jsonc +++ /dev/null @@ -1,95 +0,0 @@ -// === goToDefinition === -// === /ns.ts === -// [|export namespace Foo { -// export namespace Bar { -// export class Baz {} -// } -// }|] - -// === /usage.ts === -// type A = typeof import(/*GOTO DEF*/"./ns").Foo.Bar; -// type B = import("./ns").Foo.Bar.Baz; - - - -// === goToDefinition === -// === /ns.ts === -// export namespace [|Foo|] { -// export namespace Bar { -// export class Baz {} -// } -// } - -// === /usage.ts === -// type A = typeof import("./ns")./*GOTO DEF*/Foo.Bar; -// type B = import("./ns").Foo.Bar.Baz; - - - -// === goToDefinition === -// === /ns.ts === -// export namespace Foo { -// export namespace [|Bar|] { -// export class Baz {} -// } -// } - -// === /usage.ts === -// type A = typeof import("./ns").Foo./*GOTO DEF*/Bar; -// type B = import("./ns").Foo.Bar.Baz; - - - -// === goToDefinition === -// === /ns.ts === -// [|export namespace Foo { -// export namespace Bar { -// export class Baz {} -// } -// }|] - -// === /usage.ts === -// type A = typeof import("./ns").Foo.Bar; -// type B = import(/*GOTO DEF*/"./ns").Foo.Bar.Baz; - - - -// === goToDefinition === -// === /ns.ts === -// export namespace [|Foo|] { -// export namespace Bar { -// export class Baz {} -// } -// } - -// === /usage.ts === -// type A = typeof import("./ns").Foo.Bar; -// type B = import("./ns")./*GOTO DEF*/Foo.Bar.Baz; - - - -// === goToDefinition === -// === /ns.ts === -// export namespace Foo { -// export namespace [|Bar|] { -// export class Baz {} -// } -// } - -// === /usage.ts === -// type A = typeof import("./ns").Foo.Bar; -// type B = import("./ns").Foo./*GOTO DEF*/Bar.Baz; - - - -// === goToDefinition === -// === /ns.ts === -// export namespace Foo { -// export namespace Bar { -// export class [|Baz|] {} -// } -// } - -// === /usage.ts === -// type A = typeof import("./ns").Foo.Bar; -// type B = import("./ns").Foo.Bar./*GOTO DEF*/Baz; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/jsxSpreadReference.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/jsxSpreadReference.baseline.jsonc deleted file mode 100644 index 629dad64b0..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/jsxSpreadReference.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === goToDefinition === -// === /file.tsx === -// --- (line: 10) skipped --- -// } -// } -// -// var [|nn|]: {name?: string; size?: number}; -// var x = ; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/reallyLargeFile.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/reallyLargeFile.baseline.jsonc deleted file mode 100644 index 711b5b0614..0000000000 --- a/testdata/baselines/reference/fourslash/goToDefinition/reallyLargeFile.baseline.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// === goToDefinition === -// === /file.d.ts === -// namespace /*GOTO DEF*/[|Foo|] { -// -// -// -// // --- (line: 5) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline b/testdata/baselines/reference/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline new file mode 100644 index 0000000000..c4db2d46ea --- /dev/null +++ b/testdata/baselines/reference/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline @@ -0,0 +1,25 @@ +// === Inlay Hints === + tuples.forEach((l) => {}) + ^ +{ + "position": { + "line": 1, + "character": 19 + }, + "label": [ + { + "value": ": " + }, + { + "value": "[" + }, + { + "value": "string" + }, + { + "value": "]" + } + ], + "kind": 1, + "paddingLeft": true +} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/completionDetailsOfContextSensitiveParameterNoCrash.baseline b/testdata/baselines/reference/fourslash/quickInfo/completionDetailsOfContextSensitiveParameterNoCrash.baseline index 2ffe5f140f..2d144531b1 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/completionDetailsOfContextSensitiveParameterNoCrash.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/completionDetailsOfContextSensitiveParameterNoCrash.baseline @@ -83,7 +83,7 @@ // ...args // ): StylingFunction => { // return curry(getStylingByKeys, 2)(mergedStyling, ...args); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) args: [] @@ -108,6 +108,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) args: []\n```\n" + }, + "range": { + "start": { + "line": 82, + "character": 60 + }, + "end": { + "line": 82, + "character": 64 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/deprecatedInheritedJSDocOverload.baseline b/testdata/baselines/reference/fourslash/quickInfo/deprecatedInheritedJSDocOverload.baseline index 12afda7f60..97bb4d0a90 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/deprecatedInheritedJSDocOverload.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/deprecatedInheritedJSDocOverload.baseline @@ -23,7 +23,7 @@ // } // declare const a: ThingWithDeprecations // a.subscribe(() => { -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) ThingWithDeprecations.subscribe(observer?: PartialObserver): Subscription @@ -47,6 +47,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) ThingWithDeprecations.subscribe(observer?: PartialObserver): Subscription\n```\n" + }, + "range": { + "start": { + "line": 22, + "character": 2 + }, + "end": { + "line": 22, + "character": 11 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsDocAliasQuickInfo.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsDocAliasQuickInfo.baseline index 9ab690fbec..52ea31202e 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsDocAliasQuickInfo.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsDocAliasQuickInfo.baseline @@ -5,9 +5,12 @@ // * @type {number} // */ // export default 10; -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*1*/. +// | ```tsx +// | (property) default: 10 +// | ``` +// | Comment // | ---------------------------------------------------------------------- === /test.ts === // export { default as test } from "./jsDocAliasQuickInfo"; @@ -32,7 +35,22 @@ "Name": "1", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\n(property) default: 10\n```\nComment" + }, + "range": { + "start": { + "line": 4, + "character": 7 + }, + "end": { + "line": 4, + "character": 14 + } + } + } }, { "marker": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo1.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo1.baseline index e0e801f01b..fac037faa7 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo1.baseline @@ -47,7 +47,7 @@ // | ---------------------------------------------------------------------- // /** @type {Null} */ // var Nl; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var Nl: Null @@ -74,7 +74,7 @@ // | ---------------------------------------------------------------------- // /** @type {Object} */ // var Obj; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var Obj: Object @@ -83,7 +83,7 @@ // | ---------------------------------------------------------------------- // /** @type {Function} */ // var Func; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var Func: Function @@ -92,7 +92,7 @@ // | ---------------------------------------------------------------------- // /** @type {*} */ // var AnyType; -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var AnyType: any @@ -101,7 +101,7 @@ // | ---------------------------------------------------------------------- // /** @type {?} */ // var QType; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var QType: any @@ -110,7 +110,7 @@ // | ---------------------------------------------------------------------- // /** @type {String|Number} */ // var SOrN; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var SOrN: Number | String @@ -132,6 +132,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar S: String\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 5 + } } } }, @@ -149,6 +159,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar N: Number\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 5 + } } } }, @@ -166,6 +186,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar B: Boolean\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 5 + } } } }, @@ -183,6 +213,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar V: Void\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 4 + }, + "end": { + "line": 7, + "character": 5 + } } } }, @@ -200,6 +240,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar U: Undefined\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 4 + }, + "end": { + "line": 9, + "character": 5 + } } } }, @@ -217,6 +267,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar Nl: Null\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 6 + } } } }, @@ -234,6 +294,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar A: any[]\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 5 + } } } }, @@ -251,6 +321,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar P: Promise\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 5 + } } } }, @@ -268,6 +348,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar Obj: Object\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 7 + } } } }, @@ -285,6 +375,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar Func: Function\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 4 + }, + "end": { + "line": 19, + "character": 8 + } } } }, @@ -302,6 +402,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar AnyType: any\n```\n" + }, + "range": { + "start": { + "line": 21, + "character": 4 + }, + "end": { + "line": 21, + "character": 11 + } } } }, @@ -319,6 +429,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar QType: any\n```\n" + }, + "range": { + "start": { + "line": 23, + "character": 4 + }, + "end": { + "line": 23, + "character": 9 + } } } }, @@ -336,6 +456,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar SOrN: Number | String\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 4 + }, + "end": { + "line": 25, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo2.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo2.baseline index 51d7853a5b..63dfbe3024 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo2.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsDocTypeTagQuickInfo2.baseline @@ -47,7 +47,7 @@ // | ---------------------------------------------------------------------- // /** @type {null} */ // var nl; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var nl: null @@ -74,7 +74,7 @@ // | ---------------------------------------------------------------------- // /** @type {?number} */ // var nullable; -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var nullable: number @@ -83,7 +83,7 @@ // | ---------------------------------------------------------------------- // /** @type {function} */ // var func; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var func: function @@ -92,7 +92,7 @@ // | ---------------------------------------------------------------------- // /** @type {function (number): number} */ // var func1; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var func1: function @@ -101,7 +101,7 @@ // | ---------------------------------------------------------------------- // /** @type {string | number} */ // var sOrn; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var sOrn: string | number @@ -123,6 +123,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar s: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 5 + } } } }, @@ -140,6 +150,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar n: number\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 5 + } } } }, @@ -157,6 +177,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar b: boolean\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 5 + } } } }, @@ -174,6 +204,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar v: void\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 4 + }, + "end": { + "line": 7, + "character": 5 + } } } }, @@ -191,6 +231,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar u: undefined\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 4 + }, + "end": { + "line": 9, + "character": 5 + } } } }, @@ -208,6 +258,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar nl: null\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 6 + } } } }, @@ -225,6 +285,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: array\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 5 + } } } }, @@ -242,6 +312,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar p: promise\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 5 + } } } }, @@ -259,6 +339,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar nullable: number\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 12 + } } } }, @@ -276,6 +366,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar func: function\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 4 + }, + "end": { + "line": 19, + "character": 8 + } } } }, @@ -293,6 +393,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar func1: function\n```\n" + }, + "range": { + "start": { + "line": 21, + "character": 4 + }, + "end": { + "line": 21, + "character": 9 + } } } }, @@ -310,6 +420,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar sOrn: string | number\n```\n" + }, + "range": { + "start": { + "line": 23, + "character": 4 + }, + "end": { + "line": 23, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsDocTypedefQuickInfo1.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsDocTypedefQuickInfo1.baseline index 17be79caa3..8b042665a2 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsDocTypedefQuickInfo1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsDocTypedefQuickInfo1.baseline @@ -10,7 +10,7 @@ // * @param {Opts} opts // */ // function foo(opts) { -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) opts: Opts @@ -30,7 +30,7 @@ // * @param {Opts1} opts // */ // function foo1(opts1) { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) opts1: any @@ -55,6 +55,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) opts: Opts\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 13 + }, + "end": { + "line": 9, + "character": 17 + } } } }, @@ -72,6 +82,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) opts1: any\n```\n" + }, + "range": { + "start": { + "line": 22, + "character": 14 + }, + "end": { + "line": 22, + "character": 19 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline index 8c1c73c68e..937f3ce849 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline @@ -11,19 +11,19 @@ // * @see {@link C} its great // */ // function CC() { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function CC(): void // | ``` -// | `C` +// | [C](file:///jsdocLink1.ts#1,7-1,8) // | -// | *@wat* — Makes a `C`. A default one. -// | C() -// | C|postfix text -// | unformattedpostfix text +// | *@wat* — Makes a [C](file:///jsdocLink1.ts#1,7-1,8). A default one. +// | [C()](file:///jsdocLink1.ts#1,7-1,8) +// | [postfix text](file:///jsdocLink1.ts#1,7-1,8) +// | unformatted postfix text // | -// | *@see* — `C` its great +// | *@see* — [C](file:///jsdocLink1.ts#1,7-1,8) its great // | // | ---------------------------------------------------------------------- // } @@ -41,7 +41,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction CC(): void\n```\n`C`\n\n*@wat* — Makes a `C`. A default one.\nC()\nC|postfix text\nunformattedpostfix text\n\n*@see* — `C` its great\n" + "value": "```tsx\nfunction CC(): void\n```\n[C](file:///jsdocLink1.ts#1,7-1,8)\n\n*@wat* — Makes a [C](file:///jsdocLink1.ts#1,7-1,8). A default one.\n[C()](file:///jsdocLink1.ts#1,7-1,8)\n[postfix text](file:///jsdocLink1.ts#1,7-1,8)\nunformatted postfix text\n\n*@see* — [C](file:///jsdocLink1.ts#1,7-1,8) its great\n" + }, + "range": { + "start": { + "line": 10, + "character": 9 + }, + "end": { + "line": 10, + "character": 11 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline index 34f8283b55..51098f908d 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline @@ -3,22 +3,22 @@ // declare class I { // /** {@link I} */ // bar(): void -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I.bar(): void // | ``` -// | `I` +// | [I](file:///jsdocLink4.ts#1,15-1,16) // | ---------------------------------------------------------------------- // } // /** {@link I} */ // var n = 1 -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | var n: number // | ``` -// | `I` +// | [I](file:///jsdocLink4.ts#1,15-1,16) // | ---------------------------------------------------------------------- // /** // * A real, very serious {@link I to an interface}. Right there. @@ -27,14 +27,14 @@ // function f(x) { // } // f() -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | function f(x: any): void // | ``` -// | A real, very serious Ito an interface. Right there. +// | A real, very serious [to an interface](file:///jsdocLink4.ts#1,15-1,16). Right there. // | -// | *@param* `x` — one Poshere too +// | *@param* `x` — one [here too](file:///jsdocLink4.ts#14,6-14,9) // | ---------------------------------------------------------------------- // type Pos = [number, number] [ @@ -51,7 +51,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) I.bar(): void\n```\n`I`" + "value": "```tsx\n(method) I.bar(): void\n```\n[I](file:///jsdocLink4.ts#1,15-1,16)" + }, + "range": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 5 + } } } }, @@ -68,7 +78,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar n: number\n```\n`I`" + "value": "```tsx\nvar n: number\n```\n[I](file:///jsdocLink4.ts#1,15-1,16)" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 5 + } } } }, @@ -85,7 +105,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction f(x: any): void\n```\nA real, very serious Ito an interface. Right there.\n\n*@param* `x` — one Poshere too" + "value": "```tsx\nfunction f(x: any): void\n```\nA real, very serious [to an interface](file:///jsdocLink4.ts#1,15-1,16). Right there.\n\n*@param* `x` — one [here too](file:///jsdocLink4.ts#14,6-14,9)" + }, + "range": { + "start": { + "line": 12, + "character": 0 + }, + "end": { + "line": 12, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline index 462571cb64..3ce31de673 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline @@ -8,13 +8,13 @@ // function f(x) { // } // f() -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | function f(x: any): void // | ``` -// | g() g() g() g() 0 g()1 g() 2 -// | u() u() u() u() 0 u()1 u() 2 +// | [g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [0](file:///jsdocLink5.ts#1,10-1,11) [1](file:///jsdocLink5.ts#1,10-1,11) [2](file:///jsdocLink5.ts#1,10-1,11) +// | u () u () u () u () 0 u ()1 u () 2 // | ---------------------------------------------------------------------- [ { @@ -30,7 +30,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction f(x: any): void\n```\ng() g() g() g() 0 g()1 g() 2\nu() u() u() u() 0 u()1 u() 2" + "value": "```tsx\nfunction f(x: any): void\n```\n[g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [0](file:///jsdocLink5.ts#1,10-1,11) [1](file:///jsdocLink5.ts#1,10-1,11) [2](file:///jsdocLink5.ts#1,10-1,11)\nu () u () u () u () 0 u ()1 u () 2" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers1.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers1.baseline index 8add321440..eb80ccd6f1 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers1.baseline @@ -13,12 +13,12 @@ // // const b = new B(); // b.method; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) B.method(): void // | ``` -// | +// | Method documentation. // | ---------------------------------------------------------------------- [ { @@ -34,7 +34,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) B.method(): void\n```\n" + "value": "```tsx\n(method) B.method(): void\n```\nMethod documentation." + }, + "range": { + "start": { + "line": 12, + "character": 2 + }, + "end": { + "line": 12, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers2.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers2.baseline index 11aa33e878..e062d75099 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers2.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocOnInheritedMembers2.baseline @@ -13,12 +13,12 @@ // // const b = new B(); // b.method; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) B.method(): void // | ``` -// | +// | Method documentation. // | ---------------------------------------------------------------------- [ { @@ -34,7 +34,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) B.method(): void\n```\n" + "value": "```tsx\n(method) B.method(): void\n```\nMethod documentation." + }, + "range": { + "start": { + "line": 12, + "character": 2 + }, + "end": { + "line": 12, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCircularInstantiationExpression.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCircularInstantiationExpression.baseline index 1b6a7aed86..a3861379d6 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCircularInstantiationExpression.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCircularInstantiationExpression.baseline @@ -2,7 +2,7 @@ === /quickInfoCircularInstantiationExpression.ts === // declare function foo(t: T): typeof foo; // foo(""); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(t: string): (t: string) => ... @@ -24,6 +24,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(t: string): (t: string) => ...\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 3 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClass.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClass.baseline index afd26eff9c..493fc0d368 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClass.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClass.baseline @@ -2,7 +2,7 @@ === /quickInfoCommentsClass.ts === // /** This is class c2 without constructor*/ // class c2 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c2 @@ -11,29 +11,29 @@ // | ---------------------------------------------------------------------- // } // var i2 = new c2(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i2: c2 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx -// | class c2 +// | constructor c2(): c2 // | ``` // | This is class c2 without constructor // | ---------------------------------------------------------------------- // var i2_c = c2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i2_c: typeof c2 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c2 @@ -41,7 +41,7 @@ // | This is class c2 without constructor // | ---------------------------------------------------------------------- // class c3 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c3 @@ -53,14 +53,14 @@ // } // } // var i3 = new c3(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i3: c3 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c3(): c3 @@ -68,14 +68,14 @@ // | Constructor comment // | ---------------------------------------------------------------------- // var i3_c = c3; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i3_c: typeof c3 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c3 @@ -84,7 +84,7 @@ // | ---------------------------------------------------------------------- // /** Class comment*/ // class c4 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c4 @@ -96,14 +96,14 @@ // } // } // var i4 = new c4(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i4: c4 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c4(): c4 @@ -111,14 +111,14 @@ // | Constructor comment // | ---------------------------------------------------------------------- // var i4_c = c4; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i4_c: typeof c4 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c4 @@ -127,7 +127,7 @@ // | ---------------------------------------------------------------------- // /** Class with statics*/ // class c5 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c5 @@ -137,29 +137,29 @@ // static s1: number; // } // var i5 = new c5(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i5: c5 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx -// | class c5 +// | constructor c5(): c5 // | ``` // | Class with statics // | ---------------------------------------------------------------------- // var i5_c = c5; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i5_c: typeof c5 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c5 @@ -168,7 +168,7 @@ // | ---------------------------------------------------------------------- // /** class with statics and constructor*/ // class c6 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c6 @@ -182,14 +182,14 @@ // } // } // var i6 = new c6(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i6: c6 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c6(): c6 @@ -197,14 +197,14 @@ // | constructor comment // | ---------------------------------------------------------------------- // var i6_c = c6; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i6_c: typeof c6 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c6 @@ -232,7 +232,7 @@ // } // } // var myVar = new m.m2.c1(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor m.m2.c1(): m.m2.c1 @@ -254,6 +254,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c2\n```\nThis is class c2 without constructor" + }, + "range": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 8 + } } } }, @@ -271,6 +281,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i2: c2\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 6 + } } } }, @@ -287,7 +307,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nclass c2\n```\nThis is class c2 without constructor" + "value": "```tsx\nconstructor c2(): c2\n```\nThis is class c2 without constructor" + }, + "range": { + "start": { + "line": 3, + "character": 13 + }, + "end": { + "line": 3, + "character": 15 + } } } }, @@ -305,6 +335,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i2_c: typeof c2\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 8 + } } } }, @@ -322,6 +362,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c2\n```\nThis is class c2 without constructor" + }, + "range": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 13 + } } } }, @@ -339,6 +389,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c3\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 6 + }, + "end": { + "line": 5, + "character": 8 + } } } }, @@ -356,6 +416,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i3: c3\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 4 + }, + "end": { + "line": 10, + "character": 6 + } } } }, @@ -373,6 +443,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c3(): c3\n```\nConstructor comment" + }, + "range": { + "start": { + "line": 10, + "character": 13 + }, + "end": { + "line": 10, + "character": 15 + } } } }, @@ -390,6 +470,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i3_c: typeof c3\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 8 + } } } }, @@ -407,6 +497,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c3\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 11 + }, + "end": { + "line": 11, + "character": 13 + } } } }, @@ -424,6 +524,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c4\n```\nClass comment" + }, + "range": { + "start": { + "line": 13, + "character": 6 + }, + "end": { + "line": 13, + "character": 8 + } } } }, @@ -441,6 +551,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i4: c4\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 4 + }, + "end": { + "line": 18, + "character": 6 + } } } }, @@ -458,6 +578,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c4(): c4\n```\nConstructor comment" + }, + "range": { + "start": { + "line": 18, + "character": 13 + }, + "end": { + "line": 18, + "character": 15 + } } } }, @@ -475,6 +605,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i4_c: typeof c4\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 4 + }, + "end": { + "line": 19, + "character": 8 + } } } }, @@ -492,6 +632,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c4\n```\nClass comment" + }, + "range": { + "start": { + "line": 19, + "character": 11 + }, + "end": { + "line": 19, + "character": 13 + } } } }, @@ -509,6 +659,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c5\n```\nClass with statics" + }, + "range": { + "start": { + "line": 21, + "character": 6 + }, + "end": { + "line": 21, + "character": 8 + } } } }, @@ -526,6 +686,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i5: c5\n```\n" + }, + "range": { + "start": { + "line": 24, + "character": 4 + }, + "end": { + "line": 24, + "character": 6 + } } } }, @@ -542,7 +712,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nclass c5\n```\nClass with statics" + "value": "```tsx\nconstructor c5(): c5\n```\nClass with statics" + }, + "range": { + "start": { + "line": 24, + "character": 13 + }, + "end": { + "line": 24, + "character": 15 + } } } }, @@ -560,6 +740,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i5_c: typeof c5\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 4 + }, + "end": { + "line": 25, + "character": 8 + } } } }, @@ -577,6 +767,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c5\n```\nClass with statics" + }, + "range": { + "start": { + "line": 25, + "character": 11 + }, + "end": { + "line": 25, + "character": 13 + } } } }, @@ -594,6 +794,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c6\n```\nclass with statics and constructor" + }, + "range": { + "start": { + "line": 27, + "character": 6 + }, + "end": { + "line": 27, + "character": 8 + } } } }, @@ -611,6 +821,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i6: c6\n```\n" + }, + "range": { + "start": { + "line": 34, + "character": 4 + }, + "end": { + "line": 34, + "character": 6 + } } } }, @@ -628,6 +848,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c6(): c6\n```\nconstructor comment" + }, + "range": { + "start": { + "line": 34, + "character": 13 + }, + "end": { + "line": 34, + "character": 15 + } } } }, @@ -645,6 +875,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i6_c: typeof c6\n```\n" + }, + "range": { + "start": { + "line": 35, + "character": 4 + }, + "end": { + "line": 35, + "character": 8 + } } } }, @@ -662,6 +902,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c6\n```\nclass with statics and constructor" + }, + "range": { + "start": { + "line": 35, + "character": 11 + }, + "end": { + "line": 35, + "character": 13 + } } } }, @@ -679,6 +929,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor m.m2.c1(): m.m2.c1\n```\nconstructor comment" + }, + "range": { + "start": { + "line": 56, + "character": 21 + }, + "end": { + "line": 56, + "character": 23 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClassMembers.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClassMembers.baseline index 48ba953a02..55556c19f2 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClassMembers.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsClassMembers.baseline @@ -2,7 +2,7 @@ === /quickInfoCommentsClassMembers.ts === // /** This is comment for c1*/ // class c1 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c1 @@ -11,7 +11,7 @@ // | ---------------------------------------------------------------------- // /** p1 is property of c1*/ // public p1: number; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.p1: number @@ -20,7 +20,7 @@ // | ---------------------------------------------------------------------- // /** sum with property*/ // public p2(/** number to add*/b: number) { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.p2(b: number): number @@ -31,7 +31,7 @@ // } // /** getter property 1*/ // public get p3() { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.p3: number @@ -39,7 +39,7 @@ // | getter property 1 // | ---------------------------------------------------------------------- // return this.p2(this.p1); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.p2(b: number): number @@ -49,7 +49,7 @@ // } // /** setter property 1*/ // public set p3(/** this is value*/value: number) { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.p3: number @@ -57,7 +57,7 @@ // | getter property 1 // | ---------------------------------------------------------------------- // this.p1 = this.p2(value); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.p2(b: number): number @@ -67,7 +67,7 @@ // } // /** pp1 is property of c1*/ // private pp1: number; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.pp1: number @@ -76,7 +76,7 @@ // | ---------------------------------------------------------------------- // /** sum with property*/ // private pp2(/** number to add*/b: number) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.pp2(b: number): number @@ -87,7 +87,7 @@ // } // /** getter property 2*/ // private get pp3() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.pp3: number @@ -95,7 +95,7 @@ // | getter property 2 // | ---------------------------------------------------------------------- // return this.pp2(this.pp1); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.pp2(b: number): number @@ -105,7 +105,7 @@ // } // /** setter property 2*/ // private set pp3( /** this is value*/value: number) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.pp3: number @@ -113,7 +113,7 @@ // | getter property 2 // | ---------------------------------------------------------------------- // this.pp1 = this.pp2(value); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.pp2(b: number): number @@ -123,7 +123,7 @@ // } // /** Constructor method*/ // constructor() { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c1(): c1 @@ -133,7 +133,7 @@ // } // /** s1 is static property of c1*/ // static s1: number; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.s1: number @@ -142,7 +142,7 @@ // | ---------------------------------------------------------------------- // /** static sum with property*/ // static s2(/** number to add*/b: number) { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.s2(b: number): number @@ -153,7 +153,7 @@ // } // /** static getter property*/ // static get s3() { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.s3: number @@ -161,7 +161,7 @@ // | static getter property // | ---------------------------------------------------------------------- // return c1.s2(c1.s1); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.s2(b: number): number @@ -171,7 +171,7 @@ // } // /** setter property 3*/ // static set s3( /** this is value*/value: number) { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.s3: number @@ -179,7 +179,7 @@ // | static getter property // | ---------------------------------------------------------------------- // c1.s1 = c1.s2(value); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.s2(b: number): number @@ -188,7 +188,7 @@ // | ---------------------------------------------------------------------- // } // public nc_p1: number; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.nc_p1: number @@ -196,7 +196,7 @@ // | // | ---------------------------------------------------------------------- // public nc_p2(b: number) { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_p2(b: number): number @@ -206,7 +206,7 @@ // return this.nc_p1 + b; // } // public get nc_p3() { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_p3: number @@ -214,7 +214,7 @@ // | // | ---------------------------------------------------------------------- // return this.nc_p2(this.nc_p1); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_p2(b: number): number @@ -223,7 +223,7 @@ // | ---------------------------------------------------------------------- // } // public set nc_p3(value: number) { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_p3: number @@ -231,7 +231,7 @@ // | // | ---------------------------------------------------------------------- // this.nc_p1 = this.nc_p2(value); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_p2(b: number): number @@ -240,7 +240,7 @@ // | ---------------------------------------------------------------------- // } // private nc_pp1: number; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.nc_pp1: number @@ -248,7 +248,7 @@ // | // | ---------------------------------------------------------------------- // private nc_pp2(b: number) { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_pp2(b: number): number @@ -258,7 +258,7 @@ // return this.nc_pp1 + b; // } // private get nc_pp3() { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_pp3: number @@ -266,7 +266,7 @@ // | // | ---------------------------------------------------------------------- // return this.nc_pp2(this.nc_pp1); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_pp2(b: number): number @@ -275,7 +275,7 @@ // | ---------------------------------------------------------------------- // } // private set nc_pp3(value: number) { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_pp3: number @@ -283,7 +283,7 @@ // | // | ---------------------------------------------------------------------- // this.nc_pp1 = this.nc_pp2(value); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_pp2(b: number): number @@ -292,7 +292,7 @@ // | ---------------------------------------------------------------------- // } // static nc_s1: number; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.nc_s1: number @@ -300,7 +300,7 @@ // | // | ---------------------------------------------------------------------- // static nc_s2(b: number) { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_s2(b: number): number @@ -310,7 +310,7 @@ // return c1.nc_s1 + b; // } // static get nc_s3() { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_s3: number @@ -318,7 +318,7 @@ // | // | ---------------------------------------------------------------------- // return c1.nc_s2(c1.nc_s1); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_s2(b: number): number @@ -327,7 +327,7 @@ // | ---------------------------------------------------------------------- // } // static set nc_s3(value: number) { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_s3: number @@ -335,7 +335,7 @@ // | // | ---------------------------------------------------------------------- // c1.nc_s1 = c1.nc_s2(value); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_s2(b: number): number @@ -345,14 +345,14 @@ // } // } // var i1 = new c1(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1: c1 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c1(): c1 @@ -360,7 +360,7 @@ // | Constructor method // | ---------------------------------------------------------------------- // var i1_p = i1.p1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_p: number @@ -368,14 +368,14 @@ // | // | ---------------------------------------------------------------------- // var i1_f = i1.p2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_f: (b: number) => number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.p2(b: number): number @@ -383,14 +383,14 @@ // | sum with property // | ---------------------------------------------------------------------- // var i1_r = i1.p2(20); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_r: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.p2(b: number): number @@ -398,14 +398,14 @@ // | sum with property // | ---------------------------------------------------------------------- // var i1_prop = i1.p3; -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_prop: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.p3: number @@ -413,14 +413,14 @@ // | getter property 1 // | ---------------------------------------------------------------------- // i1.p3 = i1_prop; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.p3: number // | ``` // | getter property 1 // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_prop: number @@ -428,14 +428,14 @@ // | // | ---------------------------------------------------------------------- // var i1_nc_p = i1.nc_p1; -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_nc_p: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.nc_p1: number @@ -443,14 +443,14 @@ // | // | ---------------------------------------------------------------------- // var i1_ncf = i1.nc_p2; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_ncf: (b: number) => number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_p2(b: number): number @@ -458,14 +458,14 @@ // | // | ---------------------------------------------------------------------- // var i1_ncr = i1.nc_p2(20); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_ncr: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_p2(b: number): number @@ -473,14 +473,14 @@ // | // | ---------------------------------------------------------------------- // var i1_ncprop = i1.nc_p3; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_ncprop: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_p3: number @@ -488,14 +488,14 @@ // | // | ---------------------------------------------------------------------- // i1.nc_p3 = i1_ncprop; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_p3: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_ncprop: number @@ -503,21 +503,21 @@ // | // | ---------------------------------------------------------------------- // var i1_s_p = c1.s1; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_p: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c1 // | ``` // | This is comment for c1 // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.s1: number @@ -525,14 +525,14 @@ // | s1 is static property of c1 // | ---------------------------------------------------------------------- // var i1_s_f = c1.s2; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_f: (b: number) => number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.s2(b: number): number @@ -540,14 +540,14 @@ // | static sum with property // | ---------------------------------------------------------------------- // var i1_s_r = c1.s2(20); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_r: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.s2(b: number): number @@ -555,14 +555,14 @@ // | static sum with property // | ---------------------------------------------------------------------- // var i1_s_prop = c1.s3; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_prop: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.s3: number @@ -570,14 +570,14 @@ // | static getter property // | ---------------------------------------------------------------------- // c1.s3 = i1_s_prop; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.s3: number // | ``` // | static getter property // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_prop: number @@ -585,14 +585,14 @@ // | // | ---------------------------------------------------------------------- // var i1_s_nc_p = c1.nc_s1; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_nc_p: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c1.nc_s1: number @@ -600,14 +600,14 @@ // | // | ---------------------------------------------------------------------- // var i1_s_ncf = c1.nc_s2; -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_ncf: (b: number) => number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_s2(b: number): number @@ -615,14 +615,14 @@ // | // | ---------------------------------------------------------------------- // var i1_s_ncr = c1.nc_s2(20); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_ncr: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c1.nc_s2(b: number): number @@ -630,14 +630,14 @@ // | // | ---------------------------------------------------------------------- // var i1_s_ncprop = c1.nc_s3; -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_ncprop: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_s3: number @@ -645,14 +645,14 @@ // | // | ---------------------------------------------------------------------- // c1.nc_s3 = i1_s_ncprop; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c1.nc_s3: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_s_ncprop: number @@ -660,14 +660,14 @@ // | // | ---------------------------------------------------------------------- // var i1_c = c1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var i1_c: typeof c1 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c1 @@ -694,14 +694,14 @@ // } // var cProperties_i = new cProperties(); // cProperties_i.p2 = cProperties_i.p1; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) cProperties.p2: number // | ``` // | setter only property // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) cProperties.p1: number @@ -709,14 +709,14 @@ // | getter only property // | ---------------------------------------------------------------------- // cProperties_i.nc_p2 = cProperties_i.nc_p1; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) cProperties.nc_p2: number // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) cProperties.nc_p1: number @@ -729,7 +729,7 @@ // * @param a this is first parameter a // */ // constructor(/**more info about a*/public a: number) { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithConstructorProperty(a: number): cWithConstructorProperty @@ -740,7 +740,7 @@ // | // | ---------------------------------------------------------------------- // var bbbb = 10; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var bbbb: number @@ -748,7 +748,7 @@ // | // | ---------------------------------------------------------------------- // this.a = a + 2 + bbbb; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | this @@ -769,7 +769,7 @@ // | ``` // | more info about a // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var bbbb: number @@ -793,6 +793,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c1\n```\nThis is comment for c1" + }, + "range": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 8 + } } } }, @@ -810,6 +820,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.p1: number\n```\np1 is property of c1" + }, + "range": { + "start": { + "line": 3, + "character": 11 + }, + "end": { + "line": 3, + "character": 13 + } } } }, @@ -827,6 +847,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.p2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 13 + } } } }, @@ -844,6 +874,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.p3: number\n```\ngetter property 1" + }, + "range": { + "start": { + "line": 9, + "character": 15 + }, + "end": { + "line": 9, + "character": 17 + } } } }, @@ -861,6 +901,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.p2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 10, + "character": 20 + }, + "end": { + "line": 10, + "character": 22 + } } } }, @@ -878,6 +928,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.p3: number\n```\ngetter property 1" + }, + "range": { + "start": { + "line": 13, + "character": 15 + }, + "end": { + "line": 13, + "character": 17 + } } } }, @@ -895,6 +955,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.p2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 14, + "character": 23 + }, + "end": { + "line": 14, + "character": 25 + } } } }, @@ -912,6 +982,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.pp1: number\n```\npp1 is property of c1" + }, + "range": { + "start": { + "line": 17, + "character": 12 + }, + "end": { + "line": 17, + "character": 15 + } } } }, @@ -929,6 +1009,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.pp2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 19, + "character": 12 + }, + "end": { + "line": 19, + "character": 15 + } } } }, @@ -946,6 +1036,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.pp3: number\n```\ngetter property 2" + }, + "range": { + "start": { + "line": 23, + "character": 16 + }, + "end": { + "line": 23, + "character": 19 + } } } }, @@ -963,6 +1063,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.pp2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 24, + "character": 20 + }, + "end": { + "line": 24, + "character": 23 + } } } }, @@ -980,6 +1090,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.pp3: number\n```\ngetter property 2" + }, + "range": { + "start": { + "line": 27, + "character": 16 + }, + "end": { + "line": 27, + "character": 19 + } } } }, @@ -997,6 +1117,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.pp2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 28, + "character": 24 + }, + "end": { + "line": 28, + "character": 27 + } } } }, @@ -1014,6 +1144,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c1(): c1\n```\nConstructor method" + }, + "range": { + "start": { + "line": 31, + "character": 4 + }, + "end": { + "line": 31, + "character": 15 + } } } }, @@ -1031,6 +1171,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.s1: number\n```\ns1 is static property of c1" + }, + "range": { + "start": { + "line": 34, + "character": 11 + }, + "end": { + "line": 34, + "character": 13 + } } } }, @@ -1048,6 +1198,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.s2(b: number): number\n```\nstatic sum with property" + }, + "range": { + "start": { + "line": 36, + "character": 11 + }, + "end": { + "line": 36, + "character": 13 + } } } }, @@ -1065,6 +1225,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.s3: number\n```\nstatic getter property" + }, + "range": { + "start": { + "line": 40, + "character": 15 + }, + "end": { + "line": 40, + "character": 17 + } } } }, @@ -1082,6 +1252,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.s2(b: number): number\n```\nstatic sum with property" + }, + "range": { + "start": { + "line": 41, + "character": 18 + }, + "end": { + "line": 41, + "character": 20 + } } } }, @@ -1099,6 +1279,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.s3: number\n```\nstatic getter property" + }, + "range": { + "start": { + "line": 44, + "character": 15 + }, + "end": { + "line": 44, + "character": 17 + } } } }, @@ -1116,6 +1306,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.s2(b: number): number\n```\nstatic sum with property" + }, + "range": { + "start": { + "line": 45, + "character": 19 + }, + "end": { + "line": 45, + "character": 21 + } } } }, @@ -1133,6 +1333,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.nc_p1: number\n```\n" + }, + "range": { + "start": { + "line": 47, + "character": 11 + }, + "end": { + "line": 47, + "character": 16 + } } } }, @@ -1150,6 +1360,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_p2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 48, + "character": 11 + }, + "end": { + "line": 48, + "character": 16 + } } } }, @@ -1167,6 +1387,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_p3: number\n```\n" + }, + "range": { + "start": { + "line": 51, + "character": 15 + }, + "end": { + "line": 51, + "character": 20 + } } } }, @@ -1184,6 +1414,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_p2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 52, + "character": 20 + }, + "end": { + "line": 52, + "character": 25 + } } } }, @@ -1201,6 +1441,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_p3: number\n```\n" + }, + "range": { + "start": { + "line": 54, + "character": 15 + }, + "end": { + "line": 54, + "character": 20 + } } } }, @@ -1218,6 +1468,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_p2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 55, + "character": 26 + }, + "end": { + "line": 55, + "character": 31 + } } } }, @@ -1235,6 +1495,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.nc_pp1: number\n```\n" + }, + "range": { + "start": { + "line": 57, + "character": 12 + }, + "end": { + "line": 57, + "character": 18 + } } } }, @@ -1252,6 +1522,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_pp2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 58, + "character": 12 + }, + "end": { + "line": 58, + "character": 18 + } } } }, @@ -1269,6 +1549,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_pp3: number\n```\n" + }, + "range": { + "start": { + "line": 61, + "character": 16 + }, + "end": { + "line": 61, + "character": 22 + } } } }, @@ -1286,6 +1576,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_pp2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 62, + "character": 20 + }, + "end": { + "line": 62, + "character": 26 + } } } }, @@ -1303,6 +1603,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_pp3: number\n```\n" + }, + "range": { + "start": { + "line": 64, + "character": 16 + }, + "end": { + "line": 64, + "character": 22 + } } } }, @@ -1320,6 +1630,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_pp2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 65, + "character": 27 + }, + "end": { + "line": 65, + "character": 33 + } } } }, @@ -1337,6 +1657,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.nc_s1: number\n```\n" + }, + "range": { + "start": { + "line": 67, + "character": 11 + }, + "end": { + "line": 67, + "character": 16 + } } } }, @@ -1354,6 +1684,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_s2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 68, + "character": 11 + }, + "end": { + "line": 68, + "character": 16 + } } } }, @@ -1371,6 +1711,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_s3: number\n```\n" + }, + "range": { + "start": { + "line": 71, + "character": 15 + }, + "end": { + "line": 71, + "character": 20 + } } } }, @@ -1388,6 +1738,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_s2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 72, + "character": 18 + }, + "end": { + "line": 72, + "character": 23 + } } } }, @@ -1405,6 +1765,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_s3: number\n```\n" + }, + "range": { + "start": { + "line": 74, + "character": 15 + }, + "end": { + "line": 74, + "character": 20 + } } } }, @@ -1422,6 +1792,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_s2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 75, + "character": 22 + }, + "end": { + "line": 75, + "character": 27 + } } } }, @@ -1439,6 +1819,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1: c1\n```\n" + }, + "range": { + "start": { + "line": 78, + "character": 4 + }, + "end": { + "line": 78, + "character": 6 + } } } }, @@ -1456,6 +1846,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c1(): c1\n```\nConstructor method" + }, + "range": { + "start": { + "line": 78, + "character": 13 + }, + "end": { + "line": 78, + "character": 15 + } } } }, @@ -1473,6 +1873,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_p: number\n```\n" + }, + "range": { + "start": { + "line": 79, + "character": 4 + }, + "end": { + "line": 79, + "character": 8 + } } } }, @@ -1490,6 +1900,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_f: (b: number) => number\n```\n" + }, + "range": { + "start": { + "line": 80, + "character": 4 + }, + "end": { + "line": 80, + "character": 8 + } } } }, @@ -1507,6 +1927,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.p2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 80, + "character": 14 + }, + "end": { + "line": 80, + "character": 16 + } } } }, @@ -1524,6 +1954,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_r: number\n```\n" + }, + "range": { + "start": { + "line": 81, + "character": 4 + }, + "end": { + "line": 81, + "character": 8 + } } } }, @@ -1541,6 +1981,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.p2(b: number): number\n```\nsum with property" + }, + "range": { + "start": { + "line": 81, + "character": 14 + }, + "end": { + "line": 81, + "character": 16 + } } } }, @@ -1558,6 +2008,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_prop: number\n```\n" + }, + "range": { + "start": { + "line": 82, + "character": 4 + }, + "end": { + "line": 82, + "character": 11 + } } } }, @@ -1575,6 +2035,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.p3: number\n```\ngetter property 1" + }, + "range": { + "start": { + "line": 82, + "character": 17 + }, + "end": { + "line": 82, + "character": 19 + } } } }, @@ -1592,6 +2062,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.p3: number\n```\ngetter property 1" + }, + "range": { + "start": { + "line": 83, + "character": 3 + }, + "end": { + "line": 83, + "character": 5 + } } } }, @@ -1609,6 +2089,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_prop: number\n```\n" + }, + "range": { + "start": { + "line": 83, + "character": 8 + }, + "end": { + "line": 83, + "character": 15 + } } } }, @@ -1626,6 +2116,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_nc_p: number\n```\n" + }, + "range": { + "start": { + "line": 84, + "character": 4 + }, + "end": { + "line": 84, + "character": 11 + } } } }, @@ -1643,6 +2143,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.nc_p1: number\n```\n" + }, + "range": { + "start": { + "line": 84, + "character": 17 + }, + "end": { + "line": 84, + "character": 22 + } } } }, @@ -1660,6 +2170,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_ncf: (b: number) => number\n```\n" + }, + "range": { + "start": { + "line": 85, + "character": 4 + }, + "end": { + "line": 85, + "character": 10 + } } } }, @@ -1677,6 +2197,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_p2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 85, + "character": 16 + }, + "end": { + "line": 85, + "character": 21 + } } } }, @@ -1694,6 +2224,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_ncr: number\n```\n" + }, + "range": { + "start": { + "line": 86, + "character": 4 + }, + "end": { + "line": 86, + "character": 10 + } } } }, @@ -1711,6 +2251,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_p2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 86, + "character": 16 + }, + "end": { + "line": 86, + "character": 21 + } } } }, @@ -1728,6 +2278,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_ncprop: number\n```\n" + }, + "range": { + "start": { + "line": 87, + "character": 4 + }, + "end": { + "line": 87, + "character": 13 + } } } }, @@ -1745,6 +2305,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_p3: number\n```\n" + }, + "range": { + "start": { + "line": 87, + "character": 19 + }, + "end": { + "line": 87, + "character": 24 + } } } }, @@ -1762,6 +2332,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_p3: number\n```\n" + }, + "range": { + "start": { + "line": 88, + "character": 3 + }, + "end": { + "line": 88, + "character": 8 + } } } }, @@ -1779,6 +2359,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_ncprop: number\n```\n" + }, + "range": { + "start": { + "line": 88, + "character": 11 + }, + "end": { + "line": 88, + "character": 20 + } } } }, @@ -1796,6 +2386,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_p: number\n```\n" + }, + "range": { + "start": { + "line": 89, + "character": 4 + }, + "end": { + "line": 89, + "character": 10 + } } } }, @@ -1813,6 +2413,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c1\n```\nThis is comment for c1" + }, + "range": { + "start": { + "line": 89, + "character": 13 + }, + "end": { + "line": 89, + "character": 15 + } } } }, @@ -1830,6 +2440,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.s1: number\n```\ns1 is static property of c1" + }, + "range": { + "start": { + "line": 89, + "character": 16 + }, + "end": { + "line": 89, + "character": 18 + } } } }, @@ -1847,6 +2467,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_f: (b: number) => number\n```\n" + }, + "range": { + "start": { + "line": 90, + "character": 4 + }, + "end": { + "line": 90, + "character": 10 + } } } }, @@ -1864,6 +2494,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.s2(b: number): number\n```\nstatic sum with property" + }, + "range": { + "start": { + "line": 90, + "character": 16 + }, + "end": { + "line": 90, + "character": 18 + } } } }, @@ -1881,6 +2521,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_r: number\n```\n" + }, + "range": { + "start": { + "line": 91, + "character": 4 + }, + "end": { + "line": 91, + "character": 10 + } } } }, @@ -1898,6 +2548,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.s2(b: number): number\n```\nstatic sum with property" + }, + "range": { + "start": { + "line": 91, + "character": 16 + }, + "end": { + "line": 91, + "character": 18 + } } } }, @@ -1915,6 +2575,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_prop: number\n```\n" + }, + "range": { + "start": { + "line": 92, + "character": 4 + }, + "end": { + "line": 92, + "character": 13 + } } } }, @@ -1932,6 +2602,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.s3: number\n```\nstatic getter property" + }, + "range": { + "start": { + "line": 92, + "character": 19 + }, + "end": { + "line": 92, + "character": 21 + } } } }, @@ -1949,6 +2629,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.s3: number\n```\nstatic getter property" + }, + "range": { + "start": { + "line": 93, + "character": 3 + }, + "end": { + "line": 93, + "character": 5 + } } } }, @@ -1966,6 +2656,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_prop: number\n```\n" + }, + "range": { + "start": { + "line": 93, + "character": 8 + }, + "end": { + "line": 93, + "character": 17 + } } } }, @@ -1983,6 +2683,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_nc_p: number\n```\n" + }, + "range": { + "start": { + "line": 94, + "character": 4 + }, + "end": { + "line": 94, + "character": 13 + } } } }, @@ -2000,6 +2710,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c1.nc_s1: number\n```\n" + }, + "range": { + "start": { + "line": 94, + "character": 19 + }, + "end": { + "line": 94, + "character": 24 + } } } }, @@ -2017,6 +2737,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_ncf: (b: number) => number\n```\n" + }, + "range": { + "start": { + "line": 95, + "character": 4 + }, + "end": { + "line": 95, + "character": 12 + } } } }, @@ -2034,6 +2764,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_s2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 95, + "character": 18 + }, + "end": { + "line": 95, + "character": 23 + } } } }, @@ -2051,6 +2791,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_ncr: number\n```\n" + }, + "range": { + "start": { + "line": 96, + "character": 4 + }, + "end": { + "line": 96, + "character": 12 + } } } }, @@ -2068,6 +2818,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c1.nc_s2(b: number): number\n```\n" + }, + "range": { + "start": { + "line": 96, + "character": 18 + }, + "end": { + "line": 96, + "character": 23 + } } } }, @@ -2085,6 +2845,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_ncprop: number\n```\n" + }, + "range": { + "start": { + "line": 97, + "character": 4 + }, + "end": { + "line": 97, + "character": 15 + } } } }, @@ -2102,6 +2872,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_s3: number\n```\n" + }, + "range": { + "start": { + "line": 97, + "character": 21 + }, + "end": { + "line": 97, + "character": 26 + } } } }, @@ -2119,6 +2899,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c1.nc_s3: number\n```\n" + }, + "range": { + "start": { + "line": 98, + "character": 3 + }, + "end": { + "line": 98, + "character": 8 + } } } }, @@ -2136,6 +2926,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_s_ncprop: number\n```\n" + }, + "range": { + "start": { + "line": 98, + "character": 11 + }, + "end": { + "line": 98, + "character": 22 + } } } }, @@ -2153,6 +2953,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i1_c: typeof c1\n```\n" + }, + "range": { + "start": { + "line": 99, + "character": 4 + }, + "end": { + "line": 99, + "character": 8 + } } } }, @@ -2170,6 +2980,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c1\n```\nThis is comment for c1" + }, + "range": { + "start": { + "line": 99, + "character": 11 + }, + "end": { + "line": 99, + "character": 13 + } } } }, @@ -2187,6 +3007,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) cProperties.p2: number\n```\nsetter only property" + }, + "range": { + "start": { + "line": 119, + "character": 14 + }, + "end": { + "line": 119, + "character": 16 + } } } }, @@ -2204,6 +3034,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) cProperties.p1: number\n```\ngetter only property" + }, + "range": { + "start": { + "line": 119, + "character": 33 + }, + "end": { + "line": 119, + "character": 35 + } } } }, @@ -2221,6 +3061,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) cProperties.nc_p2: number\n```\n" + }, + "range": { + "start": { + "line": 120, + "character": 14 + }, + "end": { + "line": 120, + "character": 19 + } } } }, @@ -2238,6 +3088,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) cProperties.nc_p1: number\n```\n" + }, + "range": { + "start": { + "line": 120, + "character": 36 + }, + "end": { + "line": 120, + "character": 41 + } } } }, @@ -2255,6 +3115,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor cWithConstructorProperty(a: number): cWithConstructorProperty\n```\nthis is class cWithConstructorProperty's constructor\n\n*@param* `a` — this is first parameter a\n" + }, + "range": { + "start": { + "line": 126, + "character": 4 + }, + "end": { + "line": 126, + "character": 15 + } } } }, @@ -2272,6 +3142,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar bbbb: number\n```\n" + }, + "range": { + "start": { + "line": 127, + "character": 12 + }, + "end": { + "line": 127, + "character": 16 + } } } }, @@ -2289,6 +3169,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nthis\n```\n" + }, + "range": { + "start": { + "line": 128, + "character": 8 + }, + "end": { + "line": 128, + "character": 12 + } } } }, @@ -2306,6 +3196,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) cWithConstructorProperty.a: number\n```\nmore info about a" + }, + "range": { + "start": { + "line": 128, + "character": 13 + }, + "end": { + "line": 128, + "character": 14 + } } } }, @@ -2323,6 +3223,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\nmore info about a" + }, + "range": { + "start": { + "line": 128, + "character": 17 + }, + "end": { + "line": 128, + "character": 18 + } } } }, @@ -2340,6 +3250,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar bbbb: number\n```\n" + }, + "range": { + "start": { + "line": 128, + "character": 25 + }, + "end": { + "line": 128, + "character": 29 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsCommentParsing.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsCommentParsing.baseline index 0e4164e80a..0316da028a 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsCommentParsing.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsCommentParsing.baseline @@ -5,7 +5,7 @@ // } // // simple( ); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function simple(): void @@ -19,7 +19,7 @@ // function multiLine() { // } // multiLine( ); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function multiLine(): void @@ -31,7 +31,7 @@ // function jsDocSingleLine() { // } // jsDocSingleLine(); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocSingleLine(): void @@ -46,7 +46,7 @@ // function jsDocMultiLine() { // } // jsDocMultiLine(); -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMultiLine(): void @@ -64,7 +64,7 @@ // function jsDocMultiLineMerge() { // } // jsDocMultiLineMerge(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMultiLineMerge(): void @@ -78,7 +78,7 @@ // function jsDocMixedComments1() { // } // jsDocMixedComments1(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMixedComments1(): void @@ -91,7 +91,7 @@ // function jsDocMixedComments2() { // } // jsDocMixedComments2(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMixedComments2(): void @@ -104,7 +104,7 @@ // function jsDocMixedComments3() { // } // jsDocMixedComments3(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMixedComments3(): void @@ -118,7 +118,7 @@ // function jsDocMixedComments4() { // } // jsDocMixedComments4(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMixedComments4(): void @@ -133,7 +133,7 @@ // function jsDocMixedComments5() { // } // jsDocMixedComments5(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMixedComments5(): void @@ -149,7 +149,7 @@ // function jsDocMixedComments6() { // } // jsDocMixedComments6(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocMixedComments6(): void @@ -161,7 +161,7 @@ // function noHelpComment1() { // } // noHelpComment1(); -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function noHelpComment1(): void @@ -173,7 +173,7 @@ // function noHelpComment2() { // } // noHelpComment2(); -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function noHelpComment2(): void @@ -184,7 +184,7 @@ // function noHelpComment3() { // } // noHelpComment3(); -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function noHelpComment3(): void @@ -215,7 +215,7 @@ // return a + b; // } // sum(10, 20); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function sum(a: number, b: number): number @@ -274,7 +274,7 @@ // | ---------------------------------------------------------------------- // } // multiply(10, 20, 30, 40, 50); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function multiply(a: number, b: number, c?: number, d?: any, e?: any): void @@ -322,7 +322,7 @@ // return aOrb; // } // f1(10); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function f1(a: number): any @@ -333,7 +333,7 @@ // | // | ---------------------------------------------------------------------- // f1("hello"); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function f1(b: string): any @@ -398,7 +398,7 @@ // | ---------------------------------------------------------------------- // } // subtract(10, 20, null, null, null, null); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void @@ -439,7 +439,7 @@ // return a * a; // } // square(10); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function square(a: number): number @@ -479,7 +479,7 @@ // | ---------------------------------------------------------------------- // } // divide(10, 20); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function divide(a: number, b: number): void @@ -501,7 +501,7 @@ // @param {string} bar is second string // */ // function fooBar(foo: string, bar: string) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) foo: string @@ -509,7 +509,7 @@ // | is string // | // | ---------------------------------------------------------------------- -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) bar: string @@ -520,7 +520,7 @@ // return foo + bar; // } // fooBar("foo","bar"); -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function fooBar(foo: string, bar: string): string @@ -576,7 +576,7 @@ // return a + b + c + d; // } // jsDocParamTest(30, 40, 50, 60); -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocParamTest(a: number, b: number, c: number, d: number): number @@ -595,7 +595,7 @@ // function jsDocCommentAlignmentTest1() { // } // jsDocCommentAlignmentTest1(); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocCommentAlignmentTest1(): void @@ -609,7 +609,7 @@ // function jsDocCommentAlignmentTest2() { // } // jsDocCommentAlignmentTest2(); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocCommentAlignmentTest2(): void @@ -660,7 +660,7 @@ // | ---------------------------------------------------------------------- // } // jsDocCommentAlignmentTest3("hello",1, 2); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function jsDocCommentAlignmentTest3(a: string, b: any, c: any): void @@ -688,7 +688,7 @@ // | No quickinfo at /**/. // | ---------------------------------------------------------------------- // class NoQuickInfoClass { -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | class NoQuickInfoClass @@ -711,6 +711,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction simple(): void\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 0 + }, + "end": { + "line": 4, + "character": 6 + } } } }, @@ -728,6 +738,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction multiLine(): void\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 0 + }, + "end": { + "line": 11, + "character": 9 + } } } }, @@ -745,6 +765,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocSingleLine(): void\n```\nthis is eg of single line jsdoc style comment" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 15 + } } } }, @@ -762,6 +792,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMultiLine(): void\n```\nthis is multiple line jsdoc stule comment\nNew line1\nNew Line2" + }, + "range": { + "start": { + "line": 24, + "character": 0 + }, + "end": { + "line": 24, + "character": 14 + } } } }, @@ -779,6 +819,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMultiLineMerge(): void\n```\nAnother this one too" + }, + "range": { + "start": { + "line": 33, + "character": 0 + }, + "end": { + "line": 33, + "character": 19 + } } } }, @@ -796,6 +846,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMixedComments1(): void\n```\njsdoc comment" + }, + "range": { + "start": { + "line": 40, + "character": 0 + }, + "end": { + "line": 40, + "character": 19 + } } } }, @@ -813,6 +873,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMixedComments2(): void\n```\nanother jsDocComment" + }, + "range": { + "start": { + "line": 46, + "character": 0 + }, + "end": { + "line": 46, + "character": 19 + } } } }, @@ -830,6 +900,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMixedComments3(): void\n```\n* triplestar jsDocComment" + }, + "range": { + "start": { + "line": 52, + "character": 0 + }, + "end": { + "line": 52, + "character": 19 + } } } }, @@ -847,6 +927,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMixedComments4(): void\n```\nanother jsDocComment" + }, + "range": { + "start": { + "line": 59, + "character": 0 + }, + "end": { + "line": 59, + "character": 19 + } } } }, @@ -864,6 +954,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMixedComments5(): void\n```\nanother jsDocComment" + }, + "range": { + "start": { + "line": 67, + "character": 0 + }, + "end": { + "line": 67, + "character": 19 + } } } }, @@ -881,6 +981,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocMixedComments6(): void\n```\njsdoc comment" + }, + "range": { + "start": { + "line": 76, + "character": 0 + }, + "end": { + "line": 76, + "character": 19 + } } } }, @@ -898,6 +1008,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction noHelpComment1(): void\n```\n" + }, + "range": { + "start": { + "line": 81, + "character": 0 + }, + "end": { + "line": 81, + "character": 14 + } } } }, @@ -915,6 +1035,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction noHelpComment2(): void\n```\n" + }, + "range": { + "start": { + "line": 86, + "character": 0 + }, + "end": { + "line": 86, + "character": 14 + } } } }, @@ -932,6 +1062,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction noHelpComment3(): void\n```\n" + }, + "range": { + "start": { + "line": 90, + "character": 0 + }, + "end": { + "line": 90, + "character": 14 + } } } }, @@ -949,6 +1089,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\nfirst number\n" + }, + "range": { + "start": { + "line": 95, + "character": 13 + }, + "end": { + "line": 95, + "character": 14 + } } } }, @@ -966,6 +1116,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: number\n```\nsecond number\n" + }, + "range": { + "start": { + "line": 95, + "character": 24 + }, + "end": { + "line": 95, + "character": 25 + } } } }, @@ -983,6 +1143,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction sum(a: number, b: number): number\n```\nAdds two integers and returns the result\n\n*@param* `a` — first number\n\n\n*@param* `b` — second number\n" + }, + "range": { + "start": { + "line": 98, + "character": 0 + }, + "end": { + "line": 98, + "character": 3 + } } } }, @@ -1000,6 +1170,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\nfirst number\n" + }, + "range": { + "start": { + "line": 106, + "character": 18 + }, + "end": { + "line": 106, + "character": 19 + } } } }, @@ -1017,6 +1197,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: number\n```\n" + }, + "range": { + "start": { + "line": 106, + "character": 29 + }, + "end": { + "line": 106, + "character": 30 + } } } }, @@ -1034,6 +1224,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) c: number\n```\n" + }, + "range": { + "start": { + "line": 106, + "character": 40 + }, + "end": { + "line": 106, + "character": 41 + } } } }, @@ -1051,6 +1251,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) d: any\n```\n" + }, + "range": { + "start": { + "line": 106, + "character": 52 + }, + "end": { + "line": 106, + "character": 53 + } } } }, @@ -1068,6 +1278,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) e: any\n```\nLastParam " + }, + "range": { + "start": { + "line": 106, + "character": 56 + }, + "end": { + "line": 106, + "character": 57 + } } } }, @@ -1085,6 +1305,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction multiply(a: number, b: number, c?: number, d?: any, e?: any): void\n```\nThis is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + }, + "range": { + "start": { + "line": 108, + "character": 0 + }, + "end": { + "line": 108, + "character": 8 + } } } }, @@ -1102,6 +1332,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\n" + }, + "range": { + "start": { + "line": 112, + "character": 12 + }, + "end": { + "line": 112, + "character": 13 + } } } }, @@ -1119,6 +1359,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: string\n```\n" + }, + "range": { + "start": { + "line": 113, + "character": 12 + }, + "end": { + "line": 113, + "character": 13 + } } } }, @@ -1136,6 +1386,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f1(a: number): any\n```\nfn f1 with number\n\n*@param* `b` — about b\n" + }, + "range": { + "start": { + "line": 118, + "character": 0 + }, + "end": { + "line": 118, + "character": 2 + } } } }, @@ -1153,6 +1413,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f1(b: string): any\n```\n" + }, + "range": { + "start": { + "line": 119, + "character": 0 + }, + "end": { + "line": 119, + "character": 2 + } } } }, @@ -1170,6 +1440,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\n" + }, + "range": { + "start": { + "line": 129, + "character": 18 + }, + "end": { + "line": 129, + "character": 19 + } } } }, @@ -1187,6 +1467,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: number\n```\nthis is about b\n" + }, + "range": { + "start": { + "line": 129, + "character": 29 + }, + "end": { + "line": 129, + "character": 30 + } } } }, @@ -1204,6 +1494,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) c: () => string\n```\nthis is optional param c\n" + }, + "range": { + "start": { + "line": 129, + "character": 40 + }, + "end": { + "line": 129, + "character": 41 + } } } }, @@ -1221,6 +1521,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) d: () => string\n```\nthis is optional param d\n" + }, + "range": { + "start": { + "line": 129, + "character": 58 + }, + "end": { + "line": 129, + "character": 59 + } } } }, @@ -1238,6 +1548,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) e: () => string\n```\nthis is optional param e\n" + }, + "range": { + "start": { + "line": 129, + "character": 76 + }, + "end": { + "line": 129, + "character": 77 + } } } }, @@ -1255,6 +1575,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) f: () => string\n```\n" + }, + "range": { + "start": { + "line": 129, + "character": 94 + }, + "end": { + "line": 129, + "character": 95 + } } } }, @@ -1272,6 +1602,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void\n```\nThis is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, + "range": { + "start": { + "line": 131, + "character": 0 + }, + "end": { + "line": 131, + "character": 8 + } } } }, @@ -1289,6 +1629,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\nthis is input number\n" + }, + "range": { + "start": { + "line": 137, + "character": 16 + }, + "end": { + "line": 137, + "character": 17 + } } } }, @@ -1306,6 +1656,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction square(a: number): number\n```\nthis is square function\n\n*@paramTag* — { number } a this is input number of paramTag\n\n\n*@param* `a` — this is input number\n\n\n*@returnType* — { number } it is return type\n" + }, + "range": { + "start": { + "line": 140, + "character": 0 + }, + "end": { + "line": 140, + "character": 6 + } } } }, @@ -1323,6 +1683,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\nthis is a\n" + }, + "range": { + "start": { + "line": 146, + "character": 16 + }, + "end": { + "line": 146, + "character": 17 + } } } }, @@ -1340,6 +1710,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: number\n```\nthis is b\n" + }, + "range": { + "start": { + "line": 146, + "character": 27 + }, + "end": { + "line": 146, + "character": 28 + } } } }, @@ -1357,6 +1737,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction divide(a: number, b: number): void\n```\nthis is divide function\n\n*@param* `a` — this is a\n\n\n*@paramTag* — { number } g this is optional param g\n\n\n*@param* `b` — this is b\n" + }, + "range": { + "start": { + "line": 148, + "character": 0 + }, + "end": { + "line": 148, + "character": 6 + } } } }, @@ -1374,6 +1764,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) foo: string\n```\nis string\n" + }, + "range": { + "start": { + "line": 154, + "character": 16 + }, + "end": { + "line": 154, + "character": 19 + } } } }, @@ -1391,6 +1791,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) bar: string\n```\nis second string\n" + }, + "range": { + "start": { + "line": 154, + "character": 29 + }, + "end": { + "line": 154, + "character": 32 + } } } }, @@ -1408,6 +1818,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction fooBar(foo: string, bar: string): string\n```\nFunction returns string concat of foo and bar\n\n*@param* `foo` — is string\n\n\n*@param* `bar` — is second string\n" + }, + "range": { + "start": { + "line": 157, + "character": 0 + }, + "end": { + "line": 157, + "character": 6 + } } } }, @@ -1425,6 +1845,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\nthis is inline comment for a" + }, + "range": { + "start": { + "line": 168, + "character": 59 + }, + "end": { + "line": 168, + "character": 60 + } } } }, @@ -1442,6 +1872,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: number\n```\nthis is inline comment for b" + }, + "range": { + "start": { + "line": 168, + "character": 105 + }, + "end": { + "line": 168, + "character": 106 + } } } }, @@ -1459,6 +1899,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) c: number\n```\nit is third parameter\n" + }, + "range": { + "start": { + "line": 168, + "character": 116 + }, + "end": { + "line": 168, + "character": 117 + } } } }, @@ -1476,6 +1926,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) d: number\n```\n" + }, + "range": { + "start": { + "line": 168, + "character": 127 + }, + "end": { + "line": 168, + "character": 128 + } } } }, @@ -1493,6 +1953,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocParamTest(a: number, b: number, c: number, d: number): number\n```\nthis is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + }, + "range": { + "start": { + "line": 171, + "character": 0 + }, + "end": { + "line": 171, + "character": 14 + } } } }, @@ -1510,6 +1980,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocCommentAlignmentTest1(): void\n```\nThis is function comment\nAnd properly aligned comment" + }, + "range": { + "start": { + "line": 177, + "character": 0 + }, + "end": { + "line": 177, + "character": 26 + } } } }, @@ -1527,6 +2007,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocCommentAlignmentTest2(): void\n```\nThis is function comment\n And aligned with 4 space char margin" + }, + "range": { + "start": { + "line": 183, + "character": 0 + }, + "end": { + "line": 183, + "character": 26 + } } } }, @@ -1544,6 +2034,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: string\n```\nthis is info about a\nspanning on two lines and aligned perfectly\n" + }, + "range": { + "start": { + "line": 195, + "character": 36 + }, + "end": { + "line": 195, + "character": 37 + } } } }, @@ -1561,6 +2061,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: any\n```\nthis is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n" + }, + "range": { + "start": { + "line": 195, + "character": 47 + }, + "end": { + "line": 195, + "character": 48 + } } } }, @@ -1578,6 +2088,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) c: any\n```\nthis is info about b\nnot aligned text about parameter will eat only one space\n" + }, + "range": { + "start": { + "line": 195, + "character": 50 + }, + "end": { + "line": 195, + "character": 51 + } } } }, @@ -1595,6 +2115,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction jsDocCommentAlignmentTest3(a: string, b: any, c: any): void\n```\nThis is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + }, + "range": { + "start": { + "line": 197, + "character": 0 + }, + "end": { + "line": 197, + "character": 26 + } } } }, @@ -1624,6 +2154,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass NoQuickInfoClass\n```\n" + }, + "range": { + "start": { + "line": 199, + "character": 6 + }, + "end": { + "line": 199, + "character": 22 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionDeclaration.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionDeclaration.baseline index 73699ec88c..6c49c0e6af 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionDeclaration.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionDeclaration.baseline @@ -2,7 +2,7 @@ === /quickInfoCommentsFunctionDeclaration.ts === // /** This comment should appear for foo*/ // function foo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void @@ -11,7 +11,7 @@ // | ---------------------------------------------------------------------- // } // foo(); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void @@ -20,7 +20,7 @@ // | ---------------------------------------------------------------------- // /** This is comment for function signature*/ // function fooWithParameters(/** this is comment about a*/a: string, -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function fooWithParameters(a: string, b: number): void @@ -39,7 +39,7 @@ // | ---------------------------------------------------------------------- // } // fooWithParameters("a",10); -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function fooWithParameters(a: string, b: number): void @@ -67,6 +67,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(): void\n```\nThis comment should appear for foo" + }, + "range": { + "start": { + "line": 1, + "character": 9 + }, + "end": { + "line": 1, + "character": 12 + } } } }, @@ -84,6 +94,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(): void\n```\nThis comment should appear for foo" + }, + "range": { + "start": { + "line": 3, + "character": 0 + }, + "end": { + "line": 3, + "character": 3 + } } } }, @@ -101,6 +121,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction fooWithParameters(a: string, b: number): void\n```\nThis is comment for function signature" + }, + "range": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 26 + } } } }, @@ -118,6 +148,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar d: string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 8 + }, + "end": { + "line": 8, + "character": 9 + } } } }, @@ -135,6 +175,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction fooWithParameters(a: string, b: number): void\n```\nThis is comment for function signature" + }, + "range": { + "start": { + "line": 10, + "character": 0 + }, + "end": { + "line": 10, + "character": 17 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionExpression.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionExpression.baseline index 5416640acb..1685d5e7a4 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionExpression.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoCommentsFunctionExpression.baseline @@ -2,7 +2,7 @@ === /quickInfoCommentsFunctionExpression.ts === // /** lambdaFoo var comment*/ // var lambdaFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => a + b; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var lambdaFoo: (a: number, b: number) => number @@ -10,7 +10,7 @@ // | lambdaFoo var comment // | ---------------------------------------------------------------------- // var lambddaNoVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b; -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var lambddaNoVarComment: (a: number, b: number) => number @@ -19,7 +19,7 @@ // | ---------------------------------------------------------------------- // lambdaFoo(10, 20); // function anotherFunc(a: number) { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function anotherFunc(a: number): string @@ -29,7 +29,7 @@ // /** documentation // @param b {string} inner parameter */ // var lambdaVar = /** inner docs */(b: string) => { -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var lambdaVar: (b: string) => string @@ -46,7 +46,7 @@ // | // | ---------------------------------------------------------------------- // var localVar = "Hello "; -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var localVar: string @@ -54,7 +54,7 @@ // | // | ---------------------------------------------------------------------- // return localVar + b; -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var localVar: string @@ -70,7 +70,7 @@ // | ---------------------------------------------------------------------- // } // return lambdaVar("World") + a; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var lambdaVar: (b: string) => string @@ -86,7 +86,7 @@ // * @returns the parameter's length // */ // var assigned = /** -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var assigned: (s: string) => number @@ -106,7 +106,7 @@ // return s.length; // } // assigned("hey"); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var assigned: (s: string) => number @@ -134,6 +134,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar lambdaFoo: (a: number, b: number) => number\n```\nlambdaFoo var comment" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 13 + } } } }, @@ -151,6 +161,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar lambddaNoVarComment: (a: number, b: number) => number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 23 + } } } }, @@ -168,6 +188,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction anotherFunc(a: number): string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 9 + }, + "end": { + "line": 4, + "character": 20 + } } } }, @@ -185,6 +215,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar lambdaVar: (b: string) => string\n```\ndocumentation\n\n*@param* `b` — inner parameter " + }, + "range": { + "start": { + "line": 7, + "character": 8 + }, + "end": { + "line": 7, + "character": 17 + } } } }, @@ -202,6 +242,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: string\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 38 + }, + "end": { + "line": 7, + "character": 39 + } } } }, @@ -219,6 +269,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar localVar: string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 12 + }, + "end": { + "line": 8, + "character": 20 + } } } }, @@ -236,6 +296,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar localVar: string\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 15 + }, + "end": { + "line": 9, + "character": 23 + } } } }, @@ -253,6 +323,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: string\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 26 + }, + "end": { + "line": 9, + "character": 27 + } } } }, @@ -270,6 +350,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar lambdaVar: (b: string) => string\n```\ndocumentation\n\n*@param* `b` — inner parameter " + }, + "range": { + "start": { + "line": 11, + "character": 11 + }, + "end": { + "line": 11, + "character": 20 + } } } }, @@ -287,6 +377,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar assigned: (s: string) => number\n```\nOn variable\n\n*@param* `s` — the first parameter!\n\n\n*@returns* — the parameter's length\n" + }, + "range": { + "start": { + "line": 18, + "character": 4 + }, + "end": { + "line": 18, + "character": 12 + } } } }, @@ -304,6 +404,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar assigned: (s: string) => number\n```\nOn variable\n\n*@param* `s` — the first parameter!\n\n\n*@returns* — the parameter's length\n" + }, + "range": { + "start": { + "line": 25, + "character": 0 + }, + "end": { + "line": 25, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsArrowFunctionExpression.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsArrowFunctionExpression.baseline index fddab30122..7079622c02 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsArrowFunctionExpression.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsArrowFunctionExpression.baseline @@ -53,7 +53,7 @@ // | // | ---------------------------------------------------------------------- // var z2 = () => 10; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | var z2: () => number @@ -75,6 +75,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar x: (a: any) => number\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 5 + } } } }, @@ -92,6 +102,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: any\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 9 + } } } }, @@ -109,6 +129,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar y: (a: any, b: any) => number\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 5 + } } } }, @@ -126,6 +156,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: any\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 9 + }, + "end": { + "line": 1, + "character": 10 + } } } }, @@ -143,6 +183,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: any\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 12 + }, + "end": { + "line": 1, + "character": 13 + } } } }, @@ -160,6 +210,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar z: (a: number) => number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 5 + } } } }, @@ -177,6 +237,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 9 + }, + "end": { + "line": 2, + "character": 10 + } } } }, @@ -194,6 +264,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar z2: () => number\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 6 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClass.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClass.baseline index 6483631b59..13b5962138 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClass.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClass.baseline @@ -10,7 +10,7 @@ // | ---------------------------------------------------------------------- // } // var cInstance = new c(); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c @@ -20,12 +20,12 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | class c +// | constructor c(): c // | ``` // | // | ---------------------------------------------------------------------- // var cVal = c; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cVal: typeof c @@ -54,6 +54,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 7 + } } } }, @@ -71,6 +81,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 13 + } } } }, @@ -87,7 +107,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nclass c\n```\n" + "value": "```tsx\nconstructor c(): c\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 20 + }, + "end": { + "line": 2, + "character": 21 + } } } }, @@ -105,6 +135,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cVal: typeof c\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 8 + } } } }, @@ -122,6 +162,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 11 + }, + "end": { + "line": 3, + "character": 12 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAccessors.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAccessors.baseline index 92dc276ff5..82b98d17a5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAccessors.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAccessors.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsClassAccessors.ts === // class c { // public get publicProperty() { return ""; } -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -10,7 +10,7 @@ // | // | ---------------------------------------------------------------------- // public set publicProperty(x: string) { } -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -18,7 +18,7 @@ // | // | ---------------------------------------------------------------------- // private get privateProperty() { return ""; } -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -26,7 +26,7 @@ // | // | ---------------------------------------------------------------------- // private set privateProperty(x: string) { } -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -34,7 +34,7 @@ // | // | ---------------------------------------------------------------------- // protected get protectedProperty() { return ""; } -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -42,7 +42,7 @@ // | // | ---------------------------------------------------------------------- // protected set protectedProperty(x: string) { } -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -50,7 +50,7 @@ // | // | ---------------------------------------------------------------------- // static get staticProperty() { return ""; } -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -58,7 +58,7 @@ // | // | ---------------------------------------------------------------------- // static set staticProperty(x: string) { } -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -66,7 +66,7 @@ // | // | ---------------------------------------------------------------------- // private static get privateStaticProperty() { return ""; } -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -74,7 +74,7 @@ // | // | ---------------------------------------------------------------------- // private static set privateStaticProperty(x: string) { } -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -82,7 +82,7 @@ // | // | ---------------------------------------------------------------------- // protected static get protectedStaticProperty() { return ""; } -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -90,7 +90,7 @@ // | // | ---------------------------------------------------------------------- // protected static set protectedStaticProperty(x: string) { } -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -100,7 +100,7 @@ // method() { // var x : string; // x = this.publicProperty; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -108,7 +108,7 @@ // | // | ---------------------------------------------------------------------- // x = this.privateProperty; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -116,7 +116,7 @@ // | // | ---------------------------------------------------------------------- // x = this.protectedProperty; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -124,7 +124,7 @@ // | // | ---------------------------------------------------------------------- // x = c.staticProperty; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -132,7 +132,7 @@ // | // | ---------------------------------------------------------------------- // x = c.privateStaticProperty; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -140,7 +140,7 @@ // | // | ---------------------------------------------------------------------- // x = c.protectedStaticProperty; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -148,7 +148,7 @@ // | // | ---------------------------------------------------------------------- // this.publicProperty = ""; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -156,7 +156,7 @@ // | // | ---------------------------------------------------------------------- // this.privateProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -164,7 +164,7 @@ // | // | ---------------------------------------------------------------------- // this.protectedProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -172,7 +172,7 @@ // | // | ---------------------------------------------------------------------- // c.staticProperty = ""; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -180,7 +180,7 @@ // | // | ---------------------------------------------------------------------- // c.privateStaticProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -188,7 +188,7 @@ // | // | ---------------------------------------------------------------------- // c.protectedStaticProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -200,14 +200,14 @@ // var cInstance = new c(); // var y: string; // y = cInstance.publicProperty; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -222,7 +222,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -230,14 +230,14 @@ // | // | ---------------------------------------------------------------------- // cInstance.publicProperty = y; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -252,7 +252,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -274,6 +274,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 15 + }, + "end": { + "line": 1, + "character": 29 + } } } }, @@ -291,6 +301,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 15 + }, + "end": { + "line": 2, + "character": 29 + } } } }, @@ -308,6 +328,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 31 + } } } }, @@ -325,6 +355,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 16 + }, + "end": { + "line": 4, + "character": 31 + } } } }, @@ -342,6 +382,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 18 + }, + "end": { + "line": 5, + "character": 35 + } } } }, @@ -359,6 +409,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 18 + }, + "end": { + "line": 6, + "character": 35 + } } } }, @@ -376,6 +436,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 15 + }, + "end": { + "line": 7, + "character": 29 + } } } }, @@ -393,6 +463,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 15 + }, + "end": { + "line": 8, + "character": 29 + } } } }, @@ -410,6 +490,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 24 + }, + "end": { + "line": 9, + "character": 45 + } } } }, @@ -427,6 +517,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 23 + }, + "end": { + "line": 10, + "character": 44 + } } } }, @@ -444,6 +544,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 25 + }, + "end": { + "line": 11, + "character": 48 + } } } }, @@ -461,6 +571,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 25 + }, + "end": { + "line": 12, + "character": 48 + } } } }, @@ -478,6 +598,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 17 + }, + "end": { + "line": 15, + "character": 31 + } } } }, @@ -495,6 +625,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 17 + }, + "end": { + "line": 16, + "character": 32 + } } } }, @@ -512,6 +652,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 17 + }, + "end": { + "line": 17, + "character": 34 + } } } }, @@ -529,6 +679,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 14 + }, + "end": { + "line": 18, + "character": 28 + } } } }, @@ -546,6 +706,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 14 + }, + "end": { + "line": 19, + "character": 35 + } } } }, @@ -563,6 +733,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 20, + "character": 14 + }, + "end": { + "line": 20, + "character": 37 + } } } }, @@ -580,6 +760,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 21, + "character": 13 + }, + "end": { + "line": 21, + "character": 27 + } } } }, @@ -597,6 +787,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 22, + "character": 13 + }, + "end": { + "line": 22, + "character": 28 + } } } }, @@ -614,6 +814,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 23, + "character": 13 + }, + "end": { + "line": 23, + "character": 30 + } } } }, @@ -631,6 +841,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 24, + "character": 10 + }, + "end": { + "line": 24, + "character": 24 + } } } }, @@ -648,6 +868,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 10 + }, + "end": { + "line": 25, + "character": 31 + } } } }, @@ -665,6 +895,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 26, + "character": 10 + }, + "end": { + "line": 26, + "character": 33 + } } } }, @@ -682,6 +922,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 31, + "character": 4 + }, + "end": { + "line": 31, + "character": 13 + } } } }, @@ -699,6 +949,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 31, + "character": 14 + }, + "end": { + "line": 31, + "character": 28 + } } } }, @@ -716,6 +976,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 32, + "character": 4 + }, + "end": { + "line": 32, + "character": 5 + } } } }, @@ -733,6 +1003,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 32, + "character": 6 + }, + "end": { + "line": 32, + "character": 20 + } } } }, @@ -750,6 +1030,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 33, + "character": 0 + }, + "end": { + "line": 33, + "character": 9 + } } } }, @@ -767,6 +1057,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 33, + "character": 10 + }, + "end": { + "line": 33, + "character": 24 + } } } }, @@ -784,6 +1084,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 34, + "character": 0 + }, + "end": { + "line": 34, + "character": 1 + } } } }, @@ -801,6 +1111,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 34, + "character": 2 + }, + "end": { + "line": 34, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAutoAccessors.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAutoAccessors.baseline index f1e059e258..990edf1fae 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAutoAccessors.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassAutoAccessors.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsClassAutoAccessors.ts === // class c { // public accessor publicProperty: string; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -10,7 +10,7 @@ // | // | ---------------------------------------------------------------------- // private accessor privateProperty: string; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -18,7 +18,7 @@ // | // | ---------------------------------------------------------------------- // protected accessor protectedProperty: string; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -26,7 +26,7 @@ // | // | ---------------------------------------------------------------------- // static accessor staticProperty: string; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -34,7 +34,7 @@ // | // | ---------------------------------------------------------------------- // private static accessor privateStaticProperty: string; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -42,7 +42,7 @@ // | // | ---------------------------------------------------------------------- // protected static accessor protectedStaticProperty: string; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -52,7 +52,7 @@ // method() { // var x: string; // x = this.publicProperty; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -60,7 +60,7 @@ // | // | ---------------------------------------------------------------------- // x = this.privateProperty; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -68,7 +68,7 @@ // | // | ---------------------------------------------------------------------- // x = this.protectedProperty; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -76,7 +76,7 @@ // | // | ---------------------------------------------------------------------- // x = c.staticProperty; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -84,7 +84,7 @@ // | // | ---------------------------------------------------------------------- // x = c.privateStaticProperty; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -92,7 +92,7 @@ // | // | ---------------------------------------------------------------------- // x = c.protectedStaticProperty; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -100,7 +100,7 @@ // | // | ---------------------------------------------------------------------- // this.publicProperty = ""; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -108,7 +108,7 @@ // | // | ---------------------------------------------------------------------- // this.privateProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateProperty: string @@ -116,7 +116,7 @@ // | // | ---------------------------------------------------------------------- // this.protectedProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedProperty: string @@ -124,7 +124,7 @@ // | // | ---------------------------------------------------------------------- // c.staticProperty = ""; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -132,7 +132,7 @@ // | // | ---------------------------------------------------------------------- // c.privateStaticProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.privateStaticProperty: string @@ -140,7 +140,7 @@ // | // | ---------------------------------------------------------------------- // c.protectedStaticProperty = ""; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.protectedStaticProperty: string @@ -152,14 +152,14 @@ // var cInstance = new c(); // var y: string; // y = cInstance.publicProperty; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -174,7 +174,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -182,14 +182,14 @@ // | // | ---------------------------------------------------------------------- // cInstance.publicProperty = y; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.publicProperty: string @@ -204,7 +204,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) c.staticProperty: string @@ -226,6 +226,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 20 + }, + "end": { + "line": 1, + "character": 34 + } } } }, @@ -243,6 +253,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 21 + }, + "end": { + "line": 2, + "character": 36 + } } } }, @@ -260,6 +280,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 23 + }, + "end": { + "line": 3, + "character": 40 + } } } }, @@ -277,6 +307,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 20 + }, + "end": { + "line": 4, + "character": 34 + } } } }, @@ -294,6 +334,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 28 + }, + "end": { + "line": 5, + "character": 49 + } } } }, @@ -311,6 +361,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 30 + }, + "end": { + "line": 6, + "character": 53 + } } } }, @@ -328,6 +388,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 17 + }, + "end": { + "line": 9, + "character": 31 + } } } }, @@ -345,6 +415,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 17 + }, + "end": { + "line": 10, + "character": 32 + } } } }, @@ -362,6 +442,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 17 + }, + "end": { + "line": 11, + "character": 34 + } } } }, @@ -379,6 +469,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 14 + }, + "end": { + "line": 12, + "character": 28 + } } } }, @@ -396,6 +496,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 14 + }, + "end": { + "line": 13, + "character": 35 + } } } }, @@ -413,6 +523,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 14 + }, + "end": { + "line": 14, + "character": 37 + } } } }, @@ -430,6 +550,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 13 + }, + "end": { + "line": 15, + "character": 27 + } } } }, @@ -447,6 +577,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 13 + }, + "end": { + "line": 16, + "character": 28 + } } } }, @@ -464,6 +604,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 13 + }, + "end": { + "line": 17, + "character": 30 + } } } }, @@ -481,6 +631,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 10 + }, + "end": { + "line": 18, + "character": 24 + } } } }, @@ -498,6 +658,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 10 + }, + "end": { + "line": 19, + "character": 31 + } } } }, @@ -515,6 +685,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 20, + "character": 10 + }, + "end": { + "line": 20, + "character": 33 + } } } }, @@ -532,6 +712,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 4 + }, + "end": { + "line": 25, + "character": 13 + } } } }, @@ -549,6 +739,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 14 + }, + "end": { + "line": 25, + "character": 28 + } } } }, @@ -566,6 +766,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 26, + "character": 4 + }, + "end": { + "line": 26, + "character": 5 + } } } }, @@ -583,6 +793,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 26, + "character": 6 + }, + "end": { + "line": 26, + "character": 20 + } } } }, @@ -600,6 +820,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 27, + "character": 0 + }, + "end": { + "line": 27, + "character": 9 + } } } }, @@ -617,6 +847,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 27, + "character": 10 + }, + "end": { + "line": 27, + "character": 24 + } } } }, @@ -634,6 +874,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 28, + "character": 0 + }, + "end": { + "line": 28, + "character": 1 + } } } }, @@ -651,6 +901,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 28, + "character": 2 + }, + "end": { + "line": 28, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassConstructor.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassConstructor.baseline index f14d749f68..c863ea2792 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassConstructor.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassConstructor.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsClassConstructor.ts === // class c { // constructor() { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c(): c @@ -12,7 +12,7 @@ // } // } // var cInstance = new c(); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c @@ -27,7 +27,7 @@ // | // | ---------------------------------------------------------------------- // var cVal = c; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cVal: typeof c @@ -43,43 +43,40 @@ // | ---------------------------------------------------------------------- // class cWithOverloads { // constructor(x: string); -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithOverloads(x: string): cWithOverloads -// | constructor cWithOverloads(x: number): cWithOverloads // | ``` // | // | ---------------------------------------------------------------------- // constructor(x: number); -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | constructor cWithOverloads(x: string): cWithOverloads // | constructor cWithOverloads(x: number): cWithOverloads // | ``` // | // | ---------------------------------------------------------------------- // constructor(x: any) { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | constructor cWithOverloads(x: string): cWithOverloads -// | constructor cWithOverloads(x: number): cWithOverloads +// | constructor cWithOverloads(x: any): cWithOverloads // | ``` // | // | ---------------------------------------------------------------------- // } // } // var cWithOverloadsInstance = new cWithOverloads("hello"); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithOverloadsInstance: cWithOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithOverloads(x: string): cWithOverloads @@ -87,14 +84,14 @@ // | // | ---------------------------------------------------------------------- // var cWithOverloadsInstance2 = new cWithOverloads(10); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithOverloadsInstance2: cWithOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithOverloads(x: number): cWithOverloads @@ -102,14 +99,14 @@ // | // | ---------------------------------------------------------------------- // var cWithOverloadsVal = cWithOverloads; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithOverloadsVal: typeof cWithOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | class cWithOverloads @@ -118,56 +115,48 @@ // | ---------------------------------------------------------------------- // class cWithMultipleOverloads { // constructor(x: string); -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithMultipleOverloads(x: string): cWithMultipleOverloads -// | constructor cWithMultipleOverloads(x: number): cWithMultipleOverloads -// | constructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- // constructor(x: number); -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | constructor cWithMultipleOverloads(x: string): cWithMultipleOverloads // | constructor cWithMultipleOverloads(x: number): cWithMultipleOverloads -// | constructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- // constructor(x: boolean); -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | constructor cWithMultipleOverloads(x: string): cWithMultipleOverloads -// | constructor cWithMultipleOverloads(x: number): cWithMultipleOverloads // | constructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- // constructor(x: any) { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | constructor cWithMultipleOverloads(x: string): cWithMultipleOverloads -// | constructor cWithMultipleOverloads(x: number): cWithMultipleOverloads -// | constructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads +// | constructor cWithMultipleOverloads(x: any): cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- // } // } // var cWithMultipleOverloadsInstance = new cWithMultipleOverloads("hello"); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithMultipleOverloadsInstance: cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithMultipleOverloads(x: string): cWithMultipleOverloads @@ -175,14 +164,14 @@ // | // | ---------------------------------------------------------------------- // var cWithMultipleOverloadsInstance2 = new cWithMultipleOverloads(10); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithMultipleOverloadsInstance2: cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithMultipleOverloads(x: number): cWithMultipleOverloads @@ -190,14 +179,14 @@ // | // | ---------------------------------------------------------------------- // var cWithMultipleOverloadsInstance3 = new cWithMultipleOverloads(true); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithMultipleOverloadsInstance3: cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads @@ -205,14 +194,14 @@ // | // | ---------------------------------------------------------------------- // var cWithMultipleOverloadsVal = cWithMultipleOverloads; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cWithMultipleOverloadsVal: typeof cWithMultipleOverloads // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | class cWithMultipleOverloads @@ -234,6 +223,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c(): c\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 15 + } } } }, @@ -251,6 +250,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 13 + } } } }, @@ -268,6 +277,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c(): c\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 20 + }, + "end": { + "line": 4, + "character": 21 + } } } }, @@ -285,6 +304,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cVal: typeof c\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 8 + } } } }, @@ -302,6 +331,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 12 + } } } }, @@ -318,7 +357,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithOverloads(x: string): cWithOverloads\nconstructor cWithOverloads(x: number): cWithOverloads\n```\n" + "value": "```tsx\nconstructor cWithOverloads(x: string): cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 4 + }, + "end": { + "line": 7, + "character": 15 + } } } }, @@ -335,7 +384,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithOverloads(x: string): cWithOverloads\nconstructor cWithOverloads(x: number): cWithOverloads\n```\n" + "value": "```tsx\nconstructor cWithOverloads(x: number): cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 4 + }, + "end": { + "line": 8, + "character": 15 + } } } }, @@ -352,7 +411,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithOverloads(x: string): cWithOverloads\nconstructor cWithOverloads(x: number): cWithOverloads\n```\n" + "value": "```tsx\nconstructor cWithOverloads(x: any): cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 4 + }, + "end": { + "line": 9, + "character": 15 + } } } }, @@ -370,6 +439,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithOverloadsInstance: cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 4 + }, + "end": { + "line": 12, + "character": 26 + } } } }, @@ -387,6 +466,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor cWithOverloads(x: string): cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 33 + }, + "end": { + "line": 12, + "character": 47 + } } } }, @@ -404,6 +493,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithOverloadsInstance2: cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 27 + } } } }, @@ -421,6 +520,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor cWithOverloads(x: number): cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 34 + }, + "end": { + "line": 13, + "character": 48 + } } } }, @@ -438,6 +547,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithOverloadsVal: typeof cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 21 + } } } }, @@ -455,6 +574,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass cWithOverloads\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 24 + }, + "end": { + "line": 14, + "character": 38 + } } } }, @@ -471,7 +600,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithMultipleOverloads(x: string): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: number): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads\n```\n" + "value": "```tsx\nconstructor cWithMultipleOverloads(x: string): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 4 + }, + "end": { + "line": 16, + "character": 15 + } } } }, @@ -488,7 +627,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithMultipleOverloads(x: string): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: number): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads\n```\n" + "value": "```tsx\nconstructor cWithMultipleOverloads(x: number): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 15 + } } } }, @@ -505,7 +654,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithMultipleOverloads(x: string): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: number): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads\n```\n" + "value": "```tsx\nconstructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 4 + }, + "end": { + "line": 18, + "character": 15 + } } } }, @@ -522,7 +681,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconstructor cWithMultipleOverloads(x: string): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: number): cWithMultipleOverloads\nconstructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads\n```\n" + "value": "```tsx\nconstructor cWithMultipleOverloads(x: any): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 4 + }, + "end": { + "line": 19, + "character": 15 + } } } }, @@ -540,6 +709,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithMultipleOverloadsInstance: cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 22, + "character": 4 + }, + "end": { + "line": 22, + "character": 34 + } } } }, @@ -557,6 +736,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor cWithMultipleOverloads(x: string): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 22, + "character": 41 + }, + "end": { + "line": 22, + "character": 63 + } } } }, @@ -574,6 +763,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithMultipleOverloadsInstance2: cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 23, + "character": 4 + }, + "end": { + "line": 23, + "character": 35 + } } } }, @@ -591,6 +790,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor cWithMultipleOverloads(x: number): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 23, + "character": 42 + }, + "end": { + "line": 23, + "character": 64 + } } } }, @@ -608,6 +817,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithMultipleOverloadsInstance3: cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 24, + "character": 4 + }, + "end": { + "line": 24, + "character": 35 + } } } }, @@ -625,6 +844,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor cWithMultipleOverloads(x: boolean): cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 24, + "character": 42 + }, + "end": { + "line": 24, + "character": 64 + } } } }, @@ -642,6 +871,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cWithMultipleOverloadsVal: typeof cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 4 + }, + "end": { + "line": 25, + "character": 29 + } } } }, @@ -659,6 +898,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass cWithMultipleOverloads\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 32 + }, + "end": { + "line": 25, + "character": 54 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultAnonymous.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultAnonymous.baseline index 748eae06e8..f683142ed5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultAnonymous.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultAnonymous.baseline @@ -5,13 +5,19 @@ // | ---------------------------------------------------------------------- // | No quickinfo at /*1*/. // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*2*/. +// | ```tsx +// | class default +// | ``` +// | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*3*/. +// | ```tsx +// | class default +// | ``` +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- @@ -41,7 +47,22 @@ "Name": "2", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nclass default\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 14 + } + } + } }, { "marker": { @@ -53,7 +74,22 @@ "Name": "3", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nclass default\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 20 + } + } + } }, { "marker": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultNamed.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultNamed.baseline index c8f640ffbe..25d7225304 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultNamed.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassDefaultNamed.baseline @@ -5,13 +5,19 @@ // | ---------------------------------------------------------------------- // | No quickinfo at /*1*/. // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*2*/. +// | ```tsx +// | class C +// | ``` +// | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*3*/. +// | ```tsx +// | class C +// | ``` +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- @@ -48,7 +54,22 @@ "Name": "2", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nclass C\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 14 + } + } + } }, { "marker": { @@ -60,7 +81,22 @@ "Name": "3", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nclass C\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 20 + } + } + } }, { "marker": { @@ -76,6 +112,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass C\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 21 + }, + "end": { + "line": 0, + "character": 22 + } } } }, diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassIncomplete.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassIncomplete.baseline index c864ef9b5e..7ff456ccd2 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassIncomplete.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassIncomplete.baseline @@ -1,9 +1,12 @@ // === QuickInfo === === /quickInfoDisplayPartsClassIncomplete.ts === // class { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*1*/. +// | ```tsx +// | class __missing +// | ``` +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- @@ -21,7 +24,22 @@ "Name": "1", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nclass __missing\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 5 + } + } + } }, { "marker": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassMethod.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassMethod.baseline index d681656d03..079beadbd5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassMethod.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassMethod.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsClassMethod.ts === // class c { // public publicMethod() { } -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.publicMethod(): void @@ -10,7 +10,7 @@ // | // | ---------------------------------------------------------------------- // private privateMethod() { } -// ^ +// ^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.privateMethod(): void @@ -18,7 +18,7 @@ // | // | ---------------------------------------------------------------------- // protected protectedMethod() { } -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.protectedMethod(): void @@ -26,7 +26,7 @@ // | // | ---------------------------------------------------------------------- // static staticMethod() { } -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.staticMethod(): void @@ -34,7 +34,7 @@ // | // | ---------------------------------------------------------------------- // private static privateStaticMethod() { } -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.privateStaticMethod(): void @@ -42,7 +42,7 @@ // | // | ---------------------------------------------------------------------- // protected static protectedStaticMethod() { } -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.protectedStaticMethod(): void @@ -51,7 +51,7 @@ // | ---------------------------------------------------------------------- // method() { // this.publicMethod(); -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.publicMethod(): void @@ -59,7 +59,7 @@ // | // | ---------------------------------------------------------------------- // this.privateMethod(); -// ^ +// ^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.privateMethod(): void @@ -67,7 +67,7 @@ // | // | ---------------------------------------------------------------------- // this.protectedMethod(); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.protectedMethod(): void @@ -75,7 +75,7 @@ // | // | ---------------------------------------------------------------------- // c.staticMethod(); -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.staticMethod(): void @@ -83,7 +83,7 @@ // | // | ---------------------------------------------------------------------- // c.privateStaticMethod(); -// ^ +// ^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.privateStaticMethod(): void @@ -91,7 +91,7 @@ // | // | ---------------------------------------------------------------------- // c.protectedStaticMethod(); -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.protectedStaticMethod(): void @@ -102,14 +102,14 @@ // } // var cInstance = new c(); // cInstance.publicMethod(); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.publicMethod(): void @@ -124,7 +124,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.staticMethod(): void @@ -146,6 +146,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.publicMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 23 + } } } }, @@ -163,6 +173,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.privateMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 12 + }, + "end": { + "line": 2, + "character": 25 + } } } }, @@ -180,6 +200,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.protectedMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 14 + }, + "end": { + "line": 3, + "character": 29 + } } } }, @@ -197,6 +227,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.staticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 23 + } } } }, @@ -214,6 +254,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.privateStaticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 19 + }, + "end": { + "line": 5, + "character": 38 + } } } }, @@ -231,6 +281,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.protectedStaticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 21 + }, + "end": { + "line": 6, + "character": 42 + } } } }, @@ -248,6 +308,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.publicMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 13 + }, + "end": { + "line": 8, + "character": 25 + } } } }, @@ -265,6 +335,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.privateMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 13 + }, + "end": { + "line": 9, + "character": 26 + } } } }, @@ -282,6 +362,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.protectedMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 13 + }, + "end": { + "line": 10, + "character": 28 + } } } }, @@ -299,6 +389,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.staticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 10 + }, + "end": { + "line": 11, + "character": 22 + } } } }, @@ -316,6 +416,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.privateStaticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 10 + }, + "end": { + "line": 12, + "character": 29 + } } } }, @@ -333,6 +443,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.protectedStaticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 10 + }, + "end": { + "line": 13, + "character": 31 + } } } }, @@ -350,6 +470,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 9 + } } } }, @@ -367,6 +497,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.publicMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 10 + }, + "end": { + "line": 17, + "character": 22 + } } } }, @@ -384,6 +524,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 0 + }, + "end": { + "line": 18, + "character": 1 + } } } }, @@ -401,6 +551,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.staticMethod(): void\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 2 + }, + "end": { + "line": 18, + "character": 14 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassProperty.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassProperty.baseline index 3842a8b06c..e7b2124f9d 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassProperty.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsClassProperty.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsClassProperty.ts === // class c { // public publicProperty: string; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.publicProperty: string @@ -10,7 +10,7 @@ // | // | ---------------------------------------------------------------------- // private privateProperty: string; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.privateProperty: string @@ -18,7 +18,7 @@ // | // | ---------------------------------------------------------------------- // protected protectedProperty: string; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.protectedProperty: string @@ -26,7 +26,7 @@ // | // | ---------------------------------------------------------------------- // static staticProperty: string; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.staticProperty: string @@ -34,7 +34,7 @@ // | // | ---------------------------------------------------------------------- // private static privateStaticProperty: string; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.privateStaticProperty: string @@ -42,7 +42,7 @@ // | // | ---------------------------------------------------------------------- // protected static protectedStaticProperty: string; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.protectedStaticProperty: string @@ -51,7 +51,7 @@ // | ---------------------------------------------------------------------- // method() { // this.publicProperty; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.publicProperty: string @@ -59,7 +59,7 @@ // | // | ---------------------------------------------------------------------- // this.privateProperty; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.privateProperty: string @@ -67,7 +67,7 @@ // | // | ---------------------------------------------------------------------- // this.protectedProperty; -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.protectedProperty: string @@ -75,7 +75,7 @@ // | // | ---------------------------------------------------------------------- // c.staticProperty; -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.staticProperty: string @@ -83,7 +83,7 @@ // | // | ---------------------------------------------------------------------- // c.privateStaticProperty; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.privateStaticProperty: string @@ -91,7 +91,7 @@ // | // | ---------------------------------------------------------------------- // c.protectedStaticProperty; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.protectedStaticProperty: string @@ -102,14 +102,14 @@ // } // var cInstance = new c(); // cInstance.publicProperty; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.publicProperty: string @@ -124,7 +124,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) c.staticProperty: string @@ -146,6 +146,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 25 + } } } }, @@ -163,6 +173,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 12 + }, + "end": { + "line": 2, + "character": 27 + } } } }, @@ -180,6 +200,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 14 + }, + "end": { + "line": 3, + "character": 31 + } } } }, @@ -197,6 +227,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 25 + } } } }, @@ -214,6 +254,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 19 + }, + "end": { + "line": 5, + "character": 40 + } } } }, @@ -231,6 +281,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 21 + }, + "end": { + "line": 6, + "character": 44 + } } } }, @@ -248,6 +308,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 13 + }, + "end": { + "line": 8, + "character": 27 + } } } }, @@ -265,6 +335,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.privateProperty: string\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 13 + }, + "end": { + "line": 9, + "character": 28 + } } } }, @@ -282,6 +362,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.protectedProperty: string\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 13 + }, + "end": { + "line": 10, + "character": 30 + } } } }, @@ -299,6 +389,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 10 + }, + "end": { + "line": 11, + "character": 24 + } } } }, @@ -316,6 +416,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.privateStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 10 + }, + "end": { + "line": 12, + "character": 31 + } } } }, @@ -333,6 +443,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.protectedStaticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 10 + }, + "end": { + "line": 13, + "character": 33 + } } } }, @@ -350,6 +470,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 9 + } } } }, @@ -367,6 +497,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.publicProperty: string\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 10 + }, + "end": { + "line": 17, + "character": 24 + } } } }, @@ -384,6 +524,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 0 + }, + "end": { + "line": 18, + "character": 1 + } } } }, @@ -401,6 +551,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) c.staticProperty: string\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 2 + }, + "end": { + "line": 18, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsConst.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsConst.baseline index e347d4617f..7ff8afba28 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsConst.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsConst.baseline @@ -26,7 +26,7 @@ // | ---------------------------------------------------------------------- // if (b) { // const b1 = 10; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | const b1: 10 @@ -121,7 +121,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | const h: { (a: string): number; (a: number): string; } +// | const h: (a: number) => string // | ``` // | // | ---------------------------------------------------------------------- @@ -129,7 +129,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | const h: { (a: string): number; (a: number): string; } +// | const h: (a: string) => number // | ``` // | // | ---------------------------------------------------------------------- @@ -148,6 +148,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst a: 10\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 7 + } } } }, @@ -165,6 +175,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst b: 10\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 10 + }, + "end": { + "line": 2, + "character": 11 + } } } }, @@ -182,6 +202,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst a: 10\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 14 + }, + "end": { + "line": 2, + "character": 15 + } } } }, @@ -199,6 +229,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst b1: 10\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 14 + }, + "end": { + "line": 4, + "character": 16 + } } } }, @@ -216,6 +256,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst c: 10\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 10 + }, + "end": { + "line": 8, + "character": 11 + } } } }, @@ -233,6 +283,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst d: 10\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 17 + }, + "end": { + "line": 9, + "character": 18 + } } } }, @@ -250,6 +310,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst e: 10\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 14 + }, + "end": { + "line": 11, + "character": 15 + } } } }, @@ -267,6 +337,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst f: () => number\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 6 + }, + "end": { + "line": 14, + "character": 7 + } } } }, @@ -284,6 +364,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst g: () => number\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 6 + }, + "end": { + "line": 15, + "character": 7 + } } } }, @@ -301,6 +391,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst f: () => number\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 10 + }, + "end": { + "line": 15, + "character": 11 + } } } }, @@ -318,6 +418,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst f: () => number\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 1 + } } } }, @@ -335,6 +445,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst h: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 6 + }, + "end": { + "line": 17, + "character": 7 + } } } }, @@ -352,6 +472,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst i: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 6 + }, + "end": { + "line": 18, + "character": 7 + } } } }, @@ -369,6 +499,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst h: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 10 + }, + "end": { + "line": 18, + "character": 11 + } } } }, @@ -385,7 +525,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst h: { (a: string): number; (a: number): string; }\n```\n" + "value": "```tsx\nconst h: (a: number) => string\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 0 + }, + "end": { + "line": 19, + "character": 1 + } } } }, @@ -402,7 +552,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst h: { (a: string): number; (a: number): string; }\n```\n" + "value": "```tsx\nconst h: (a: string) => number\n```\n" + }, + "range": { + "start": { + "line": 20, + "character": 0 + }, + "end": { + "line": 20, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum1.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum1.baseline index a6943094df..b52bd6268b 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum1.baseline @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // e1, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e1 = 0 @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // e2 = 10, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e2 = 10 @@ -25,7 +25,7 @@ // | // | ---------------------------------------------------------------------- // e3 -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e3 = 11 @@ -34,7 +34,7 @@ // | ---------------------------------------------------------------------- // } // var eInstance: E; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -49,7 +49,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E.e1; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -63,7 +63,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e1 = 0 @@ -71,7 +71,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E.e2; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -85,7 +85,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e2 = 10 @@ -93,7 +93,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E.e3; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -107,7 +107,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e3 = 11 @@ -115,7 +115,7 @@ // | // | ---------------------------------------------------------------------- // const enum constE { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE @@ -123,7 +123,7 @@ // | // | ---------------------------------------------------------------------- // e1, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e1 = 0 @@ -131,7 +131,7 @@ // | // | ---------------------------------------------------------------------- // e2 = 10, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e2 = 10 @@ -139,7 +139,7 @@ // | // | ---------------------------------------------------------------------- // e3 -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e3 = 11 @@ -148,14 +148,14 @@ // | ---------------------------------------------------------------------- // } // var eInstance1: constE; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE @@ -163,21 +163,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE.e1; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e1 = 0 @@ -185,21 +185,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE.e2; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e2 = 10 @@ -207,21 +207,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE.e3; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e3 = 11 @@ -243,6 +243,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 6 + } } } }, @@ -260,6 +270,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 6 + } } } }, @@ -277,6 +297,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 6 + } } } }, @@ -294,6 +324,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 6 + } } } }, @@ -311,6 +351,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 13 + } } } }, @@ -328,6 +378,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 15 + }, + "end": { + "line": 5, + "character": 16 + } } } }, @@ -345,6 +405,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 0 + }, + "end": { + "line": 6, + "character": 9 + } } } }, @@ -362,6 +432,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 12 + }, + "end": { + "line": 6, + "character": 13 + } } } }, @@ -379,6 +459,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 14 + }, + "end": { + "line": 6, + "character": 16 + } } } }, @@ -396,6 +486,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 9 + } } } }, @@ -413,6 +513,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 12 + }, + "end": { + "line": 7, + "character": 13 + } } } }, @@ -430,6 +540,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 14 + }, + "end": { + "line": 7, + "character": 16 + } } } }, @@ -447,6 +567,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 9 + } } } }, @@ -464,6 +594,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 12 + }, + "end": { + "line": 8, + "character": 13 + } } } }, @@ -481,6 +621,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 14 + }, + "end": { + "line": 8, + "character": 16 + } } } }, @@ -498,6 +648,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 11 + }, + "end": { + "line": 9, + "character": 17 + } } } }, @@ -515,6 +675,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 4 + }, + "end": { + "line": 10, + "character": 6 + } } } }, @@ -532,6 +702,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 6 + } } } }, @@ -549,6 +729,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 4 + }, + "end": { + "line": 12, + "character": 6 + } } } }, @@ -566,6 +756,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 14 + } } } }, @@ -583,6 +783,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 16 + }, + "end": { + "line": 14, + "character": 22 + } } } }, @@ -600,6 +810,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 0 + }, + "end": { + "line": 15, + "character": 10 + } } } }, @@ -617,6 +837,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 13 + }, + "end": { + "line": 15, + "character": 19 + } } } }, @@ -634,6 +864,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 20 + }, + "end": { + "line": 15, + "character": 22 + } } } }, @@ -651,6 +891,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 10 + } } } }, @@ -668,6 +918,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 13 + }, + "end": { + "line": 16, + "character": 19 + } } } }, @@ -685,6 +945,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 20 + }, + "end": { + "line": 16, + "character": 22 + } } } }, @@ -702,6 +972,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 10 + } } } }, @@ -719,6 +999,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 13 + }, + "end": { + "line": 17, + "character": 19 + } } } }, @@ -736,6 +1026,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 20 + }, + "end": { + "line": 17, + "character": 22 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum2.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum2.baseline index b779d9db5b..5568fe4340 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum2.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum2.baseline @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // "e1", -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e1 = 0 @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // 'e2' = 10, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e2 = 10 @@ -25,7 +25,7 @@ // | // | ---------------------------------------------------------------------- // "e3" -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e3 = 11 @@ -34,7 +34,7 @@ // | ---------------------------------------------------------------------- // } // var eInstance: E; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -49,7 +49,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E.e1; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -63,7 +63,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e1 = 0 @@ -71,7 +71,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E.e2; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -85,7 +85,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e2 = 10 @@ -93,7 +93,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E.e3; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -107,7 +107,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e3 = 11 @@ -115,7 +115,7 @@ // | // | ---------------------------------------------------------------------- // const enum constE { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE @@ -123,7 +123,7 @@ // | // | ---------------------------------------------------------------------- // "e1", -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e1 = 0 @@ -131,7 +131,7 @@ // | // | ---------------------------------------------------------------------- // 'e2' = 10, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e2 = 10 @@ -139,7 +139,7 @@ // | // | ---------------------------------------------------------------------- // "e3" -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e3 = 11 @@ -148,14 +148,14 @@ // | ---------------------------------------------------------------------- // } // var eInstance1: constE; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE @@ -163,21 +163,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE.e1; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e1 = 0 @@ -185,21 +185,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE.e2; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e2 = 10 @@ -207,21 +207,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE.e3; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e3 = 11 @@ -243,6 +243,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 6 + } } } }, @@ -260,6 +270,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 5 + }, + "end": { + "line": 1, + "character": 7 + } } } }, @@ -277,6 +297,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 5 + }, + "end": { + "line": 2, + "character": 7 + } } } }, @@ -294,6 +324,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 5 + }, + "end": { + "line": 3, + "character": 7 + } } } }, @@ -311,6 +351,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 13 + } } } }, @@ -328,6 +378,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 15 + }, + "end": { + "line": 5, + "character": 16 + } } } }, @@ -345,6 +405,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 0 + }, + "end": { + "line": 6, + "character": 9 + } } } }, @@ -362,6 +432,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 12 + }, + "end": { + "line": 6, + "character": 13 + } } } }, @@ -379,6 +459,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 14 + }, + "end": { + "line": 6, + "character": 16 + } } } }, @@ -396,6 +486,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 9 + } } } }, @@ -413,6 +513,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 12 + }, + "end": { + "line": 7, + "character": 13 + } } } }, @@ -430,6 +540,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 14 + }, + "end": { + "line": 7, + "character": 16 + } } } }, @@ -447,6 +567,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 9 + } } } }, @@ -464,6 +594,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 12 + }, + "end": { + "line": 8, + "character": 13 + } } } }, @@ -481,6 +621,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 14 + }, + "end": { + "line": 8, + "character": 16 + } } } }, @@ -498,6 +648,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 11 + }, + "end": { + "line": 9, + "character": 17 + } } } }, @@ -515,6 +675,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 5 + }, + "end": { + "line": 10, + "character": 7 + } } } }, @@ -532,6 +702,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 5 + }, + "end": { + "line": 11, + "character": 7 + } } } }, @@ -549,6 +729,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 5 + }, + "end": { + "line": 12, + "character": 7 + } } } }, @@ -566,6 +756,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 14 + } } } }, @@ -583,6 +783,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 16 + }, + "end": { + "line": 14, + "character": 22 + } } } }, @@ -600,6 +810,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 0 + }, + "end": { + "line": 15, + "character": 10 + } } } }, @@ -617,6 +837,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 13 + }, + "end": { + "line": 15, + "character": 19 + } } } }, @@ -634,6 +864,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 20 + }, + "end": { + "line": 15, + "character": 22 + } } } }, @@ -651,6 +891,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 10 + } } } }, @@ -668,6 +918,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 13 + }, + "end": { + "line": 16, + "character": 19 + } } } }, @@ -685,6 +945,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 20 + }, + "end": { + "line": 16, + "character": 22 + } } } }, @@ -702,6 +972,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 10 + } } } }, @@ -719,6 +999,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 13 + }, + "end": { + "line": 17, + "character": 19 + } } } }, @@ -736,6 +1026,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 20 + }, + "end": { + "line": 17, + "character": 22 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum3.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum3.baseline index e158a55c64..75e16bd456 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum3.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum3.baseline @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // "e1", -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e1 = 0 @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // 'e2' = 10, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e2 = 10 @@ -25,7 +25,7 @@ // | // | ---------------------------------------------------------------------- // "e3" -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e3 = 11 @@ -34,7 +34,7 @@ // | ---------------------------------------------------------------------- // } // var eInstance: E; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -49,7 +49,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E["e1"]; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -63,7 +63,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e1 = 0 @@ -71,7 +71,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E["e2"]; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -85,7 +85,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e2 = 10 @@ -93,7 +93,7 @@ // | // | ---------------------------------------------------------------------- // eInstance = E['e3']; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance: E @@ -107,7 +107,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) E.e3 = 11 @@ -115,7 +115,7 @@ // | // | ---------------------------------------------------------------------- // const enum constE { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE @@ -123,7 +123,7 @@ // | // | ---------------------------------------------------------------------- // "e1", -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e1 = 0 @@ -131,7 +131,7 @@ // | // | ---------------------------------------------------------------------- // 'e2' = 10, -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e2 = 10 @@ -139,7 +139,7 @@ // | // | ---------------------------------------------------------------------- // "e3" -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e3 = 11 @@ -148,14 +148,14 @@ // | ---------------------------------------------------------------------- // } // var eInstance1: constE; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE @@ -163,21 +163,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE["e1"]; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e1 = 0 @@ -185,21 +185,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE["e2"]; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e2 = 10 @@ -207,21 +207,21 @@ // | // | ---------------------------------------------------------------------- // eInstance1 = constE['e3']; -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var eInstance1: constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | enum constE // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) constE.e3 = 11 @@ -243,6 +243,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 6 + } } } }, @@ -260,6 +270,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 5 + }, + "end": { + "line": 1, + "character": 7 + } } } }, @@ -277,6 +297,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 5 + }, + "end": { + "line": 2, + "character": 7 + } } } }, @@ -294,6 +324,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 5 + }, + "end": { + "line": 3, + "character": 7 + } } } }, @@ -311,6 +351,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 13 + } } } }, @@ -328,6 +378,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 15 + }, + "end": { + "line": 5, + "character": 16 + } } } }, @@ -345,6 +405,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 0 + }, + "end": { + "line": 6, + "character": 9 + } } } }, @@ -362,6 +432,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 12 + }, + "end": { + "line": 6, + "character": 13 + } } } }, @@ -379,6 +459,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 15 + }, + "end": { + "line": 6, + "character": 17 + } } } }, @@ -396,6 +486,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 9 + } } } }, @@ -413,6 +513,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 12 + }, + "end": { + "line": 7, + "character": 13 + } } } }, @@ -430,6 +540,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 15 + }, + "end": { + "line": 7, + "character": 17 + } } } }, @@ -447,6 +567,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance: E\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 9 + } } } }, @@ -464,6 +594,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum E\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 12 + }, + "end": { + "line": 8, + "character": 13 + } } } }, @@ -481,6 +621,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) E.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 15 + }, + "end": { + "line": 8, + "character": 17 + } } } }, @@ -498,6 +648,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 11 + }, + "end": { + "line": 9, + "character": 17 + } } } }, @@ -515,6 +675,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 5 + }, + "end": { + "line": 10, + "character": 7 + } } } }, @@ -532,6 +702,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 5 + }, + "end": { + "line": 11, + "character": 7 + } } } }, @@ -549,6 +729,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 5 + }, + "end": { + "line": 12, + "character": 7 + } } } }, @@ -566,6 +756,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 14 + } } } }, @@ -583,6 +783,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 16 + }, + "end": { + "line": 14, + "character": 22 + } } } }, @@ -600,6 +810,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 0 + }, + "end": { + "line": 15, + "character": 10 + } } } }, @@ -617,6 +837,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 13 + }, + "end": { + "line": 15, + "character": 19 + } } } }, @@ -634,6 +864,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e1 = 0\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 21 + }, + "end": { + "line": 15, + "character": 23 + } } } }, @@ -651,6 +891,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 10 + } } } }, @@ -668,6 +918,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 13 + }, + "end": { + "line": 16, + "character": 19 + } } } }, @@ -685,6 +945,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e2 = 10\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 21 + }, + "end": { + "line": 16, + "character": 23 + } } } }, @@ -702,6 +972,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar eInstance1: constE\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 10 + } } } }, @@ -719,6 +999,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nenum constE\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 13 + }, + "end": { + "line": 17, + "character": 19 + } } } }, @@ -736,6 +1026,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) constE.e3 = 11\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 21 + }, + "end": { + "line": 17, + "character": 23 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum4.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum4.baseline index 2dd6b63672..c9898f8af5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum4.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsEnum4.baseline @@ -5,7 +5,7 @@ // "\u007f" = 127, // } // Foo["\t"] -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) typeof Foo["\t"] = 9 @@ -13,7 +13,7 @@ // | // | ---------------------------------------------------------------------- // Foo["\u007f"] -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (enum member) typeof Foo[""] = 127 @@ -35,6 +35,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) typeof Foo[\"\\t\"] = 9\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 5 + }, + "end": { + "line": 4, + "character": 7 + } } } }, @@ -52,6 +62,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(enum member) typeof Foo[\"\"] = 127\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 5 + }, + "end": { + "line": 5, + "character": 11 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsExternalModules.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsExternalModules.baseline index 9eb32d25c6..9476c1e290 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsExternalModules.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsExternalModules.baseline @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // var namespaceElemWithoutExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithoutExport: number @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // export var namespaceElemWithExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithExport: number @@ -56,7 +56,7 @@ // | // | ---------------------------------------------------------------------- // export namespace m1.m2 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1 @@ -68,7 +68,7 @@ // | No quickinfo at /*9*/. // | ---------------------------------------------------------------------- // var namespaceElemWithoutExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithoutExport: number @@ -76,7 +76,7 @@ // | // | ---------------------------------------------------------------------- // export var namespaceElemWithExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithExport: number @@ -92,14 +92,14 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1.m2 @@ -114,14 +114,14 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1.m2 @@ -143,6 +143,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 18 + } } } }, @@ -160,6 +170,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithoutExport: number\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 34 + } } } }, @@ -177,6 +197,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithExport: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 15 + }, + "end": { + "line": 2, + "character": 38 + } } } }, @@ -194,6 +224,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: typeof m\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 12 + } } } }, @@ -211,6 +251,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 15 + }, + "end": { + "line": 4, + "character": 16 + } } } }, @@ -228,6 +278,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar b: typeof m\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 12 + } } } }, @@ -245,6 +305,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 21 + }, + "end": { + "line": 5, + "character": 22 + } } } }, @@ -262,6 +332,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 17 + }, + "end": { + "line": 6, + "character": 19 + } } } }, @@ -291,6 +371,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithoutExport: number\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 8 + }, + "end": { + "line": 7, + "character": 34 + } } } }, @@ -308,6 +398,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithExport: number\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 15 + }, + "end": { + "line": 8, + "character": 38 + } } } }, @@ -325,6 +425,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar x: typeof m1.m2\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 11 + }, + "end": { + "line": 10, + "character": 12 + } } } }, @@ -342,6 +452,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 15 + }, + "end": { + "line": 10, + "character": 17 + } } } }, @@ -359,6 +479,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1.m2\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 18 + }, + "end": { + "line": 10, + "character": 20 + } } } }, @@ -376,6 +506,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar y: typeof m1.m2\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 11 + }, + "end": { + "line": 11, + "character": 12 + } } } }, @@ -393,6 +533,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 21 + }, + "end": { + "line": 11, + "character": 23 + } } } }, @@ -410,6 +560,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1.m2\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 24 + }, + "end": { + "line": 11, + "character": 26 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunction.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunction.baseline index a4f8ae7fc3..bccaaa43e7 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunction.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunction.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoDisplayPartsFunction.ts === // function foo(param: string, optionalParam?: string, paramWithInitializer = "hello", ...restParam: string[]) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void @@ -10,78 +10,67 @@ // | ---------------------------------------------------------------------- // } // function foowithoverload(a: string): string; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowithoverload(a: string): string -// | function foowithoverload(a: number): number // | ``` // | // | ---------------------------------------------------------------------- // function foowithoverload(a: number): number; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowithoverload(a: string): string // | function foowithoverload(a: number): number // | ``` // | // | ---------------------------------------------------------------------- // function foowithoverload(a: any): any { -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowithoverload(a: string): string -// | function foowithoverload(a: number): number +// | function foowithoverload(a: any): any // | ``` // | // | ---------------------------------------------------------------------- // return a; // } // function foowith3overload(a: string): string; -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: string): string -// | function foowith3overload(a: number): number -// | function foowith3overload(a: boolean): boolean // | ``` // | // | ---------------------------------------------------------------------- // function foowith3overload(a: number): number; -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowith3overload(a: string): string // | function foowith3overload(a: number): number -// | function foowith3overload(a: boolean): boolean // | ``` // | // | ---------------------------------------------------------------------- // function foowith3overload(a: boolean): boolean; -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowith3overload(a: string): string -// | function foowith3overload(a: number): number // | function foowith3overload(a: boolean): boolean // | ``` // | // | ---------------------------------------------------------------------- // function foowith3overload(a: any): any { -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowith3overload(a: string): string -// | function foowith3overload(a: number): number -// | function foowith3overload(a: boolean): boolean +// | function foowith3overload(a: any): any // | ``` // | // | ---------------------------------------------------------------------- // return a; // } // foo("hello"); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void @@ -89,7 +78,7 @@ // | // | ---------------------------------------------------------------------- // foowithoverload("hello"); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowithoverload(a: string): string @@ -97,7 +86,7 @@ // | // | ---------------------------------------------------------------------- // foowithoverload(10); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowithoverload(a: number): number @@ -105,7 +94,7 @@ // | // | ---------------------------------------------------------------------- // foowith3overload("hello"); -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: string): string @@ -113,7 +102,7 @@ // | // | ---------------------------------------------------------------------- // foowith3overload(10); -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: number): number @@ -121,7 +110,7 @@ // | // | ---------------------------------------------------------------------- // foowith3overload(true); -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: boolean): boolean @@ -143,6 +132,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 12 + } } } }, @@ -159,7 +158,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowithoverload(a: string): string\nfunction foowithoverload(a: number): number\n```\n" + "value": "```tsx\nfunction foowithoverload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 9 + }, + "end": { + "line": 2, + "character": 24 + } } } }, @@ -176,7 +185,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowithoverload(a: string): string\nfunction foowithoverload(a: number): number\n```\n" + "value": "```tsx\nfunction foowithoverload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 9 + }, + "end": { + "line": 3, + "character": 24 + } } } }, @@ -193,7 +212,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowithoverload(a: string): string\nfunction foowithoverload(a: number): number\n```\n" + "value": "```tsx\nfunction foowithoverload(a: any): any\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 9 + }, + "end": { + "line": 4, + "character": 24 + } } } }, @@ -210,7 +239,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 25 + } } } }, @@ -227,7 +266,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 9 + }, + "end": { + "line": 8, + "character": 25 + } } } }, @@ -244,7 +293,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: boolean): boolean\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 9 + }, + "end": { + "line": 9, + "character": 25 + } } } }, @@ -261,7 +320,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: any): any\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 9 + }, + "end": { + "line": 10, + "character": 25 + } } } }, @@ -279,6 +348,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 0 + }, + "end": { + "line": 13, + "character": 3 + } } } }, @@ -296,6 +375,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowithoverload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 0 + }, + "end": { + "line": 14, + "character": 15 + } } } }, @@ -313,6 +402,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowithoverload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 0 + }, + "end": { + "line": 15, + "character": 15 + } } } }, @@ -330,6 +429,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowith3overload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 16 + } } } }, @@ -347,6 +456,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowith3overload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 16 + } } } }, @@ -364,6 +483,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowith3overload(a: boolean): boolean\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 0 + }, + "end": { + "line": 18, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionExpression.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionExpression.baseline index 86455d0563..045d231bb1 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionExpression.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionExpression.baseline @@ -8,7 +8,7 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void @@ -16,7 +16,7 @@ // | // | ---------------------------------------------------------------------- // foo(); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void @@ -34,7 +34,7 @@ // | ---------------------------------------------------------------------- // }; // (function foo1() { -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo1(): void @@ -42,7 +42,7 @@ // | // | ---------------------------------------------------------------------- // foo1(); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo1(): void @@ -65,6 +65,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar x: () => void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 5 + } } } }, @@ -82,6 +92,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 20 + } } } }, @@ -99,6 +119,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(): void\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 7 + } } } }, @@ -116,6 +146,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar y: () => void\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 5 + } } } }, @@ -133,6 +173,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo1(): void\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 10 + }, + "end": { + "line": 5, + "character": 14 + } } } }, @@ -150,6 +200,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo1(): void\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 4 + }, + "end": { + "line": 6, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionIncomplete.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionIncomplete.baseline index 4fdac11c6d..65e84951fa 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionIncomplete.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsFunctionIncomplete.baseline @@ -1,9 +1,13 @@ // === QuickInfo === === /quickInfoDisplayPartsFunctionIncomplete.ts === // function (param: string) { -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*1*/. +// | ```tsx +// | function (Missing)(param: string): void +// | function (Missing)(): void +// | ``` +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- @@ -11,9 +15,13 @@ // | ---------------------------------------------------------------------- // }\ // function { -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*3*/. +// | ```tsx +// | function (Missing)(param: string): void +// | function (Missing)(): void +// | ``` +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- @@ -31,7 +39,22 @@ "Name": "1", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nfunction (Missing)(param: string): void\nfunction (Missing)(): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 8 + } + } + } }, { "marker": { @@ -55,7 +78,22 @@ "Name": "3", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\nfunction (Missing)(param: string): void\nfunction (Missing)(): void\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 0 + }, + "end": { + "line": 2, + "character": 8 + } + } + } }, { "marker": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterface.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterface.baseline index 0683b75288..5ba9dea299 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterface.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterface.baseline @@ -10,7 +10,7 @@ // | ---------------------------------------------------------------------- // } // var iInstance: i; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iInstance: i @@ -39,6 +39,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface i\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 11 + } } } }, @@ -56,6 +66,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iInstance: i\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 13 + } } } }, @@ -73,6 +93,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface i\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 15 + }, + "end": { + "line": 2, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterfaceMembers.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterfaceMembers.baseline index 5263452b01..a6c509a4f2 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterfaceMembers.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInterfaceMembers.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsInterfaceMembers.ts === // interface I { // property: string; -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) I.property: string @@ -10,7 +10,7 @@ // | // | ---------------------------------------------------------------------- // method(): string; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I.method(): string @@ -22,28 +22,28 @@ // } // var iInstance: I; // iInstance.property = iInstance.method(); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iInstance: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) I.property: string // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iInstance: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I.method(): string @@ -51,25 +51,25 @@ // | // | ---------------------------------------------------------------------- // iInstance(); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | var iInstance: I +// | var iInstance: () => string // | ``` // | // | ---------------------------------------------------------------------- // var anotherInstance = new iInstance(); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var anotherInstance: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | var iInstance: I +// | var iInstance: () => I // | ``` // | // | ---------------------------------------------------------------------- @@ -88,6 +88,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) I.property: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 12 + } } } }, @@ -105,6 +115,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) I.method(): string\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 10 + } } } }, @@ -122,6 +142,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iInstance: I\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 9 + } } } }, @@ -139,6 +169,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) I.property: string\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 10 + }, + "end": { + "line": 7, + "character": 18 + } } } }, @@ -156,6 +196,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iInstance: I\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 21 + }, + "end": { + "line": 7, + "character": 30 + } } } }, @@ -173,6 +223,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) I.method(): string\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 31 + }, + "end": { + "line": 7, + "character": 37 + } } } }, @@ -189,7 +249,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar iInstance: I\n```\n" + "value": "```tsx\nvar iInstance: () => string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 9 + } } } }, @@ -207,6 +277,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar anotherInstance: I\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 4 + }, + "end": { + "line": 9, + "character": 19 + } } } }, @@ -223,7 +303,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar iInstance: I\n```\n" + "value": "```tsx\nvar iInstance: () => I\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 26 + }, + "end": { + "line": 9, + "character": 35 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInternalModuleAlias.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInternalModuleAlias.baseline index 5f209327b5..10fe8f29ea 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInternalModuleAlias.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsInternalModuleAlias.baseline @@ -6,7 +6,7 @@ // } // module m2 { // import a1 = m; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m @@ -14,7 +14,7 @@ // | // | ---------------------------------------------------------------------- // new a1.m1.c(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m @@ -22,7 +22,7 @@ // | // | ---------------------------------------------------------------------- // import a2 = m.m1; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m.m1 @@ -30,7 +30,7 @@ // | // | ---------------------------------------------------------------------- // new a2.c(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m.m1 @@ -38,7 +38,7 @@ // | // | ---------------------------------------------------------------------- // export import a3 = m; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m @@ -46,7 +46,7 @@ // | // | ---------------------------------------------------------------------- // new a3.m1.c(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m @@ -54,7 +54,7 @@ // | // | ---------------------------------------------------------------------- // export import a4 = m.m1; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m.m1 @@ -62,7 +62,7 @@ // | // | ---------------------------------------------------------------------- // new a4.c(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | (alias) namespace m.m1 @@ -85,6 +85,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 13 + } } } }, @@ -102,6 +112,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 8 + }, + "end": { + "line": 6, + "character": 10 + } } } }, @@ -119,6 +139,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m.m1\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 11 + }, + "end": { + "line": 7, + "character": 13 + } } } }, @@ -136,6 +166,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m.m1\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 8 + }, + "end": { + "line": 8, + "character": 10 + } } } }, @@ -153,6 +193,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 18 + }, + "end": { + "line": 9, + "character": 20 + } } } }, @@ -170,6 +220,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 8 + }, + "end": { + "line": 10, + "character": 10 + } } } }, @@ -187,6 +247,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m.m1\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 18 + }, + "end": { + "line": 11, + "character": 20 + } } } }, @@ -204,6 +274,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(alias) namespace m.m1\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 8 + }, + "end": { + "line": 12, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLet.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLet.baseline index b1241d1974..939ce26c55 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLet.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLet.baseline @@ -26,7 +26,7 @@ // | ---------------------------------------------------------------------- // if (b) { // let b1 = 10; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | let b1: number @@ -121,7 +121,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | let h: { (a: string): number; (a: number): string; } +// | let h: (a: number) => string // | ``` // | // | ---------------------------------------------------------------------- @@ -129,7 +129,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | let h: { (a: string): number; (a: number): string; } +// | let h: (a: string) => number // | ``` // | // | ---------------------------------------------------------------------- @@ -148,6 +148,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet a: number\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 5 + } } } }, @@ -165,6 +175,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet b: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 9 + } } } }, @@ -182,6 +202,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet a: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 12 + }, + "end": { + "line": 2, + "character": 13 + } } } }, @@ -199,6 +229,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet b1: number\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 12 + }, + "end": { + "line": 4, + "character": 14 + } } } }, @@ -216,6 +256,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet c: number\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 8 + }, + "end": { + "line": 8, + "character": 9 + } } } }, @@ -233,6 +283,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet d: number\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 15 + }, + "end": { + "line": 9, + "character": 16 + } } } }, @@ -250,6 +310,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet e: number\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 12 + }, + "end": { + "line": 11, + "character": 13 + } } } }, @@ -267,6 +337,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet f: () => number\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 5 + } } } }, @@ -284,6 +364,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet g: () => number\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 5 + } } } }, @@ -301,6 +391,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet f: () => number\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 8 + }, + "end": { + "line": 15, + "character": 9 + } } } }, @@ -318,6 +418,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet f: () => number\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 1 + } } } }, @@ -335,6 +445,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet h: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 5 + } } } }, @@ -352,6 +472,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet i: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 4 + }, + "end": { + "line": 18, + "character": 5 + } } } }, @@ -369,6 +499,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet h: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 8 + }, + "end": { + "line": 18, + "character": 9 + } } } }, @@ -385,7 +525,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nlet h: { (a: string): number; (a: number): string; }\n```\n" + "value": "```tsx\nlet h: (a: number) => string\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 0 + }, + "end": { + "line": 19, + "character": 1 + } } } }, @@ -402,7 +552,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nlet h: { (a: string): number; (a: number): string; }\n```\n" + "value": "```tsx\nlet h: (a: string) => number\n```\n" + }, + "range": { + "start": { + "line": 20, + "character": 0 + }, + "end": { + "line": 20, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLiteralLikeNames01.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLiteralLikeNames01.baseline index 0aa3ae36d9..8ff248c197 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLiteralLikeNames01.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLiteralLikeNames01.baseline @@ -10,7 +10,7 @@ // | // | ---------------------------------------------------------------------- // private Infinity() { } -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.Infinity(): void @@ -18,7 +18,7 @@ // | // | ---------------------------------------------------------------------- // protected NaN() { } -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.NaN(): void @@ -26,7 +26,7 @@ // | // | ---------------------------------------------------------------------- // static "stringLiteralName"() { } -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C["stringLiteralName"](): void @@ -43,7 +43,7 @@ // | // | ---------------------------------------------------------------------- // this["1"](); -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C[1](): void @@ -51,7 +51,7 @@ // | // | ---------------------------------------------------------------------- // this.Infinity(); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.Infinity(): void @@ -59,7 +59,7 @@ // | // | ---------------------------------------------------------------------- // this["Infinity"](); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.Infinity(): void @@ -67,7 +67,7 @@ // | // | ---------------------------------------------------------------------- // this.NaN(); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.NaN(): void @@ -75,7 +75,7 @@ // | // | ---------------------------------------------------------------------- // C.stringLiteralName(); -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C["stringLiteralName"](): void @@ -98,6 +98,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C[1](): void\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 12 + } } } }, @@ -115,6 +125,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.Infinity(): void\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 12 + }, + "end": { + "line": 2, + "character": 20 + } } } }, @@ -132,6 +152,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.NaN(): void\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 14 + }, + "end": { + "line": 3, + "character": 17 + } } } }, @@ -149,6 +179,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C[\"stringLiteralName\"](): void\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 12 + }, + "end": { + "line": 4, + "character": 29 + } } } }, @@ -166,6 +206,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C[1](): void\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 13 + }, + "end": { + "line": 6, + "character": 14 + } } } }, @@ -183,6 +233,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C[1](): void\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 14 + }, + "end": { + "line": 7, + "character": 15 + } } } }, @@ -200,6 +260,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.Infinity(): void\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 13 + }, + "end": { + "line": 8, + "character": 21 + } } } }, @@ -217,6 +287,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.Infinity(): void\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 14 + }, + "end": { + "line": 9, + "character": 22 + } } } }, @@ -234,6 +314,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.NaN(): void\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 13 + }, + "end": { + "line": 10, + "character": 16 + } } } }, @@ -251,6 +341,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C[\"stringLiteralName\"](): void\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 10 + }, + "end": { + "line": 11, + "character": 27 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLocalFunction.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLocalFunction.baseline index 09021e94d2..c96c894c38 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLocalFunction.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsLocalFunction.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoDisplayPartsLocalFunction.ts === // function outerFoo() { -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function outerFoo(): void @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // function foo(param: string, optionalParam?: string, paramWithInitializer = "hello", ...restParam: string[]) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void @@ -18,78 +18,67 @@ // | ---------------------------------------------------------------------- // } // function foowithoverload(a: string): string; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowithoverload(a: string): string -// | function foowithoverload(a: number): number // | ``` // | // | ---------------------------------------------------------------------- // function foowithoverload(a: number): number; -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowithoverload(a: string): string // | function foowithoverload(a: number): number // | ``` // | // | ---------------------------------------------------------------------- // function foowithoverload(a: any): any { -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowithoverload(a: string): string -// | function foowithoverload(a: number): number +// | function foowithoverload(a: any): any // | ``` // | // | ---------------------------------------------------------------------- // return a; // } // function foowith3overload(a: string): string; -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: string): string -// | function foowith3overload(a: number): number -// | function foowith3overload(a: boolean): boolean // | ``` // | // | ---------------------------------------------------------------------- // function foowith3overload(a: number): number; -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowith3overload(a: string): string // | function foowith3overload(a: number): number -// | function foowith3overload(a: boolean): boolean // | ``` // | // | ---------------------------------------------------------------------- // function foowith3overload(a: boolean): boolean; -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowith3overload(a: string): string -// | function foowith3overload(a: number): number // | function foowith3overload(a: boolean): boolean // | ``` // | // | ---------------------------------------------------------------------- // function foowith3overload(a: any): any { -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foowith3overload(a: string): string -// | function foowith3overload(a: number): number -// | function foowith3overload(a: boolean): boolean +// | function foowith3overload(a: any): any // | ``` // | // | ---------------------------------------------------------------------- // return a; // } // foo("hello"); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void @@ -97,7 +86,7 @@ // | // | ---------------------------------------------------------------------- // foowithoverload("hello"); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowithoverload(a: string): string @@ -105,7 +94,7 @@ // | // | ---------------------------------------------------------------------- // foowithoverload(10); -// ^ +// ^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowithoverload(a: number): number @@ -113,7 +102,7 @@ // | // | ---------------------------------------------------------------------- // foowith3overload("hello"); -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: string): string @@ -121,7 +110,7 @@ // | // | ---------------------------------------------------------------------- // foowith3overload(10); -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: number): number @@ -129,7 +118,7 @@ // | // | ---------------------------------------------------------------------- // foowith3overload(true); -// ^ +// ^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foowith3overload(a: boolean): boolean @@ -138,7 +127,7 @@ // | ---------------------------------------------------------------------- // } // outerFoo(); -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function outerFoo(): void @@ -160,6 +149,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction outerFoo(): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 17 + } } } }, @@ -177,6 +176,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 13 + }, + "end": { + "line": 1, + "character": 16 + } } } }, @@ -193,7 +202,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowithoverload(a: string): string\nfunction foowithoverload(a: number): number\n```\n" + "value": "```tsx\nfunction foowithoverload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 13 + }, + "end": { + "line": 3, + "character": 28 + } } } }, @@ -210,7 +229,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowithoverload(a: string): string\nfunction foowithoverload(a: number): number\n```\n" + "value": "```tsx\nfunction foowithoverload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 13 + }, + "end": { + "line": 4, + "character": 28 + } } } }, @@ -227,7 +256,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowithoverload(a: string): string\nfunction foowithoverload(a: number): number\n```\n" + "value": "```tsx\nfunction foowithoverload(a: any): any\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 13 + }, + "end": { + "line": 5, + "character": 28 + } } } }, @@ -244,7 +283,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 13 + }, + "end": { + "line": 8, + "character": 29 + } } } }, @@ -261,7 +310,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 13 + }, + "end": { + "line": 9, + "character": 29 + } } } }, @@ -278,7 +337,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: boolean): boolean\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 13 + }, + "end": { + "line": 10, + "character": 29 + } } } }, @@ -295,7 +364,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foowith3overload(a: string): string\nfunction foowith3overload(a: number): number\nfunction foowith3overload(a: boolean): boolean\n```\n" + "value": "```tsx\nfunction foowith3overload(a: any): any\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 13 + }, + "end": { + "line": 11, + "character": 29 + } } } }, @@ -313,6 +392,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 7 + } } } }, @@ -330,6 +419,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowithoverload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 19 + } } } }, @@ -347,6 +446,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowithoverload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 4 + }, + "end": { + "line": 16, + "character": 19 + } } } }, @@ -364,6 +473,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowith3overload(a: string): string\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 20 + } } } }, @@ -381,6 +500,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowith3overload(a: number): number\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 4 + }, + "end": { + "line": 18, + "character": 20 + } } } }, @@ -398,6 +527,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foowith3overload(a: boolean): boolean\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 4 + }, + "end": { + "line": 19, + "character": 20 + } } } }, @@ -415,6 +554,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction outerFoo(): void\n```\n" + }, + "range": { + "start": { + "line": 21, + "character": 0 + }, + "end": { + "line": 21, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsModules.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsModules.baseline index e53d6f58bd..98273875a2 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsModules.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsModules.baseline @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // var namespaceElemWithoutExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithoutExport: number @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // export var namespaceElemWithExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithExport: number @@ -56,7 +56,7 @@ // | // | ---------------------------------------------------------------------- // namespace m1.m2 { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1 @@ -68,7 +68,7 @@ // | No quickinfo at /*9*/. // | ---------------------------------------------------------------------- // var namespaceElemWithoutExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithoutExport: number @@ -76,7 +76,7 @@ // | // | ---------------------------------------------------------------------- // export var namespaceElemWithExport = 10; -// ^ +// ^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var namespaceElemWithExport: number @@ -92,14 +92,14 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1.m2 @@ -114,14 +114,14 @@ // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | namespace m1.m2 @@ -143,6 +143,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 11 + } } } }, @@ -160,6 +170,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithoutExport: number\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 34 + } } } }, @@ -177,6 +197,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithExport: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 15 + }, + "end": { + "line": 2, + "character": 38 + } } } }, @@ -194,6 +224,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: typeof m\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 5 + } } } }, @@ -211,6 +251,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 8 + }, + "end": { + "line": 4, + "character": 9 + } } } }, @@ -228,6 +278,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar b: typeof m\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 5 + } } } }, @@ -245,6 +305,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 15 + } } } }, @@ -262,6 +332,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 12 + } } } }, @@ -291,6 +371,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithoutExport: number\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 8 + }, + "end": { + "line": 7, + "character": 34 + } } } }, @@ -308,6 +398,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar namespaceElemWithExport: number\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 15 + }, + "end": { + "line": 8, + "character": 38 + } } } }, @@ -325,6 +425,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar x: typeof m1.m2\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 4 + }, + "end": { + "line": 10, + "character": 5 + } } } }, @@ -342,6 +452,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 8 + }, + "end": { + "line": 10, + "character": 10 + } } } }, @@ -359,6 +479,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1.m2\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 11 + }, + "end": { + "line": 10, + "character": 13 + } } } }, @@ -376,6 +506,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar y: typeof m1.m2\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 5 + } } } }, @@ -393,6 +533,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 14 + }, + "end": { + "line": 11, + "character": 16 + } } } }, @@ -410,6 +560,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nnamespace m1.m2\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 17 + }, + "end": { + "line": 11, + "character": 19 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsParameters.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsParameters.baseline index 51d767306d..f8a607fce9 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsParameters.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsParameters.baseline @@ -2,7 +2,7 @@ === /quickInfoDisplayPartsParameters.ts === // /** @return *crunch* */ // function foo(param: string, optionalParam?: string, paramWithInitializer = "hello", ...restParam: string[]) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void @@ -11,28 +11,28 @@ // | // | *@return* — *crunch* // | ---------------------------------------------------------------------- -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) param: string // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) optionalParam: string // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) paramWithInitializer: string // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) restParam: string[] @@ -40,7 +40,7 @@ // | // | ---------------------------------------------------------------------- // param = "Hello"; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) param: string @@ -48,7 +48,7 @@ // | // | ---------------------------------------------------------------------- // optionalParam = "World"; -// ^ +// ^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) optionalParam: string @@ -56,7 +56,7 @@ // | // | ---------------------------------------------------------------------- // paramWithInitializer = "Hello"; -// ^ +// ^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) paramWithInitializer: string @@ -64,7 +64,7 @@ // | // | ---------------------------------------------------------------------- // restParam[0] = "World"; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) restParam: string[] @@ -87,6 +87,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(param: string, optionalParam?: string, paramWithInitializer?: string, ...restParam: string[]): void\n```\n\n\n*@return* — *crunch* " + }, + "range": { + "start": { + "line": 1, + "character": 9 + }, + "end": { + "line": 1, + "character": 12 + } } } }, @@ -104,6 +114,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) param: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 13 + }, + "end": { + "line": 1, + "character": 18 + } } } }, @@ -121,6 +141,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) optionalParam: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 28 + }, + "end": { + "line": 1, + "character": 41 + } } } }, @@ -138,6 +168,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) paramWithInitializer: string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 52 + }, + "end": { + "line": 1, + "character": 72 + } } } }, @@ -155,6 +195,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) restParam: string[]\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 87 + }, + "end": { + "line": 1, + "character": 96 + } } } }, @@ -172,6 +222,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) param: string\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 9 + } } } }, @@ -189,6 +249,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) optionalParam: string\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 17 + } } } }, @@ -206,6 +276,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) paramWithInitializer: string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 24 + } } } }, @@ -223,6 +303,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) restParam: string[]\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 13 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeAlias.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeAlias.baseline index db7ccbdd05..4ba0f03aed 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeAlias.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeAlias.baseline @@ -10,7 +10,7 @@ // | ---------------------------------------------------------------------- // } // type t1 = c; -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | type t1 = c @@ -25,14 +25,14 @@ // | // | ---------------------------------------------------------------------- // var cInstance: t1 = new c(); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | type t1 = c @@ -42,7 +42,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | class c +// | constructor c(): c // | ``` // | // | ---------------------------------------------------------------------- @@ -61,6 +61,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 7 + } } } }, @@ -78,6 +88,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype t1 = c\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 5 + }, + "end": { + "line": 2, + "character": 7 + } } } }, @@ -95,6 +115,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 10 + }, + "end": { + "line": 2, + "character": 11 + } } } }, @@ -112,6 +142,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 13 + } } } }, @@ -129,6 +169,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype t1 = c\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 15 + }, + "end": { + "line": 3, + "character": 17 + } } } }, @@ -145,7 +195,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nclass c\n```\n" + "value": "```tsx\nconstructor c(): c\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 24 + }, + "end": { + "line": 3, + "character": 25 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInClass.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInClass.baseline index 0c212ea09e..58d5c23ef5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInClass.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInClass.baseline @@ -16,7 +16,7 @@ // | // | ---------------------------------------------------------------------- // constructor(a: T) { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c(a: T): c @@ -39,7 +39,7 @@ // | ---------------------------------------------------------------------- // } // method(a: U, b: T) { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.method(a: U, b: T): U @@ -92,7 +92,7 @@ // } // } // var cInstance = new c("Hello"); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c @@ -107,7 +107,7 @@ // | // | ---------------------------------------------------------------------- // var cVal = c; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cVal: typeof c @@ -122,14 +122,14 @@ // | // | ---------------------------------------------------------------------- // cInstance.method("hello", "cello"); -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c.method<"hello">(a: "hello", b: string): "hello" @@ -137,7 +137,7 @@ // | // | ---------------------------------------------------------------------- // class c2> { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c2> @@ -159,7 +159,7 @@ // | // | ---------------------------------------------------------------------- // constructor(a: T) { -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c2>(a: T): c2 @@ -182,7 +182,7 @@ // | ---------------------------------------------------------------------- // } // method>(a: U, b: T) { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c2.method>(a: U, b: T): U @@ -242,21 +242,21 @@ // } // } // var cInstance1 = new c2(cInstance); -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance1: c2> // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor c2>(a: c): c2> // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c @@ -264,14 +264,14 @@ // | // | ---------------------------------------------------------------------- // var cVal2 = c2; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cVal2: typeof c2 // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | class c2> @@ -279,28 +279,28 @@ // | // | ---------------------------------------------------------------------- // cInstance1.method(cInstance, cInstance); -// ^ +// ^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance1: c2> // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) c2.method>(a: c, b: c): c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var cInstance: c @@ -322,6 +322,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 7 + } } } }, @@ -339,6 +349,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 9 + } } } }, @@ -356,6 +376,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c(a: T): c\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 15 + } } } }, @@ -373,6 +403,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: T\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 16 + }, + "end": { + "line": 1, + "character": 17 + } } } }, @@ -390,6 +430,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 19 + }, + "end": { + "line": 1, + "character": 20 + } } } }, @@ -407,6 +457,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.method(a: U, b: T): U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 10 + } } } }, @@ -424,6 +484,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 11 + }, + "end": { + "line": 3, + "character": 12 + } } } }, @@ -441,6 +511,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 14 + }, + "end": { + "line": 3, + "character": 15 + } } } }, @@ -458,6 +538,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 17 + }, + "end": { + "line": 3, + "character": 18 + } } } }, @@ -475,6 +565,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 20 + }, + "end": { + "line": 3, + "character": 21 + } } } }, @@ -492,6 +592,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 23 + }, + "end": { + "line": 3, + "character": 24 + } } } }, @@ -509,6 +619,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 15 + }, + "end": { + "line": 4, + "character": 16 + } } } }, @@ -526,6 +646,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 4 + }, + "end": { + "line": 7, + "character": 13 + } } } }, @@ -543,6 +673,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c(a: string): c\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 20 + }, + "end": { + "line": 7, + "character": 21 + } } } }, @@ -560,6 +700,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cVal: typeof c\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 4 + }, + "end": { + "line": 8, + "character": 8 + } } } }, @@ -577,6 +727,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 11 + }, + "end": { + "line": 8, + "character": 12 + } } } }, @@ -594,6 +754,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 0 + }, + "end": { + "line": 9, + "character": 9 + } } } }, @@ -611,6 +781,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c.method<\"hello\">(a: \"hello\", b: string): \"hello\"\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 10 + }, + "end": { + "line": 9, + "character": 16 + } } } }, @@ -628,6 +808,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c2>\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 6 + }, + "end": { + "line": 10, + "character": 8 + } } } }, @@ -645,6 +835,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends c\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 9 + }, + "end": { + "line": 10, + "character": 10 + } } } }, @@ -662,6 +862,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 19 + }, + "end": { + "line": 10, + "character": 20 + } } } }, @@ -679,6 +889,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c2>(a: T): c2\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 15 + } } } }, @@ -696,6 +916,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: T\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 16 + }, + "end": { + "line": 11, + "character": 17 + } } } }, @@ -713,6 +943,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends c\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 19 + }, + "end": { + "line": 11, + "character": 20 + } } } }, @@ -730,6 +970,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c2.method>(a: U, b: T): U\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 10 + } } } }, @@ -747,6 +997,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends c\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 11 + }, + "end": { + "line": 13, + "character": 12 + } } } }, @@ -764,6 +1024,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 21 + }, + "end": { + "line": 13, + "character": 22 + } } } }, @@ -781,6 +1051,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 32 + }, + "end": { + "line": 13, + "character": 33 + } } } }, @@ -798,6 +1078,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends c\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 35 + }, + "end": { + "line": 13, + "character": 36 + } } } }, @@ -815,6 +1105,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 38 + }, + "end": { + "line": 13, + "character": 39 + } } } }, @@ -832,6 +1132,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends c\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 41 + }, + "end": { + "line": 13, + "character": 42 + } } } }, @@ -849,6 +1159,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 15 + }, + "end": { + "line": 14, + "character": 16 + } } } }, @@ -866,6 +1186,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance1: c2>\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 14 + } } } }, @@ -883,6 +1213,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor c2>(a: c): c2>\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 21 + }, + "end": { + "line": 17, + "character": 23 + } } } }, @@ -900,6 +1240,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 24 + }, + "end": { + "line": 17, + "character": 33 + } } } }, @@ -917,6 +1267,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cVal2: typeof c2\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 4 + }, + "end": { + "line": 18, + "character": 9 + } } } }, @@ -934,6 +1294,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass c2>\n```\n" + }, + "range": { + "start": { + "line": 18, + "character": 12 + }, + "end": { + "line": 18, + "character": 14 + } } } }, @@ -951,6 +1321,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance1: c2>\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 0 + }, + "end": { + "line": 19, + "character": 10 + } } } }, @@ -968,6 +1348,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) c2.method>(a: c, b: c): c\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 11 + }, + "end": { + "line": 19, + "character": 17 + } } } }, @@ -985,6 +1375,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 18 + }, + "end": { + "line": 19, + "character": 27 + } } } }, @@ -1002,6 +1402,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar cInstance: c\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 29 + }, + "end": { + "line": 19, + "character": 38 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunction.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunction.baseline index 89635c55b6..4da604dc1a 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunction.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunction.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoDisplayPartsTypeParameterInFunction.ts === // function foo(a: U) { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(a: U): U @@ -39,7 +39,7 @@ // | ---------------------------------------------------------------------- // } // foo("Hello"); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo<"Hello">(a: "Hello"): "Hello" @@ -47,7 +47,7 @@ // | // | ---------------------------------------------------------------------- // function foo2(a: U) { -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo2(a: U): U @@ -85,7 +85,7 @@ // | ---------------------------------------------------------------------- // } // foo2("hello"); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo2<"hello">(a: "hello"): "hello" @@ -107,6 +107,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(a: U): U\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 12 + } } } }, @@ -124,6 +134,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 13 + }, + "end": { + "line": 0, + "character": 14 + } } } }, @@ -141,6 +161,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 16 + }, + "end": { + "line": 0, + "character": 17 + } } } }, @@ -158,6 +188,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 19 + }, + "end": { + "line": 0, + "character": 20 + } } } }, @@ -175,6 +215,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 12 + } } } }, @@ -192,6 +242,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo<\"Hello\">(a: \"Hello\"): \"Hello\"\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 0 + }, + "end": { + "line": 3, + "character": 3 + } } } }, @@ -209,6 +269,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo2(a: U): U\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 9 + }, + "end": { + "line": 4, + "character": 13 + } } } }, @@ -226,6 +296,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 14 + }, + "end": { + "line": 4, + "character": 15 + } } } }, @@ -243,6 +323,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 32 + }, + "end": { + "line": 4, + "character": 33 + } } } }, @@ -260,6 +350,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends string\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 35 + }, + "end": { + "line": 4, + "character": 36 + } } } }, @@ -277,6 +377,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 12 + } } } }, @@ -294,6 +404,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo2<\"hello\">(a: \"hello\"): \"hello\"\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 4 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunctionLikeInTypeAlias.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunctionLikeInTypeAlias.baseline index 9e7a964b12..34f227d6b5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunctionLikeInTypeAlias.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInFunctionLikeInTypeAlias.baseline @@ -38,6 +38,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) A\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 30 + }, + "end": { + "line": 0, + "character": 31 + } } } }, @@ -55,6 +65,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) A\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 59 + }, + "end": { + "line": 0, + "character": 60 + } } } }, @@ -72,6 +92,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) A\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 74 + }, + "end": { + "line": 1, + "character": 75 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInInterface.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInInterface.baseline index 5d6cb24e7d..5f6dcceb8c 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInInterface.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInInterface.baseline @@ -102,7 +102,7 @@ // | // | ---------------------------------------------------------------------- // method(a: U, b: T): U; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I.method(a: U, b: T): U @@ -153,7 +153,7 @@ // | ---------------------------------------------------------------------- // } // var iVal: I; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I @@ -168,30 +168,30 @@ // | // | ---------------------------------------------------------------------- // new iVal("hello", "hello"); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | var iVal: I +// | var iVal: <"hello">(a: "hello", b: string) => "hello" // | ``` // | // | ---------------------------------------------------------------------- // iVal("hello", "hello"); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | var iVal: I +// | var iVal: <"hello">(a: "hello", b: string) => "hello" // | ``` // | // | ---------------------------------------------------------------------- // iVal.method("hello", "hello"); -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I.method<"hello">(a: "hello", b: string): "hello" @@ -199,7 +199,7 @@ // | // | ---------------------------------------------------------------------- // interface I1> { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | interface I1> @@ -321,7 +321,7 @@ // | // | ---------------------------------------------------------------------- // method>(a: U, b: T): U; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I1.method>(a: U, b: T): U @@ -379,14 +379,14 @@ // | ---------------------------------------------------------------------- // } // var iVal1: I1>; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal1: I1> // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | interface I1> @@ -401,21 +401,21 @@ // | // | ---------------------------------------------------------------------- // new iVal1(iVal, iVal); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | var iVal1: I1> +// | var iVal1: >(a: I, b: I) => I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I @@ -423,21 +423,21 @@ // | // | ---------------------------------------------------------------------- // iVal1(iVal, iVal); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | var iVal1: I1> +// | var iVal1: >(a: I, b: I) => I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I @@ -445,28 +445,28 @@ // | // | ---------------------------------------------------------------------- // iVal1.method(iVal, iVal); -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal1: I1> // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) I1.method>(a: I, b: I): I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var iVal: I @@ -488,6 +488,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 11 + } } } }, @@ -505,6 +515,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 12 + }, + "end": { + "line": 0, + "character": 13 + } } } }, @@ -522,6 +542,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 9 + }, + "end": { + "line": 1, + "character": 10 + } } } }, @@ -539,6 +569,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 12 + }, + "end": { + "line": 1, + "character": 13 + } } } }, @@ -556,6 +596,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 15 + }, + "end": { + "line": 1, + "character": 16 + } } } }, @@ -573,6 +623,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 18 + }, + "end": { + "line": 1, + "character": 19 + } } } }, @@ -590,6 +650,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 21 + }, + "end": { + "line": 1, + "character": 22 + } } } }, @@ -607,6 +677,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 25 + }, + "end": { + "line": 1, + "character": 26 + } } } }, @@ -624,6 +704,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 5 + }, + "end": { + "line": 2, + "character": 6 + } } } }, @@ -641,6 +731,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 9 + } } } }, @@ -658,6 +758,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 11 + }, + "end": { + "line": 2, + "character": 12 + } } } }, @@ -675,6 +785,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 14 + }, + "end": { + "line": 2, + "character": 15 + } } } }, @@ -692,6 +812,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 17 + }, + "end": { + "line": 2, + "character": 18 + } } } }, @@ -709,6 +839,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 21 + }, + "end": { + "line": 2, + "character": 22 + } } } }, @@ -726,6 +866,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) I.method(a: U, b: T): U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 4 + }, + "end": { + "line": 3, + "character": 10 + } } } }, @@ -743,6 +893,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 11 + }, + "end": { + "line": 3, + "character": 12 + } } } }, @@ -760,6 +920,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 14 + }, + "end": { + "line": 3, + "character": 15 + } } } }, @@ -777,6 +947,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 17 + }, + "end": { + "line": 3, + "character": 18 + } } } }, @@ -794,6 +974,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 20 + }, + "end": { + "line": 3, + "character": 21 + } } } }, @@ -811,6 +1001,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 23 + }, + "end": { + "line": 3, + "character": 24 + } } } }, @@ -828,6 +1028,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 27 + }, + "end": { + "line": 3, + "character": 28 + } } } }, @@ -845,6 +1055,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 8 + } } } }, @@ -862,6 +1082,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 10 + }, + "end": { + "line": 5, + "character": 11 + } } } }, @@ -878,7 +1108,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar iVal: I\n```\n" + "value": "```tsx\nvar iVal: <\"hello\">(a: \"hello\", b: string) => \"hello\"\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 4 + }, + "end": { + "line": 6, + "character": 8 + } } } }, @@ -895,7 +1135,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar iVal: I\n```\n" + "value": "```tsx\nvar iVal: <\"hello\">(a: \"hello\", b: string) => \"hello\"\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 0 + }, + "end": { + "line": 7, + "character": 4 + } } } }, @@ -913,6 +1163,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 4 + } } } }, @@ -930,6 +1190,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) I.method<\"hello\">(a: \"hello\", b: string): \"hello\"\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 5 + }, + "end": { + "line": 8, + "character": 11 + } } } }, @@ -947,6 +1217,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I1>\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 10 + }, + "end": { + "line": 9, + "character": 12 + } } } }, @@ -964,6 +1244,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends I\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 13 + }, + "end": { + "line": 9, + "character": 14 + } } } }, @@ -981,6 +1271,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 23 + }, + "end": { + "line": 9, + "character": 24 + } } } }, @@ -998,6 +1298,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 9 + }, + "end": { + "line": 10, + "character": 10 + } } } }, @@ -1015,6 +1325,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 19 + }, + "end": { + "line": 10, + "character": 20 + } } } }, @@ -1032,6 +1352,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 30 + }, + "end": { + "line": 10, + "character": 31 + } } } }, @@ -1049,6 +1379,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 33 + }, + "end": { + "line": 10, + "character": 34 + } } } }, @@ -1066,6 +1406,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 36 + }, + "end": { + "line": 10, + "character": 37 + } } } }, @@ -1083,6 +1433,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends I\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 39 + }, + "end": { + "line": 10, + "character": 40 + } } } }, @@ -1100,6 +1460,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 43 + }, + "end": { + "line": 10, + "character": 44 + } } } }, @@ -1117,6 +1487,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 5 + }, + "end": { + "line": 11, + "character": 6 + } } } }, @@ -1134,6 +1514,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 15 + }, + "end": { + "line": 11, + "character": 16 + } } } }, @@ -1151,6 +1541,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 26 + }, + "end": { + "line": 11, + "character": 27 + } } } }, @@ -1168,6 +1568,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 29 + }, + "end": { + "line": 11, + "character": 30 + } } } }, @@ -1185,6 +1595,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 32 + }, + "end": { + "line": 11, + "character": 33 + } } } }, @@ -1202,6 +1622,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends I\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 35 + }, + "end": { + "line": 11, + "character": 36 + } } } }, @@ -1219,6 +1649,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 39 + }, + "end": { + "line": 11, + "character": 40 + } } } }, @@ -1236,6 +1676,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) I1.method>(a: U, b: T): U\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 4 + }, + "end": { + "line": 12, + "character": 10 + } } } }, @@ -1253,6 +1703,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 11 + }, + "end": { + "line": 12, + "character": 12 + } } } }, @@ -1270,6 +1730,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 21 + }, + "end": { + "line": 12, + "character": 22 + } } } }, @@ -1287,6 +1757,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) a: U\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 32 + }, + "end": { + "line": 12, + "character": 33 + } } } }, @@ -1304,6 +1784,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 35 + }, + "end": { + "line": 12, + "character": 36 + } } } }, @@ -1321,6 +1811,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) b: T\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 38 + }, + "end": { + "line": 12, + "character": 39 + } } } }, @@ -1338,6 +1838,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends I\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 41 + }, + "end": { + "line": 12, + "character": 42 + } } } }, @@ -1355,6 +1865,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) U extends I\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 45 + }, + "end": { + "line": 12, + "character": 46 + } } } }, @@ -1372,6 +1892,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal1: I1>\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 9 + } } } }, @@ -1389,6 +1919,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I1>\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 11 + }, + "end": { + "line": 14, + "character": 13 + } } } }, @@ -1406,6 +1946,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ninterface I\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 14 + }, + "end": { + "line": 14, + "character": 15 + } } } }, @@ -1422,7 +1972,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar iVal1: I1>\n```\n" + "value": "```tsx\nvar iVal1: >(a: I, b: I) => I\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 9 + } } } }, @@ -1440,6 +2000,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 10 + }, + "end": { + "line": 15, + "character": 14 + } } } }, @@ -1457,6 +2027,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 15, + "character": 16 + }, + "end": { + "line": 15, + "character": 20 + } } } }, @@ -1473,7 +2053,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar iVal1: I1>\n```\n" + "value": "```tsx\nvar iVal1: >(a: I, b: I) => I\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 0 + }, + "end": { + "line": 16, + "character": 5 + } } } }, @@ -1491,6 +2081,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 6 + }, + "end": { + "line": 16, + "character": 10 + } } } }, @@ -1508,6 +2108,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 16, + "character": 12 + }, + "end": { + "line": 16, + "character": 16 + } } } }, @@ -1525,6 +2135,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal1: I1>\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 5 + } } } }, @@ -1542,6 +2162,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) I1.method>(a: I, b: I): I\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 6 + }, + "end": { + "line": 17, + "character": 12 + } } } }, @@ -1559,6 +2189,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 13 + }, + "end": { + "line": 17, + "character": 17 + } } } }, @@ -1576,6 +2216,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar iVal: I\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 19 + }, + "end": { + "line": 17, + "character": 23 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInTypeAlias.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInTypeAlias.baseline index bbda7b9577..299f34e6ae 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInTypeAlias.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInTypeAlias.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoDisplayPartsTypeParameterInTypeAlias.ts === // type List = T[] -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type List = T[] @@ -23,7 +23,7 @@ // | // | ---------------------------------------------------------------------- // type List2 = T[]; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type List2 = T[] @@ -59,6 +59,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype List = T[]\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 9 + } } } }, @@ -76,6 +86,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 11 + } } } }, @@ -93,6 +113,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 16 + } } } }, @@ -110,6 +140,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype List2 = T[]\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 5 + }, + "end": { + "line": 1, + "character": 10 + } } } }, @@ -127,6 +167,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 12 + } } } }, @@ -144,6 +194,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(type parameter) T extends string\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 31 + }, + "end": { + "line": 1, + "character": 32 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsUsing.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsUsing.baseline index 8cd399f48d..18bea2f9e4 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsUsing.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsUsing.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoDisplayPartsUsing.ts === // using a = "a"; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | using a: "a" @@ -33,6 +33,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nusing a: \"a\"\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 7 + } } } }, @@ -50,6 +60,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nawait using b: { [Symbol.asyncDispose](): Promise; }\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 16 + }, + "end": { + "line": 2, + "character": 17 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVar.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVar.baseline index e80c22615a..a41312cf14 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVar.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVar.baseline @@ -101,7 +101,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | var h: { (a: string): number; (a: number): string; } +// | var h: (a: number) => string // | ``` // | // | ---------------------------------------------------------------------- @@ -109,7 +109,7 @@ // ^ // | ---------------------------------------------------------------------- // | ```tsx -// | var h: { (a: string): number; (a: number): string; } +// | var h: (a: string) => number // | ``` // | // | ---------------------------------------------------------------------- @@ -128,6 +128,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: number\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 5 + } } } }, @@ -145,6 +155,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar b: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 9 + } } } }, @@ -162,6 +182,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: number\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 12 + }, + "end": { + "line": 2, + "character": 13 + } } } }, @@ -179,6 +209,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar c: number\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 9 + } } } }, @@ -196,6 +236,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar d: number\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 15 + }, + "end": { + "line": 6, + "character": 16 + } } } }, @@ -213,6 +263,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar f: () => number\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 4 + }, + "end": { + "line": 8, + "character": 5 + } } } }, @@ -230,6 +290,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar g: () => number\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 4 + }, + "end": { + "line": 9, + "character": 5 + } } } }, @@ -247,6 +317,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar f: () => number\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 8 + }, + "end": { + "line": 9, + "character": 9 + } } } }, @@ -264,6 +344,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar f: () => number\n```\n" + }, + "range": { + "start": { + "line": 10, + "character": 0 + }, + "end": { + "line": 10, + "character": 1 + } } } }, @@ -281,6 +371,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar h: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 5 + } } } }, @@ -298,6 +398,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar i: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 4 + }, + "end": { + "line": 12, + "character": 5 + } } } }, @@ -315,6 +425,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar h: { (a: string): number; (a: number): string; }\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 8 + }, + "end": { + "line": 12, + "character": 9 + } } } }, @@ -331,7 +451,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar h: { (a: string): number; (a: number): string; }\n```\n" + "value": "```tsx\nvar h: (a: number) => string\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 0 + }, + "end": { + "line": 13, + "character": 1 + } } } }, @@ -348,7 +478,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar h: { (a: string): number; (a: number): string; }\n```\n" + "value": "```tsx\nvar h: (a: string) => number\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 0 + }, + "end": { + "line": 14, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVarWithStringTypes01.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVarWithStringTypes01.baseline index f608f7f0c4..cf733365dd 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVarWithStringTypes01.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsVarWithStringTypes01.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoDisplayPartsVarWithStringTypes01.ts === // let hello: "hello" | 'hello' = "hello"; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | let hello: "hello" @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // let world: 'world' = "world"; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | let world: "world" @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // let helloOrWorld: "hello" | 'world'; -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | let helloOrWorld: "hello" | "world" @@ -39,6 +39,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet hello: \"hello\"\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 9 + } } } }, @@ -56,6 +66,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet world: \"world\"\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 9 + } } } }, @@ -73,6 +93,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nlet helloOrWorld: \"hello\" | \"world\"\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode1.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode1.baseline index 58c5d146ec..a9bc2873be 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode1.baseline @@ -5,7 +5,7 @@ // } // // function f2(x) { -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function f2(x: any): void @@ -16,7 +16,7 @@ // } // // f2(''); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function f2(x: any): void @@ -38,6 +38,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f2(x: any): void\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 9 + }, + "end": { + "line": 4, + "character": 11 + } } } }, @@ -55,6 +65,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f2(x: any): void\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 2 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode2.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode2.baseline index 270ca1246c..7a826925ae 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode2.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForArgumentsPropertyNameInJsMode2.baseline @@ -34,6 +34,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f(x: any): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 10 + } } } }, @@ -51,6 +61,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f(x: any): void\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForConstAssertions.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForConstAssertions.baseline index 58e3a82f0b..e5598148bb 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForConstAssertions.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForConstAssertions.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoForConstAssertions.ts === // const a = { a: 1 } as const; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type const @@ -9,7 +9,7 @@ // | // | ---------------------------------------------------------------------- // const b = 1 as const; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type const @@ -17,7 +17,7 @@ // | // | ---------------------------------------------------------------------- // const c = "c" as const; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type const @@ -25,7 +25,7 @@ // | // | ---------------------------------------------------------------------- // const d = [1, 2] as const; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type const @@ -47,6 +47,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype const\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 22 + }, + "end": { + "line": 0, + "character": 27 + } } } }, @@ -64,6 +74,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype const\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 15 + }, + "end": { + "line": 1, + "character": 20 + } } } }, @@ -81,6 +101,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype const\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 17 + }, + "end": { + "line": 2, + "character": 22 + } } } }, @@ -98,6 +128,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype const\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 20 + }, + "end": { + "line": 3, + "character": 25 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline index ad5bd08794..63b64218fb 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocCodefence.baseline @@ -7,7 +7,7 @@ // * ``` // */ // function foo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): string @@ -29,7 +29,7 @@ // * ` // */ // function boo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function boo(): string @@ -58,6 +58,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(): string\n```\n\n\n*@example*\n```\n1 + 2\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 9 + }, + "end": { + "line": 6, + "character": 12 + } } } }, @@ -75,6 +85,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction boo(): string\n```\n\n\n*@example* — ``\n1 + 2\n`\n" + }, + "range": { + "start": { + "line": 15, + "character": 9 + }, + "end": { + "line": 15, + "character": 12 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline index 7f38a922c6..1ace37d779 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocUnknownTag.baseline @@ -7,7 +7,7 @@ // * } // */ // function foo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): string @@ -28,7 +28,7 @@ // } // */ // function foo2() { -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo2(): string @@ -49,7 +49,7 @@ // * b // */ // function moo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function moo(): string @@ -71,7 +71,7 @@ // * b // */ // function boo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function boo(): string @@ -94,7 +94,7 @@ // * b // */ // function goo() { -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function goo(): string @@ -125,6 +125,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(): string\n```\n\n\n*@example* — if (true) {\n foo()\n}\n" + }, + "range": { + "start": { + "line": 6, + "character": 9 + }, + "end": { + "line": 6, + "character": 12 + } } } }, @@ -142,6 +152,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo2(): string\n```\n\n\n*@example* — {\n foo()\n}\n" + }, + "range": { + "start": { + "line": 15, + "character": 9 + }, + "end": { + "line": 15, + "character": 13 + } } } }, @@ -159,6 +179,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction moo(): string\n```\n\n\n*@example* — x y\n 12345\n b\n" + }, + "range": { + "start": { + "line": 24, + "character": 9 + }, + "end": { + "line": 24, + "character": 12 + } } } }, @@ -176,6 +206,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction boo(): string\n```\n\n\n*@func*\n\n*@example* — x y\n 12345\n b\n" + }, + "range": { + "start": { + "line": 34, + "character": 9 + }, + "end": { + "line": 34, + "character": 12 + } } } }, @@ -193,6 +233,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction goo(): string\n```\n\n\n*@func*\n\n*@example* — x y\n12345\n b\n" + }, + "range": { + "start": { + "line": 43, + "character": 9 + }, + "end": { + "line": 43, + "character": 12 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline index f119b73655..fbb8265ce2 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline @@ -1,7 +1,7 @@ // === QuickInfo === === /quickInfoForJSDocWithHttpLinks.js === // /** @typedef {number} https://wat */ -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type https = number @@ -12,7 +12,7 @@ // /** // * @typedef {Object} Oops // * @property {number} https://wass -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) https: number @@ -23,7 +23,7 @@ // // // /** @callback http://vad */ -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type http = () => any @@ -33,7 +33,7 @@ // // /** @see https://hvad */ // var see1 = true -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var see1: boolean @@ -45,24 +45,24 @@ // // /** @see {@link https://hva} */ // var see2 = true -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var see2: boolean // | ``` // | // | -// | *@see* — https://hva +// | *@see* — [https://hva](https://hva) // | ---------------------------------------------------------------------- // // /** {@link https://hvaD} */ // var see3 = true -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var see3: boolean // | ``` -// | https://hvaD +// | [https://hvaD](https://hvaD) // | ---------------------------------------------------------------------- [ { @@ -79,6 +79,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype https = number\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 22 + }, + "end": { + "line": 0, + "character": 27 + } } } }, @@ -96,6 +106,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) https: number\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 21 + }, + "end": { + "line": 4, + "character": 26 + } } } }, @@ -113,6 +133,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype http = () => any\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 14 + }, + "end": { + "line": 8, + "character": 18 + } } } }, @@ -130,6 +160,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar see1: boolean\n```\n\n\n*@see* `https` — ://hvad " + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 8 + } } } }, @@ -146,7 +186,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — https://hva " + "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — [https://hva](https://hva) " + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 8 + } } } }, @@ -163,7 +213,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see3: boolean\n```\nhttps://hvaD" + "value": "```tsx\nvar see3: boolean\n```\n[https://hvaD](https://hvaD)" + }, + "range": { + "start": { + "line": 17, + "character": 4 + }, + "end": { + "line": 17, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline index fcd61bd90e..7bb050551c 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline @@ -2,24 +2,24 @@ === /quickInfoForJSDocWithHttpLinks.js === // /** @see {@link https://hva} */ // var see2 = true -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var see2: boolean // | ``` // | // | -// | *@see* — https://hva +// | *@see* — [https://hva](https://hva) // | ---------------------------------------------------------------------- // // /** {@link https://hvaD} */ // var see3 = true -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var see3: boolean // | ``` -// | https://hvaD +// | [https://hvaD](https://hvaD) // | ---------------------------------------------------------------------- [ { @@ -35,7 +35,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — https://hva " + "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — [https://hva](https://hva) " + }, + "range": { + "start": { + "line": 1, + "character": 4 + }, + "end": { + "line": 1, + "character": 8 + } } } }, @@ -52,7 +62,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see3: boolean\n```\nhttps://hvaD" + "value": "```tsx\nvar see3: boolean\n```\n[https://hvaD](https://hvaD)" + }, + "range": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName03.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName03.baseline index 2a6a51a9be..0e0a6ea1c5 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName03.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName03.baseline @@ -9,7 +9,7 @@ // // function f({ foo }: Options) { // foo; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var foo: string @@ -32,6 +32,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar foo: string\n```\n" + }, + "range": { + "start": { + "line": 8, + "character": 4 + }, + "end": { + "line": 8, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName04.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName04.baseline index 96f0152680..926bfdf720 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName04.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName04.baseline @@ -14,7 +14,7 @@ // // function f({ a, a: { b } }: Options) { // a; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | var a: { b: string; } @@ -22,7 +22,7 @@ // | // | ---------------------------------------------------------------------- // b; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | var b: string @@ -45,6 +45,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: { b: string; }\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 5 + } } } }, @@ -62,6 +72,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar b: string\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 4 + }, + "end": { + "line": 14, + "character": 5 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName05.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName05.baseline index 26b721dc7a..8ba464b2a4 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName05.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName05.baseline @@ -12,7 +12,7 @@ // // function f({ a }: A | B) { // a; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | var a: string | number @@ -35,6 +35,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar a: string | number\n```\n" + }, + "range": { + "start": { + "line": 11, + "character": 4 + }, + "end": { + "line": 11, + "character": 5 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName06.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName06.baseline index 2abcbd5a35..71b808900c 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName06.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForObjectBindingElementName06.baseline @@ -18,7 +18,7 @@ // // const { isBaz: isBar } = f(); // isBar; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const isBar: boolean @@ -40,6 +40,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst isBar: boolean\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 0 + }, + "end": { + "line": 17, + "character": 5 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoImportMeta.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoImportMeta.baseline index d5ab03079f..83487e44ce 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoImportMeta.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoImportMeta.baseline @@ -7,7 +7,7 @@ // | ---------------------------------------------------------------------- // | No quickinfo at /*1*/. // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) ImportMetaExpression.meta: ImportMeta @@ -41,6 +41,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) ImportMetaExpression.meta: ImportMeta\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 0 + }, + "end": { + "line": 2, + "character": 11 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc.baseline index 3e962e1430..c490bd95dc 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc.baseline @@ -35,7 +35,7 @@ // * @param {{ tiger: string; lion: string; }} [mySpecificStuff] Description of my specific parameter. // */ // public static doSomethingUseful(mySpecificStuff?: { tiger: string; lion: string; }): string { -// ^ +// ^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) SubClass.doSomethingUseful(mySpecificStuff?: { tiger: string; lion: string; }): string @@ -60,7 +60,7 @@ // * @returns {void} SubClass.func1.returns // */ // public static func1(stuff1: any): void { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) SubClass.func1(stuff1: any): void @@ -83,7 +83,7 @@ // * text after tag // */ // public static readonly someProperty: string = 'specific to this class value' -// ^ +// ^^^^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) SubClass.someProperty: string @@ -109,6 +109,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) SubClass.doSomethingUseful(mySpecificStuff?: { tiger: string; lion: string; }): string\n```\n\n\n*@inheritDoc*\n\n*@param* `mySpecificStuff` — Description of my specific parameter.\n" + }, + "range": { + "start": { + "line": 34, + "character": 18 + }, + "end": { + "line": 34, + "character": 35 + } } } }, @@ -126,6 +136,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) SubClass.func1(stuff1: any): void\n```\n\n\n*@inheritDoc*\n\n*@param* `stuff1` — SubClass.func1.stuff1\n\n\n*@returns* — SubClass.func1.returns\n" + }, + "range": { + "start": { + "line": 47, + "character": 18 + }, + "end": { + "line": 47, + "character": 23 + } } } }, @@ -143,6 +163,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) SubClass.someProperty: string\n```\ntext over tag\n\n*@inheritDoc* — text after tag\n" + }, + "range": { + "start": { + "line": 55, + "character": 27 + }, + "end": { + "line": 55, + "character": 39 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc2.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc2.baseline index d29548d380..4e8510c723 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc2.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc2.baseline @@ -13,7 +13,7 @@ // * SubClass.prop // */ // prop: T | undefined; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) SubClass.prop: T @@ -39,6 +39,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) SubClass.prop: T\n```\n\n\n*@inheritdoc* — SubClass.prop\n" + }, + "range": { + "start": { + "line": 12, + "character": 4 + }, + "end": { + "line": 12, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc3.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc3.baseline index f76416b1da..47214ef747 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc3.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc3.baseline @@ -14,7 +14,7 @@ // * SubClass.prop // */ // prop: string | undefined; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) SubClass.prop: string @@ -40,6 +40,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) SubClass.prop: string\n```\n\n\n*@inheritdoc* — SubClass.prop\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 8 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc4.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc4.baseline index fa23158f8c..51c71f1fff 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc4.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc4.baseline @@ -7,7 +7,7 @@ // * @inheritdoc // */ // static value() { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) B.value(): any @@ -34,6 +34,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) B.value(): any\n```\n\n\n*@inheritdoc*" + }, + "range": { + "start": { + "line": 6, + "character": 11 + }, + "end": { + "line": 6, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc5.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc5.baseline index f86c973bda..9c9e2c5f9b 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc5.baseline @@ -7,7 +7,7 @@ // * @inheritdoc // */ // static value() { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) B.value(): any @@ -34,6 +34,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) B.value(): any\n```\n\n\n*@inheritdoc*" + }, + "range": { + "start": { + "line": 6, + "character": 11 + }, + "end": { + "line": 6, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc6.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc6.baseline index 9e651b20ea..6e2695e85c 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc6.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc6.baseline @@ -5,7 +5,7 @@ // * @inheritdoc // */ // static value() { -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) B.value(): any @@ -32,6 +32,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) B.value(): any\n```\n\n\n*@inheritdoc*" + }, + "range": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocAtBeforeSpace.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocAtBeforeSpace.baseline index 6bc22d3678..8b0b1fecbb 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocAtBeforeSpace.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocAtBeforeSpace.baseline @@ -59,6 +59,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f(): void\n```\n\n\n*@return* — Don't @ me\n" + }, + "range": { + "start": { + "line": 3, + "character": 9 + }, + "end": { + "line": 3, + "character": 10 + } } } }, @@ -76,6 +86,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction g(): void\n```\n\n\n*@return* — One final @\n" + }, + "range": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 10 + } } } }, @@ -93,6 +113,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction h(): void\n```\n\n\n*@return* — An @\nBut another line\n" + }, + "range": { + "start": { + "line": 12, + "character": 9 + }, + "end": { + "line": 12, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocTags.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocTags.baseline index cccda6068d..61621b6159 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocTags.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJSDocTags.baseline @@ -50,7 +50,7 @@ // newMethod() {} // } // var foo = new Foo(4); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | constructor Foo(value: number): Foo @@ -65,7 +65,7 @@ // | No quickinfo at /*10*/. // | ---------------------------------------------------------------------- // Foo.method1(); -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | class Foo @@ -75,7 +75,7 @@ // | *@mytag* — comment1 comment2 // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Foo.method1(): void @@ -90,7 +90,7 @@ // | No quickinfo at /*11*/. // | ---------------------------------------------------------------------- // foo.method2(); -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Foo.method2(): void @@ -104,7 +104,7 @@ // | No quickinfo at /*12*/. // | ---------------------------------------------------------------------- // foo.method3(); -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Foo.method3(): number @@ -119,7 +119,7 @@ // | No quickinfo at /*13*/. // | ---------------------------------------------------------------------- // foo.method4(); -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Foo.method4(foo: string): number @@ -135,7 +135,7 @@ // | *@mytag* // | ---------------------------------------------------------------------- // foo.property1; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Foo.property1: string @@ -146,7 +146,7 @@ // | // | ---------------------------------------------------------------------- // foo.property2; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Foo.property2: number @@ -165,7 +165,7 @@ // | *@mytag* // | ---------------------------------------------------------------------- // foo.method5(); -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Foo.method5(): void @@ -194,6 +194,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconstructor Foo(value: number): Foo\n```\nThis is the constructor.\n\n*@myjsdoctag* — this is a comment\n" + }, + "range": { + "start": { + "line": 49, + "character": 14 + }, + "end": { + "line": 49, + "character": 17 + } } } }, @@ -223,6 +233,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass Foo\n```\nThis is class Foo.\n\n*@mytag* — comment1 comment2\n" + }, + "range": { + "start": { + "line": 50, + "character": 0 + }, + "end": { + "line": 50, + "character": 3 + } } } }, @@ -240,6 +260,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Foo.method1(): void\n```\nmethod1 documentation\n\n*@mytag* — comment1 comment2\n" + }, + "range": { + "start": { + "line": 50, + "character": 4 + }, + "end": { + "line": 50, + "character": 11 + } } } }, @@ -269,6 +299,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Foo.method2(): void\n```\n\n\n*@mytag*" + }, + "range": { + "start": { + "line": 51, + "character": 4 + }, + "end": { + "line": 51, + "character": 11 + } } } }, @@ -298,6 +338,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Foo.method3(): number\n```\n\n\n*@returns* — a value\n" + }, + "range": { + "start": { + "line": 52, + "character": 4 + }, + "end": { + "line": 52, + "character": 11 + } } } }, @@ -327,6 +377,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Foo.method4(foo: string): number\n```\n\n\n*@param* `foo` — A value.\n\n\n*@returns* — Another value\n\n\n*@mytag*" + }, + "range": { + "start": { + "line": 53, + "character": 4 + }, + "end": { + "line": 53, + "character": 11 + } } } }, @@ -344,6 +404,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) Foo.property1: string\n```\n\n\n*@mytag* — comment1 comment2\n" + }, + "range": { + "start": { + "line": 54, + "character": 4 + }, + "end": { + "line": 54, + "character": 13 + } } } }, @@ -361,6 +431,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) Foo.property2: number\n```\n\n\n*@mytag1* — some comments\nsome more comments about mytag1\n\n\n*@mytag2* — here all the comments are on a new line\n\n\n*@mytag3*\n\n*@mytag*" + }, + "range": { + "start": { + "line": 55, + "character": 4 + }, + "end": { + "line": 55, + "character": 13 + } } } }, @@ -378,6 +458,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Foo.method5(): void\n```\n\n\n*@mytag*" + }, + "range": { + "start": { + "line": 56, + "character": 4 + }, + "end": { + "line": 56, + "character": 11 + } } } }, diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDoc.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDoc.baseline index 9b7306bd60..26419cae89 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDoc.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDoc.baseline @@ -39,7 +39,7 @@ // // get a() { // this.field; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) C.field: string @@ -49,7 +49,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // this.getter; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) C.getter: void @@ -59,7 +59,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // this.m; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.m(): void @@ -69,7 +69,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // foo; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var foo: string @@ -79,7 +79,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // C/; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | class C @@ -99,7 +99,7 @@ // // set a(value: number) { // this.field; -// ^ +// ^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) C.field: string @@ -109,7 +109,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // this.getter; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (accessor) C.getter: void @@ -119,7 +119,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // this.m; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.m(): void @@ -129,7 +129,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // foo; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | var foo: string @@ -139,7 +139,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // C; -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | class C @@ -149,7 +149,7 @@ // | *@deprecated* // | ---------------------------------------------------------------------- // fn(); -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function fn(): void @@ -175,6 +175,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) C.field: string\n```\nA field\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 38, + "character": 13 + }, + "end": { + "line": 38, + "character": 18 + } } } }, @@ -192,6 +202,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) C.getter: void\n```\nA getter\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 39, + "character": 13 + }, + "end": { + "line": 39, + "character": 19 + } } } }, @@ -209,6 +229,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.m(): void\n```\nA method\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 40, + "character": 13 + }, + "end": { + "line": 40, + "character": 14 + } } } }, @@ -226,6 +256,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar foo: string\n```\nA constant\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 41, + "character": 8 + }, + "end": { + "line": 41, + "character": 11 + } } } }, @@ -243,6 +283,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass C\n```\nA class\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 42, + "character": 8 + }, + "end": { + "line": 42, + "character": 9 + } } } }, @@ -272,6 +322,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) C.field: string\n```\nA field\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 49, + "character": 13 + }, + "end": { + "line": 49, + "character": 18 + } } } }, @@ -289,6 +349,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) C.getter: void\n```\nA getter\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 50, + "character": 13 + }, + "end": { + "line": 50, + "character": 19 + } } } }, @@ -306,6 +376,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.m(): void\n```\nA method\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 51, + "character": 13 + }, + "end": { + "line": 51, + "character": 14 + } } } }, @@ -323,6 +403,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar foo: string\n```\nA constant\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 52, + "character": 8 + }, + "end": { + "line": 52, + "character": 11 + } } } }, @@ -340,6 +430,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nclass C\n```\nA class\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 53, + "character": 8 + }, + "end": { + "line": 53, + "character": 9 + } } } }, @@ -357,6 +457,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction fn(): void\n```\nA function\n\n*@deprecated*" + }, + "range": { + "start": { + "line": 54, + "character": 8 + }, + "end": { + "line": 54, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocGetterSetter.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocGetterSetter.baseline index ebcd3ed5b1..b27e42bf2e 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocGetterSetter.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocGetterSetter.baseline @@ -149,6 +149,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) A.x: string\n```\ngetter A\n\n*@returns* — return A\n" + }, + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 9 + } } } }, @@ -166,6 +176,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) A.x: string\n```\ngetter A\n\n*@returns* — return A\n" + }, + "range": { + "start": { + "line": 13, + "character": 8 + }, + "end": { + "line": 13, + "character": 9 + } } } }, @@ -183,6 +203,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) B.x: string\n```\ngetter B\n\n*@returns* — return B\n" + }, + "range": { + "start": { + "line": 21, + "character": 8 + }, + "end": { + "line": 21, + "character": 9 + } } } }, @@ -200,6 +230,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) B.x: string\n```\ngetter B\n\n*@returns* — return B\n" + }, + "range": { + "start": { + "line": 28, + "character": 8 + }, + "end": { + "line": 28, + "character": 9 + } } } }, @@ -217,6 +257,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) D.x: string\n```\nsetter D\n\n*@param* `value` — foo D\n" + }, + "range": { + "start": { + "line": 38, + "character": 8 + }, + "end": { + "line": 38, + "character": 9 + } } } }, @@ -234,6 +284,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) A.x: string\n```\ngetter A\n\n*@returns* — return A\n" + }, + "range": { + "start": { + "line": 40, + "character": 8 + }, + "end": { + "line": 40, + "character": 9 + } } } }, @@ -251,6 +311,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) B.x: string\n```\ngetter B\n\n*@returns* — return B\n" + }, + "range": { + "start": { + "line": 41, + "character": 8 + }, + "end": { + "line": 41, + "character": 9 + } } } }, @@ -268,6 +338,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) A.x: string\n```\ngetter A\n\n*@returns* — return A\n" + }, + "range": { + "start": { + "line": 42, + "character": 8 + }, + "end": { + "line": 42, + "character": 9 + } } } }, @@ -285,6 +365,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(accessor) D.x: string\n```\nsetter D\n\n*@param* `value` — foo D\n" + }, + "range": { + "start": { + "line": 43, + "character": 8 + }, + "end": { + "line": 43, + "character": 9 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocInheritage.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocInheritage.baseline index cea936d462..4e62ce9359 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocInheritage.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocInheritage.baseline @@ -26,7 +26,7 @@ // // method for function signature // class C implements A, B { // foo1: number = 1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) C.foo1: number @@ -34,7 +34,7 @@ // | // | ---------------------------------------------------------------------- // foo2(q: string) { return 1 } -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.foo2(q: string): number @@ -47,7 +47,7 @@ // // property for function signature // class D implements A, B { // foo1: number = 1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) D.foo1: number @@ -55,7 +55,7 @@ // | // | ---------------------------------------------------------------------- // foo2 = (q: string) => { return 1 } -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) D.foo2: (q: string) => number @@ -65,7 +65,7 @@ // } // // new C().foo1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) C.foo1: number @@ -73,7 +73,7 @@ // | // | ---------------------------------------------------------------------- // new C().foo2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.foo2(q: string): number @@ -81,7 +81,7 @@ // | // | ---------------------------------------------------------------------- // new D().foo1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) D.foo1: number @@ -89,7 +89,7 @@ // | // | ---------------------------------------------------------------------- // new D().foo2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) D.foo2: (q: string) => number @@ -115,20 +115,29 @@ // // property override method // class Drived1 extends Base1 implements A { // foo1: number = 1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived1.foo1: number // | ``` // | +// | +// | *@description* — Base1.foo1 +// | // | ---------------------------------------------------------------------- // foo2(para1: string) { return 1 }; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Drived1.foo2(para1: string): number // | ``` // | +// | +// | *@param* `q` — Base1.foo2 parameter +// | +// | +// | *@returns* — Base1.foo2 return +// | // | ---------------------------------------------------------------------- // } // @@ -136,20 +145,29 @@ // // method override method // class Drived2 extends Base1 implements B { // foo1: number = 1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived2.foo1: number // | ``` // | +// | +// | *@description* — Base1.foo1 +// | // | ---------------------------------------------------------------------- // foo2 = (para1: string) => { return 1; }; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived2.foo2: (para1: string) => number // | ``` // | +// | +// | *@param* `q` — Base1.foo2 parameter +// | +// | +// | *@returns* — Base1.foo2 return +// | // | ---------------------------------------------------------------------- // } // @@ -170,20 +188,29 @@ // // property override method // class Drived3 extends Base2 implements A { // foo1: number = 1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived3.foo1: number // | ``` // | +// | +// | *@description* — Base2.foo1 +// | // | ---------------------------------------------------------------------- // foo2(para1: string) { return 1 }; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Drived3.foo2(para1: string): number // | ``` // | +// | +// | *@param* `q` — Base2.foo2 parameter +// | +// | +// | *@returns* — Base2.foo2 return +// | // | ---------------------------------------------------------------------- // } // @@ -191,86 +218,131 @@ // // method override method // class Drived4 extends Base2 implements B { // foo1: number = 1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived4.foo1: number // | ``` // | +// | +// | *@description* — Base2.foo1 +// | // | ---------------------------------------------------------------------- // foo2 = (para1: string) => { return 1; }; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived4.foo2: (para1: string) => number // | ``` // | +// | +// | *@param* `q` — Base2.foo2 parameter +// | +// | +// | *@returns* — Base2.foo2 return +// | // | ---------------------------------------------------------------------- // } // // new Drived1().foo1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived1.foo1: number // | ``` // | +// | +// | *@description* — Base1.foo1 +// | // | ---------------------------------------------------------------------- // new Drived1().foo2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Drived1.foo2(para1: string): number // | ``` // | +// | +// | *@param* `q` — Base1.foo2 parameter +// | +// | +// | *@returns* — Base1.foo2 return +// | // | ---------------------------------------------------------------------- // new Drived2().foo1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived2.foo1: number // | ``` // | +// | +// | *@description* — Base1.foo1 +// | // | ---------------------------------------------------------------------- // new Drived2().foo2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived2.foo2: (para1: string) => number // | ``` // | +// | +// | *@param* `q` — Base1.foo2 parameter +// | +// | +// | *@returns* — Base1.foo2 return +// | // | ---------------------------------------------------------------------- // new Drived3().foo1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived3.foo1: number // | ``` // | +// | +// | *@description* — Base2.foo1 +// | // | ---------------------------------------------------------------------- // new Drived3().foo2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Drived3.foo2(para1: string): number // | ``` // | +// | +// | *@param* `q` — Base2.foo2 parameter +// | +// | +// | *@returns* — Base2.foo2 return +// | // | ---------------------------------------------------------------------- // new Drived4().foo1; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived4.foo1: number // | ``` // | +// | +// | *@description* — Base2.foo1 +// | // | ---------------------------------------------------------------------- // new Drived4().foo2; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Drived4.foo2: (para1: string) => number // | ``` // | +// | +// | *@param* `q` — Base2.foo2 parameter +// | +// | +// | *@returns* — Base2.foo2 return +// | // | ---------------------------------------------------------------------- [ { @@ -287,6 +359,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) C.foo1: number\n```\n" + }, + "range": { + "start": { + "line": 25, + "character": 4 + }, + "end": { + "line": 25, + "character": 8 + } } } }, @@ -304,6 +386,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.foo2(q: string): number\n```\n" + }, + "range": { + "start": { + "line": 26, + "character": 4 + }, + "end": { + "line": 26, + "character": 8 + } } } }, @@ -321,6 +413,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) D.foo1: number\n```\n" + }, + "range": { + "start": { + "line": 32, + "character": 4 + }, + "end": { + "line": 32, + "character": 8 + } } } }, @@ -338,6 +440,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) D.foo2: (q: string) => number\n```\n" + }, + "range": { + "start": { + "line": 33, + "character": 4 + }, + "end": { + "line": 33, + "character": 8 + } } } }, @@ -355,6 +467,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) C.foo1: number\n```\n" + }, + "range": { + "start": { + "line": 36, + "character": 8 + }, + "end": { + "line": 36, + "character": 12 + } } } }, @@ -372,6 +494,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) C.foo2(q: string): number\n```\n" + }, + "range": { + "start": { + "line": 37, + "character": 8 + }, + "end": { + "line": 37, + "character": 12 + } } } }, @@ -389,6 +521,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) D.foo1: number\n```\n" + }, + "range": { + "start": { + "line": 38, + "character": 8 + }, + "end": { + "line": 38, + "character": 12 + } } } }, @@ -406,6 +548,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) D.foo2: (q: string) => number\n```\n" + }, + "range": { + "start": { + "line": 39, + "character": 8 + }, + "end": { + "line": 39, + "character": 12 + } } } }, @@ -422,7 +574,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived1.foo1: number\n```\n" + "value": "```tsx\n(property) Drived1.foo1: number\n```\n\n\n*@description* — Base1.foo1 \n" + }, + "range": { + "start": { + "line": 58, + "character": 4 + }, + "end": { + "line": 58, + "character": 8 + } } } }, @@ -439,7 +601,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) Drived1.foo2(para1: string): number\n```\n" + "value": "```tsx\n(method) Drived1.foo2(para1: string): number\n```\n\n\n*@param* `q` — Base1.foo2 parameter\n\n\n*@returns* — Base1.foo2 return\n" + }, + "range": { + "start": { + "line": 59, + "character": 4 + }, + "end": { + "line": 59, + "character": 8 + } } } }, @@ -456,7 +628,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived2.foo1: number\n```\n" + "value": "```tsx\n(property) Drived2.foo1: number\n```\n\n\n*@description* — Base1.foo1 \n" + }, + "range": { + "start": { + "line": 65, + "character": 4 + }, + "end": { + "line": 65, + "character": 8 + } } } }, @@ -473,7 +655,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived2.foo2: (para1: string) => number\n```\n" + "value": "```tsx\n(property) Drived2.foo2: (para1: string) => number\n```\n\n\n*@param* `q` — Base1.foo2 parameter\n\n\n*@returns* — Base1.foo2 return\n" + }, + "range": { + "start": { + "line": 66, + "character": 4 + }, + "end": { + "line": 66, + "character": 8 + } } } }, @@ -490,7 +682,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived3.foo1: number\n```\n" + "value": "```tsx\n(property) Drived3.foo1: number\n```\n\n\n*@description* — Base2.foo1 \n" + }, + "range": { + "start": { + "line": 85, + "character": 4 + }, + "end": { + "line": 85, + "character": 8 + } } } }, @@ -507,7 +709,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) Drived3.foo2(para1: string): number\n```\n" + "value": "```tsx\n(method) Drived3.foo2(para1: string): number\n```\n\n\n*@param* `q` — Base2.foo2 parameter\n\n\n*@returns* — Base2.foo2 return\n" + }, + "range": { + "start": { + "line": 86, + "character": 4 + }, + "end": { + "line": 86, + "character": 8 + } } } }, @@ -524,7 +736,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived4.foo1: number\n```\n" + "value": "```tsx\n(property) Drived4.foo1: number\n```\n\n\n*@description* — Base2.foo1 \n" + }, + "range": { + "start": { + "line": 92, + "character": 4 + }, + "end": { + "line": 92, + "character": 8 + } } } }, @@ -541,7 +763,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived4.foo2: (para1: string) => number\n```\n" + "value": "```tsx\n(property) Drived4.foo2: (para1: string) => number\n```\n\n\n*@param* `q` — Base2.foo2 parameter\n\n\n*@returns* — Base2.foo2 return\n" + }, + "range": { + "start": { + "line": 93, + "character": 4 + }, + "end": { + "line": 93, + "character": 8 + } } } }, @@ -558,7 +790,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived1.foo1: number\n```\n" + "value": "```tsx\n(property) Drived1.foo1: number\n```\n\n\n*@description* — Base1.foo1 \n" + }, + "range": { + "start": { + "line": 96, + "character": 14 + }, + "end": { + "line": 96, + "character": 18 + } } } }, @@ -575,7 +817,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) Drived1.foo2(para1: string): number\n```\n" + "value": "```tsx\n(method) Drived1.foo2(para1: string): number\n```\n\n\n*@param* `q` — Base1.foo2 parameter\n\n\n*@returns* — Base1.foo2 return\n" + }, + "range": { + "start": { + "line": 97, + "character": 14 + }, + "end": { + "line": 97, + "character": 18 + } } } }, @@ -592,7 +844,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived2.foo1: number\n```\n" + "value": "```tsx\n(property) Drived2.foo1: number\n```\n\n\n*@description* — Base1.foo1 \n" + }, + "range": { + "start": { + "line": 98, + "character": 14 + }, + "end": { + "line": 98, + "character": 18 + } } } }, @@ -609,7 +871,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived2.foo2: (para1: string) => number\n```\n" + "value": "```tsx\n(property) Drived2.foo2: (para1: string) => number\n```\n\n\n*@param* `q` — Base1.foo2 parameter\n\n\n*@returns* — Base1.foo2 return\n" + }, + "range": { + "start": { + "line": 99, + "character": 14 + }, + "end": { + "line": 99, + "character": 18 + } } } }, @@ -626,7 +898,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived3.foo1: number\n```\n" + "value": "```tsx\n(property) Drived3.foo1: number\n```\n\n\n*@description* — Base2.foo1 \n" + }, + "range": { + "start": { + "line": 100, + "character": 14 + }, + "end": { + "line": 100, + "character": 18 + } } } }, @@ -643,7 +925,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) Drived3.foo2(para1: string): number\n```\n" + "value": "```tsx\n(method) Drived3.foo2(para1: string): number\n```\n\n\n*@param* `q` — Base2.foo2 parameter\n\n\n*@returns* — Base2.foo2 return\n" + }, + "range": { + "start": { + "line": 101, + "character": 14 + }, + "end": { + "line": 101, + "character": 18 + } } } }, @@ -660,7 +952,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived4.foo1: number\n```\n" + "value": "```tsx\n(property) Drived4.foo1: number\n```\n\n\n*@description* — Base2.foo1 \n" + }, + "range": { + "start": { + "line": 102, + "character": 14 + }, + "end": { + "line": 102, + "character": 18 + } } } }, @@ -677,7 +979,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) Drived4.foo2: (para1: string) => number\n```\n" + "value": "```tsx\n(property) Drived4.foo2: (para1: string) => number\n```\n\n\n*@param* `q` — Base2.foo2 parameter\n\n\n*@returns* — Base2.foo2 return\n" + }, + "range": { + "start": { + "line": 103, + "character": 14 + }, + "end": { + "line": 103, + "character": 18 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags1.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags1.baseline index 4c6b2c784b..bd24b08def 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags1.baseline @@ -13,7 +13,7 @@ // * @see x (the parameter) // */ // function foo(x) {} -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(x: any): void @@ -35,6 +35,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction foo(x: any): void\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 9 + }, + "end": { + "line": 12, + "character": 12 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags10.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags10.baseline index dc3bfddfdc..ba57a2ddeb 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags10.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags10.baseline @@ -6,7 +6,7 @@ // * @template T1,T2 Comment Text // */ // const foo = (a, b) => {}; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const foo: (a: T1, b: any) => void @@ -35,6 +35,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst foo: (a: T1, b: any) => void\n```\n\n\n*@param* `a`\n\n*@param* `a`\n\n*@template* `T1`, `T2` — Comment Text\n" + }, + "range": { + "start": { + "line": 5, + "character": 6 + }, + "end": { + "line": 5, + "character": 9 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags11.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags11.baseline index 560ff899d5..5bded65551 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags11.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags11.baseline @@ -7,7 +7,7 @@ // * @template {number} T2 Comment T2 // */ // const foo = (a, b) => {}; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const foo: (a: T1, b: T2) => void @@ -39,6 +39,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst foo: (a: T1, b: T2) => void\n```\n\n\n*@param* `a`\n\n*@param* `b`\n\n*@template* `T1` — Comment T1\n\n\n*@template* `T2` — Comment T2\n" + }, + "range": { + "start": { + "line": 6, + "character": 6 + }, + "end": { + "line": 6, + "character": 9 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags12.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags12.baseline index 8dd86acbc7..64f140eeab 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags12.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags12.baseline @@ -39,6 +39,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f(options: any, callback?: any): void\n```\n\n\n*@param* `options` — the args object\n\n\n*@param* `callback` — the callback function\n\n\n*@returns*" + }, + "range": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags14.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags14.baseline index 2fe294b332..c47cb3065f 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags14.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags14.baseline @@ -10,7 +10,7 @@ // * @returns {number} // */ // function fn(options, callback = null) { } -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | function fn(options: any, callback?: any): void @@ -40,6 +40,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction fn(options: any, callback?: any): void\n```\n\n\n*@param* `options` — the args object\n\n\n*@param* `callback` — the callback function\n\n\n*@returns*" + }, + "range": { + "start": { + "line": 9, + "character": 9 + }, + "end": { + "line": 9, + "character": 11 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags15.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags15.baseline index e961f604eb..7d27be220b 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags15.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags15.baseline @@ -3,7 +3,7 @@ // import * as _a from "./a.js"; // /** // * @implements {_a.Foo} -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type Foo = { getName: _a.Bar; } @@ -15,7 +15,7 @@ // // /** // * @extends {_a.Foo} -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type Foo = { getName: _a.Bar; } @@ -27,7 +27,7 @@ // // /** // * @augments {_a.Foo} -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type Foo = { getName: _a.Bar; } @@ -51,6 +51,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype Foo = { getName: _a.Bar; }\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 19 + }, + "end": { + "line": 2, + "character": 22 + } } } }, @@ -68,6 +78,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype Foo = { getName: _a.Bar; }\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 16 + }, + "end": { + "line": 7, + "character": 19 + } } } }, @@ -85,6 +105,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype Foo = { getName: _a.Bar; }\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 17 + }, + "end": { + "line": 12, + "character": 20 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags16.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags16.baseline index b6c858ac2a..e47770a431 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags16.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags16.baseline @@ -11,23 +11,27 @@ // // class B extends A { // override foo() { } -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) B.foo(): void // | ``` +// | Description text here. // | +// | *@virtual* // | ---------------------------------------------------------------------- // } // // class C extends B { // override foo() { } -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) C.foo(): void // | ``` +// | Description text here. // | +// | *@virtual* // | ---------------------------------------------------------------------- // } [ @@ -44,7 +48,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) B.foo(): void\n```\n" + "value": "```tsx\n(method) B.foo(): void\n```\nDescription text here.\n\n*@virtual*" + }, + "range": { + "start": { + "line": 10, + "character": 13 + }, + "end": { + "line": 10, + "character": 16 + } } } }, @@ -61,7 +75,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) C.foo(): void\n```\n" + "value": "```tsx\n(method) C.foo(): void\n```\nDescription text here.\n\n*@virtual*" + }, + "range": { + "start": { + "line": 14, + "character": 13 + }, + "end": { + "line": 14, + "character": 16 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags3.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags3.baseline index 63802eb7be..8543b36c5a 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags3.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags3.baseline @@ -14,7 +14,7 @@ // // class Bar implements Foo { // method(): void { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Bar.method(): void @@ -39,6 +39,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Bar.method(): void\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 4 + }, + "end": { + "line": 13, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags4.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags4.baseline index eff3013da0..64e87ec6b8 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags4.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags4.baseline @@ -16,11 +16,26 @@ // // class Bar extends Foo { // method(x: number, y: number): number { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Bar.method(x: number, y: number): number // | ``` +// | comment +// | +// | *@author* — Me +// | +// | +// | *@see* `x` — (the parameter) +// | +// | +// | *@param* `x` - x comment +// | +// | +// | *@param* `y` - y comment +// | +// | +// | *@returns* — The result // | // | ---------------------------------------------------------------------- // const res = super.method(x, y) + 100; @@ -41,7 +56,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) Bar.method(x: number, y: number): number\n```\n" + "value": "```tsx\n(method) Bar.method(x: number, y: number): number\n```\ncomment\n\n*@author* — Me \n\n\n*@see* `x` — (the parameter)\n\n\n*@param* `x` - x comment\n\n\n*@param* `y` - y comment\n\n\n*@returns* — The result\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags5.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags5.baseline index dfba523d41..383e41d30a 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags5.baseline @@ -16,11 +16,26 @@ // // class Bar extends Foo { // method(x, y) { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Bar.method(x: any, y: any): number // | ``` +// | comment +// | +// | *@author* — Me +// | +// | +// | *@see* `x` — (the parameter) +// | +// | +// | *@param* `x` - x comment +// | +// | +// | *@param* `y` - y comment +// | +// | +// | *@returns* — The result // | // | ---------------------------------------------------------------------- // const res = super.method(x, y) + 100; @@ -41,7 +56,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) Bar.method(x: any, y: any): number\n```\n" + "value": "```tsx\n(method) Bar.method(x: any, y: any): number\n```\ncomment\n\n*@author* — Me \n\n\n*@see* `x` — (the parameter)\n\n\n*@param* `x` - x comment\n\n\n*@param* `y` - y comment\n\n\n*@returns* — The result\n" + }, + "range": { + "start": { + "line": 15, + "character": 4 + }, + "end": { + "line": 15, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags6.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags6.baseline index 98f1da3ac5..63fb95c127 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags6.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags6.baseline @@ -17,7 +17,7 @@ // class Bar extends Foo { // /** @inheritDoc */ // method(x, y) { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (method) Bar.method(x: any, y: any): number @@ -45,6 +45,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(method) Bar.method(x: any, y: any): number\n```\n\n\n*@inheritDoc*" + }, + "range": { + "start": { + "line": 16, + "character": 4 + }, + "end": { + "line": 16, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags7.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags7.baseline index 5e563c6730..d78603cd65 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags7.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags7.baseline @@ -9,7 +9,7 @@ // * @template T // */ // const foo = t => t.y; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const foo: (t: T) => number @@ -33,6 +33,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst foo: (t: T) => number\n```\n\n\n*@template* `T`" + }, + "range": { + "start": { + "line": 8, + "character": 6 + }, + "end": { + "line": 8, + "character": 9 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags8.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags8.baseline index a14cc55397..f778578cff 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags8.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags8.baseline @@ -9,7 +9,7 @@ // * @template {Foo} T // */ // const foo = t => t.y; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const foo: (t: T) => number @@ -33,6 +33,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst foo: (t: T) => number\n```\n\n\n*@template* `T`" + }, + "range": { + "start": { + "line": 8, + "character": 6 + }, + "end": { + "line": 8, + "character": 9 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags9.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags9.baseline index 5f0f6ba7ea..568d8acf22 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags9.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTags9.baseline @@ -9,7 +9,7 @@ // * @template {Foo} T Comment Text // */ // const foo = t => t.y; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const foo: (t: T) => number @@ -34,6 +34,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst foo: (t: T) => number\n```\n\n\n*@template* `T` — Comment Text\n" + }, + "range": { + "start": { + "line": 8, + "character": 6 + }, + "end": { + "line": 8, + "character": 9 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsCallback.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsCallback.baseline index 5678302b53..9d24adc4e0 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsCallback.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsCallback.baseline @@ -2,7 +2,7 @@ === /quickInfoJsDocTagsCallback.js === // /** // * @callback cb -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | type cb = (x: string) => any @@ -14,7 +14,7 @@ // // /** // * @param {cb} bar -callback comment -// ^ +// ^^ // | ---------------------------------------------------------------------- // | ```tsx // | type cb = (x: string) => any @@ -40,6 +40,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype cb = (x: string) => any\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 13 + }, + "end": { + "line": 1, + "character": 15 + } } } }, @@ -57,6 +67,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype cb = (x: string) => any\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 11 + }, + "end": { + "line": 6, + "character": 13 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload01.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload01.baseline index a3a2dce10d..4a272576b6 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload01.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload01.baseline @@ -4,11 +4,10 @@ // * Doc foo // */ // declare function foo(): void; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void -// | function foo(x: number): void // | ``` // | Doc foo // | ---------------------------------------------------------------------- @@ -18,13 +17,15 @@ // * @tag Tag text // */ // declare function foo(x: number): void -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foo(): void // | function foo(x: number): void // | ``` -// | Doc foo +// | Doc foo overloaded +// | +// | *@tag* — Tag text +// | // | ---------------------------------------------------------------------- [ { @@ -40,7 +41,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): void\nfunction foo(x: number): void\n```\nDoc foo" + "value": "```tsx\nfunction foo(): void\n```\nDoc foo" + }, + "range": { + "start": { + "line": 3, + "character": 17 + }, + "end": { + "line": 3, + "character": 20 + } } } }, @@ -57,7 +68,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): void\nfunction foo(x: number): void\n```\nDoc foo" + "value": "```tsx\nfunction foo(x: number): void\n```\nDoc foo overloaded\n\n*@tag* — Tag text\n" + }, + "range": { + "start": { + "line": 9, + "character": 17 + }, + "end": { + "line": 9, + "character": 20 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload03.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload03.baseline index 2e07a08600..530d7887a4 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload03.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload03.baseline @@ -1,11 +1,10 @@ // === QuickInfo === === /quickInfoJsDocTagsFunctionOverload03.ts === // declare function foo(): void; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void -// | function foo(x: number): void // | ``` // | // | ---------------------------------------------------------------------- @@ -15,12 +14,14 @@ // * @tag Tag text // */ // declare function foo(x: number): void -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foo(): void // | function foo(x: number): void // | ``` +// | Doc foo overloaded +// | +// | *@tag* — Tag text // | // | ---------------------------------------------------------------------- [ @@ -37,7 +38,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): void\nfunction foo(x: number): void\n```\n" + "value": "```tsx\nfunction foo(): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 20 + } } } }, @@ -54,7 +65,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): void\nfunction foo(x: number): void\n```\n" + "value": "```tsx\nfunction foo(x: number): void\n```\nDoc foo overloaded\n\n*@tag* — Tag text\n" + }, + "range": { + "start": { + "line": 6, + "character": 17 + }, + "end": { + "line": 6, + "character": 20 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload05.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload05.baseline index 3901bb9548..7ffcd11adc 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload05.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsFunctionOverload05.baseline @@ -1,11 +1,10 @@ // === QuickInfo === === /quickInfoJsDocTagsFunctionOverload05.ts === // declare function foo(): void; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | function foo(): void -// | function foo(x: number): void // | ``` // | // | ---------------------------------------------------------------------- @@ -14,13 +13,15 @@ // * @tag Tag text // */ // declare function foo(x: number): void -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx -// | function foo(): void // | function foo(x: number): void // | ``` // | +// | +// | *@tag* — Tag text +// | // | ---------------------------------------------------------------------- [ { @@ -36,7 +37,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): void\nfunction foo(x: number): void\n```\n" + "value": "```tsx\nfunction foo(): void\n```\n" + }, + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 20 + } } } }, @@ -53,7 +64,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction foo(): void\nfunction foo(x: number): void\n```\n" + "value": "```tsx\nfunction foo(x: number): void\n```\n\n\n*@tag* — Tag text\n" + }, + "range": { + "start": { + "line": 5, + "character": 17 + }, + "end": { + "line": 5, + "character": 20 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline index b42648cf6d..05bd1f6763 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline @@ -3,7 +3,7 @@ // /** // * Bar comment // * @typedef {Object} Bar -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type Bar = { baz: string; qux: string; } @@ -17,7 +17,7 @@ // /** // * foo comment // * @param {Bar} x - x comment -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | type Bar = { baz: string; qux: string; } @@ -44,6 +44,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype Bar = { baz: string; qux: string; }\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 21 + }, + "end": { + "line": 2, + "character": 24 + } } } }, @@ -61,6 +71,16 @@ "contents": { "kind": "markdown", "value": "```tsx\ntype Bar = { baz: string; qux: string; }\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 11 + }, + "end": { + "line": 9, + "character": 14 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocThisTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocThisTag.baseline index f0e4e4aa86..84ef16c621 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocThisTag.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocThisTag.baseline @@ -2,7 +2,7 @@ === /a.ts === // /** @this {number} */ // function f() { -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | function f(): void @@ -28,6 +28,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f(): void\n```\n\n\n*@this*" + }, + "range": { + "start": { + "line": 1, + "character": 9 + }, + "end": { + "line": 1, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline index 9436eebded..eeedf34a77 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline @@ -9,7 +9,7 @@ // | ```tsx // | const a: () => number // | ``` -// | start https://vscode.dev/ | end +// | start [end](https://vscode.dev/) // | ---------------------------------------------------------------------- [ { @@ -25,7 +25,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst a: () => number\n```\nstart https://vscode.dev/ | end" + "value": "```tsx\nconst a: () => number\n```\nstart [end](https://vscode.dev/)" + }, + "range": { + "start": { + "line": 3, + "character": 6 + }, + "end": { + "line": 3, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline index 50655f184b..970f6fc772 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline @@ -14,10 +14,10 @@ // | ```tsx // | function f(): void // | ``` -// | https://vscode.dev +// | [https://vscode.dev](https://vscode.dev) // | [link text]{https://vscode.dev} -// | https://vscode.dev|link text -// | https://vscode.dev link text +// | [link text](https://vscode.dev) +// | [link text](https://vscode.dev) // | ---------------------------------------------------------------------- [ { @@ -33,7 +33,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction f(): void\n```\nhttps://vscode.dev\n[link text]{https://vscode.dev}\nhttps://vscode.dev|link text\nhttps://vscode.dev link text" + "value": "```tsx\nfunction f(): void\n```\n[https://vscode.dev](https://vscode.dev)\n[link text]{https://vscode.dev}\n[link text](https://vscode.dev)\n[link text](https://vscode.dev)" + }, + "range": { + "start": { + "line": 8, + "character": 0 + }, + "end": { + "line": 8, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline index 6064786e91..0d5b1aff12 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline @@ -10,7 +10,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See A| constant A instead +// | See [constant A](file:///quickInfoLink5.ts#1,7-1,8) instead // | ---------------------------------------------------------------------- [ { @@ -26,7 +26,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee A| constant A instead" + "value": "```tsx\nconst B: 456\n```\nSee [constant A](file:///quickInfoLink5.ts#1,7-1,8) instead" + }, + "range": { + "start": { + "line": 4, + "character": 6 + }, + "end": { + "line": 4, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline index 44aee68e6e..6148214554 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline @@ -10,7 +10,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See A|constant A instead +// | See [constant A](file:///quickInfoLink6.ts#1,7-1,8) instead // | ---------------------------------------------------------------------- [ { @@ -26,7 +26,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee A|constant A instead" + "value": "```tsx\nconst B: 456\n```\nSee [constant A](file:///quickInfoLink6.ts#1,7-1,8) instead" + }, + "range": { + "start": { + "line": 4, + "character": 6 + }, + "end": { + "line": 4, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline index 72b2cb44ce..0d639bf361 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline @@ -9,7 +9,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See | instead +// | See | instead // | ---------------------------------------------------------------------- [ { @@ -25,7 +25,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee | instead" + "value": "```tsx\nconst B: 456\n```\nSee | instead" + }, + "range": { + "start": { + "line": 3, + "character": 6 + }, + "end": { + "line": 3, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline index d336abcb17..e85f0f34cf 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline @@ -10,7 +10,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See A| constant A instead +// | See [constant A](file:///quickInfoLink8.ts#1,7-1,8) instead // | ---------------------------------------------------------------------- [ { @@ -26,7 +26,17 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee A| constant A instead" + "value": "```tsx\nconst B: 456\n```\nSee [constant A](file:///quickInfoLink8.ts#1,7-1,8) instead" + }, + "range": { + "start": { + "line": 4, + "character": 6 + }, + "end": { + "line": 4, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoNestedExportEqualExportDefault.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoNestedExportEqualExportDefault.baseline index 655529433b..ae5f4f86d3 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoNestedExportEqualExportDefault.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoNestedExportEqualExportDefault.baseline @@ -2,16 +2,19 @@ === /quickInfoNestedExportEqualExportDefault.ts === // export = (state, messages) => { // export default { -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) (Anonymous function).default: {} // | ``` // | // | ---------------------------------------------------------------------- -// ^ +// ^^^^^^^ // | ---------------------------------------------------------------------- -// | No quickinfo at /*2*/. +// | ```tsx +// | (property) (Anonymous function).default: {} +// | ``` +// | // | ---------------------------------------------------------------------- // } // } @@ -30,6 +33,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) (Anonymous function).default: {}\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 3 + }, + "end": { + "line": 1, + "character": 9 + } } } }, @@ -43,6 +56,21 @@ "Name": "2", "Data": {} }, - "item": null + "item": { + "contents": { + "kind": "markdown", + "value": "```tsx\n(property) (Anonymous function).default: {}\n```\n" + }, + "range": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 17 + } + } + } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingCatchCallIndexSignature.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingCatchCallIndexSignature.baseline index 7778999760..db99bd7f4d 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingCatchCallIndexSignature.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingCatchCallIndexSignature.baseline @@ -4,7 +4,7 @@ // interface IntrinsicElements { [elemName: string]: any; } // } //
; -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | any @@ -26,6 +26,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nany\n```\n" + }, + "range": { + "start": { + "line": 3, + "character": 1 + }, + "end": { + "line": 3, + "character": 4 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.baseline index 897ac34cc1..1e6e27d05e 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnJsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.baseline @@ -7,7 +7,7 @@ // } // } // ; -// ^ +// ^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | any @@ -15,7 +15,7 @@ // | // | ---------------------------------------------------------------------- // ; -// ^ +// ^^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | any @@ -37,6 +37,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nany\n```\n" + }, + "range": { + "start": { + "line": 6, + "character": 1 + }, + "end": { + "line": 6, + "character": 7 + } } } }, @@ -54,6 +64,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nany\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 1 + }, + "end": { + "line": 7, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnParameterProperties.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnParameterProperties.baseline index 399006c05a..953611479b 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnParameterProperties.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnParameterProperties.baseline @@ -13,7 +13,7 @@ // //public name: string = ''; // constructor( // public name: string, // documentation should leech and work ! -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Foo.name: string @@ -27,7 +27,7 @@ // // test2 work // class Foo2 implements IFoo { // public name: string = ''; // documentation leeched and work ! -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) Foo2.name: string @@ -54,6 +54,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) Foo.name: string\n```\n" + }, + "range": { + "start": { + "line": 12, + "character": 11 + }, + "end": { + "line": 12, + "character": 15 + } } } }, @@ -71,6 +81,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) Foo2.name: string\n```\n" + }, + "range": { + "start": { + "line": 19, + "character": 9 + }, + "end": { + "line": 19, + "character": 13 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnThis5.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnThis5.baseline index 0baad3b4d9..2d7a07ec52 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnThis5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnThis5.baseline @@ -9,7 +9,7 @@ // | No quickinfo at /*1*/. // | ---------------------------------------------------------------------- // type Z = typeof this.num; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | any @@ -19,7 +19,7 @@ // }, // g(this: number) { // type X = typeof this; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) this: number @@ -32,7 +32,7 @@ // num = 0; // f() { // type Y = typeof this; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | this @@ -40,7 +40,7 @@ // | // | ---------------------------------------------------------------------- // type Z = typeof this.num; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | this @@ -50,7 +50,7 @@ // } // g(this: number) { // type X = typeof this; -// ^ +// ^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (parameter) this: number @@ -86,6 +86,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nany\n```\n" + }, + "range": { + "start": { + "line": 4, + "character": 24 + }, + "end": { + "line": 4, + "character": 28 + } } } }, @@ -103,6 +113,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) this: number\n```\n" + }, + "range": { + "start": { + "line": 7, + "character": 24 + }, + "end": { + "line": 7, + "character": 28 + } } } }, @@ -120,6 +140,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nthis\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 24 + }, + "end": { + "line": 13, + "character": 28 + } } } }, @@ -137,6 +167,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nthis\n```\n" + }, + "range": { + "start": { + "line": 14, + "character": 24 + }, + "end": { + "line": 14, + "character": 28 + } } } }, @@ -154,6 +194,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(parameter) this: number\n```\n" + }, + "range": { + "start": { + "line": 17, + "character": 24 + }, + "end": { + "line": 17, + "character": 28 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.baseline index 6de7f6562d..d15c818fb1 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.baseline @@ -25,7 +25,7 @@ // // declare let x: DocumentFilter; // x.language -// ^ +// ^^^^^^^^ // | ---------------------------------------------------------------------- // | ```tsx // | (property) language: string @@ -47,6 +47,16 @@ "contents": { "kind": "markdown", "value": "```tsx\n(property) language: string\n```\n" + }, + "range": { + "start": { + "line": 24, + "character": 2 + }, + "end": { + "line": 24, + "character": 10 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoSalsaMethodsOnAssignedFunctionExpressions.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoSalsaMethodsOnAssignedFunctionExpressions.baseline index d74b904a4e..e4a3c884b1 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoSalsaMethodsOnAssignedFunctionExpressions.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoSalsaMethodsOnAssignedFunctionExpressions.baseline @@ -10,7 +10,7 @@ // // var x = new C(); // x.m(); -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | var x: any @@ -32,6 +32,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nvar x: any\n```\n" + }, + "range": { + "start": { + "line": 9, + "character": 0 + }, + "end": { + "line": 9, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoSatisfiesTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoSatisfiesTag.baseline index 2f32d40691..f7553d1e8d 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoSatisfiesTag.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoSatisfiesTag.baseline @@ -26,6 +26,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst a: 1\n```\n\n\n*@satisfies* — comment " + }, + "range": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 7 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoTypedefTag.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoTypedefTag.baseline index c82883bc73..f472279f2c 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoTypedefTag.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoTypedefTag.baseline @@ -6,7 +6,7 @@ // */ // function f() { } // f() -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | function f(): void @@ -21,7 +21,7 @@ // */ // function g() { } // g() -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | function g(): void @@ -36,7 +36,7 @@ // */ // function h(keep) { } // h({ nope: 1 }) -// ^ +// ^ // | ---------------------------------------------------------------------- // | ```tsx // | function h(keep: Local): void @@ -58,6 +58,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction f(): void\n```\n" + }, + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 1 + } } } }, @@ -75,6 +85,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction g(): void\n```\n" + }, + "range": { + "start": { + "line": 13, + "character": 0 + }, + "end": { + "line": 13, + "character": 1 + } } } }, @@ -92,6 +112,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nfunction h(keep: Local): void\n```\n" + }, + "range": { + "start": { + "line": 21, + "character": 0 + }, + "end": { + "line": 21, + "character": 1 + } } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoUniqueSymbolJsDoc.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoUniqueSymbolJsDoc.baseline index e16714bca5..9bbc1db294 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoUniqueSymbolJsDoc.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoUniqueSymbolJsDoc.baseline @@ -3,7 +3,7 @@ // /** @type {unique symbol} */ // const foo = Symbol(); // foo -// ^ +// ^^^ // | ---------------------------------------------------------------------- // | ```tsx // | const foo: typeof foo @@ -25,6 +25,16 @@ "contents": { "kind": "markdown", "value": "```tsx\nconst foo: typeof foo\n```\n" + }, + "range": { + "start": { + "line": 2, + "character": 0 + }, + "end": { + "line": 2, + "character": 3 + } } } } diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline index 5b85fe7115..8ccdf99070 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline @@ -8,6 +8,10 @@ // ^ // | ---------------------------------------------------------------------- // | foo(): module +// | +// | +// | *@returns* — :@nodefuel/web~Webserver~wsServer#hello} Websocket server object +// | // | ---------------------------------------------------------------------- // // /** @@ -42,6 +46,10 @@ "signatures": [ { "label": "foo(): module", + "documentation": { + "kind": "markdown", + "value": "\n\n*@returns* — :@nodefuel/web~Webserver~wsServer#hello} Websocket server object\n" + }, "parameters": [] } ], diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline index 4738ec0a65..57f7193a17 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline @@ -15,6 +15,22 @@ // ^ // | ---------------------------------------------------------------------- // | pathFilter(**basePath: String**, pattern: String, type: String, options: Object): any[] +// | Filters a path based on a regexp or glob pattern. +// | +// | *@param* `basePath` — The base path where the search will be performed. +// | +// | +// | *@param* `pattern` — A string defining a regexp of a glob pattern. +// | +// | +// | *@param* `type` — The search pattern type, can be a regexp or a glob. +// | +// | +// | *@param* `options` — A object containing options to the search. +// | +// | +// | *@return* — A list containing the filtered paths. +// | // | ---------------------------------------------------------------------- [ { @@ -31,6 +47,10 @@ "signatures": [ { "label": "pathFilter(basePath: String, pattern: String, type: String, options: Object): any[]", + "documentation": { + "kind": "markdown", + "value": "Filters a path based on a regexp or glob pattern.\n\n*@param* `basePath` — The base path where the search will be performed.\n\n\n*@param* `pattern` — A string defining a regexp of a glob pattern.\n\n\n*@param* `type` — The search pattern type, can be a regexp or a glob.\n\n\n*@param* `options` — A object containing options to the search.\n\n\n*@return* — A list containing the filtered paths.\n" + }, "parameters": [ { "label": "basePath: String" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline index bb6a6fdfb8..490770f2a3 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline @@ -11,18 +11,70 @@ // ^ // | ---------------------------------------------------------------------- // | f1(**p1: string**, p2: string, p3?: string, p4?: string): void +// | +// | +// | *@param* `p1` - A string param +// | +// | +// | *@param* `p2` - An optional param +// | +// | +// | *@param* `p3` - Another optional param +// | +// | +// | *@param* `p4` - An optional param with a default value +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | f1(p1: string, **p2: string**, p3?: string, p4?: string): void +// | +// | +// | *@param* `p1` - A string param +// | +// | +// | *@param* `p2` - An optional param +// | +// | +// | *@param* `p3` - Another optional param +// | +// | +// | *@param* `p4` - An optional param with a default value +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | f1(p1: string, p2: string, **p3?: string**, p4?: string): void +// | +// | +// | *@param* `p1` - A string param +// | +// | +// | *@param* `p2` - An optional param +// | +// | +// | *@param* `p3` - Another optional param +// | +// | +// | *@param* `p4` - An optional param with a default value +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | f1(p1: string, p2: string, p3?: string, **p4?: string**): void +// | +// | +// | *@param* `p1` - A string param +// | +// | +// | *@param* `p2` - An optional param +// | +// | +// | *@param* `p3` - Another optional param +// | +// | +// | *@param* `p4` - An optional param with a default value +// | // | ---------------------------------------------------------------------- [ { @@ -39,6 +91,10 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" + }, "parameters": [ { "label": "p1: string" @@ -73,6 +129,10 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" + }, "parameters": [ { "label": "p1: string" @@ -107,6 +167,10 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" + }, "parameters": [ { "label": "p1: string" @@ -141,6 +205,10 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" + }, "parameters": [ { "label": "p1: string" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline index 2043548ae2..09b671b368 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline @@ -13,6 +13,16 @@ // ^ // | ---------------------------------------------------------------------- // | find(**l: unknown[]**, x: unknown): unknown +// | Find an item +// | +// | *@template* `T` +// | +// | *@param* `l` +// | +// | *@param* `x` +// | +// | *@returns* — The names of the found item(s). +// | // | ---------------------------------------------------------------------- [ { @@ -29,6 +39,10 @@ "signatures": [ { "label": "find(l: unknown[], x: unknown): unknown", + "documentation": { + "kind": "markdown", + "value": "Find an item\n\n*@template* `T`\n\n*@param* `l`\n\n*@param* `x`\n\n*@returns* — The names of the found item(s).\n" + }, "parameters": [ { "label": "l: unknown[]" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline index 0a70cac362..aa84850695 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline @@ -40,26 +40,61 @@ // ^ // | ---------------------------------------------------------------------- // | f1(**var1: any**, var2: any): void +// | +// | +// | *@param* `var1` — **Highlighted text** +// | +// | +// | *@param* `var2` — Another **Highlighted text** +// | // | ---------------------------------------------------------------------- // f2(); // ^ // | ---------------------------------------------------------------------- // | f2(**var1: any**, var2: any): void +// | +// | +// | *@param* `var1` — *Regular text with an asterisk +// | +// | +// | *@param* `var2` — Another *Regular text with an asterisk +// | // | ---------------------------------------------------------------------- // f3(); // ^ // | ---------------------------------------------------------------------- // | f3(**var1: any**, var2: any): void +// | +// | +// | *@param* `var1` — *Regular text with an asterisk +// | +// | +// | *@param* `var2` — Another *Regular text with an asterisk +// | // | ---------------------------------------------------------------------- // f4(); // ^ // | ---------------------------------------------------------------------- // | f4(**var1: any**, var2: any): void +// | +// | +// | *@param* `var1` — **Highlighted text** +// | +// | +// | *@param* `var2` — Another **Highlighted text** +// | // | ---------------------------------------------------------------------- // f5(); // ^ // | ---------------------------------------------------------------------- // | f5(**var1: any**, var2: any): void +// | +// | +// | *@param* `var1` — **Highlighted text** +// | +// | +// | *@param* `var2` — Another **Highlighted text** +// | // | ---------------------------------------------------------------------- [ { @@ -76,6 +111,10 @@ "signatures": [ { "label": "f1(var1: any, var2: any): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `var1` — **Highlighted text**\n\n\n*@param* `var2` — Another **Highlighted text**\n" + }, "parameters": [ { "label": "var1: any" @@ -104,6 +143,10 @@ "signatures": [ { "label": "f2(var1: any, var2: any): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `var1` — *Regular text with an asterisk\n\n\n*@param* `var2` — Another *Regular text with an asterisk\n" + }, "parameters": [ { "label": "var1: any" @@ -132,6 +175,10 @@ "signatures": [ { "label": "f3(var1: any, var2: any): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `var1` — *Regular text with an asterisk\n\n\n*@param* `var2` — Another *Regular text with an asterisk\n" + }, "parameters": [ { "label": "var1: any" @@ -160,6 +207,10 @@ "signatures": [ { "label": "f4(var1: any, var2: any): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `var1` — **Highlighted text**\n\n\n*@param* `var2` — Another **Highlighted text**\n" + }, "parameters": [ { "label": "var1: any" @@ -188,6 +239,10 @@ "signatures": [ { "label": "f5(var1: any, var2: any): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `var1` — **Highlighted text**\n\n\n*@param* `var2` — Another **Highlighted text**\n" + }, "parameters": [ { "label": "var1: any" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline index 3ac1bec561..eee615b3a5 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline @@ -18,6 +18,7 @@ // ^ // | ---------------------------------------------------------------------- // | c3(): c3 +// | Constructor comment // | ---------------------------------------------------------------------- // var i3_c = c3; // /** Class comment*/ @@ -30,6 +31,7 @@ // ^ // | ---------------------------------------------------------------------- // | c4(): c4 +// | Constructor comment // | ---------------------------------------------------------------------- // var i4_c = c4; // /** Class with statics*/ @@ -54,6 +56,7 @@ // ^ // | ---------------------------------------------------------------------- // | c6(): c6 +// | constructor comment // | ---------------------------------------------------------------------- // var i6_c = c6; // @@ -69,6 +72,10 @@ // ^ // | ---------------------------------------------------------------------- // | a(**a: string**): a +// | constructor for a +// | +// | *@param* `a` — this is my a +// | // | ---------------------------------------------------------------------- // module m { // export module m2 { @@ -117,6 +124,10 @@ "signatures": [ { "label": "c3(): c3", + "documentation": { + "kind": "markdown", + "value": "Constructor comment" + }, "parameters": [] } ], @@ -138,6 +149,10 @@ "signatures": [ { "label": "c4(): c4", + "documentation": { + "kind": "markdown", + "value": "Constructor comment" + }, "parameters": [] } ], @@ -180,6 +195,10 @@ "signatures": [ { "label": "c6(): c6", + "documentation": { + "kind": "markdown", + "value": "constructor comment" + }, "parameters": [] } ], @@ -201,6 +220,10 @@ "signatures": [ { "label": "a(a: string): a", + "documentation": { + "kind": "markdown", + "value": "constructor for a\n\n*@param* `a` — this is my a\n" + }, "parameters": [ { "label": "a: string" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline index 3240abb65d..d6c43e6b24 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline @@ -14,6 +14,7 @@ // ^ // | ---------------------------------------------------------------------- // | p2(**b: number**): number +// | sum with property // | ---------------------------------------------------------------------- // } // /** setter property 1*/ @@ -22,6 +23,7 @@ // ^ // | ---------------------------------------------------------------------- // | p2(**b: number**): number +// | sum with property // | ---------------------------------------------------------------------- // } // /** pp1 is property of c1*/ @@ -36,6 +38,7 @@ // ^ // | ---------------------------------------------------------------------- // | pp2(**b: number**): number +// | sum with property // | ---------------------------------------------------------------------- // } // /** setter property 2*/ @@ -44,6 +47,7 @@ // ^ // | ---------------------------------------------------------------------- // | pp2(**b: number**): number +// | sum with property // | ---------------------------------------------------------------------- // } // /** Constructor method*/ @@ -61,6 +65,7 @@ // ^ // | ---------------------------------------------------------------------- // | s2(**b: number**): number +// | static sum with property // | ---------------------------------------------------------------------- // } // /** setter property 3*/ @@ -69,6 +74,7 @@ // ^ // | ---------------------------------------------------------------------- // | s2(**b: number**): number +// | static sum with property // | ---------------------------------------------------------------------- // } // public nc_p1: number; @@ -130,6 +136,7 @@ // ^ // | ---------------------------------------------------------------------- // | c1(): c1 +// | Constructor method // | ---------------------------------------------------------------------- // var i1_p = i1.p1; // var i1_f = i1.p2; @@ -137,6 +144,7 @@ // ^ // | ---------------------------------------------------------------------- // | p2(**b: number**): number +// | sum with property // | ---------------------------------------------------------------------- // var i1_prop = i1.p3; // i1.p3 = i1_prop; @@ -155,6 +163,7 @@ // ^ // | ---------------------------------------------------------------------- // | s2(**b: number**): number +// | static sum with property // | ---------------------------------------------------------------------- // var i1_s_prop = c1.s3; // c1.s3 = i1_s_prop; @@ -214,6 +223,10 @@ "signatures": [ { "label": "p2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "sum with property" + }, "parameters": [ { "label": "b: number" @@ -239,6 +252,10 @@ "signatures": [ { "label": "p2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "sum with property" + }, "parameters": [ { "label": "b: number" @@ -264,6 +281,10 @@ "signatures": [ { "label": "pp2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "sum with property" + }, "parameters": [ { "label": "b: number" @@ -289,6 +310,10 @@ "signatures": [ { "label": "pp2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "sum with property" + }, "parameters": [ { "label": "b: number" @@ -314,6 +339,10 @@ "signatures": [ { "label": "s2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "static sum with property" + }, "parameters": [ { "label": "b: number" @@ -339,6 +368,10 @@ "signatures": [ { "label": "s2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "static sum with property" + }, "parameters": [ { "label": "b: number" @@ -514,6 +547,10 @@ "signatures": [ { "label": "c1(): c1", + "documentation": { + "kind": "markdown", + "value": "Constructor method" + }, "parameters": [] } ], @@ -535,6 +572,10 @@ "signatures": [ { "label": "p2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "sum with property" + }, "parameters": [ { "label": "b: number" @@ -585,6 +626,10 @@ "signatures": [ { "label": "s2(b: number): number", + "documentation": { + "kind": "markdown", + "value": "static sum with property" + }, "parameters": [ { "label": "b: number" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline index e347d6162a..f9f951a722 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline @@ -28,6 +28,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocSingleLine(): void +// | this is eg of single line jsdoc style comment // | ---------------------------------------------------------------------- // // @@ -40,6 +41,9 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMultiLine(): void +// | this is multiple line jsdoc stule comment +// | New line1 +// | New Line2 // | ---------------------------------------------------------------------- // // /** multiple line jsdoc comments no longer merge @@ -53,6 +57,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMultiLineMerge(): void +// | Another this one too // | ---------------------------------------------------------------------- // // @@ -64,6 +69,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMixedComments1(): void +// | jsdoc comment // | ---------------------------------------------------------------------- // // /// Triple slash comment @@ -74,6 +80,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMixedComments2(): void +// | another jsDocComment // | ---------------------------------------------------------------------- // // /** jsdoc comment */ /*** triplestar jsDocComment*/ @@ -84,6 +91,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMixedComments3(): void +// | * triplestar jsDocComment // | ---------------------------------------------------------------------- // // /** jsdoc comment */ /** another jsDocComment*/ @@ -95,6 +103,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMixedComments4(): void +// | another jsDocComment // | ---------------------------------------------------------------------- // // /// Triple slash comment 1 @@ -107,6 +116,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMixedComments5(): void +// | another jsDocComment // | ---------------------------------------------------------------------- // // /** another jsDocComment*/ @@ -120,6 +130,7 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocMixedComments6(): void +// | jsdoc comment // | ---------------------------------------------------------------------- // // // This shoulnot be help comment @@ -158,10 +169,24 @@ // ^ // | ---------------------------------------------------------------------- // | sum(**a: number**, b: number): number +// | Adds two integers and returns the result +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` — second number +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | sum(a: number, **b: number**): number +// | Adds two integers and returns the result +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` — second number +// | // | ---------------------------------------------------------------------- // /** This is multiplication function // * @param @@ -176,22 +201,112 @@ // ^ // | ---------------------------------------------------------------------- // | multiply(**a: number**, b: number, c?: number, d?: any, e?: any): void +// | This is multiplication function +// | +// | *@param* `` +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` +// | +// | *@param* `c` +// | +// | *@param* `d` +// | +// | *@anotherTag* +// | +// | *@param* `e` — LastParam +// | +// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, **b: number**, c?: number, d?: any, e?: any): void +// | This is multiplication function +// | +// | *@param* `` +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` +// | +// | *@param* `c` +// | +// | *@param* `d` +// | +// | *@anotherTag* +// | +// | *@param* `e` — LastParam +// | +// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, b: number, **c?: number**, d?: any, e?: any): void +// | This is multiplication function +// | +// | *@param* `` +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` +// | +// | *@param* `c` +// | +// | *@param* `d` +// | +// | *@anotherTag* +// | +// | *@param* `e` — LastParam +// | +// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, b: number, c?: number, **d?: any**, e?: any): void +// | This is multiplication function +// | +// | *@param* `` +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` +// | +// | *@param* `c` +// | +// | *@param* `d` +// | +// | *@anotherTag* +// | +// | *@param* `e` — LastParam +// | +// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, b: number, c?: number, d?: any, **e?: any**): void +// | This is multiplication function +// | +// | *@param* `` +// | +// | *@param* `a` — first number +// | +// | +// | *@param* `b` +// | +// | *@param* `c` +// | +// | *@param* `d` +// | +// | *@anotherTag* +// | +// | *@param* `e` — LastParam +// | +// | *@anotherTag* // | ---------------------------------------------------------------------- // /** fn f1 with number // * @param { string} b about b @@ -206,6 +321,10 @@ // ^ // | ---------------------------------------------------------------------- // | f1(**a: number**): any +// | fn f1 with number +// | +// | *@param* `b` — about b +// | // | ---------------------------------------------------------------------- // f1("hello"); // ^ @@ -227,26 +346,134 @@ // ^ // | ---------------------------------------------------------------------- // | subtract(**a: number**, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void +// | This is subtract function +// | +// | *@param* `` +// | +// | *@param* `b` — this is about b +// | +// | +// | *@param* `c` — this is optional param c +// | +// | +// | *@param* `d` — this is optional param d +// | +// | +// | *@param* `e` — this is optional param e +// | +// | +// | *@param* `` — { () => string; } } f this is optional param f +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, **b: number**, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void +// | This is subtract function +// | +// | *@param* `` +// | +// | *@param* `b` — this is about b +// | +// | +// | *@param* `c` — this is optional param c +// | +// | +// | *@param* `d` — this is optional param d +// | +// | +// | *@param* `e` — this is optional param e +// | +// | +// | *@param* `` — { () => string; } } f this is optional param f +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, **c?: () => string**, d?: () => string, e?: () => string, f?: () => string): void +// | This is subtract function +// | +// | *@param* `` +// | +// | *@param* `b` — this is about b +// | +// | +// | *@param* `c` — this is optional param c +// | +// | +// | *@param* `d` — this is optional param d +// | +// | +// | *@param* `e` — this is optional param e +// | +// | +// | *@param* `` — { () => string; } } f this is optional param f +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, c?: () => string, **d?: () => string**, e?: () => string, f?: () => string): void +// | This is subtract function +// | +// | *@param* `` +// | +// | *@param* `b` — this is about b +// | +// | +// | *@param* `c` — this is optional param c +// | +// | +// | *@param* `d` — this is optional param d +// | +// | +// | *@param* `e` — this is optional param e +// | +// | +// | *@param* `` — { () => string; } } f this is optional param f +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, c?: () => string, d?: () => string, **e?: () => string**, f?: () => string): void +// | This is subtract function +// | +// | *@param* `` +// | +// | *@param* `b` — this is about b +// | +// | +// | *@param* `c` — this is optional param c +// | +// | +// | *@param* `d` — this is optional param d +// | +// | +// | *@param* `e` — this is optional param e +// | +// | +// | *@param* `` — { () => string; } } f this is optional param f +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, **f?: () => string**): void +// | This is subtract function +// | +// | *@param* `` +// | +// | *@param* `b` — this is about b +// | +// | +// | *@param* `c` — this is optional param c +// | +// | +// | *@param* `d` — this is optional param d +// | +// | +// | *@param* `e` — this is optional param e +// | +// | +// | *@param* `` — { () => string; } } f this is optional param f +// | // | ---------------------------------------------------------------------- // /** this is square function // @paramTag { number } a this is input number of paramTag @@ -260,6 +487,16 @@ // ^ // | ---------------------------------------------------------------------- // | square(**a: number**): number +// | this is square function +// | +// | *@paramTag* — { number } a this is input number of paramTag +// | +// | +// | *@param* `a` — this is input number +// | +// | +// | *@returnType* — { number } it is return type +// | // | ---------------------------------------------------------------------- // /** this is divide function // @param { number} a this is a @@ -272,10 +509,30 @@ // ^ // | ---------------------------------------------------------------------- // | divide(**a: number**, b: number): void +// | this is divide function +// | +// | *@param* `a` — this is a +// | +// | +// | *@paramTag* — { number } g this is optional param g +// | +// | +// | *@param* `b` — this is b +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | divide(a: number, **b: number**): void +// | this is divide function +// | +// | *@param* `a` — this is a +// | +// | +// | *@paramTag* — { number } g this is optional param g +// | +// | +// | *@param* `b` — this is b +// | // | ---------------------------------------------------------------------- // /** // Function returns string concat of foo and bar @@ -289,10 +546,24 @@ // ^ // | ---------------------------------------------------------------------- // | fooBar(**foo: string**, bar: string): string +// | Function returns string concat of foo and bar +// | +// | *@param* `foo` — is string +// | +// | +// | *@param* `bar` — is second string +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | fooBar(foo: string, **bar: string**): string +// | Function returns string concat of foo and bar +// | +// | *@param* `foo` — is string +// | +// | +// | *@param* `bar` — is second string +// | // | ---------------------------------------------------------------------- // /** This is a comment */ // var x; @@ -315,18 +586,46 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(**a: number**, b: number, c: number, d: number): number +// | this is jsdoc style function with param tag as well as inline parameter help +// | +// | *@param* `a` — it is first parameter +// | +// | +// | *@param* `c` — it is third parameter +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(a: number, **b: number**, c: number, d: number): number +// | this is jsdoc style function with param tag as well as inline parameter help +// | +// | *@param* `a` — it is first parameter +// | +// | +// | *@param* `c` — it is third parameter +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(a: number, b: number, **c: number**, d: number): number +// | this is jsdoc style function with param tag as well as inline parameter help +// | +// | *@param* `a` — it is first parameter +// | +// | +// | *@param* `c` — it is third parameter +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(a: number, b: number, c: number, **d: number**): number +// | this is jsdoc style function with param tag as well as inline parameter help +// | +// | *@param* `a` — it is first parameter +// | +// | +// | *@param* `c` — it is third parameter +// | // | ---------------------------------------------------------------------- // /** This is function comment // * And properly aligned comment @@ -337,6 +636,8 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest1(): void +// | This is function comment +// | And properly aligned comment // | ---------------------------------------------------------------------- // /** This is function comment // * And aligned with 4 space char margin @@ -347,6 +648,8 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest2(): void +// | This is function comment +// | And aligned with 4 space char margin // | ---------------------------------------------------------------------- // /** This is function comment // * And aligned with 4 space char margin @@ -365,14 +668,62 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest3(**a: string**, b: any, c: any): void +// | This is function comment +// | And aligned with 4 space char margin +// | +// | *@param* `a` — this is info about a +// | spanning on two lines and aligned perfectly +// | +// | +// | *@param* `b` — this is info about b +// | spanning on two lines and aligned perfectly +// | spanning one more line alined perfectly +// | spanning another line with more margin +// | +// | +// | *@param* `c` — this is info about b +// | not aligned text about parameter will eat only one space +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest3(a: string, **b: any**, c: any): void +// | This is function comment +// | And aligned with 4 space char margin +// | +// | *@param* `a` — this is info about a +// | spanning on two lines and aligned perfectly +// | +// | +// | *@param* `b` — this is info about b +// | spanning on two lines and aligned perfectly +// | spanning one more line alined perfectly +// | spanning another line with more margin +// | +// | +// | *@param* `c` — this is info about b +// | not aligned text about parameter will eat only one space +// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest3(a: string, b: any, **c: any**): void +// | This is function comment +// | And aligned with 4 space char margin +// | +// | *@param* `a` — this is info about a +// | spanning on two lines and aligned perfectly +// | +// | +// | *@param* `b` — this is info about b +// | spanning on two lines and aligned perfectly +// | spanning one more line alined perfectly +// | spanning another line with more margin +// | +// | +// | *@param* `c` — this is info about b +// | not aligned text about parameter will eat only one space +// | // | ---------------------------------------------------------------------- // // ^ @@ -438,6 +789,10 @@ "signatures": [ { "label": "jsDocSingleLine(): void", + "documentation": { + "kind": "markdown", + "value": "this is eg of single line jsdoc style comment" + }, "parameters": [] } ], @@ -459,6 +814,10 @@ "signatures": [ { "label": "jsDocMultiLine(): void", + "documentation": { + "kind": "markdown", + "value": "this is multiple line jsdoc stule comment\nNew line1\nNew Line2" + }, "parameters": [] } ], @@ -480,6 +839,10 @@ "signatures": [ { "label": "jsDocMultiLineMerge(): void", + "documentation": { + "kind": "markdown", + "value": "Another this one too" + }, "parameters": [] } ], @@ -501,6 +864,10 @@ "signatures": [ { "label": "jsDocMixedComments1(): void", + "documentation": { + "kind": "markdown", + "value": "jsdoc comment" + }, "parameters": [] } ], @@ -522,6 +889,10 @@ "signatures": [ { "label": "jsDocMixedComments2(): void", + "documentation": { + "kind": "markdown", + "value": "another jsDocComment" + }, "parameters": [] } ], @@ -543,6 +914,10 @@ "signatures": [ { "label": "jsDocMixedComments3(): void", + "documentation": { + "kind": "markdown", + "value": "* triplestar jsDocComment" + }, "parameters": [] } ], @@ -564,6 +939,10 @@ "signatures": [ { "label": "jsDocMixedComments4(): void", + "documentation": { + "kind": "markdown", + "value": "another jsDocComment" + }, "parameters": [] } ], @@ -585,6 +964,10 @@ "signatures": [ { "label": "jsDocMixedComments5(): void", + "documentation": { + "kind": "markdown", + "value": "another jsDocComment" + }, "parameters": [] } ], @@ -606,6 +989,10 @@ "signatures": [ { "label": "jsDocMixedComments6(): void", + "documentation": { + "kind": "markdown", + "value": "jsdoc comment" + }, "parameters": [] } ], @@ -690,6 +1077,10 @@ "signatures": [ { "label": "sum(a: number, b: number): number", + "documentation": { + "kind": "markdown", + "value": "Adds two integers and returns the result\n\n*@param* `a` — first number\n\n\n*@param* `b` — second number\n" + }, "parameters": [ { "label": "a: number" @@ -718,6 +1109,10 @@ "signatures": [ { "label": "sum(a: number, b: number): number", + "documentation": { + "kind": "markdown", + "value": "Adds two integers and returns the result\n\n*@param* `a` — first number\n\n\n*@param* `b` — second number\n" + }, "parameters": [ { "label": "a: number" @@ -746,6 +1141,10 @@ "signatures": [ { "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", + "documentation": { + "kind": "markdown", + "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + }, "parameters": [ { "label": "a: number" @@ -783,6 +1182,10 @@ "signatures": [ { "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", + "documentation": { + "kind": "markdown", + "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + }, "parameters": [ { "label": "a: number" @@ -820,6 +1223,10 @@ "signatures": [ { "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", + "documentation": { + "kind": "markdown", + "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + }, "parameters": [ { "label": "a: number" @@ -857,6 +1264,10 @@ "signatures": [ { "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", + "documentation": { + "kind": "markdown", + "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + }, "parameters": [ { "label": "a: number" @@ -894,6 +1305,10 @@ "signatures": [ { "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", + "documentation": { + "kind": "markdown", + "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + }, "parameters": [ { "label": "a: number" @@ -931,6 +1346,10 @@ "signatures": [ { "label": "f1(a: number): any", + "documentation": { + "kind": "markdown", + "value": "fn f1 with number\n\n*@param* `b` — about b\n" + }, "parameters": [ { "label": "a: number" @@ -964,6 +1383,10 @@ "signatures": [ { "label": "f1(a: number): any", + "documentation": { + "kind": "markdown", + "value": "fn f1 with number\n\n*@param* `b` — about b\n" + }, "parameters": [ { "label": "a: number" @@ -997,6 +1420,10 @@ "signatures": [ { "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", + "documentation": { + "kind": "markdown", + "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, "parameters": [ { "label": "a: number" @@ -1037,6 +1464,10 @@ "signatures": [ { "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", + "documentation": { + "kind": "markdown", + "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, "parameters": [ { "label": "a: number" @@ -1077,6 +1508,10 @@ "signatures": [ { "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", + "documentation": { + "kind": "markdown", + "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, "parameters": [ { "label": "a: number" @@ -1117,6 +1552,10 @@ "signatures": [ { "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", + "documentation": { + "kind": "markdown", + "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, "parameters": [ { "label": "a: number" @@ -1157,6 +1596,10 @@ "signatures": [ { "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", + "documentation": { + "kind": "markdown", + "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, "parameters": [ { "label": "a: number" @@ -1197,6 +1640,10 @@ "signatures": [ { "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", + "documentation": { + "kind": "markdown", + "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + }, "parameters": [ { "label": "a: number" @@ -1237,6 +1684,10 @@ "signatures": [ { "label": "square(a: number): number", + "documentation": { + "kind": "markdown", + "value": "this is square function\n\n*@paramTag* — { number } a this is input number of paramTag\n\n\n*@param* `a` — this is input number\n\n\n*@returnType* — { number } it is return type\n" + }, "parameters": [ { "label": "a: number" @@ -1262,6 +1713,10 @@ "signatures": [ { "label": "divide(a: number, b: number): void", + "documentation": { + "kind": "markdown", + "value": "this is divide function\n\n*@param* `a` — this is a\n\n\n*@paramTag* — { number } g this is optional param g\n\n\n*@param* `b` — this is b\n" + }, "parameters": [ { "label": "a: number" @@ -1290,6 +1745,10 @@ "signatures": [ { "label": "divide(a: number, b: number): void", + "documentation": { + "kind": "markdown", + "value": "this is divide function\n\n*@param* `a` — this is a\n\n\n*@paramTag* — { number } g this is optional param g\n\n\n*@param* `b` — this is b\n" + }, "parameters": [ { "label": "a: number" @@ -1318,6 +1777,10 @@ "signatures": [ { "label": "fooBar(foo: string, bar: string): string", + "documentation": { + "kind": "markdown", + "value": "Function returns string concat of foo and bar\n\n*@param* `foo` — is string\n\n\n*@param* `bar` — is second string\n" + }, "parameters": [ { "label": "foo: string" @@ -1346,6 +1809,10 @@ "signatures": [ { "label": "fooBar(foo: string, bar: string): string", + "documentation": { + "kind": "markdown", + "value": "Function returns string concat of foo and bar\n\n*@param* `foo` — is string\n\n\n*@param* `bar` — is second string\n" + }, "parameters": [ { "label": "foo: string" @@ -1386,6 +1853,10 @@ "signatures": [ { "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", + "documentation": { + "kind": "markdown", + "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + }, "parameters": [ { "label": "a: number" @@ -1420,6 +1891,10 @@ "signatures": [ { "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", + "documentation": { + "kind": "markdown", + "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + }, "parameters": [ { "label": "a: number" @@ -1454,6 +1929,10 @@ "signatures": [ { "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", + "documentation": { + "kind": "markdown", + "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + }, "parameters": [ { "label": "a: number" @@ -1488,6 +1967,10 @@ "signatures": [ { "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", + "documentation": { + "kind": "markdown", + "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + }, "parameters": [ { "label": "a: number" @@ -1522,6 +2005,10 @@ "signatures": [ { "label": "jsDocCommentAlignmentTest1(): void", + "documentation": { + "kind": "markdown", + "value": "This is function comment\nAnd properly aligned comment" + }, "parameters": [] } ], @@ -1543,6 +2030,10 @@ "signatures": [ { "label": "jsDocCommentAlignmentTest2(): void", + "documentation": { + "kind": "markdown", + "value": "This is function comment\n And aligned with 4 space char margin" + }, "parameters": [] } ], @@ -1564,6 +2055,10 @@ "signatures": [ { "label": "jsDocCommentAlignmentTest3(a: string, b: any, c: any): void", + "documentation": { + "kind": "markdown", + "value": "This is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + }, "parameters": [ { "label": "a: string" @@ -1595,6 +2090,10 @@ "signatures": [ { "label": "jsDocCommentAlignmentTest3(a: string, b: any, c: any): void", + "documentation": { + "kind": "markdown", + "value": "This is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + }, "parameters": [ { "label": "a: string" @@ -1626,6 +2125,10 @@ "signatures": [ { "label": "jsDocCommentAlignmentTest3(a: string, b: any, c: any): void", + "documentation": { + "kind": "markdown", + "value": "This is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + }, "parameters": [ { "label": "a: string" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline index 7eeca6af5e..9379624b79 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline @@ -7,6 +7,7 @@ // ^ // | ---------------------------------------------------------------------- // | foo(): void +// | This comment should appear for foo // | ---------------------------------------------------------------------- // /** This is comment for function signature*/ // function fooWithParameters(/** this is comment about a*/a: string, @@ -18,10 +19,12 @@ // ^ // | ---------------------------------------------------------------------- // | fooWithParameters(**a: string**, b: number): void +// | This is comment for function signature // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | fooWithParameters(a: string, **b: number**): void +// | This is comment for function signature // | ---------------------------------------------------------------------- // /** // * Does something @@ -32,6 +35,10 @@ // ^ // | ---------------------------------------------------------------------- // | fn(**a: string**): any +// | Does something +// | +// | *@param* `a` — a string +// | // | ---------------------------------------------------------------------- [ { @@ -48,6 +55,10 @@ "signatures": [ { "label": "foo(): void", + "documentation": { + "kind": "markdown", + "value": "This comment should appear for foo" + }, "parameters": [] } ], @@ -69,6 +80,10 @@ "signatures": [ { "label": "fooWithParameters(a: string, b: number): void", + "documentation": { + "kind": "markdown", + "value": "This is comment for function signature" + }, "parameters": [ { "label": "a: string" @@ -97,6 +112,10 @@ "signatures": [ { "label": "fooWithParameters(a: string, b: number): void", + "documentation": { + "kind": "markdown", + "value": "This is comment for function signature" + }, "parameters": [ { "label": "a: string" @@ -125,6 +144,10 @@ "signatures": [ { "label": "fn(a: string): any", + "documentation": { + "kind": "markdown", + "value": "Does something\n\n*@param* `a` — a string\n" + }, "parameters": [ { "label": "a: string" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline index ddd0d0daad..909f65f09e 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline @@ -7,10 +7,12 @@ // ^ // | ---------------------------------------------------------------------- // | lambdaFoo(**a: number**, b: number): number +// | this is lambda comment // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | lambdaFoo(a: number, **b: number**): number +// | this is lambda comment // | ---------------------------------------------------------------------- // function anotherFunc(a: number) { // /** documentation @@ -37,6 +39,13 @@ // ^ // | ---------------------------------------------------------------------- // | assigned(**s: string**): number +// | Summary on expression +// | +// | *@param* `s` — param on expression +// | +// | +// | *@returns* — return on expression +// | // | ---------------------------------------------------------------------- [ { @@ -53,6 +62,10 @@ "signatures": [ { "label": "lambdaFoo(a: number, b: number): number", + "documentation": { + "kind": "markdown", + "value": "this is lambda comment" + }, "parameters": [ { "label": "a: number" @@ -81,6 +94,10 @@ "signatures": [ { "label": "lambdaFoo(a: number, b: number): number", + "documentation": { + "kind": "markdown", + "value": "this is lambda comment" + }, "parameters": [ { "label": "a: number" @@ -109,6 +126,10 @@ "signatures": [ { "label": "assigned(s: string): number", + "documentation": { + "kind": "markdown", + "value": "Summary on expression\n\n*@param* `s` — param on expression\n\n\n*@returns* — return on expression\n" + }, "parameters": [ { "label": "s: string" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline index a9c2da5bea..1250243a32 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline @@ -12,6 +12,10 @@ // ^ // | ---------------------------------------------------------------------- // | Circle(**radius: number**): Circle +// | Initialize a circle. +// | +// | *@param* `radius` — The radius of the circle. +// | // | ---------------------------------------------------------------------- [ { @@ -28,6 +32,10 @@ "signatures": [ { "label": "Circle(radius: number): Circle", + "documentation": { + "kind": "markdown", + "value": "Initialize a circle.\n\n*@param* `radius` — The radius of the circle.\n" + }, "parameters": [ { "label": "radius: number" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline index b4af169f8c..58c8b36f34 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline @@ -53,21 +53,36 @@ // ^ // | ---------------------------------------------------------------------- // | Foo(**value: number**): Foo +// | This is the constructor. +// | +// | *@myjsdoctag* — this is a comment +// | // | ---------------------------------------------------------------------- // Foo.method1(); // ^ // | ---------------------------------------------------------------------- // | method1(): void +// | method1 documentation +// | +// | *@mytag* — comment1 comment2 +// | // | ---------------------------------------------------------------------- // foo.method2(); // ^ // | ---------------------------------------------------------------------- // | method2(): void +// | +// | +// | *@mytag* // | ---------------------------------------------------------------------- // foo.method3(); // ^ // | ---------------------------------------------------------------------- // | method3(): number +// | +// | +// | *@returns* — a value +// | // | ---------------------------------------------------------------------- // foo.method4(); // foo.property1; @@ -89,6 +104,10 @@ "signatures": [ { "label": "Foo(value: number): Foo", + "documentation": { + "kind": "markdown", + "value": "This is the constructor.\n\n*@myjsdoctag* — this is a comment\n" + }, "parameters": [ { "label": "value: number" @@ -114,6 +133,10 @@ "signatures": [ { "label": "method1(): void", + "documentation": { + "kind": "markdown", + "value": "method1 documentation\n\n*@mytag* — comment1 comment2\n" + }, "parameters": [] } ], @@ -135,6 +158,10 @@ "signatures": [ { "label": "method2(): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@mytag*" + }, "parameters": [] } ], @@ -156,6 +183,10 @@ "signatures": [ { "label": "method3(): number", + "documentation": { + "kind": "markdown", + "value": "\n\n*@returns* — a value\n" + }, "parameters": [] } ], diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline index 4da40c046b..0bfd6e0bd5 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline @@ -4,6 +4,14 @@ // ^ // | ---------------------------------------------------------------------- // | assign(target: object, **...sources: any[]**): any +// | Copy the values of all of the enumerable own properties from one or more source objects to a +// | target object. Returns the target object. +// | +// | *@param* `target` — The target object to copy to. +// | +// | +// | *@param* `sources` — One or more source objects from which to copy properties +// | // | ---------------------------------------------------------------------- [ { @@ -20,6 +28,10 @@ "signatures": [ { "label": "assign(target: T, source: U): T & U", + "documentation": { + "kind": "markdown", + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `source` — The source object from which to copy properties.\n" + }, "parameters": [ { "label": "target: T" @@ -31,6 +43,10 @@ }, { "label": "assign(target: T, source1: U, source2: V): T & U & V", + "documentation": { + "kind": "markdown", + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `source1` — The first source object from which to copy properties.\n\n\n*@param* `source2` — The second source object from which to copy properties.\n" + }, "parameters": [ { "label": "target: T" @@ -45,6 +61,10 @@ }, { "label": "assign(target: T, source1: U, source2: V, source3: W): T & U & V & W", + "documentation": { + "kind": "markdown", + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `source1` — The first source object from which to copy properties.\n\n\n*@param* `source2` — The second source object from which to copy properties.\n\n\n*@param* `source3` — The third source object from which to copy properties.\n" + }, "parameters": [ { "label": "target: T" @@ -62,6 +82,10 @@ }, { "label": "assign(target: object, ...sources: any[]): any", + "documentation": { + "kind": "markdown", + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `sources` — One or more source objects from which to copy properties\n" + }, "parameters": [ { "label": "target: object" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline index b18da8a20e..04519d87b3 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline @@ -12,21 +12,81 @@ // ^ // | ---------------------------------------------------------------------- // | f<**T**, U, V, W>(a: number, b: string, c: boolean): void +// | some documentation +// | +// | *@template* `T` — some documentation 2 +// | +// | +// | *@template* `W` +// | +// | *@template* `U`, `V` — others +// | +// | +// | *@param* `a` — ok +// | +// | +// | *@param* `b` — not ok +// | // | ---------------------------------------------------------------------- // f(a: number, b: string, c: boolean): void +// | some documentation +// | +// | *@template* `T` — some documentation 2 +// | +// | +// | *@template* `W` +// | +// | *@template* `U`, `V` — others +// | +// | +// | *@param* `a` — ok +// | +// | +// | *@param* `b` — not ok +// | // | ---------------------------------------------------------------------- // f(a: number, b: string, c: boolean): void +// | some documentation +// | +// | *@template* `T` — some documentation 2 +// | +// | +// | *@template* `W` +// | +// | *@template* `U`, `V` — others +// | +// | +// | *@param* `a` — ok +// | +// | +// | *@param* `b` — not ok +// | // | ---------------------------------------------------------------------- // f(a: number, b: string, c: boolean): void +// | some documentation +// | +// | *@template* `T` — some documentation 2 +// | +// | +// | *@template* `W` +// | +// | *@template* `U`, `V` — others +// | +// | +// | *@param* `a` — ok +// | +// | +// | *@param* `b` — not ok +// | // | ---------------------------------------------------------------------- [ { @@ -43,6 +103,10 @@ "signatures": [ { "label": "f(a: number, b: string, c: boolean): void", + "documentation": { + "kind": "markdown", + "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + }, "parameters": [ { "label": "T" @@ -77,6 +141,10 @@ "signatures": [ { "label": "f(a: number, b: string, c: boolean): void", + "documentation": { + "kind": "markdown", + "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + }, "parameters": [ { "label": "T" @@ -111,6 +179,10 @@ "signatures": [ { "label": "f(a: number, b: string, c: boolean): void", + "documentation": { + "kind": "markdown", + "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + }, "parameters": [ { "label": "T" @@ -145,6 +217,10 @@ "signatures": [ { "label": "f(a: number, b: string, c: boolean): void", + "documentation": { + "kind": "markdown", + "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + }, "parameters": [ { "label": "T" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline index b0c6b6254b..3bc1d52dab 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline @@ -4,6 +4,10 @@ // ^ // | ---------------------------------------------------------------------- // | eval(**x: string**): any +// | Evaluates JavaScript code and executes it. +// | +// | *@param* `x` — A String value that contains valid JavaScript code. +// | // | ---------------------------------------------------------------------- [ { @@ -20,6 +24,10 @@ "signatures": [ { "label": "eval(x: string): any", + "documentation": { + "kind": "markdown", + "value": "Evaluates JavaScript code and executes it.\n\n*@param* `x` — A String value that contains valid JavaScript code.\n" + }, "parameters": [ { "label": "x: string" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline b/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline index 3de5364af9..a605b34030 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline @@ -12,6 +12,10 @@ // ^ // | ---------------------------------------------------------------------- // | str(n: number, **radix: number**): string +// | Stringifies a number with radix +// | +// | *@param* `radix` — The radix +// | // | ---------------------------------------------------------------------- // // declare function f(a: T): T; @@ -43,6 +47,10 @@ }, { "label": "str(n: number, radix: number): string", + "documentation": { + "kind": "markdown", + "value": "Stringifies a number with radix\n\n*@param* `radix` — The radix\n" + }, "parameters": [ { "label": "n: number" diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline new file mode 100644 index 0000000000..3403e09e0b --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline @@ -0,0 +1,170 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/user.ts] *new* +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a.fnA(); b.fnB(); a.instanceA; } + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/bin/a\";\nimport * as b from \"../b/bin/b\";\nexport function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /dev/null/inferred (default) +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + }, + "position": { + "line": 2, + "character": 29 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/dev/null/inferred] + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /a/tsconfig.json + + + + +// === findAllReferences === +// === /a/a.ts === +// export function [|fnA|]() {} +// export interface IfaceA {} +// export const instanceA: IfaceA = {}; + +// === /user/user.ts === +// import * as a from "../a/bin/a"; +// import * as b from "../b/bin/b"; +// export function fnUser() { a./*FIND ALL REFS*/[|fnA|](); b.fnB(); a.instanceA; } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/a/tsconfig.json] *deleted* + /a/a.ts + [/dev/null/inferred] *deleted* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *deleted* + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline new file mode 100644 index 0000000000..86588d5549 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline @@ -0,0 +1,109 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function f() {} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "../bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/b.ts] *new* +import { f } from "../bin/a"; +f(); +//// [/b/tsconfig.json] *new* +{ + "references": [ + { "path": "../a" } + ] +} +//// [/bin/a.d.ts] *new* +export declare function f(): void; +//# sourceMappingURL=a.d.ts.map +//// [/bin/a.d.ts.map] *new* +{ + "version":3, + "file":"a.d.ts", + "sourceRoot":"", + "sources":["a.ts"], + "names":[], + "mappings":"AAAA,wBAAgB,CAAC,SAAK" +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///b/b.ts", + "languageId": "typescript", + "version": 0, + "text": "import { f } from \"../bin/a\";\nf();" + } + } +} + +Projects:: + [/b/tsconfig.json] *new* + /a/a.ts + /b/b.ts +Open Files:: + [/b/b.ts] *new* + /b/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /b/tsconfig.json + [/b/tsconfig.json] *new* + RetainingProjects: + /b/tsconfig.json + RetainingOpenFiles: + /b/b.ts +Config File Names:: + [/b/b.ts] *new* + NearestConfigFileName: /b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///b/b.ts" + }, + "position": { + "line": 1, + "character": 0 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/b/tsconfig.json] + /a/a.ts + /b/b.ts +Config:: + [/a/tsconfig.json] *modified* + RetainingProjects: *modified* + /a/tsconfig.json *new* + /b/tsconfig.json + [/b/tsconfig.json] + RetainingProjects: + /b/tsconfig.json + RetainingOpenFiles: + /b/b.ts + + + + +// === findAllReferences === +// === /a/a.ts === +// export function [|f|]() {} + +// === /b/b.ts === +// import { [|f|] } from "../bin/a"; +// /*FIND ALL REFS*/[|f|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline new file mode 100644 index 0000000000..e11f907aeb --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline @@ -0,0 +1,208 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/user.ts] *new* +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a.fnA(); b.fnB(); a.instanceA; } + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/bin/a\";\nimport * as b from \"../b/bin/b\";\nexport function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /dev/null/inferred (default) +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///a/a.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fnA() {}\nexport interface IfaceA {}\nexport const instanceA: IfaceA = {};" + } + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/dev/null/inferred] + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/a/a.ts] *new* + /a/tsconfig.json (default) + [/user/user.ts] + /dev/null/inferred (default) +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /a/tsconfig.json + RetainingOpenFiles: + /a/a.ts +Config File Names:: + [/a/a.ts] *new* + NearestConfigFileName: /a/tsconfig.json + Ancestors: + /a/tsconfig.json + [/user/user.ts] + NearestConfigFileName: + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///a/a.ts" + }, + "position": { + "line": 0, + "character": 16 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /a/a.ts === +// export function /*FIND ALL REFS*/[|fnA|]() {} +// export interface IfaceA {} +// export const instanceA: IfaceA = {}; + +// === /user/user.ts === +// import * as a from "../a/bin/a"; +// import * as b from "../b/bin/b"; +// export function fnUser() { a.[|fnA|](); b.fnB(); a.instanceA; } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/a/a.ts] + /a/tsconfig.json (default) + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/a/tsconfig.json] + /a/a.ts + [/dev/null/inferred] *deleted* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/a/a.ts] + /a/tsconfig.json (default) + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/a/tsconfig.json] + RetainingProjects: + /a/tsconfig.json + RetainingOpenFiles: + /a/a.ts + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts +Config File Names:: + [/a/a.ts] + NearestConfigFileName: /a/tsconfig.json + Ancestors: + /a/tsconfig.json + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline new file mode 100644 index 0000000000..c07f940327 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline @@ -0,0 +1,154 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/user.ts] *new* +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a.fnA(); b.fnB(); a.instanceA; } + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/bin/a\";\nimport * as b from \"../b/bin/b\";\nexport function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /dev/null/inferred (default) +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + }, + "position": { + "line": 2, + "character": 38 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /b/bin/b.d.ts === +// export declare function [|fnB|](): void; +// //# sourceMappingURL=b.d.ts.map + +// === /user/user.ts === +// import * as a from "../a/bin/a"; +// import * as b from "../b/bin/b"; +// export function fnUser() { a.fnA(); b./*FIND ALL REFS*/[|fnB|](); a.instanceA; } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/dev/null/inferred] *deleted* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline new file mode 100644 index 0000000000..19bddaea89 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline @@ -0,0 +1,107 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.d.ts] *new* +export declare class A { +} +//# sourceMappingURL=a.d.ts.map +//// [/a/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["./a.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;CAAI" +} +//// [/a/a.ts] *new* +export class A { } +//// [/a/tsconfig.json] *new* +{} +//// [/b/b.ts] *new* +import {A} from "../a/a"; +new A(); +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "references": [ + { "path": "../a" } + ] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///b/b.ts", + "languageId": "typescript", + "version": 0, + "text": "import {A} from \"../a/a\";\nnew A();" + } + } +} + +Projects:: + [/b/tsconfig.json] *new* + /a/a.ts + /b/b.ts +Open Files:: + [/b/b.ts] *new* + /b/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /b/tsconfig.json + [/b/tsconfig.json] *new* + RetainingProjects: + /b/tsconfig.json + RetainingOpenFiles: + /b/b.ts +Config File Names:: + [/b/b.ts] *new* + NearestConfigFileName: /b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///b/b.ts" + }, + "position": { + "line": 1, + "character": 4 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/b/tsconfig.json] + /a/a.ts + /b/b.ts +Config:: + [/a/tsconfig.json] *modified* + RetainingProjects: *modified* + /a/tsconfig.json *new* + /b/tsconfig.json + [/b/tsconfig.json] + RetainingProjects: + /b/tsconfig.json + RetainingOpenFiles: + /b/b.ts + + + + +// === findAllReferences === +// === /a/a.ts === +// export class [|A|] { } + +// === /b/b.ts === +// import {[|A|]} from "../a/a"; +// new /*FIND ALL REFS*/[|A|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline new file mode 100644 index 0000000000..fa57e3f9aa --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline @@ -0,0 +1,107 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.d.ts] *new* +export declare class A { +} +//# sourceMappingURL=a.d.ts.map +//// [/a/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["./a.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;CAAI" +} +//// [/a/a.ts] *new* +export class A { } +//// [/a/tsconfig.json] *new* +{} +//// [/b/b.ts] *new* +import {A} from "../a/a"; +new A(); +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": true + }, + "references": [ + { "path": "../a" } + ] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///b/b.ts", + "languageId": "typescript", + "version": 0, + "text": "import {A} from \"../a/a\";\nnew A();" + } + } +} + +Projects:: + [/b/tsconfig.json] *new* + /a/a.d.ts + /b/b.ts +Open Files:: + [/b/b.ts] *new* + /b/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /b/tsconfig.json + [/b/tsconfig.json] *new* + RetainingProjects: + /b/tsconfig.json + RetainingOpenFiles: + /b/b.ts +Config File Names:: + [/b/b.ts] *new* + NearestConfigFileName: /b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///b/b.ts" + }, + "position": { + "line": 1, + "character": 4 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/b/tsconfig.json] + /a/a.d.ts + /b/b.ts +Config:: + [/a/tsconfig.json] *modified* + RetainingProjects: *modified* + /a/tsconfig.json *new* + /b/tsconfig.json + [/b/tsconfig.json] + RetainingProjects: + /b/tsconfig.json + RetainingOpenFiles: + /b/b.ts + + + + +// === findAllReferences === +// === /a/a.ts === +// export class [|A|] { } + +// === /b/b.ts === +// import {[|A|]} from "../a/a"; +// new /*FIND ALL REFS*/[|A|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRename.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRename.baseline new file mode 100644 index 0000000000..229282bede --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRename.baseline @@ -0,0 +1,168 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/user.ts] *new* +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a.fnA(); b.fnB(); a.instanceA; } + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/bin/a\";\nimport * as b from \"../b/bin/b\";\nexport function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /dev/null/inferred (default) +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + }, + "position": { + "line": 2, + "character": 29 + }, + "newName": "?" + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/dev/null/inferred] + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /a/tsconfig.json + + + + +// === findRenameLocations === +// === /a/a.ts === +// export function [|fnARENAME|]() {} +// export interface IfaceA {} +// export const instanceA: IfaceA = {}; + +// === /user/user.ts === +// import * as a from "../a/bin/a"; +// import * as b from "../b/bin/b"; +// export function fnUser() { a./*RENAME*/[|fnARENAME|](); b.fnB(); a.instanceA; } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/a/tsconfig.json] *deleted* + /a/a.ts + [/dev/null/inferred] *deleted* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *deleted* + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameStartingAtDefinition.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameStartingAtDefinition.baseline new file mode 100644 index 0000000000..eae0a698b7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameStartingAtDefinition.baseline @@ -0,0 +1,206 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/user.ts] *new* +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a.fnA(); b.fnB(); a.instanceA; } + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/bin/a\";\nimport * as b from \"../b/bin/b\";\nexport function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /dev/null/inferred (default) +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///a/a.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fnA() {}\nexport interface IfaceA {}\nexport const instanceA: IfaceA = {};" + } + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/dev/null/inferred] + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/a/a.ts] *new* + /a/tsconfig.json (default) + [/user/user.ts] + /dev/null/inferred (default) +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /a/tsconfig.json + RetainingOpenFiles: + /a/a.ts +Config File Names:: + [/a/a.ts] *new* + NearestConfigFileName: /a/tsconfig.json + Ancestors: + /a/tsconfig.json + [/user/user.ts] + NearestConfigFileName: + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///a/a.ts" + }, + "position": { + "line": 0, + "character": 16 + }, + "newName": "?" + } +} + + + + +// === findRenameLocations === +// === /a/a.ts === +// export function /*RENAME*/[|fnARENAME|]() {} +// export interface IfaceA {} +// export const instanceA: IfaceA = {}; + +// === /user/user.ts === +// import * as a from "../a/bin/a"; +// import * as b from "../b/bin/b"; +// export function fnUser() { a.[|fnARENAME|](); b.fnB(); a.instanceA; } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/a/a.ts] + /a/tsconfig.json (default) + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/a/tsconfig.json] + /a/a.ts + [/dev/null/inferred] *deleted* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/a/a.ts] + /a/tsconfig.json (default) + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/a/tsconfig.json] + RetainingProjects: + /a/tsconfig.json + RetainingOpenFiles: + /a/a.ts + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts +Config File Names:: + [/a/a.ts] + NearestConfigFileName: /a/tsconfig.json + Ancestors: + /a/tsconfig.json + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameTargetDoesNotExist.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameTargetDoesNotExist.baseline new file mode 100644 index 0000000000..4346f9eaf9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameTargetDoesNotExist.baseline @@ -0,0 +1,152 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/user.ts] *new* +import * as a from "../a/bin/a"; +import * as b from "../b/bin/b"; +export function fnUser() { a.fnA(); b.fnB(); a.instanceA; } + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/bin/a\";\nimport * as b from \"../b/bin/b\";\nexport function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /dev/null/inferred (default) +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + }, + "position": { + "line": 2, + "character": 38 + }, + "newName": "?" + } +} + + + + +// === findRenameLocations === +// === /b/bin/b.d.ts === +// export declare function [|fnBRENAME|](): void; +// //# sourceMappingURL=b.d.ts.map + +// === /user/user.ts === +// import * as a from "../a/bin/a"; +// import * as b from "../b/bin/b"; +// export function fnUser() { a.fnA(); b./*RENAME*/[|fnBRENAME|](); a.instanceA; } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/dev/null/inferred] *deleted* + /a/bin/a.d.ts + /b/bin/b.d.ts + /user/user.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirect.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirect.baseline new file mode 100644 index 0000000000..d810eb9bd7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirect.baseline @@ -0,0 +1,446 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": true + }, + "references": [{ "path": "../dependency" }] +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": true + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/random/tsconfig.json] *new* + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/random/tsconfig.json] *new* + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/random/random.ts] *new* + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + [/random/tsconfig.json] + /random/random.ts +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/main/tsconfig.json *new* + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] *new* + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] *closed* + [/random/random.ts] + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *deleted* + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *deleted* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *deleted* + [/myproject/main/tsconfig.json] *deleted* + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *deleted* + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirectEdit.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirectEdit.baseline new file mode 100644 index 0000000000..2d9b7d45c9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirectEdit.baseline @@ -0,0 +1,929 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": true + }, + "references": [{ "path": "../dependency" }] +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": true + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/main/tsconfig.json *new* + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 1 + }, + "end": { + "line": 0, + "character": 1 + } + }, + "text": "u" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 2 + }, + "end": { + "line": 0, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 3 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "text": "i" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 6 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 7 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 11 + }, + "end": { + "line": 0, + "character": 11 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 12 + }, + "end": { + "line": 0, + "character": 12 + } + }, + "text": "B" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 16 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 13 + }, + "end": { + "line": 0, + "character": 13 + } + }, + "text": "a" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 17 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 14 + } + }, + "text": "r" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 18 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 15 + } + }, + "text": "(" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 19 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 16 + }, + "end": { + "line": 0, + "character": 16 + } + }, + "text": ")" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 20 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 17 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 21 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 0, + "character": 18 + } + }, + "text": "{" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 22 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 19 + }, + "end": { + "line": 0, + "character": 19 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 23 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 20 + }, + "end": { + "line": 0, + "character": 20 + } + }, + "text": "}" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 24 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 21 + }, + "end": { + "line": 0, + "character": 21 + } + }, + "text": "\n" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 3, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/main/tsconfig.json] + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// function fooBar() { } +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// fn3, +// [|fn4RENAME|], +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// fn3(); +// [|fn4RENAME|](); +// fn5(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirectEditEnd.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirectEditEnd.baseline new file mode 100644 index 0000000000..4a3267804a --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithDisableSourceOfProjectReferenceRedirectEditEnd.baseline @@ -0,0 +1,703 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": true + }, + "references": [{ "path": "../dependency" }] +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": true + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/main/tsconfig.json *new* + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 1 + }, + "end": { + "line": 5, + "character": 1 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 3 + }, + "end": { + "line": 5, + "character": 3 + } + }, + "text": "s" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 5 + }, + "end": { + "line": 5, + "character": 5 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 6 + }, + "end": { + "line": 5, + "character": 6 + } + }, + "text": "x" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 7 + }, + "end": { + "line": 5, + "character": 7 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "text": "=" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 9 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 10 + }, + "end": { + "line": 5, + "character": 10 + } + }, + "text": "1" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 11 + } + }, + "text": "0" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 12 + }, + "end": { + "line": 5, + "character": 12 + } + }, + "text": ";" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/main/tsconfig.json] + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// const x = 10; + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferences.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferences.baseline new file mode 100644 index 0000000000..a49ff4483e --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferences.baseline @@ -0,0 +1,300 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + "references": [{ "path": "../dependency" }] +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/random/tsconfig.json] *new* + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/random/tsconfig.json] *new* + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/random/random.ts] *new* + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/dependency/FnS.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/myproject/dependency/FnS.ts] *modified* + /myproject/dependency/tsconfig.json (default) + /myproject/main/tsconfig.json *new* + [/random/random.ts] + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/main/tsconfig.json *new* + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + /myproject/main/tsconfig.json + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + /myproject/main/tsconfig.json + [/random/random.ts] *new* + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] *closed* + [/random/random.ts] + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *deleted* + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *deleted* + /myproject/dependency/FnS.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *deleted* + [/myproject/main/tsconfig.json] *deleted* + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *deleted* + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferencesEdit.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferencesEdit.baseline new file mode 100644 index 0000000000..9e647c2c2f --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferencesEdit.baseline @@ -0,0 +1,779 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + "references": [{ "path": "../dependency" }] +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/dependency/FnS.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* +Open Files:: + [/myproject/dependency/FnS.ts] *modified* + /myproject/dependency/tsconfig.json (default) + /myproject/main/tsconfig.json *new* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/main/tsconfig.json *new* + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 1 + }, + "end": { + "line": 0, + "character": 1 + } + }, + "text": "u" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 2 + }, + "end": { + "line": 0, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 3 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "text": "i" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 6 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 7 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 11 + }, + "end": { + "line": 0, + "character": 11 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 12 + }, + "end": { + "line": 0, + "character": 12 + } + }, + "text": "B" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 16 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 13 + }, + "end": { + "line": 0, + "character": 13 + } + }, + "text": "a" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 17 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 14 + } + }, + "text": "r" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 18 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 15 + } + }, + "text": "(" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 19 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 16 + }, + "end": { + "line": 0, + "character": 16 + } + }, + "text": ")" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 20 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 17 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 21 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 0, + "character": 18 + } + }, + "text": "{" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 22 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 19 + }, + "end": { + "line": 0, + "character": 19 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 23 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 20 + }, + "end": { + "line": 0, + "character": 20 + } + }, + "text": "}" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 24 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 21 + }, + "end": { + "line": 0, + "character": 21 + } + }, + "text": "\n" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 3, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/main/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + /myproject/main/main.ts + [/myproject/tsconfig.json] + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// function fooBar() { } +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferencesEditEnd.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferencesEditEnd.baseline new file mode 100644 index 0000000000..13e6ff1734 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithProjectReferencesEditEnd.baseline @@ -0,0 +1,553 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + "references": [{ "path": "../dependency" }] +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/dependency/FnS.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* +Open Files:: + [/myproject/dependency/FnS.ts] *modified* + /myproject/dependency/tsconfig.json (default) + /myproject/main/tsconfig.json *new* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/main/tsconfig.json *new* + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 1 + }, + "end": { + "line": 5, + "character": 1 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 3 + }, + "end": { + "line": 5, + "character": 3 + } + }, + "text": "s" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 5 + }, + "end": { + "line": 5, + "character": 5 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 6 + }, + "end": { + "line": 5, + "character": 6 + } + }, + "text": "x" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 7 + }, + "end": { + "line": 5, + "character": 7 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "text": "=" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 9 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 10 + }, + "end": { + "line": 5, + "character": 10 + } + }, + "text": "1" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 11 + } + }, + "text": "0" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 12 + }, + "end": { + "line": 5, + "character": 12 + } + }, + "text": ";" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/main/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + /myproject/main/main.ts + [/myproject/tsconfig.json] + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// const x = 10; + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMaps.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMaps.baseline new file mode 100644 index 0000000000..55325881c9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMaps.baseline @@ -0,0 +1,423 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/random/tsconfig.json] *new* + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/random/tsconfig.json] *new* + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/random/random.ts] *new* + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *modified* + [/random/tsconfig.json] + /random/random.ts +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] *new* + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] *closed* + [/random/random.ts] + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *deleted* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *deleted* + [/myproject/main/tsconfig.json] *deleted* + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *deleted* + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsEdit.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsEdit.baseline new file mode 100644 index 0000000000..964d19c2e6 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsEdit.baseline @@ -0,0 +1,891 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *modified* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 1 + }, + "end": { + "line": 0, + "character": 1 + } + }, + "text": "u" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 2 + }, + "end": { + "line": 0, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 3 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "text": "i" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 6 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 7 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 11 + }, + "end": { + "line": 0, + "character": 11 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 12 + }, + "end": { + "line": 0, + "character": 12 + } + }, + "text": "B" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 16 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 13 + }, + "end": { + "line": 0, + "character": 13 + } + }, + "text": "a" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 17 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 14 + } + }, + "text": "r" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 18 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 15 + } + }, + "text": "(" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 19 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 16 + }, + "end": { + "line": 0, + "character": 16 + } + }, + "text": ")" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 20 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 17 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 21 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 0, + "character": 18 + } + }, + "text": "{" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 22 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 19 + }, + "end": { + "line": 0, + "character": 19 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 23 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 20 + }, + "end": { + "line": 0, + "character": 20 + } + }, + "text": "}" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 24 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 21 + }, + "end": { + "line": 0, + "character": 21 + } + }, + "text": "\n" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 3, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/tsconfig.json] + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// function fooBar() { } +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsEditEnd.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsEditEnd.baseline new file mode 100644 index 0000000000..98b9e58e70 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsEditEnd.baseline @@ -0,0 +1,665 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + "files": [], + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *modified* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 1 + }, + "end": { + "line": 5, + "character": 1 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 3 + }, + "end": { + "line": 5, + "character": 3 + } + }, + "text": "s" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 5 + }, + "end": { + "line": 5, + "character": 5 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 6 + }, + "end": { + "line": 5, + "character": 6 + } + }, + "text": "x" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 7 + }, + "end": { + "line": 5, + "character": 7 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "text": "=" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 9 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 10 + }, + "end": { + "line": 5, + "character": 10 + } + }, + "text": "1" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 11 + } + }, + "text": "0" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 12 + }, + "end": { + "line": 5, + "character": 12 + } + }, + "text": ";" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/tsconfig.json] + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// const x = 10; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolution.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolution.baseline new file mode 100644 index 0000000000..d40fc5b87e --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolution.baseline @@ -0,0 +1,457 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/random/tsconfig.json] *new* + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/random/tsconfig.json] *new* + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/random/random.ts] *new* + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) + [/random/random.ts] + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *new* + /myproject/main/main.ts *new* + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/myproject/dependency/FnS.ts] *modified* + /myproject/dependency/tsconfig.json (default) + /myproject/tsconfig.json *new* + [/random/random.ts] + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + /myproject/tsconfig.json + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] + /myproject/dependency/tsconfig.json (default) + /myproject/tsconfig.json + [/random/random.ts] *new* + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + } + } +} + +Open Files:: + [/myproject/dependency/FnS.ts] *closed* + [/random/random.ts] + /random/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///random/random.ts" + } + } +} + +Open Files:: + [/random/random.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///random/random.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *deleted* + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *deleted* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *deleted* + /myproject/dependency/FnS.ts + /myproject/main/main.ts + [/random/tsconfig.json] + /random/random.ts +Open Files:: + [/random/random.ts] *new* + /random/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *deleted* + [/myproject/main/tsconfig.json] *deleted* + [/myproject/tsconfig.json] *deleted* + [/random/tsconfig.json] + RetainingProjects: + /random/tsconfig.json + RetainingOpenFiles: + /random/random.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *deleted* + [/random/random.ts] + NearestConfigFileName: /random/tsconfig.json diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolutionEdit.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolutionEdit.baseline new file mode 100644 index 0000000000..8525100948 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolutionEdit.baseline @@ -0,0 +1,936 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *new* + /myproject/main/main.ts *new* +Open Files:: + [/myproject/dependency/FnS.ts] *modified* + /myproject/dependency/tsconfig.json (default) + /myproject/tsconfig.json *new* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 1 + }, + "end": { + "line": 0, + "character": 1 + } + }, + "text": "u" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 2 + }, + "end": { + "line": 0, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 3 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "text": "i" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 6 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 7 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "text": "f" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 10 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 11 + }, + "end": { + "line": 0, + "character": 11 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 12 + }, + "end": { + "line": 0, + "character": 12 + } + }, + "text": "B" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 16 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 13 + }, + "end": { + "line": 0, + "character": 13 + } + }, + "text": "a" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 17 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 14 + } + }, + "text": "r" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 18 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 15 + }, + "end": { + "line": 0, + "character": 15 + } + }, + "text": "(" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 19 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 16 + }, + "end": { + "line": 0, + "character": 16 + } + }, + "text": ")" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 20 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 17 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 21 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 0, + "character": 18 + } + }, + "text": "{" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 22 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 19 + }, + "end": { + "line": 0, + "character": 19 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 23 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 20 + }, + "end": { + "line": 0, + "character": 20 + } + }, + "text": "}" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 24 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 21 + }, + "end": { + "line": 0, + "character": 21 + } + }, + "text": "\n" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 3, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/main/tsconfig.json] + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + /myproject/main/main.ts + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// function fooBar() { } +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolutionEditEnd.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolutionEditEnd.baseline new file mode 100644 index 0000000000..f923c0fdbb --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsRenameWithSourceMapsNotSolutionEditEnd.baseline @@ -0,0 +1,710 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/decls/FnS.d.ts] *new* +export declare function fn1(): void; +export declare function fn2(): void; +export declare function fn3(): void; +export declare function fn4(): void; +export declare function fn5(): void; +//# sourceMappingURL=FnS.d.ts.map +//// [/myproject/decls/FnS.d.ts.map] *new* +{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM"} +//// [/myproject/dependency/FnS.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fn1 = fn1; +exports.fn2 = fn2; +exports.fn3 = fn3; +exports.fn4 = fn4; +exports.fn5 = fn5; +function fn1() { } +function fn2() { } +function fn3() { } +function fn4() { } +function fn5() { } + +//// [/myproject/dependency/FnS.ts] *new* +export function fn1() { } +export function fn2() { } +export function fn3() { } +export function fn4() { } +export function fn5() { } + +//// [/myproject/dependency/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "declarationDir": "../decls" + } +} +//// [/myproject/dependency/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./FnS.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n","signature":"bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n","impliedNodeFormat":1}],"options":{"composite":true,"declarationDir":"../decls","declarationMap":true},"latestChangedDtsFile":"../decls/FnS.d.ts"} +//// [/myproject/dependency/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./FnS.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./FnS.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./FnS.ts", + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "dabc23167a661a3e71744cf63ff5adcc-export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n", + "signature": "bf56b5172c2fd500384b437b7700d594-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "declarationDir": "../decls", + "declarationMap": true + }, + "latestChangedDtsFile": "../decls/FnS.d.ts", + "size": 1423 +} +//// [/myproject/main/main.d.ts] *new* +export {}; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/main/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":""} +//// [/myproject/main/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const FnS_1 = require("../decls/FnS"); +(0, FnS_1.fn1)(); +(0, FnS_1.fn2)(); +(0, FnS_1.fn3)(); +(0, FnS_1.fn4)(); +(0, FnS_1.fn5)(); + +//// [/myproject/main/main.ts] *new* +import { + fn1, + fn2, + fn3, + fn4, + fn5 +} from "../decls/FnS"; + +fn1(); +fn2(); +fn3(); +fn4(); +fn5(); +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "disableSourceOfProjectReferenceRedirect": false + }, + +} +//// [/myproject/main/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[3],"fileNames":["lib.d.ts","../decls/FnS.d.ts","./main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map",{"version":"72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true},"referencedMap":[[3,1]],"latestChangedDtsFile":"./main.d.ts"} +//// [/myproject/main/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./main.ts" + ], + "original": 3 + } + ], + "fileNames": [ + "lib.d.ts", + "../decls/FnS.d.ts", + "./main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../decls/FnS.d.ts", + "version": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "signature": "ccbe7f3de9ff1ded77b994bef4cf9dce-export declare function fn1(): void;\nexport declare function fn2(): void;\nexport declare function fn3(): void;\nexport declare function fn4(): void;\nexport declare function fn5(): void;\n//# sourceMappingURL=FnS.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./main.ts", + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "72620bcff3a257f2c990b3f030e1b8e3-import {\n\tfn1,\n\tfn2,\n\tfn3,\n\tfn4,\n\tfn5\n} from \"../decls/FnS\";\n\nfn1();\nfn2();\nfn3();\nfn4();\nfn5();", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../decls/FnS.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true + }, + "referencedMap": { + "./main.ts": [ + "../decls/FnS.d.ts" + ] + }, + "latestChangedDtsFile": "./main.d.ts", + "size": 1515 +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": false + }, + + "references": [ + { "path": "dependency" }, + { "path": "main" } + ] +} +//// [/random/random.ts] *new* +export const a = 10; +//// [/random/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "languageId": "typescript", + "version": 0, + "text": "export function fn1() { }\nexport function fn2() { }\nexport function fn3() { }\nexport function fn4() { }\nexport function fn5() { }\n" + } + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *new* + /myproject/dependency/FnS.ts + [/myproject/tsconfig.json] *new* +Open Files:: + [/myproject/dependency/FnS.ts] *new* + /myproject/dependency/tsconfig.json (default) +Config:: + [/myproject/dependency/tsconfig.json] *new* + RetainingProjects: + /myproject/dependency/tsconfig.json + RetainingOpenFiles: + /myproject/dependency/FnS.ts +Config File Names:: + [/myproject/dependency/FnS.ts] *new* + NearestConfigFileName: /myproject/dependency/tsconfig.json + Ancestors: + /myproject/dependency/tsconfig.json /myproject/tsconfig.json + /myproject/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *new* + /myproject/main/main.ts *new* +Open Files:: + [/myproject/dependency/FnS.ts] *modified* + /myproject/dependency/tsconfig.json (default) + /myproject/tsconfig.json *new* +Config:: + [/myproject/dependency/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/dependency/tsconfig.json + /myproject/tsconfig.json *new* + RetainingOpenFiles: + /myproject/dependency/FnS.ts + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 0 + }, + "end": { + "line": 5, + "character": 0 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 1 + }, + "end": { + "line": 5, + "character": 1 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 3 + }, + "end": { + "line": 5, + "character": 3 + } + }, + "text": "s" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 4 + }, + "end": { + "line": 5, + "character": 4 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 5 + }, + "end": { + "line": 5, + "character": 5 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 6 + }, + "end": { + "line": 5, + "character": 6 + } + }, + "text": "x" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 7 + }, + "end": { + "line": 5, + "character": 7 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "text": "=" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 9 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 13 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 10 + }, + "end": { + "line": 5, + "character": 10 + } + }, + "text": "1" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 14 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 11 + }, + "end": { + "line": 5, + "character": 11 + } + }, + "text": "0" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts", + "version": 15 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 5, + "character": 12 + }, + "end": { + "line": 5, + "character": 12 + } + }, + "text": ";" + } + ] + } +} + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///myproject/dependency/FnS.ts" + }, + "position": { + "line": 2, + "character": 16 + }, + "newName": "?" + } +} + +Projects:: + [/myproject/dependency/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + [/myproject/main/tsconfig.json] + /myproject/decls/FnS.d.ts + /myproject/main/main.ts + [/myproject/tsconfig.json] *modified* + /myproject/dependency/FnS.ts *modified* + /myproject/main/main.ts + + + + +// === findRenameLocations === +// === /myproject/dependency/FnS.ts === +// export function fn1() { } +// export function fn2() { } +// export function /*RENAME*/[|fn3RENAME|]() { } +// export function fn4() { } +// export function fn5() { } +// const x = 10; + +// === /myproject/main/main.ts === +// import { +// fn1, +// fn2, +// [|fn3RENAME|], +// fn4, +// fn5 +// } from "../decls/FnS"; +// +// fn1(); +// fn2(); +// [|fn3RENAME|](); +// fn4(); +// fn5(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline new file mode 100644 index 0000000000..27108ed47a --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline @@ -0,0 +1,216 @@ +UseCaseSensitiveFileNames: true +//// [/a/a.ts] *new* +export function fnA() {} +export interface IfaceA {} +export const instanceA: IfaceA = {}; +//// [/a/bin/a.d.ts] *new* +export declare function fnA(): void; +export interface IfaceA { +} +export declare const instanceA: IfaceA; +//# sourceMappingURL=a.d.ts.map +//// [/a/bin/a.d.ts.map] *new* +{ + "version": 3, + "file": "a.d.ts", + "sourceRoot": "", + "sources": ["../a.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" +} +//// [/a/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/b/b.ts] *new* +export function fnB() {} +//// [/b/bin/b.d.ts] *new* +export declare function fnB(): void; +//# sourceMappingURL=b.d.ts.map +//// [/b/bin/b.d.ts.map] *new* +{ + "version": 3, + "file": "b.d.ts", + "sourceRoot": "", + "sources": ["../b.ts"], + "names": [], + "mappings": "AAAA,wBAAgB,GAAG,SAAK" +} +//// [/b/c.ts] *new* +export function fnC() {} +//// [/b/tsconfig.json] *new* +{ + "compilerOptions": { + "outDir": "bin", + "declarationMap": true, + "composite": true + } +} +//// [/dummy/dummy.ts] *new* +export const a = 10; +//// [/dummy/tsconfig.json] *new* +{} +//// [/user/tsconfig.json] *new* +{ + "references": [ + { "path": "../a" }, + { "path": "../b" } + ] +} +//// [/user/user.ts] *new* +import * as a from "../a/a"; +import * as b from "../b/b"; +export function fnUser() { + a.fnA(); + b.fnB(); + a.instanceA; +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///user/user.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as a from \"../a/a\";\nimport * as b from \"../b/b\";\nexport function fnUser() {\n\ta.fnA();\n\tb.fnB();\n\ta.instanceA;\n}" + } + } +} + +Projects:: + [/user/tsconfig.json] *new* + /a/a.ts + /b/b.ts + /user/user.ts +Open Files:: + [/user/user.ts] *new* + /user/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *new* + RetainingProjects: + /user/tsconfig.json + [/b/tsconfig.json] *new* + RetainingProjects: + /user/tsconfig.json + [/user/tsconfig.json] *new* + RetainingProjects: + /user/tsconfig.json + RetainingOpenFiles: + /user/user.ts +Config File Names:: + [/user/user.ts] *new* + NearestConfigFileName: /user/tsconfig.json + +{ + "method": "workspace/symbol", + "params": { + "query": "fn" + } +} + +Projects:: + [/a/tsconfig.json] *new* + /a/a.ts + [/b/tsconfig.json] *new* + /b/b.ts + /b/c.ts + [/user/tsconfig.json] + /a/a.ts + /b/b.ts + /user/user.ts +Config:: + [/a/tsconfig.json] *modified* + RetainingProjects: *modified* + /a/tsconfig.json *new* + /user/tsconfig.json + [/b/tsconfig.json] *modified* + RetainingProjects: *modified* + /b/tsconfig.json *new* + /user/tsconfig.json + [/user/tsconfig.json] + RetainingProjects: + /user/tsconfig.json + RetainingOpenFiles: + /user/user.ts + + + + +// === workspaceSymbol === +// === /a/a.ts === +// [|{| name: fnA, kind: Function |}export function fnA() {}|] +// export interface IfaceA {} +// export const instanceA: IfaceA = {}; + +// === /b/b.ts === +// [|{| name: fnB, kind: Function |}export function fnB() {}|] + +// === /b/c.ts === +// [|{| name: fnC, kind: Function |}export function fnC() {}|] + +// === /user/user.ts === +// import * as a from "../a/a"; +// import * as b from "../b/b"; +// [|{| name: fnUser, kind: Function |}export function fnUser() { +// a.fnA(); +// b.fnB(); +// a.instanceA; +// }|] +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///user/user.ts" + } + } +} + +Open Files:: + [/user/user.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "export const a = 10;" + } + } +} + +Projects:: + [/a/tsconfig.json] *deleted* + /a/a.ts + [/b/tsconfig.json] *deleted* + /b/b.ts + /b/c.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts + [/user/tsconfig.json] *deleted* + /a/a.ts + /b/b.ts + /user/user.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/a/tsconfig.json] *deleted* + [/b/tsconfig.json] *deleted* + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/user/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/user/user.ts] *deleted* diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline new file mode 100644 index 0000000000..ec8c01300b --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline @@ -0,0 +1,179 @@ +UseCaseSensitiveFileNames: true +//// [/solution/compiler/program.ts] *new* +namespace ts { + export const program: Program = { + getSourceFiles: () => [getSourceFile()] + }; + function getSourceFile() { return "something"; } +} +//// [/solution/compiler/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "disableSolutionSearching": false, + }, + "files": ["./types.ts", "./program.ts"] +} +//// [/solution/compiler/types.ts] *new* +namespace ts { + export interface Program { + getSourceFiles(): string[]; + } +} +//// [/solution/services/services.ts] *new* +/// +/// +namespace ts { + const result = program.getSourceFiles(); +} +//// [/solution/services/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + }, + "files": ["./services.ts"], + "references": [ + { "path": "../compiler" }, + ], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "include": [], + "references": [ + { "path": "./compiler" }, + { "path": "./services" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/compiler/program.ts", + "languageId": "typescript", + "version": 0, + "text": "namespace ts {\n\texport const program: Program = {\n\t\tgetSourceFiles: () => [getSourceFile()]\n\t};\n\tfunction getSourceFile() { return \"something\"; }\n}" + } + } +} + +Projects:: + [/solution/compiler/tsconfig.json] *new* + /solution/compiler/types.ts + /solution/compiler/program.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/compiler/program.ts] *new* + /solution/compiler/tsconfig.json (default) +Config:: + [/solution/compiler/tsconfig.json] *new* + RetainingProjects: + /solution/compiler/tsconfig.json + RetainingOpenFiles: + /solution/compiler/program.ts +Config File Names:: + [/solution/compiler/program.ts] *new* + NearestConfigFileName: /solution/compiler/tsconfig.json + Ancestors: + /solution/compiler/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/compiler/program.ts" + }, + "position": { + "line": 2, + "character": 25 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /solution/compiler/program.ts === +// namespace ts { +// export const program: Program = { +// getSourceFiles: () => [/*FIND ALL REFS*/[|getSourceFile|]()] +// }; +// function [|getSourceFile|]() { return "something"; } +// } +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/compiler/program.ts" + }, + "position": { + "line": 2, + "character": 2 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/compiler/tsconfig.json] + /solution/compiler/types.ts + /solution/compiler/program.ts + [/solution/services/tsconfig.json] *new* + /solution/compiler/types.ts + /solution/compiler/program.ts + /solution/services/services.ts + [/solution/tsconfig.json] *modified* +Open Files:: + [/solution/compiler/program.ts] *modified* + /solution/compiler/tsconfig.json (default) + /solution/services/tsconfig.json *new* +Config:: + [/solution/compiler/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/compiler/tsconfig.json + /solution/services/tsconfig.json *new* + /solution/tsconfig.json *new* + RetainingOpenFiles: + /solution/compiler/program.ts + [/solution/services/tsconfig.json] *new* + RetainingProjects: + /solution/services/tsconfig.json + /solution/tsconfig.json + [/solution/tsconfig.json] *new* + RetainingProjects: + /solution/tsconfig.json + + + + +// === findAllReferences === +// === /solution/compiler/program.ts === +// namespace ts { +// export const program: Program = { +// /*FIND ALL REFS*/[|getSourceFiles|]: () => [getSourceFile()] +// }; +// function getSourceFile() { return "something"; } +// } + +// === /solution/compiler/types.ts === +// namespace ts { +// export interface Program { +// [|getSourceFiles|](): string[]; +// } +// } + +// === /solution/services/services.ts === +// /// +// /// +// namespace ts { +// const result = program.[|getSourceFiles|](); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline new file mode 100644 index 0000000000..e544f1b7eb --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline @@ -0,0 +1,139 @@ +UseCaseSensitiveFileNames: true +//// [/solution/compiler/program.ts] *new* +namespace ts { + export const program: Program = { + getSourceFiles: () => [getSourceFile()] + }; + function getSourceFile() { return "something"; } +} +//// [/solution/compiler/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "disableSolutionSearching": true, + }, + "files": ["./types.ts", "./program.ts"] +} +//// [/solution/compiler/types.ts] *new* +namespace ts { + export interface Program { + getSourceFiles(): string[]; + } +} +//// [/solution/services/services.ts] *new* +/// +/// +namespace ts { + const result = program.getSourceFiles(); +} +//// [/solution/services/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + }, + "files": ["./services.ts"], + "references": [ + { "path": "../compiler" }, + ], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "include": [], + "references": [ + { "path": "./compiler" }, + { "path": "./services" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/compiler/program.ts", + "languageId": "typescript", + "version": 0, + "text": "namespace ts {\n\texport const program: Program = {\n\t\tgetSourceFiles: () => [getSourceFile()]\n\t};\n\tfunction getSourceFile() { return \"something\"; }\n}" + } + } +} + +Projects:: + [/solution/compiler/tsconfig.json] *new* + /solution/compiler/types.ts + /solution/compiler/program.ts +Open Files:: + [/solution/compiler/program.ts] *new* + /solution/compiler/tsconfig.json (default) +Config:: + [/solution/compiler/tsconfig.json] *new* + RetainingProjects: + /solution/compiler/tsconfig.json + RetainingOpenFiles: + /solution/compiler/program.ts +Config File Names:: + [/solution/compiler/program.ts] *new* + NearestConfigFileName: /solution/compiler/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/compiler/program.ts" + }, + "position": { + "line": 2, + "character": 25 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /solution/compiler/program.ts === +// namespace ts { +// export const program: Program = { +// getSourceFiles: () => [/*FIND ALL REFS*/[|getSourceFile|]()] +// }; +// function [|getSourceFile|]() { return "something"; } +// } +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/compiler/program.ts" + }, + "position": { + "line": 2, + "character": 2 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /solution/compiler/program.ts === +// namespace ts { +// export const program: Program = { +// /*FIND ALL REFS*/[|getSourceFiles|]: () => [getSourceFile()] +// }; +// function getSourceFile() { return "something"; } +// } + +// === /solution/compiler/types.ts === +// namespace ts { +// export interface Program { +// [|getSourceFiles|](): string[]; +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..d650756384 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -0,0 +1,130 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..26e0d60718 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -0,0 +1,142 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..26e216f15e --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -0,0 +1,130 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..34ead087ea --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -0,0 +1,142 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..744a08f01c --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -0,0 +1,130 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..a84a5fd038 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -0,0 +1,142 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..b9b50f45dc --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -0,0 +1,130 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..8f986664fd --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -0,0 +1,142 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/b/helper.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \".\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Open Files:: + [/myproject/a/index.ts] + /myproject/a/tsconfig.json (default) + [/myproject/b/helper.ts] *new* + /myproject/b/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + RetainingOpenFiles: + /myproject/b/helper.ts +Config File Names:: + [/myproject/a/index.ts] + NearestConfigFileName: /myproject/a/tsconfig.json + [/myproject/b/helper.ts] *new* + NearestConfigFileName: /myproject/b/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..23659d8d85 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -0,0 +1,88 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..46b5b8d577 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -0,0 +1,118 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..bf66bd9fe5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -0,0 +1,88 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..b7fcab8376 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -0,0 +1,118 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..e75c517c0a --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -0,0 +1,88 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..d98007bb4b --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -0,0 +1,118 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": true, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline new file mode 100644 index 0000000000..fd2ef7802c --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -0,0 +1,88 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/lib/index.d.ts === +// export declare class [|B|] { +// M(): void; +// } +// //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline new file mode 100644 index 0000000000..455c0744bc --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -0,0 +1,118 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/a/index.ts] *new* +import { B } from "../b/lib"; +const b: B = new B(); +//// [/myproject/a/tsconfig.json] *new* +{ + "disableReferencedProjectLoad": false, + "disableSourceOfProjectReferenceRedirect": false, + "composite": true +} +//// [/myproject/b/helper.ts] *new* +import { B } from "."; +const b: B = new B(); +//// [/myproject/b/index.ts] *new* +export class B { + M() {} +} +//// [/myproject/b/lib/index.d.ts] *new* +export declare class B { + M(): void; +} +//# sourceMappingURL=index.d.ts.map +//// [/myproject/b/lib/index.d.ts.map] *new* +{ + "version": 3, + "file": "index.d.ts", + "sourceRoot": "", + "sources": ["../index.ts"], + "names": [], + "mappings": "AAAA,qBAAa,CAAC;IACV,CAAC;CACJ" +} +//// [/myproject/b/tsconfig.json] *new* +{ + "declarationMap": true, + "outDir": "lib", + "composite": true, +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { B } from \"../b/lib\";\nconst b: B = new B();" + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] *new* + /myproject/b/lib/index.d.ts + /myproject/a/index.ts +Open Files:: + [/myproject/a/index.ts] *new* + /myproject/a/tsconfig.json (default) +Config:: + [/myproject/a/tsconfig.json] *new* + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts +Config File Names:: + [/myproject/a/index.ts] *new* + NearestConfigFileName: /myproject/a/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/a/index.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/a/tsconfig.json] + /myproject/b/lib/index.d.ts + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + /myproject/b/index.ts + /myproject/b/helper.ts + /myproject/b/lib/index.d.ts +Config:: + [/myproject/a/tsconfig.json] + RetainingProjects: + /myproject/a/tsconfig.json + RetainingOpenFiles: + /myproject/a/index.ts + [/myproject/b/tsconfig.json] *new* + RetainingProjects: + /myproject/b/tsconfig.json + + + + +// === findAllReferences === +// === /myproject/a/index.ts === +// import { [|B|] } from "../b/lib"; +// const b: /*FIND ALL REFS*/[|B|] = new [|B|](); + +// === /myproject/b/helper.ts === +// import { [|B|] } from "."; +// const b: [|B|] = new [|B|](); + +// === /myproject/b/index.ts === +// export class [|B|] { +// M() {} +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline new file mode 100644 index 0000000000..109e42807c --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline @@ -0,0 +1,452 @@ +UseCaseSensitiveFileNames: true +//// [/packages/babel-loader/src/index.ts] *new* +import type { Foo } from "../../core/src/index.js"; +//// [/packages/babel-loader/tsconfig.json] *new* +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "composite": true, + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"], + "references": [{"path": "../core"}] +} +//// [/packages/core/src/index.ts] *new* +import { Bar } from "./loading-indicator.js"; +export type Foo = {}; +const bar: Bar = { + prop: 0 +} +//// [/packages/core/src/loading-indicator.ts] *new* +export interface Bar { + prop: number; +} +const bar: Bar = { + prop: 1 +} +//// [/packages/core/tsconfig.json] *new* +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "composite": true, + "rootDir": "./src", + "outDir": "./dist", + }, + "include": ["./src"] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import type { Foo } from \"../../core/src/index.js\";" + } + } +} + +Projects:: + [/packages/babel-loader/tsconfig.json] *new* + /packages/core/src/loading-indicator.ts + /packages/core/src/index.ts + /packages/babel-loader/src/index.ts +Open Files:: + [/packages/babel-loader/src/index.ts] *new* + /packages/babel-loader/tsconfig.json (default) +Config:: + [/packages/babel-loader/tsconfig.json] *new* + RetainingProjects: + /packages/babel-loader/tsconfig.json + RetainingOpenFiles: + /packages/babel-loader/src/index.ts + [/packages/core/tsconfig.json] *new* + RetainingProjects: + /packages/babel-loader/tsconfig.json +Config File Names:: + [/packages/babel-loader/src/index.ts] *new* + NearestConfigFileName: /packages/babel-loader/tsconfig.json + Ancestors: + /packages/babel-loader/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///packages/core/src/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { Bar } from \"./loading-indicator.js\";\nexport type Foo = {};\nconst bar: Bar = {\n\tprop: 0\n}" + } + } +} + +Projects:: + [/packages/babel-loader/tsconfig.json] + /packages/core/src/loading-indicator.ts + /packages/core/src/index.ts + /packages/babel-loader/src/index.ts + [/packages/core/tsconfig.json] *new* + /packages/core/src/loading-indicator.ts + /packages/core/src/index.ts +Open Files:: + [/packages/babel-loader/src/index.ts] + /packages/babel-loader/tsconfig.json (default) + [/packages/core/src/index.ts] *new* + /packages/babel-loader/tsconfig.json + /packages/core/tsconfig.json (default) +Config:: + [/packages/babel-loader/tsconfig.json] + RetainingProjects: + /packages/babel-loader/tsconfig.json + RetainingOpenFiles: + /packages/babel-loader/src/index.ts + [/packages/core/tsconfig.json] *modified* + RetainingProjects: *modified* + /packages/babel-loader/tsconfig.json + /packages/core/tsconfig.json *new* + RetainingOpenFiles: *modified* + /packages/core/src/index.ts *new* +Config File Names:: + [/packages/babel-loader/src/index.ts] + NearestConfigFileName: /packages/babel-loader/tsconfig.json + Ancestors: + /packages/babel-loader/tsconfig.json + [/packages/core/src/index.ts] *new* + NearestConfigFileName: /packages/core/tsconfig.json + Ancestors: + /packages/core/tsconfig.json + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 3 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "text": "/" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 4 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 1 + }, + "end": { + "line": 0, + "character": 1 + } + }, + "text": "/" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 5 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 2 + }, + "end": { + "line": 0, + "character": 2 + } + }, + "text": " " + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 6 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 3 + } + }, + "text": "c" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 7 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 4 + } + }, + "text": "o" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 8 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "text": "m" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 9 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 6 + } + }, + "text": "m" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 10 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 7 + } + }, + "text": "e" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 11 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 8 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "text": "n" + } + ] + } +} + +{ + "method": "textDocument/didChange", + "params": { + "textDocument": { + "uri": "file:///packages/babel-loader/src/index.ts", + "version": 12 + }, + "contentChanges": [ + { + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "text": "t" + } + ] + } +} + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///packages/core/src/index.ts" + }, + "position": { + "line": 3, + "character": 1 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/packages/babel-loader/tsconfig.json] *modified* + /packages/babel-loader/src/index.ts *modified* + /packages/core/src/loading-indicator.ts *deleted* + /packages/core/src/index.ts *deleted* + [/packages/core/tsconfig.json] + /packages/core/src/loading-indicator.ts + /packages/core/src/index.ts +Open Files:: + [/packages/babel-loader/src/index.ts] + /packages/babel-loader/tsconfig.json (default) + [/packages/core/src/index.ts] *modified* + /packages/babel-loader/tsconfig.json *deleted* + /packages/core/tsconfig.json (default) + + + + +// === findAllReferences === +// === /packages/core/src/index.ts === +// import { Bar } from "./loading-indicator.js"; +// export type Foo = {}; +// const bar: Bar = { +// /*FIND ALL REFS*/[|prop|]: 0 +// } + +// === /packages/core/src/loading-indicator.ts === +// export interface Bar { +// [|prop|]: number; +// } +// const bar: Bar = { +// [|prop|]: 1 +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline new file mode 100644 index 0000000000..176a89c9d9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline @@ -0,0 +1,122 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/playground/tests.ts] *new* +export function foo() {} +//// [/myproject/playground/tsconfig-json/src/src.ts] *new* +export function foobar() {} +//// [/myproject/playground/tsconfig-json/tests/spec.ts] *new* +export function bar() { } + +//// [/myproject/playground/tsconfig-json/tsconfig.json] *new* +{ + "include": ["./src"] +} +//// [/myproject/playground/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/playground/tests.ts", + "languageId": "typescript", + "version": 0, + "text": "export function foo() {}" + } + } +} + +Projects:: + [/myproject/playground/tsconfig.json] *new* + /myproject/playground/tests.ts + /myproject/playground/tsconfig-json/src/src.ts + /myproject/playground/tsconfig-json/tests/spec.ts +Open Files:: + [/myproject/playground/tests.ts] *new* + /myproject/playground/tsconfig.json (default) +Config:: + [/myproject/playground/tsconfig.json] *new* + RetainingProjects: + /myproject/playground/tsconfig.json + RetainingOpenFiles: + /myproject/playground/tests.ts +Config File Names:: + [/myproject/playground/tests.ts] *new* + NearestConfigFileName: /myproject/playground/tsconfig.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/playground/tests.ts" + } + } +} + +Open Files:: + [/myproject/playground/tests.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/playground/tsconfig-json/tests/spec.ts", + "languageId": "typescript", + "version": 0, + "text": "export function bar() { }\n" + } + } +} + +Projects:: + [/myproject/playground/tsconfig-json/tsconfig.json] *new* + /myproject/playground/tsconfig-json/src/src.ts + [/myproject/playground/tsconfig.json] + /myproject/playground/tests.ts + /myproject/playground/tsconfig-json/src/src.ts + /myproject/playground/tsconfig-json/tests/spec.ts +Open Files:: + [/myproject/playground/tsconfig-json/tests/spec.ts] *new* + /myproject/playground/tsconfig.json (default) +Config:: + [/myproject/playground/tsconfig-json/tsconfig.json] *new* + RetainingProjects: + /myproject/playground/tsconfig-json/tsconfig.json + RetainingOpenFiles: + /myproject/playground/tsconfig-json/tests/spec.ts + [/myproject/playground/tsconfig.json] *modified* + RetainingProjects: + /myproject/playground/tsconfig.json + RetainingOpenFiles: *modified* + /myproject/playground/tests.ts *deleted* + /myproject/playground/tsconfig-json/tests/spec.ts *new* +Config File Names:: + [/myproject/playground/tests.ts] *deleted* + [/myproject/playground/tsconfig-json/tests/spec.ts] *new* + NearestConfigFileName: /myproject/playground/tsconfig-json/tsconfig.json + Ancestors: + /myproject/playground/tsconfig-json/tsconfig.json /myproject/playground/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/playground/tsconfig-json/tests/spec.ts" + }, + "position": { + "line": 0, + "character": 16 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/playground/tsconfig-json/tests/spec.ts === +// export function /*FIND ALL REFS*/[|bar|]() { } +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline new file mode 100644 index 0000000000..4707f0a907 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline @@ -0,0 +1,237 @@ +UseCaseSensitiveFileNames: true +//// [/solution/a/index.ts] *new* +export interface I { + M(): void; +} +//// [/solution/a/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "files": ["./index.ts"] +} +//// [/solution/b/index.ts] *new* +import { I } from "../a"; +export class B implements I { + M() {} +} +//// [/solution/b/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + }, + "files": ["./index.ts"], + "references": [ + { "path": "../a" }, + ], +} +//// [/solution/c/index.ts] *new* +import { I } from "../a"; +import { B } from "../b"; +export const C: I = new B(); +//// [/solution/c/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + }, + "files": ["./index.ts"], + "references": [ + { "path": "../b" }, + ], +} +//// [/solution/d/index.ts] *new* +import { I } from "../a"; +import { C } from "../c"; +export const D: I = C; + +//// [/solution/d/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true + }, + "files": ["./index.ts"], + "references": [ + { "path": "../c" }, + ], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "include": [], + "references": [ + { "path": "./a" }, + { "path": "./b" }, + { "path": "./c" }, + { "path": "./d" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/b/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { I } from \"../a\";\nexport class B implements I {\n\tM() {}\n}" + } + } +} + +Projects:: + [/solution/b/tsconfig.json] *new* + /solution/a/index.ts + /solution/b/index.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/b/index.ts] *new* + /solution/b/tsconfig.json (default) +Config:: + [/solution/a/tsconfig.json] *new* + RetainingProjects: + /solution/b/tsconfig.json + [/solution/b/tsconfig.json] *new* + RetainingProjects: + /solution/b/tsconfig.json + RetainingOpenFiles: + /solution/b/index.ts +Config File Names:: + [/solution/b/index.ts] *new* + NearestConfigFileName: /solution/b/tsconfig.json + Ancestors: + /solution/b/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/b/index.ts" + }, + "position": { + "line": 1, + "character": 26 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/a/tsconfig.json] *new* + /solution/a/index.ts + [/solution/b/tsconfig.json] + /solution/a/index.ts + /solution/b/index.ts + [/solution/c/tsconfig.json] *new* + /solution/a/index.ts + /solution/b/index.ts + /solution/c/index.ts + [/solution/d/tsconfig.json] *new* + /solution/a/index.ts + /solution/b/index.ts + /solution/c/index.ts + /solution/d/index.ts + [/solution/tsconfig.json] *modified* +Open Files:: + [/solution/b/index.ts] *modified* + /solution/b/tsconfig.json (default) + /solution/c/tsconfig.json *new* + /solution/d/tsconfig.json *new* +Config:: + [/solution/a/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/a/tsconfig.json *new* + /solution/b/tsconfig.json + /solution/c/tsconfig.json *new* + /solution/d/tsconfig.json *new* + /solution/tsconfig.json *new* + [/solution/b/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/b/tsconfig.json + /solution/c/tsconfig.json *new* + /solution/d/tsconfig.json *new* + /solution/tsconfig.json *new* + RetainingOpenFiles: + /solution/b/index.ts + [/solution/c/tsconfig.json] *new* + RetainingProjects: + /solution/c/tsconfig.json + /solution/d/tsconfig.json + /solution/tsconfig.json + [/solution/d/tsconfig.json] *new* + RetainingProjects: + /solution/d/tsconfig.json + /solution/tsconfig.json + [/solution/tsconfig.json] *new* + RetainingProjects: + /solution/tsconfig.json + + + + +// === findAllReferences === +// === /solution/a/index.ts === +// export interface [|I|] { +// M(): void; +// } + +// === /solution/b/index.ts === +// import { [|I|] } from "../a"; +// export class B implements /*FIND ALL REFS*/[|I|] { +// M() {} +// } + +// === /solution/c/index.ts === +// import { [|I|] } from "../a"; +// import { B } from "../b"; +// export const C: [|I|] = new B(); + +// === /solution/d/index.ts === +// import { [|I|] } from "../a"; +// import { C } from "../c"; +// export const D: [|I|] = C; +// +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/b/index.ts" + }, + "position": { + "line": 1, + "character": 26 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /solution/a/index.ts === +// export interface [|I|] { +// M(): void; +// } + +// === /solution/b/index.ts === +// import { [|I|] } from "../a"; +// export class B implements /*FIND ALL REFS*/[|I|] { +// M() {} +// } + +// === /solution/c/index.ts === +// import { [|I|] } from "../a"; +// import { B } from "../b"; +// export const C: [|I|] = new B(); + +// === /solution/d/index.ts === +// import { [|I|] } from "../a"; +// import { C } from "../c"; +// export const D: [|I|] = C; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline new file mode 100644 index 0000000000..aaf116174f --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline @@ -0,0 +1,514 @@ +UseCaseSensitiveFileNames: true +//// [/dummy/dummy.ts] *new* +const x = 1; +//// [/dummy/tsconfig.json] *new* +{ } +//// [/myproject/indirect3/main.ts] *new* +import { foo } from '../target/src/main'; +foo() +export function bar() {} + +//// [/myproject/indirect3/tsconfig.json] *new* +{ } +//// [/myproject/own/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bar = bar; +const main_1 = require("../target/src/main"); +(0, main_1.foo)(); +function bar() { } + +//// [/myproject/own/main.ts] *new* +import { foo } from '../target/src/main'; +foo(); +export function bar() {} +//// [/myproject/src/helpers/functions.ts] *new* +export function foo() { return 1; } +//// [/myproject/src/main.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//// [/myproject/target/src/helpers/functions.d.ts] *new* +export declare function foo(): number; +//# sourceMappingURL=functions.d.ts.map +//// [/myproject/target/src/helpers/functions.d.ts.map] *new* +{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/helpers/functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,WAAgB"} +//// [/myproject/target/src/helpers/functions.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { return 1; } + +//// [/myproject/target/src/main.d.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/target/src/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,CAAC"} +//// [/myproject/target/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +const functions_1 = require("./helpers/functions"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return functions_1.foo; } }); + +//// [/myproject/target/tsconfig-src.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/helpers/functions.ts","../src/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }","signature":"029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n","impliedNodeFormat":1},{"version":"29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };","signature":"e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/myproject/target/tsconfig-src.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/helpers/functions.ts", + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/helpers/functions.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/main.ts": [ + "../src/helpers/functions.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1479 +} +//// [/myproject/tsconfig-src.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +//// [/myproject/tsconfig.json] *new* +{ + "files": ["./own/main.ts"], + "references": [{ "path": "./tsconfig-src.json" }] +} +//// [/myproject/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":["./own/main.ts"]} +//// [/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./own/main.ts" + ], + "original": "./own/main.ts" + } + ], + "size": 52 +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + /myproject/own/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) + /myproject/tsconfig.json +Config:: + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + /myproject/tsconfig.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/tsconfig.json] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + /myproject/own/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) + /myproject/tsconfig.json +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-src.json] + RetainingProjects: + /myproject/tsconfig-src.json + /myproject/tsconfig.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] + RetainingProjects: + /myproject/tsconfig.json + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) + /myproject/tsconfig.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/tsconfig.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + /myproject/own/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *deleted* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + /myproject/own/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) + /myproject/tsconfig.json +Config:: + [/dummy/tsconfig.json] *deleted* + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + /myproject/tsconfig.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *deleted* + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { /*FIND ALL REFS*/foo }; +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from '../target/src/main';\nfoo()\nexport function bar() {}\n" + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] *new* + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/tsconfig.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + /myproject/own/main.ts +Open Files:: + [/myproject/indirect3/main.ts] *new* + /myproject/indirect3/tsconfig.json (default) +Config:: + [/myproject/indirect3/tsconfig.json] *new* + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/myproject/indirect3/main.ts] *new* + NearestConfigFileName: /myproject/indirect3/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + /myproject/own/main.ts +Config:: + [/myproject/indirect3/tsconfig.json] + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + /myproject/tsconfig.json + [/myproject/tsconfig.json] *new* + RetainingProjects: + /myproject/tsconfig.json + + + + +// === findAllReferences === +// === /myproject/indirect3/main.ts === +// import { /*FIND ALL REFS*/[|foo|] } from '../target/src/main'; +// [|foo|]() +// export function bar() {} +// + +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { foo }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline new file mode 100644 index 0000000000..d98432e861 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline @@ -0,0 +1,163 @@ +UseCaseSensitiveFileNames: true +//// [/src/common/input/keyboard.test.ts] *new* +import { evaluateKeyboardEvent } from 'common/input/keyboard'; +function testEvaluateKeyboardEvent() { + return evaluateKeyboardEvent(); +} +//// [/src/common/input/keyboard.ts] *new* +function bar() { return "just a random function so .d.ts location doesnt match"; } +export function evaluateKeyboardEvent() { } +//// [/src/common/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "outDir": "../../out", + "disableSourceOfProjectReferenceRedirect": false, + "paths": { + "*": ["../*"], + }, + }, + "include": ["./\**/*"] +} +//// [/src/terminal.ts] *new* +import { evaluateKeyboardEvent } from 'common/input/keyboard'; +function foo() { + return evaluateKeyboardEvent(); +} +//// [/src/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "outDir": "../out", + "disableSourceOfProjectReferenceRedirect": false, + "paths": { + "common/*": ["./common/*"], + }, + "tsBuildInfoFile": "../out/src.tsconfig.tsbuildinfo" + }, + "include": ["./\**/*"], + "references": [ + { "path": "./common" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///src/common/input/keyboard.ts", + "languageId": "typescript", + "version": 0, + "text": "function bar() { return \"just a random function so .d.ts location doesnt match\"; }\nexport function evaluateKeyboardEvent() { }" + } + } +} + +Projects:: + [/src/common/tsconfig.json] *new* + /src/common/input/keyboard.ts + /src/common/input/keyboard.test.ts + [/src/tsconfig.json] *new* +Open Files:: + [/src/common/input/keyboard.ts] *new* + /src/common/tsconfig.json (default) +Config:: + [/src/common/tsconfig.json] *new* + RetainingProjects: + /src/common/tsconfig.json + RetainingOpenFiles: + /src/common/input/keyboard.ts +Config File Names:: + [/src/common/input/keyboard.ts] *new* + NearestConfigFileName: /src/common/tsconfig.json + Ancestors: + /src/common/tsconfig.json /src/tsconfig.json + /src/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///src/terminal.ts", + "languageId": "typescript", + "version": 0, + "text": "import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction foo() {\n\treturn evaluateKeyboardEvent();\n}" + } + } +} + +Projects:: + [/src/common/tsconfig.json] + /src/common/input/keyboard.ts + /src/common/input/keyboard.test.ts + [/src/tsconfig.json] *modified* + /src/common/input/keyboard.ts *new* + /src/terminal.ts *new* + /src/common/input/keyboard.test.ts *new* +Open Files:: + [/src/common/input/keyboard.ts] *modified* + /src/common/tsconfig.json (default) + /src/tsconfig.json *new* + [/src/terminal.ts] *new* + /src/tsconfig.json (default) +Config:: + [/src/common/tsconfig.json] *modified* + RetainingProjects: *modified* + /src/common/tsconfig.json + /src/tsconfig.json *new* + RetainingOpenFiles: + /src/common/input/keyboard.ts + [/src/tsconfig.json] *new* + RetainingProjects: + /src/tsconfig.json + RetainingOpenFiles: + /src/terminal.ts +Config File Names:: + [/src/common/input/keyboard.ts] + NearestConfigFileName: /src/common/tsconfig.json + Ancestors: + /src/common/tsconfig.json /src/tsconfig.json + /src/tsconfig.json + [/src/terminal.ts] *new* + NearestConfigFileName: /src/tsconfig.json + Ancestors: + /src/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///src/common/input/keyboard.ts" + }, + "position": { + "line": 1, + "character": 16 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /src/common/input/keyboard.test.ts === +// import { [|evaluateKeyboardEvent|] } from 'common/input/keyboard'; +// function testEvaluateKeyboardEvent() { +// return [|evaluateKeyboardEvent|](); +// } + +// === /src/common/input/keyboard.ts === +// function bar() { return "just a random function so .d.ts location doesnt match"; } +// export function /*FIND ALL REFS*/[|evaluateKeyboardEvent|]() { } + +// === /src/terminal.ts === +// import { [|evaluateKeyboardEvent|] } from 'common/input/keyboard'; +// function foo() { +// return [|evaluateKeyboardEvent|](); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline new file mode 100644 index 0000000000..1c5b3a7160 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline @@ -0,0 +1,368 @@ +UseCaseSensitiveFileNames: true +//// [/out/input/keyboard.d.ts] *new* +export declare function evaluateKeyboardEvent(): void; +//# sourceMappingURL=keyboard.d.ts.map +//// [/out/input/keyboard.d.ts.map] *new* +{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/common/input/keyboard.ts"],"names":[],"mappings":"AACA,wBAAgB,qBAAqB,SAAM"} +//// [/out/input/keyboard.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.evaluateKeyboardEvent = evaluateKeyboardEvent; +function bar() { return "just a random function so .d.ts location doesnt match"; } +function evaluateKeyboardEvent() { } + +//// [/out/input/keyboard.test.d.ts] *new* +export {}; +//# sourceMappingURL=keyboard.test.d.ts.map +//// [/out/input/keyboard.test.d.ts.map] *new* +{"version":3,"file":"keyboard.test.d.ts","sourceRoot":"","sources":["../../src/common/input/keyboard.test.ts"],"names":[],"mappings":""} +//// [/out/input/keyboard.test.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const keyboard_1 = require("common/input/keyboard"); +function testEvaluateKeyboardEvent() { + return (0, keyboard_1.evaluateKeyboardEvent)(); +} + +//// [/out/src.tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,4]],"fileNames":["lib.d.ts","./input/keyboard.d.ts","../src/terminal.ts","./input/keyboard.test.d.ts","../src/common/input/keyboard.ts","../src/common/input/keyboard.test.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"362bf1943c7d2a927f25978d1f24d61f-export declare function evaluateKeyboardEvent(): void;\n//# sourceMappingURL=keyboard.d.ts.map",{"version":"ff8262b3768be0c0049523b4b8a7b4f7-import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction foo() {\n\treturn evaluateKeyboardEvent();\n}","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1},"aaff3960e003a07ef50db935cb91a696-export {};\n//# sourceMappingURL=keyboard.test.d.ts.map"],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./","tsBuildInfoFile":"./src.tsconfig.tsbuildinfo"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./terminal.d.ts","resolvedRoot":[[2,5],[4,6]]} +//// [/out/src.tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./input/keyboard.d.ts", + "../src/terminal.ts", + "./input/keyboard.test.d.ts" + ], + "original": [ + 2, + 4 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "./input/keyboard.d.ts", + "../src/terminal.ts", + "./input/keyboard.test.d.ts", + "../src/common/input/keyboard.ts", + "../src/common/input/keyboard.test.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./input/keyboard.d.ts", + "version": "362bf1943c7d2a927f25978d1f24d61f-export declare function evaluateKeyboardEvent(): void;\n//# sourceMappingURL=keyboard.d.ts.map", + "signature": "362bf1943c7d2a927f25978d1f24d61f-export declare function evaluateKeyboardEvent(): void;\n//# sourceMappingURL=keyboard.d.ts.map", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "../src/terminal.ts", + "version": "ff8262b3768be0c0049523b4b8a7b4f7-import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction foo() {\n\treturn evaluateKeyboardEvent();\n}", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "ff8262b3768be0c0049523b4b8a7b4f7-import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction foo() {\n\treturn evaluateKeyboardEvent();\n}", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./input/keyboard.test.d.ts", + "version": "aaff3960e003a07ef50db935cb91a696-export {};\n//# sourceMappingURL=keyboard.test.d.ts.map", + "signature": "aaff3960e003a07ef50db935cb91a696-export {};\n//# sourceMappingURL=keyboard.test.d.ts.map", + "impliedNodeFormat": "CommonJS" + } + ], + "fileIdsList": [ + [ + "./input/keyboard.d.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./", + "tsBuildInfoFile": "./src.tsconfig.tsbuildinfo" + }, + "referencedMap": { + "../src/terminal.ts": [ + "./input/keyboard.d.ts" + ] + }, + "latestChangedDtsFile": "./terminal.d.ts", + "resolvedRoot": [ + [ + "./input/keyboard.d.ts", + "../src/common/input/keyboard.ts" + ], + [ + "./input/keyboard.test.d.ts", + "../src/common/input/keyboard.test.ts" + ] + ], + "size": 1693 +} +//// [/out/terminal.d.ts] *new* +export {}; +//# sourceMappingURL=terminal.d.ts.map +//// [/out/terminal.d.ts.map] *new* +{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":""} +//// [/out/terminal.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const keyboard_1 = require("common/input/keyboard"); +function foo() { + return (0, keyboard_1.evaluateKeyboardEvent)(); +} + +//// [/out/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/common/input/keyboard.ts","../src/common/input/keyboard.test.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6e37abb18685aa8e2642ab0218eef699-function bar() { return \"just a random function so .d.ts location doesnt match\"; }\nexport function evaluateKeyboardEvent() { }","signature":"569df1f274cf52f322c6e7a2f4e891fe-export declare function evaluateKeyboardEvent(): void;\n","impliedNodeFormat":1},{"version":"e844013c2f8764710bfebda24351c0d3-import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction testEvaluateKeyboardEvent() {\n\treturn evaluateKeyboardEvent();\n}","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./input/keyboard.test.d.ts"} +//// [/out/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/common/input/keyboard.ts", + "../src/common/input/keyboard.test.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/common/input/keyboard.ts", + "../src/common/input/keyboard.test.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/common/input/keyboard.ts", + "version": "6e37abb18685aa8e2642ab0218eef699-function bar() { return \"just a random function so .d.ts location doesnt match\"; }\nexport function evaluateKeyboardEvent() { }", + "signature": "569df1f274cf52f322c6e7a2f4e891fe-export declare function evaluateKeyboardEvent(): void;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "6e37abb18685aa8e2642ab0218eef699-function bar() { return \"just a random function so .d.ts location doesnt match\"; }\nexport function evaluateKeyboardEvent() { }", + "signature": "569df1f274cf52f322c6e7a2f4e891fe-export declare function evaluateKeyboardEvent(): void;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/common/input/keyboard.test.ts", + "version": "e844013c2f8764710bfebda24351c0d3-import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction testEvaluateKeyboardEvent() {\n\treturn evaluateKeyboardEvent();\n}", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "e844013c2f8764710bfebda24351c0d3-import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction testEvaluateKeyboardEvent() {\n\treturn evaluateKeyboardEvent();\n}", + "signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/common/input/keyboard.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/common/input/keyboard.test.ts": [ + "../src/common/input/keyboard.ts" + ] + }, + "latestChangedDtsFile": "./input/keyboard.test.d.ts", + "size": 1658 +} +//// [/src/common/input/keyboard.test.ts] *new* +import { evaluateKeyboardEvent } from 'common/input/keyboard'; +function testEvaluateKeyboardEvent() { + return evaluateKeyboardEvent(); +} +//// [/src/common/input/keyboard.ts] *new* +function bar() { return "just a random function so .d.ts location doesnt match"; } +export function evaluateKeyboardEvent() { } +//// [/src/common/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "outDir": "../../out", + "disableSourceOfProjectReferenceRedirect": true, + "paths": { + "*": ["../*"], + }, + }, + "include": ["./\**/*"] +} +//// [/src/terminal.ts] *new* +import { evaluateKeyboardEvent } from 'common/input/keyboard'; +function foo() { + return evaluateKeyboardEvent(); +} +//// [/src/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "declarationMap": true, + "outDir": "../out", + "disableSourceOfProjectReferenceRedirect": true, + "paths": { + "common/*": ["./common/*"], + }, + "tsBuildInfoFile": "../out/src.tsconfig.tsbuildinfo" + }, + "include": ["./\**/*"], + "references": [ + { "path": "./common" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///src/common/input/keyboard.ts", + "languageId": "typescript", + "version": 0, + "text": "function bar() { return \"just a random function so .d.ts location doesnt match\"; }\nexport function evaluateKeyboardEvent() { }" + } + } +} + +Projects:: + [/src/common/tsconfig.json] *new* + /src/common/input/keyboard.ts + /src/common/input/keyboard.test.ts + [/src/tsconfig.json] *new* +Open Files:: + [/src/common/input/keyboard.ts] *new* + /src/common/tsconfig.json (default) +Config:: + [/src/common/tsconfig.json] *new* + RetainingProjects: + /src/common/tsconfig.json + RetainingOpenFiles: + /src/common/input/keyboard.ts +Config File Names:: + [/src/common/input/keyboard.ts] *new* + NearestConfigFileName: /src/common/tsconfig.json + Ancestors: + /src/common/tsconfig.json /src/tsconfig.json + /src/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///src/terminal.ts", + "languageId": "typescript", + "version": 0, + "text": "import { evaluateKeyboardEvent } from 'common/input/keyboard';\nfunction foo() {\n\treturn evaluateKeyboardEvent();\n}" + } + } +} + +Projects:: + [/src/common/tsconfig.json] + /src/common/input/keyboard.ts + /src/common/input/keyboard.test.ts + [/src/tsconfig.json] *modified* + /out/input/keyboard.d.ts *new* + /src/terminal.ts *new* + /out/input/keyboard.test.d.ts *new* +Open Files:: + [/src/common/input/keyboard.ts] + /src/common/tsconfig.json (default) + [/src/terminal.ts] *new* + /src/tsconfig.json (default) +Config:: + [/src/common/tsconfig.json] *modified* + RetainingProjects: *modified* + /src/common/tsconfig.json + /src/tsconfig.json *new* + RetainingOpenFiles: + /src/common/input/keyboard.ts + [/src/tsconfig.json] *new* + RetainingProjects: + /src/tsconfig.json + RetainingOpenFiles: + /src/terminal.ts +Config File Names:: + [/src/common/input/keyboard.ts] + NearestConfigFileName: /src/common/tsconfig.json + Ancestors: + /src/common/tsconfig.json /src/tsconfig.json + /src/tsconfig.json + [/src/terminal.ts] *new* + NearestConfigFileName: /src/tsconfig.json + Ancestors: + /src/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///src/common/input/keyboard.ts" + }, + "position": { + "line": 1, + "character": 16 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /src/common/input/keyboard.test.ts === +// import { [|evaluateKeyboardEvent|] } from 'common/input/keyboard'; +// function testEvaluateKeyboardEvent() { +// return [|evaluateKeyboardEvent|](); +// } + +// === /src/common/input/keyboard.ts === +// function bar() { return "just a random function so .d.ts location doesnt match"; } +// export function /*FIND ALL REFS*/[|evaluateKeyboardEvent|]() { } + +// === /src/terminal.ts === +// import { [|evaluateKeyboardEvent|] } from 'common/input/keyboard'; +// function foo() { +// return [|evaluateKeyboardEvent|](); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline new file mode 100644 index 0000000000..9c58b15719 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline @@ -0,0 +1,447 @@ +UseCaseSensitiveFileNames: true +//// [/dummy/dummy.ts] *new* +const x = 1; +//// [/dummy/tsconfig.json] *new* +{ } +//// [/myproject/indirect3/main.ts] *new* +import { foo } from '../target/src/main'; +foo() +export function bar() {} + +//// [/myproject/indirect3/tsconfig.json] *new* +{ } +//// [/myproject/src/helpers/functions.ts] *new* +export function foo() { return 1; } +//// [/myproject/src/main.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//// [/myproject/target/src/helpers/functions.d.ts] *new* +export declare function foo(): number; +//# sourceMappingURL=functions.d.ts.map +//// [/myproject/target/src/helpers/functions.d.ts.map] *new* +{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/helpers/functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,WAAgB"} +//// [/myproject/target/src/helpers/functions.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { return 1; } + +//// [/myproject/target/src/main.d.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/target/src/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,CAAC"} +//// [/myproject/target/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +const functions_1 = require("./helpers/functions"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return functions_1.foo; } }); + +//// [/myproject/target/tsconfig-src.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/helpers/functions.ts","../src/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }","signature":"029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n","impliedNodeFormat":1},{"version":"29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };","signature":"e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/myproject/target/tsconfig-src.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/helpers/functions.ts", + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/helpers/functions.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/main.ts": [ + "../src/helpers/functions.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1479 +} +//// [/myproject/tsconfig-src.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +//// [/myproject/tsconfig.json] *new* +{ + "files": [], + "references": [{ "path": "./tsconfig-src.json" }] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) +Config:: + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-src.json] + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *deleted* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) +Config:: + [/dummy/tsconfig.json] *deleted* + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *deleted* + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { /*FIND ALL REFS*/foo }; +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from '../target/src/main';\nfoo()\nexport function bar() {}\n" + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] *new* + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/indirect3/main.ts] *new* + /myproject/indirect3/tsconfig.json (default) +Config:: + [/myproject/indirect3/tsconfig.json] *new* + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/myproject/indirect3/main.ts] *new* + NearestConfigFileName: /myproject/indirect3/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Config:: + [/myproject/indirect3/tsconfig.json] + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + [/myproject/tsconfig.json] *new* + + + + +// === findAllReferences === +// === /myproject/indirect3/main.ts === +// import { /*FIND ALL REFS*/[|foo|] } from '../target/src/main'; +// [|foo|]() +// export function bar() {} +// + +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { foo }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline new file mode 100644 index 0000000000..5eaa2c7552 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline @@ -0,0 +1,623 @@ +UseCaseSensitiveFileNames: true +//// [/dummy/dummy.ts] *new* +const x = 1; +//// [/dummy/tsconfig.json] *new* +{ } +//// [/myproject/indirect1/main.ts] *new* +export const indirect = 1; +//// [/myproject/indirect2/main.ts] *new* +export const indirect = 1; +//// [/myproject/indirect3/main.ts] *new* +import { foo } from '../target/src/main'; +foo() +export function bar() {} +//// [/myproject/indirect3/tsconfig.json] *new* +{ } +//// [/myproject/src/helpers/functions.ts] *new* +export function foo() { return 1; } +//// [/myproject/src/main.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//// [/myproject/target/indirect1/main.d.ts] *new* +export declare const indirect = 1; + +//// [/myproject/target/indirect1/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indirect = void 0; +exports.indirect = 1; + +//// [/myproject/target/indirect2/main.d.ts] *new* +export declare const indirect = 1; + +//// [/myproject/target/indirect2/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indirect = void 0; +exports.indirect = 1; + +//// [/myproject/target/src/helpers/functions.d.ts] *new* +export declare function foo(): number; +//# sourceMappingURL=functions.d.ts.map +//// [/myproject/target/src/helpers/functions.d.ts.map] *new* +{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/helpers/functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,WAAgB"} +//// [/myproject/target/src/helpers/functions.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { return 1; } + +//// [/myproject/target/src/main.d.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/target/src/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,CAAC"} +//// [/myproject/target/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +const functions_1 = require("./helpers/functions"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return functions_1.foo; } }); + +//// [/myproject/target/tsconfig-indirect1.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../indirect1/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"265b044bf7f805e401e883488ec6cb29-export const indirect = 1;","signature":"bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./indirect1/main.d.ts"} +//// [/myproject/target/tsconfig-indirect1.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../indirect1/main.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "../indirect1/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../indirect1/main.ts", + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./indirect1/main.d.ts", + "size": 1140 +} +//// [/myproject/target/tsconfig-indirect2.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../indirect2/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"265b044bf7f805e401e883488ec6cb29-export const indirect = 1;","signature":"bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./indirect2/main.d.ts"} +//// [/myproject/target/tsconfig-indirect2.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../indirect2/main.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "../indirect2/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../indirect2/main.ts", + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./indirect2/main.d.ts", + "size": 1140 +} +//// [/myproject/target/tsconfig-src.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/helpers/functions.ts","../src/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }","signature":"029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n","impliedNodeFormat":1},{"version":"29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };","signature":"e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/myproject/target/tsconfig-src.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/helpers/functions.ts", + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/helpers/functions.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/main.ts": [ + "../src/helpers/functions.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1479 +} +//// [/myproject/tsconfig-indirect1.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + }, + "files": [ + "./indirect1/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +//// [/myproject/tsconfig-indirect2.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + }, + "files": [ + "./indirect2/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} + +//// [/myproject/tsconfig-src.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +//// [/myproject/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./tsconfig-indirect1.json" }, + { "path": "./tsconfig-indirect2.json" }, + ] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) +Config:: + [/myproject/tsconfig-indirect1.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-indirect1.json] + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-src.json] + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-indirect1.json] *deleted* + [/myproject/tsconfig-indirect2.json] *deleted* + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *deleted* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) +Config:: + [/dummy/tsconfig.json] *deleted* + [/myproject/tsconfig-indirect1.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *deleted* + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { /*FIND ALL REFS*/foo }; +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from '../target/src/main';\nfoo()\nexport function bar() {}" + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] *new* + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/indirect3/main.ts] *new* + /myproject/indirect3/tsconfig.json (default) +Config:: + [/myproject/indirect3/tsconfig.json] *new* + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-indirect1.json] *deleted* + [/myproject/tsconfig-indirect2.json] *deleted* + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/myproject/indirect3/main.ts] *new* + NearestConfigFileName: /myproject/indirect3/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Config:: + [/myproject/indirect3/tsconfig.json] + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-indirect1.json] *new* + [/myproject/tsconfig-indirect2.json] *new* + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + [/myproject/tsconfig.json] *new* + + + + +// === findAllReferences === +// === /myproject/indirect3/main.ts === +// import { /*FIND ALL REFS*/[|foo|] } from '../target/src/main'; +// [|foo|]() +// export function bar() {} + +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { foo }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline new file mode 100644 index 0000000000..5a6e45d798 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline @@ -0,0 +1,597 @@ +UseCaseSensitiveFileNames: true +//// [/dummy/dummy.ts] *new* +const x = 1; +//// [/dummy/tsconfig.json] *new* +{ } +//// [/myproject/indirect1/main.ts] *new* +export const indirect = 1; +//// [/myproject/indirect2/main.ts] *new* +export const indirect = 1; +//// [/myproject/indirect3/main.ts] *new* +import { foo } from '../target/src/main'; +foo() +export function bar() {} +//// [/myproject/indirect3/tsconfig.json] *new* +{ } +//// [/myproject/src/helpers/functions.ts] *new* +export function foo() { return 1; } +//// [/myproject/src/main.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//// [/myproject/target/indirect1/main.d.ts] *new* +export declare const indirect = 1; + +//// [/myproject/target/indirect1/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indirect = void 0; +exports.indirect = 1; + +//// [/myproject/target/indirect2/main.d.ts] *new* +export declare const indirect = 1; + +//// [/myproject/target/indirect2/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indirect = void 0; +exports.indirect = 1; + +//// [/myproject/target/src/helpers/functions.d.ts] *new* +export declare function foo(): number; +//# sourceMappingURL=functions.d.ts.map +//// [/myproject/target/src/helpers/functions.d.ts.map] *new* +{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/helpers/functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,WAAgB"} +//// [/myproject/target/src/helpers/functions.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { return 1; } + +//// [/myproject/target/src/main.d.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/target/src/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,CAAC"} +//// [/myproject/target/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +const functions_1 = require("./helpers/functions"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return functions_1.foo; } }); + +//// [/myproject/target/tsconfig-indirect1.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../indirect1/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"265b044bf7f805e401e883488ec6cb29-export const indirect = 1;","signature":"bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./indirect1/main.d.ts"} +//// [/myproject/target/tsconfig-indirect1.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../indirect1/main.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "../indirect1/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../indirect1/main.ts", + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./indirect1/main.d.ts", + "size": 1140 +} +//// [/myproject/target/tsconfig-indirect2.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../indirect2/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"265b044bf7f805e401e883488ec6cb29-export const indirect = 1;","signature":"bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./indirect2/main.d.ts"} +//// [/myproject/target/tsconfig-indirect2.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../indirect2/main.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "../indirect2/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../indirect2/main.ts", + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./indirect2/main.d.ts", + "size": 1140 +} +//// [/myproject/target/tsconfig-src.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/helpers/functions.ts","../src/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }","signature":"029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n","impliedNodeFormat":1},{"version":"29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };","signature":"e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/myproject/target/tsconfig-src.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/helpers/functions.ts", + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/helpers/functions.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/main.ts": [ + "../src/helpers/functions.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1479 +} +//// [/myproject/tsconfig-indirect1.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + "disableReferencedProjectLoad": true, + }, + "files": [ + "./indirect1/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +//// [/myproject/tsconfig-indirect2.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + "disableReferencedProjectLoad": true, + }, + "files": [ + "./indirect2/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} + +//// [/myproject/tsconfig-src.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +//// [/myproject/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./tsconfig-indirect1.json" }, + { "path": "./tsconfig-indirect2.json" }, + ] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /dev/null/inferred (default) +Config:: + [/myproject/tsconfig-indirect1.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dev/null/inferred] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) + [/myproject/src/main.ts] + /dev/null/inferred (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-indirect1.json] + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + [/myproject/src/main.ts] + /dev/null/inferred (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dev/null/inferred] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/dummy/tsconfig.json] + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-indirect1.json] *deleted* + [/myproject/tsconfig-indirect2.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/dummy/tsconfig.json] *deleted* + /dummy/dummy.ts +Open Files:: + [/myproject/src/main.ts] *new* + /dev/null/inferred (default) +Config:: + [/dummy/tsconfig.json] *deleted* + [/myproject/tsconfig-indirect1.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *deleted* + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { /*FIND ALL REFS*/foo }; +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from '../target/src/main';\nfoo()\nexport function bar() {}" + } + } +} + +Projects:: + [/dev/null/inferred] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/indirect3/tsconfig.json] *new* + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts +Open Files:: + [/myproject/indirect3/main.ts] *new* + /myproject/indirect3/tsconfig.json (default) +Config:: + [/myproject/indirect3/tsconfig.json] *new* + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-indirect1.json] *deleted* + [/myproject/tsconfig-indirect2.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/myproject/indirect3/main.ts] *new* + NearestConfigFileName: /myproject/indirect3/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Config:: + [/myproject/indirect3/tsconfig.json] + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-indirect1.json] *new* + [/myproject/tsconfig-indirect2.json] *new* + [/myproject/tsconfig.json] *new* + + + + +// === findAllReferences === +// === /myproject/indirect3/main.ts === +// import { /*FIND ALL REFS*/[|foo|] } from '../target/src/main'; +// [|foo|]() +// export function bar() {} + +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { foo }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline new file mode 100644 index 0000000000..2f2df123c2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline @@ -0,0 +1,624 @@ +UseCaseSensitiveFileNames: true +//// [/dummy/dummy.ts] *new* +const x = 1; +//// [/dummy/tsconfig.json] *new* +{ } +//// [/myproject/indirect1/main.ts] *new* +export const indirect = 1; +//// [/myproject/indirect2/main.ts] *new* +export const indirect = 1; +//// [/myproject/indirect3/main.ts] *new* +import { foo } from '../target/src/main'; +foo() +export function bar() {} +//// [/myproject/indirect3/tsconfig.json] *new* +{ } +//// [/myproject/src/helpers/functions.ts] *new* +export function foo() { return 1; } +//// [/myproject/src/main.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//// [/myproject/target/indirect1/main.d.ts] *new* +export declare const indirect = 1; + +//// [/myproject/target/indirect1/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indirect = void 0; +exports.indirect = 1; + +//// [/myproject/target/indirect2/main.d.ts] *new* +export declare const indirect = 1; + +//// [/myproject/target/indirect2/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.indirect = void 0; +exports.indirect = 1; + +//// [/myproject/target/src/helpers/functions.d.ts] *new* +export declare function foo(): number; +//# sourceMappingURL=functions.d.ts.map +//// [/myproject/target/src/helpers/functions.d.ts.map] *new* +{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/helpers/functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,WAAgB"} +//// [/myproject/target/src/helpers/functions.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { return 1; } + +//// [/myproject/target/src/main.d.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/target/src/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,CAAC"} +//// [/myproject/target/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +const functions_1 = require("./helpers/functions"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return functions_1.foo; } }); + +//// [/myproject/target/tsconfig-indirect1.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../indirect1/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"265b044bf7f805e401e883488ec6cb29-export const indirect = 1;","signature":"bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./indirect1/main.d.ts"} +//// [/myproject/target/tsconfig-indirect1.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../indirect1/main.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "../indirect1/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../indirect1/main.ts", + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./indirect1/main.d.ts", + "size": 1140 +} +//// [/myproject/target/tsconfig-indirect2.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../indirect2/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"265b044bf7f805e401e883488ec6cb29-export const indirect = 1;","signature":"bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n","impliedNodeFormat":1}],"options":{"composite":true,"outDir":"./"},"latestChangedDtsFile":"./indirect2/main.d.ts"} +//// [/myproject/target/tsconfig-indirect2.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../indirect2/main.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "../indirect2/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../indirect2/main.ts", + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "265b044bf7f805e401e883488ec6cb29-export const indirect = 1;", + "signature": "bf177928c61dd707122e7eeb99aa0ef0-export declare const indirect = 1;\n", + "impliedNodeFormat": 1 + } + } + ], + "options": { + "composite": true, + "outDir": "./" + }, + "latestChangedDtsFile": "./indirect2/main.d.ts", + "size": 1140 +} +//// [/myproject/target/tsconfig-src.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/helpers/functions.ts","../src/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }","signature":"029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n","impliedNodeFormat":1},{"version":"29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };","signature":"e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/myproject/target/tsconfig-src.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/helpers/functions.ts", + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/helpers/functions.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/main.ts": [ + "../src/helpers/functions.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1479 +} +//// [/myproject/tsconfig-indirect1.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + "disableReferencedProjectLoad": true, + }, + "files": [ + "./indirect1/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} +//// [/myproject/tsconfig-indirect2.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target/", + }, + "files": [ + "./indirect2/main.ts" + ], + "references": [ + { + "path": "./tsconfig-src.json" + } + ] +} + +//// [/myproject/tsconfig-src.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +//// [/myproject/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./tsconfig-indirect1.json" }, + { "path": "./tsconfig-indirect2.json" }, + ] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) +Config:: + [/myproject/tsconfig-indirect1.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-indirect1.json] + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-src.json] + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + [/myproject/src/main.ts] + /myproject/tsconfig-src.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dummy/tsconfig.json] + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig-indirect1.json] *deleted* + [/myproject/tsconfig-indirect2.json] *deleted* + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dummy/tsconfig.json] *deleted* + /dummy/dummy.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /myproject/tsconfig-src.json (default) +Config:: + [/dummy/tsconfig.json] *deleted* + [/myproject/tsconfig-indirect1.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-indirect2.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + RetainingOpenFiles: + /myproject/src/main.ts + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *deleted* + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig-src.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { /*FIND ALL REFS*/foo }; +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from '../target/src/main';\nfoo()\nexport function bar() {}" + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] *new* + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/indirect3/main.ts] *new* + /myproject/indirect3/tsconfig.json (default) +Config:: + [/myproject/indirect3/tsconfig.json] *new* + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-indirect1.json] *deleted* + [/myproject/tsconfig-indirect2.json] *deleted* + [/myproject/tsconfig-src.json] *deleted* + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/myproject/indirect3/main.ts] *new* + NearestConfigFileName: /myproject/indirect3/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/indirect3/tsconfig.json] + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts + [/myproject/tsconfig-src.json] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Config:: + [/myproject/indirect3/tsconfig.json] + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig-indirect1.json] *new* + [/myproject/tsconfig-indirect2.json] *new* + [/myproject/tsconfig-src.json] *new* + RetainingProjects: + /myproject/tsconfig-src.json + [/myproject/tsconfig.json] *new* + + + + +// === findAllReferences === +// === /myproject/indirect3/main.ts === +// import { /*FIND ALL REFS*/[|foo|] } from '../target/src/main'; +// [|foo|]() +// export function bar() {} + +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { foo }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline new file mode 100644 index 0000000000..42f55d9673 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline @@ -0,0 +1,422 @@ +UseCaseSensitiveFileNames: true +//// [/dummy/dummy.ts] *new* +const x = 1; +//// [/dummy/tsconfig.json] *new* +{ } +//// [/myproject/indirect3/main.ts] *new* +import { foo } from '../target/src/main'; +foo() +export function bar() {} + +//// [/myproject/indirect3/tsconfig.json] *new* +{ } +//// [/myproject/src/helpers/functions.ts] *new* +export function foo() { return 1; } +//// [/myproject/src/main.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//// [/myproject/target/src/helpers/functions.d.ts] *new* +export declare function foo(): number; +//# sourceMappingURL=functions.d.ts.map +//// [/myproject/target/src/helpers/functions.d.ts.map] *new* +{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/helpers/functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,WAAgB"} +//// [/myproject/target/src/helpers/functions.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { return 1; } + +//// [/myproject/target/src/main.d.ts] *new* +import { foo } from './helpers/functions'; +export { foo }; +//# sourceMappingURL=main.d.ts.map +//// [/myproject/target/src/main.d.ts.map] *new* +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,CAAC"} +//// [/myproject/target/src/main.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +const functions_1 = require("./helpers/functions"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return functions_1.foo; } }); + +//// [/myproject/target/tsconfig-src.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","../src/helpers/functions.ts","../src/main.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }","signature":"029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n","impliedNodeFormat":1},{"version":"29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };","signature":"e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"composite":true,"declarationMap":true,"outDir":"./"},"referencedMap":[[3,1]],"latestChangedDtsFile":"./src/main.d.ts"} +//// [/myproject/target/tsconfig-src.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "../src/helpers/functions.ts", + "../src/main.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/helpers/functions.ts", + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "bf6a9d57f087ab0066015134975ea2b2-export function foo() { return 1; }", + "signature": "029742dfbcde5b1dfd06f9129660afb3-export declare function foo(): number;\n", + "impliedNodeFormat": 1 + } + }, + { + "fileName": "../src/main.ts", + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": "CommonJS", + "original": { + "version": "29b72d75211ebc765497b1845400b55d-import { foo } from './helpers/functions';\nexport { foo };", + "signature": "e7ab16a2673b38216aba41fa1cf9516c-import { foo } from './helpers/functions';\nexport { foo };\n", + "impliedNodeFormat": 1 + } + } + ], + "fileIdsList": [ + [ + "../src/helpers/functions.ts" + ] + ], + "options": { + "composite": true, + "declarationMap": true, + "outDir": "./" + }, + "referencedMap": { + "../src/main.ts": [ + "../src/helpers/functions.ts" + ] + }, + "latestChangedDtsFile": "./src/main.d.ts", + "size": 1479 +} +//// [/myproject/tsconfig-src.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "./target", + "declarationMap": true, + }, + "include": ["./src/\**/*"] +} +//// [/myproject/tsconfig.json] *new* +{ + "compilerOptions": { + "disableReferencedProjectLoad": true + }, + "files": [], + "references": [{ "path": "./tsconfig-src.json" }] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts +Open Files:: + [/myproject/src/main.ts] *new* + /dev/null/inferred (default) +Config:: + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dev/null/inferred] + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/dummy/tsconfig.json] *new* + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) + [/myproject/src/main.ts] + /dev/null/inferred (default) +Config:: + [/dummy/tsconfig.json] *new* + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig.json] + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *new* + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig.json + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + [/myproject/src/main.ts] + /dev/null/inferred (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts", + "languageId": "typescript", + "version": 0, + "text": "const x = 1;" + } + } +} + +Projects:: + [/dev/null/inferred] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/dummy/tsconfig.json] + /dummy/dummy.ts +Open Files:: + [/dummy/dummy.ts] *new* + /dummy/tsconfig.json (default) +Config:: + [/dummy/tsconfig.json] + RetainingProjects: + /dummy/tsconfig.json + RetainingOpenFiles: + /dummy/dummy.ts + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/dummy/dummy.ts] + NearestConfigFileName: /dummy/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///dummy/dummy.ts" + } + } +} + +Open Files:: + [/dummy/dummy.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from './helpers/functions';\nexport { foo };" + } + } +} + +Projects:: + [/dev/null/inferred] *new* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/dummy/tsconfig.json] *deleted* + /dummy/dummy.ts +Open Files:: + [/myproject/src/main.ts] *new* + /dev/null/inferred (default) +Config:: + [/dummy/tsconfig.json] *deleted* + [/myproject/tsconfig.json] *new* + RetainingOpenFiles: + /myproject/src/main.ts +Config File Names:: + [/dummy/dummy.ts] *deleted* + [/myproject/src/main.ts] *new* + NearestConfigFileName: /myproject/tsconfig.json + Ancestors: + /myproject/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + }, + "position": { + "line": 1, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + + + + +// === findAllReferences === +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { /*FIND ALL REFS*/foo }; +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///myproject/src/main.ts" + } + } +} + +Open Files:: + [/myproject/src/main.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts", + "languageId": "typescript", + "version": 0, + "text": "import { foo } from '../target/src/main';\nfoo()\nexport function bar() {}\n" + } + } +} + +Projects:: + [/dev/null/inferred] *deleted* + /myproject/src/helpers/functions.ts + /myproject/src/main.ts + [/myproject/indirect3/tsconfig.json] *new* + /myproject/target/src/helpers/functions.d.ts + /myproject/target/src/main.d.ts + /myproject/indirect3/main.ts +Open Files:: + [/myproject/indirect3/main.ts] *new* + /myproject/indirect3/tsconfig.json (default) +Config:: + [/myproject/indirect3/tsconfig.json] *new* + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig.json] *deleted* +Config File Names:: + [/myproject/indirect3/main.ts] *new* + NearestConfigFileName: /myproject/indirect3/tsconfig.json + [/myproject/src/main.ts] *deleted* + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/indirect3/main.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Config:: + [/myproject/indirect3/tsconfig.json] + RetainingProjects: + /myproject/indirect3/tsconfig.json + RetainingOpenFiles: + /myproject/indirect3/main.ts + [/myproject/tsconfig.json] *new* + + + + +// === findAllReferences === +// === /myproject/indirect3/main.ts === +// import { /*FIND ALL REFS*/[|foo|] } from '../target/src/main'; +// [|foo|]() +// export function bar() {} +// + +// === /myproject/src/helpers/functions.ts === +// export function [|foo|]() { return 1; } + +// === /myproject/src/main.ts === +// import { [|foo|] } from './helpers/functions'; +// export { foo }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline new file mode 100644 index 0000000000..91a1f25a3a --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline @@ -0,0 +1,130 @@ +UseCaseSensitiveFileNames: true +//// [/solution/api/src/server.ts] *new* +import * as shared from "../../shared/dist" +shared.foo.bar(); +//// [/solution/api/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/app/src/app.ts] *new* +import * as shared from "../../shared/dist" +shared.foo.bar(); +//// [/solution/app/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/shared/src/index.ts] *new* +const local = { bar: () => { } }; +export const foo = local; +//// [/solution/shared/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./api" }, + { "path": "./app" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as shared from \"../../shared/dist\"\nshared.foo.bar();" + } + } +} + +Projects:: + [/solution/api/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/api/src/server.ts] *new* + /solution/api/tsconfig.json (default) +Config:: + [/solution/api/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json +Config File Names:: + [/solution/api/src/server.ts] *new* + NearestConfigFileName: /solution/api/tsconfig.json + Ancestors: + /solution/api/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts" + }, + "position": { + "line": 1, + "character": 11 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/api/tsconfig.json] + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *new* + /solution/shared/src/index.ts + [/solution/tsconfig.json] +Config:: + [/solution/api/tsconfig.json] + RetainingProjects: + /solution/api/tsconfig.json + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/shared/tsconfig.json *new* + + + + +// === findAllReferences === +// === /solution/api/src/server.ts === +// import * as shared from "../../shared/dist" +// shared.foo./*FIND ALL REFS*/[|bar|](); + +// === /solution/shared/src/index.ts === +// const local = { [|bar|]: () => { } }; +// export const foo = local; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline new file mode 100644 index 0000000000..950d470291 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline @@ -0,0 +1,145 @@ +UseCaseSensitiveFileNames: true +//// [/solution/api/src/server.ts] *new* +import * as shared from "../../shared/dist" +shared.foo.bar(); +//// [/solution/api/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/app/src/app.ts] *new* +import * as shared from "../../shared/dist" +shared.foo.bar(); +//// [/solution/app/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/shared/src/index.ts] *new* +export const foo = { bar: () => { } }; +//// [/solution/shared/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./api" }, + { "path": "./app" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as shared from \"../../shared/dist\"\nshared.foo.bar();" + } + } +} + +Projects:: + [/solution/api/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/api/src/server.ts] *new* + /solution/api/tsconfig.json (default) +Config:: + [/solution/api/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json +Config File Names:: + [/solution/api/src/server.ts] *new* + NearestConfigFileName: /solution/api/tsconfig.json + Ancestors: + /solution/api/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts" + }, + "position": { + "line": 1, + "character": 11 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/api/tsconfig.json] + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/app/src/app.ts + [/solution/shared/tsconfig.json] *new* + /solution/shared/src/index.ts + [/solution/tsconfig.json] *modified* +Config:: + [/solution/api/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/tsconfig.json *new* + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + RetainingProjects: + /solution/app/tsconfig.json + /solution/tsconfig.json + [/solution/shared/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/app/tsconfig.json *new* + /solution/shared/tsconfig.json *new* + /solution/tsconfig.json *new* + [/solution/tsconfig.json] *new* + RetainingProjects: + /solution/tsconfig.json + + + + +// === findAllReferences === +// === /solution/api/src/server.ts === +// import * as shared from "../../shared/dist" +// shared.foo./*FIND ALL REFS*/[|bar|](); + +// === /solution/app/src/app.ts === +// import * as shared from "../../shared/dist" +// shared.foo.[|bar|](); + +// === /solution/shared/src/index.ts === +// export const foo = { [|bar|]: () => { } }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline new file mode 100644 index 0000000000..79d114c2db --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline @@ -0,0 +1,145 @@ +UseCaseSensitiveFileNames: true +//// [/solution/api/src/server.ts] *new* +import * as shared from "../../shared/dist" +shared.dog(); +//// [/solution/api/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/app/src/app.ts] *new* +import * as shared from "../../shared/dist" +shared.dog(); +//// [/solution/app/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/shared/src/index.ts] *new* +export const dog = () => { }; +//// [/solution/shared/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./api" }, + { "path": "./app" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as shared from \"../../shared/dist\"\nshared.dog();" + } + } +} + +Projects:: + [/solution/api/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/api/src/server.ts] *new* + /solution/api/tsconfig.json (default) +Config:: + [/solution/api/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json +Config File Names:: + [/solution/api/src/server.ts] *new* + NearestConfigFileName: /solution/api/tsconfig.json + Ancestors: + /solution/api/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts" + }, + "position": { + "line": 1, + "character": 7 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/api/tsconfig.json] + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/app/src/app.ts + [/solution/shared/tsconfig.json] *new* + /solution/shared/src/index.ts + [/solution/tsconfig.json] *modified* +Config:: + [/solution/api/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/tsconfig.json *new* + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + RetainingProjects: + /solution/app/tsconfig.json + /solution/tsconfig.json + [/solution/shared/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/app/tsconfig.json *new* + /solution/shared/tsconfig.json *new* + /solution/tsconfig.json *new* + [/solution/tsconfig.json] *new* + RetainingProjects: + /solution/tsconfig.json + + + + +// === findAllReferences === +// === /solution/api/src/server.ts === +// import * as shared from "../../shared/dist" +// shared./*FIND ALL REFS*/[|dog|](); + +// === /solution/app/src/app.ts === +// import * as shared from "../../shared/dist" +// shared.[|dog|](); + +// === /solution/shared/src/index.ts === +// export const [|dog|] = () => { }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline new file mode 100644 index 0000000000..ea029f1196 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline @@ -0,0 +1,149 @@ +UseCaseSensitiveFileNames: true +//// [/solution/api/src/server.ts] *new* +import * as shared from "../../shared/dist" +const instance = new shared.foo(); +instance.fly(); +//// [/solution/api/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/app/src/app.ts] *new* +import * as shared from "../../shared/dist" +const instance = new shared.foo(); +instance.fly(); +//// [/solution/app/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/shared/src/index.ts] *new* +export const foo = class { fly() {} }; +//// [/solution/shared/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./api" }, + { "path": "./app" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as shared from \"../../shared/dist\"\nconst instance = new shared.foo();\ninstance.fly();" + } + } +} + +Projects:: + [/solution/api/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/api/src/server.ts] *new* + /solution/api/tsconfig.json (default) +Config:: + [/solution/api/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json +Config File Names:: + [/solution/api/src/server.ts] *new* + NearestConfigFileName: /solution/api/tsconfig.json + Ancestors: + /solution/api/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts" + }, + "position": { + "line": 2, + "character": 9 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/api/tsconfig.json] + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/app/src/app.ts + [/solution/shared/tsconfig.json] *new* + /solution/shared/src/index.ts + [/solution/tsconfig.json] *modified* +Config:: + [/solution/api/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/tsconfig.json *new* + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + RetainingProjects: + /solution/app/tsconfig.json + /solution/tsconfig.json + [/solution/shared/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/app/tsconfig.json *new* + /solution/shared/tsconfig.json *new* + /solution/tsconfig.json *new* + [/solution/tsconfig.json] *new* + RetainingProjects: + /solution/tsconfig.json + + + + +// === findAllReferences === +// === /solution/api/src/server.ts === +// import * as shared from "../../shared/dist" +// const instance = new shared.foo(); +// instance./*FIND ALL REFS*/[|fly|](); + +// === /solution/app/src/app.ts === +// import * as shared from "../../shared/dist" +// const instance = new shared.foo(); +// instance.[|fly|](); + +// === /solution/shared/src/index.ts === +// export const foo = class { [|fly|]() {} }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline new file mode 100644 index 0000000000..00d57bb417 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline @@ -0,0 +1,145 @@ +UseCaseSensitiveFileNames: true +//// [/solution/api/src/server.ts] *new* +import * as shared from "../../shared/dist" +shared.foo.baz; +//// [/solution/api/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/app/src/app.ts] *new* +import * as shared from "../../shared/dist" +shared.foo.baz; +//// [/solution/app/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "references": [{ "path": "../shared" }], +} +//// [/solution/shared/src/index.ts] *new* +export const foo = { baz: "BAZ" }; +//// [/solution/shared/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], +} +//// [/solution/tsconfig.json] *new* +{ + "files": [], + "references": [ + { "path": "./api" }, + { "path": "./app" }, + ], +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts", + "languageId": "typescript", + "version": 0, + "text": "import * as shared from \"../../shared/dist\"\nshared.foo.baz;" + } + } +} + +Projects:: + [/solution/api/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/tsconfig.json] *new* +Open Files:: + [/solution/api/src/server.ts] *new* + /solution/api/tsconfig.json (default) +Config:: + [/solution/api/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/shared/tsconfig.json] *new* + RetainingProjects: + /solution/api/tsconfig.json +Config File Names:: + [/solution/api/src/server.ts] *new* + NearestConfigFileName: /solution/api/tsconfig.json + Ancestors: + /solution/api/tsconfig.json /solution/tsconfig.json + /solution/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///solution/api/src/server.ts" + }, + "position": { + "line": 1, + "character": 11 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/solution/api/tsconfig.json] + /solution/shared/src/index.ts + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + /solution/shared/src/index.ts + /solution/app/src/app.ts + [/solution/shared/tsconfig.json] *new* + /solution/shared/src/index.ts + [/solution/tsconfig.json] *modified* +Config:: + [/solution/api/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/tsconfig.json *new* + RetainingOpenFiles: + /solution/api/src/server.ts + [/solution/app/tsconfig.json] *new* + RetainingProjects: + /solution/app/tsconfig.json + /solution/tsconfig.json + [/solution/shared/tsconfig.json] *modified* + RetainingProjects: *modified* + /solution/api/tsconfig.json + /solution/app/tsconfig.json *new* + /solution/shared/tsconfig.json *new* + /solution/tsconfig.json *new* + [/solution/tsconfig.json] *new* + RetainingProjects: + /solution/tsconfig.json + + + + +// === findAllReferences === +// === /solution/api/src/server.ts === +// import * as shared from "../../shared/dist" +// shared.foo./*FIND ALL REFS*/[|baz|]; + +// === /solution/app/src/app.ts === +// import * as shared from "../../shared/dist" +// shared.foo.[|baz|]; + +// === /solution/shared/src/index.ts === +// export const foo = { [|baz|]: "BAZ" }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline new file mode 100644 index 0000000000..d1dde71935 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline @@ -0,0 +1,369 @@ +UseCaseSensitiveFileNames: true +//// [/myproject/core/src/file1.ts] *new* +export const coreConst = 10; +//// [/myproject/core/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, +} +//// [/myproject/coreRef1/src/file1.ts] *new* +export const coreRef1Const = 10; +//// [/myproject/coreRef1/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + ] +} +//// [/myproject/coreRef2/src/file1.ts] *new* +export const coreRef2Const = 10; +//// [/myproject/coreRef2/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + ] +} +//// [/myproject/coreRef3/src/file1.ts] *new* +export const coreRef3Const = 10; +//// [/myproject/coreRef3/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + ] +} +//// [/myproject/indirect/src/file1.ts] *new* +export const indirectConst = 10; +//// [/myproject/indirect/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../coreRef1" }, + ] +} +//// [/myproject/indirectDisabledChildLoad1/src/file1.ts] *new* +export const indirectDisabledChildLoad1Const = 10; +//// [/myproject/indirectDisabledChildLoad1/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "disableReferencedProjectLoad": true, + }, + "references": [ + { "path": "../coreRef2" }, + ] +} +//// [/myproject/indirectDisabledChildLoad2/src/file1.ts] *new* +export const indirectDisabledChildLoad2Const = 10; +//// [/myproject/indirectDisabledChildLoad2/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "disableReferencedProjectLoad": true, + }, + "references": [ + { "path": "../coreRef3" }, + ] +} +//// [/myproject/indirectNoCoreRef/src/file1.ts] *new* +export const indirectNoCoreRefConst = 10; +//// [/myproject/indirectNoCoreRef/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../noCoreRef2" }, + ] +} +//// [/myproject/main/src/file1.ts] *new* +export const mainConst = 10; +//// [/myproject/main/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../core" }, + { "path": "../indirect" }, + { "path": "../noCoreRef1" }, + { "path": "../indirectDisabledChildLoad1" }, + { "path": "../indirectDisabledChildLoad2" }, + { "path": "../refToCoreRef3" }, + { "path": "../indirectNoCoreRef" } + ] +} +//// [/myproject/noCoreRef1/src/file1.ts] *new* +export const noCoreRef1Const = 10; +//// [/myproject/noCoreRef1/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, +} +//// [/myproject/noCoreRef2/src/file1.ts] *new* +export const noCoreRef2Const = 10; +//// [/myproject/noCoreRef2/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, +} +//// [/myproject/refToCoreRef3/src/file1.ts] *new* +export const refToCoreRef3Const = 10; +//// [/myproject/refToCoreRef3/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "references": [ + { "path": "../coreRef3" }, + ] +} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/main/src/file1.ts", + "languageId": "typescript", + "version": 0, + "text": "export const mainConst = 10;" + } + } +} + +Projects:: + [/myproject/main/tsconfig.json] *new* + /myproject/main/src/file1.ts +Open Files:: + [/myproject/main/src/file1.ts] *new* + /myproject/main/tsconfig.json (default) +Config:: + [/myproject/core/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/coreRef1/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/coreRef2/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/coreRef3/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirect/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirectDisabledChildLoad1/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirectDisabledChildLoad2/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirectNoCoreRef/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/main/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + RetainingOpenFiles: + /myproject/main/src/file1.ts + [/myproject/noCoreRef1/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/noCoreRef2/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/refToCoreRef3/tsconfig.json] *new* + RetainingProjects: + /myproject/main/tsconfig.json +Config File Names:: + [/myproject/main/src/file1.ts] *new* + NearestConfigFileName: /myproject/main/tsconfig.json + Ancestors: + /myproject/main/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///myproject/core/src/file1.ts", + "languageId": "typescript", + "version": 0, + "text": "export const coreConst = 10;" + } + } +} + +Projects:: + [/myproject/core/tsconfig.json] *new* + /myproject/core/src/file1.ts + [/myproject/main/tsconfig.json] + /myproject/main/src/file1.ts +Open Files:: + [/myproject/core/src/file1.ts] *new* + /myproject/core/tsconfig.json (default) + [/myproject/main/src/file1.ts] + /myproject/main/tsconfig.json (default) +Config:: + [/myproject/core/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/core/tsconfig.json *new* + /myproject/main/tsconfig.json + RetainingOpenFiles: *modified* + /myproject/core/src/file1.ts *new* + [/myproject/coreRef1/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/coreRef2/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/coreRef3/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirect/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirectDisabledChildLoad1/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirectDisabledChildLoad2/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/indirectNoCoreRef/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/main/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + RetainingOpenFiles: + /myproject/main/src/file1.ts + [/myproject/noCoreRef1/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/noCoreRef2/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/refToCoreRef3/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json +Config File Names:: + [/myproject/core/src/file1.ts] *new* + NearestConfigFileName: /myproject/core/tsconfig.json + Ancestors: + /myproject/core/tsconfig.json + [/myproject/main/src/file1.ts] + NearestConfigFileName: /myproject/main/tsconfig.json + Ancestors: + /myproject/main/tsconfig.json + +{ + "method": "textDocument/references", + "params": { + "textDocument": { + "uri": "file:///myproject/core/src/file1.ts" + }, + "position": { + "line": 0, + "character": 13 + }, + "context": { + "includeDeclaration": false + } + } +} + +Projects:: + [/myproject/core/tsconfig.json] + /myproject/core/src/file1.ts + [/myproject/coreRef1/tsconfig.json] *new* + /myproject/coreRef1/src/file1.ts + [/myproject/coreRef3/tsconfig.json] *new* + /myproject/coreRef3/src/file1.ts + [/myproject/indirect/tsconfig.json] *new* + /myproject/indirect/src/file1.ts + [/myproject/indirectDisabledChildLoad1/tsconfig.json] *new* + /myproject/indirectDisabledChildLoad1/src/file1.ts + [/myproject/indirectDisabledChildLoad2/tsconfig.json] *new* + /myproject/indirectDisabledChildLoad2/src/file1.ts + [/myproject/main/tsconfig.json] + /myproject/main/src/file1.ts + [/myproject/refToCoreRef3/tsconfig.json] *new* + /myproject/refToCoreRef3/src/file1.ts +Config:: + [/myproject/core/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/core/tsconfig.json + /myproject/coreRef1/tsconfig.json *new* + /myproject/coreRef3/tsconfig.json *new* + /myproject/indirect/tsconfig.json *new* + /myproject/indirectDisabledChildLoad1/tsconfig.json *new* + /myproject/indirectDisabledChildLoad2/tsconfig.json *new* + /myproject/main/tsconfig.json + /myproject/refToCoreRef3/tsconfig.json *new* + RetainingOpenFiles: + /myproject/core/src/file1.ts + [/myproject/coreRef1/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/coreRef1/tsconfig.json *new* + /myproject/indirect/tsconfig.json *new* + /myproject/main/tsconfig.json + [/myproject/coreRef2/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/indirectDisabledChildLoad1/tsconfig.json *new* + /myproject/main/tsconfig.json + [/myproject/coreRef3/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/coreRef3/tsconfig.json *new* + /myproject/indirectDisabledChildLoad2/tsconfig.json *new* + /myproject/main/tsconfig.json + /myproject/refToCoreRef3/tsconfig.json *new* + [/myproject/indirect/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/indirect/tsconfig.json *new* + /myproject/main/tsconfig.json + [/myproject/indirectDisabledChildLoad1/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/indirectDisabledChildLoad1/tsconfig.json *new* + /myproject/main/tsconfig.json + [/myproject/indirectDisabledChildLoad2/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/indirectDisabledChildLoad2/tsconfig.json *new* + /myproject/main/tsconfig.json + [/myproject/indirectNoCoreRef/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/main/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + RetainingOpenFiles: + /myproject/main/src/file1.ts + [/myproject/noCoreRef1/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/noCoreRef2/tsconfig.json] + RetainingProjects: + /myproject/main/tsconfig.json + [/myproject/refToCoreRef3/tsconfig.json] *modified* + RetainingProjects: *modified* + /myproject/main/tsconfig.json + /myproject/refToCoreRef3/tsconfig.json *new* + + + + +// === findAllReferences === +// === /myproject/core/src/file1.ts === +// export const /*FIND ALL REFS*/[|coreConst|] = 10; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/renameAncestorProjectRefMangement.baseline b/testdata/baselines/reference/fourslash/state/renameAncestorProjectRefMangement.baseline new file mode 100644 index 0000000000..5fdfa774d0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/renameAncestorProjectRefMangement.baseline @@ -0,0 +1,254 @@ +UseCaseSensitiveFileNames: true +//// [/projects/container/compositeExec/index.ts] *new* +import { myConst } from "../lib"; +export function getMyConst() { + return myConst; +} +//// [/projects/container/compositeExec/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + "files": ["./index.ts"], + "references": [ + { "path": "../lib" }, + ], +} +//// [/projects/container/exec/index.ts] *new* +import { myConst } from "../lib"; +export function getMyConst() { + return myConst; +} +//// [/projects/container/exec/tsconfig.json] *new* +{ + "files": ["./index.ts"], + "references": [ + { "path": "../lib" }, + ], +} +//// [/projects/container/lib/index.ts] *new* +export const myConst = 30; +//// [/projects/container/lib/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + }, + references: [], + files: [ + "index.ts", + ], +} +//// [/projects/container/tsconfig.json] *new* +{ + "files": [], + "include": [], + "references": [ + { "path": "./exec" }, + { "path": "./compositeExec" }, + ], +} + +//// [/projects/temp/temp.ts] *new* +let x = 10 +//// [/projects/temp/tsconfig.json] *new* +{} + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/container/compositeExec/index.ts", + "languageId": "typescript", + "version": 0, + "text": "import { myConst } from \"../lib\";\nexport function getMyConst() {\n\treturn myConst;\n}" + } + } +} + +Projects:: + [/projects/container/compositeExec/tsconfig.json] *new* + /projects/container/lib/index.ts + /projects/container/compositeExec/index.ts + [/projects/container/tsconfig.json] *new* +Open Files:: + [/projects/container/compositeExec/index.ts] *new* + /projects/container/compositeExec/tsconfig.json (default) +Config:: + [/projects/container/compositeExec/tsconfig.json] *new* + RetainingProjects: + /projects/container/compositeExec/tsconfig.json + RetainingOpenFiles: + /projects/container/compositeExec/index.ts + [/projects/container/lib/tsconfig.json] *new* + RetainingProjects: + /projects/container/compositeExec/tsconfig.json +Config File Names:: + [/projects/container/compositeExec/index.ts] *new* + NearestConfigFileName: /projects/container/compositeExec/tsconfig.json + Ancestors: + /projects/container/compositeExec/tsconfig.json /projects/container/tsconfig.json + /projects/container/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/temp/temp.ts", + "languageId": "typescript", + "version": 0, + "text": "let x = 10" + } + } +} + +Projects:: + [/projects/container/compositeExec/tsconfig.json] + /projects/container/lib/index.ts + /projects/container/compositeExec/index.ts + [/projects/container/tsconfig.json] + [/projects/temp/tsconfig.json] *new* + /projects/temp/temp.ts +Open Files:: + [/projects/container/compositeExec/index.ts] + /projects/container/compositeExec/tsconfig.json (default) + [/projects/temp/temp.ts] *new* + /projects/temp/tsconfig.json (default) +Config:: + [/projects/container/compositeExec/tsconfig.json] + RetainingProjects: + /projects/container/compositeExec/tsconfig.json + RetainingOpenFiles: + /projects/container/compositeExec/index.ts + [/projects/container/lib/tsconfig.json] + RetainingProjects: + /projects/container/compositeExec/tsconfig.json + [/projects/temp/tsconfig.json] *new* + RetainingProjects: + /projects/temp/tsconfig.json + RetainingOpenFiles: + /projects/temp/temp.ts +Config File Names:: + [/projects/container/compositeExec/index.ts] + NearestConfigFileName: /projects/container/compositeExec/tsconfig.json + Ancestors: + /projects/container/compositeExec/tsconfig.json /projects/container/tsconfig.json + /projects/container/tsconfig.json + [/projects/temp/temp.ts] *new* + NearestConfigFileName: /projects/temp/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///projects/container/compositeExec/index.ts" + }, + "position": { + "line": 0, + "character": 9 + }, + "newName": "?" + } +} + + + + +// === findRenameLocations === +// === /projects/container/compositeExec/index.ts === +// import { /*START PREFIX*/myConst as /*RENAME*/[|myConstRENAME|] } from "../lib"; +// export function getMyConst() { +// return [|myConstRENAME|]; +// } +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///projects/temp/temp.ts" + } + } +} + +Open Files:: + [/projects/container/compositeExec/index.ts] + /projects/container/compositeExec/tsconfig.json (default) + [/projects/temp/temp.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/temp/temp.ts", + "languageId": "typescript", + "version": 0, + "text": "let x = 10" + } + } +} + +Open Files:: + [/projects/container/compositeExec/index.ts] + /projects/container/compositeExec/tsconfig.json (default) + [/projects/temp/temp.ts] *new* + /projects/temp/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///projects/container/compositeExec/index.ts" + } + } +} + +Open Files:: + [/projects/container/compositeExec/index.ts] *closed* + [/projects/temp/temp.ts] + /projects/temp/tsconfig.json (default) + +{ + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "file:///projects/temp/temp.ts" + } + } +} + +Open Files:: + [/projects/temp/temp.ts] *closed* + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/temp/temp.ts", + "languageId": "typescript", + "version": 0, + "text": "let x = 10" + } + } +} + +Projects:: + [/projects/container/compositeExec/tsconfig.json] *deleted* + /projects/container/lib/index.ts + /projects/container/compositeExec/index.ts + [/projects/container/tsconfig.json] *deleted* + [/projects/temp/tsconfig.json] + /projects/temp/temp.ts +Open Files:: + [/projects/temp/temp.ts] *new* + /projects/temp/tsconfig.json (default) +Config:: + [/projects/container/compositeExec/tsconfig.json] *deleted* + [/projects/container/lib/tsconfig.json] *deleted* + [/projects/temp/tsconfig.json] + RetainingProjects: + /projects/temp/tsconfig.json + RetainingOpenFiles: + /projects/temp/temp.ts +Config File Names:: + [/projects/container/compositeExec/index.ts] *deleted* + [/projects/temp/temp.ts] + NearestConfigFileName: /projects/temp/tsconfig.json diff --git a/testdata/baselines/reference/fourslash/state/renameInCommonFile.baseline b/testdata/baselines/reference/fourslash/state/renameInCommonFile.baseline new file mode 100644 index 0000000000..01ee54f6f7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/state/renameInCommonFile.baseline @@ -0,0 +1,197 @@ +UseCaseSensitiveFileNames: true +//// [/projects/a/a.ts] *new* +import {C} from "./c/fc"; +console.log(C) +//// [/projects/a/c] -> /projects/c *new* +//// [/projects/a/tsconfig.json] *new* +{} +//// [/projects/b/b.ts] *new* +import {C} from "../c/fc"; +console.log(C) +//// [/projects/b/c] -> /projects/c *new* +//// [/projects/b/tsconfig.json] *new* +{} +//// [/projects/c/fc.ts] *new* +export const C = 42; + + + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/a/a.ts", + "languageId": "typescript", + "version": 0, + "text": "import {C} from \"./c/fc\";\nconsole.log(C)" + } + } +} + +Projects:: + [/projects/a/tsconfig.json] *new* + /projects/a/c/fc.ts + /projects/a/a.ts +Open Files:: + [/projects/a/a.ts] *new* + /projects/a/tsconfig.json (default) +Config:: + [/projects/a/tsconfig.json] *new* + RetainingProjects: + /projects/a/tsconfig.json + RetainingOpenFiles: + /projects/a/a.ts +Config File Names:: + [/projects/a/a.ts] *new* + NearestConfigFileName: /projects/a/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/b/b.ts", + "languageId": "typescript", + "version": 0, + "text": "import {C} from \"../c/fc\";\nconsole.log(C)" + } + } +} + +Projects:: + [/projects/a/tsconfig.json] + /projects/a/c/fc.ts + /projects/a/a.ts + [/projects/b/tsconfig.json] *new* + /projects/c/fc.ts + /projects/b/b.ts + /projects/b/c/fc.ts +Open Files:: + [/projects/a/a.ts] + /projects/a/tsconfig.json (default) + [/projects/b/b.ts] *new* + /projects/b/tsconfig.json (default) +Config:: + [/projects/a/tsconfig.json] + RetainingProjects: + /projects/a/tsconfig.json + RetainingOpenFiles: + /projects/a/a.ts + [/projects/b/tsconfig.json] *new* + RetainingProjects: + /projects/b/tsconfig.json + RetainingOpenFiles: + /projects/b/b.ts +Config File Names:: + [/projects/a/a.ts] + NearestConfigFileName: /projects/a/tsconfig.json + [/projects/b/b.ts] *new* + NearestConfigFileName: /projects/b/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/a/c/fc.ts", + "languageId": "typescript", + "version": 0, + "text": "export const C = 42;\n" + } + } +} + +Open Files:: + [/projects/a/a.ts] + /projects/a/tsconfig.json (default) + [/projects/a/c/fc.ts] *new* + /projects/a/tsconfig.json (default) + [/projects/b/b.ts] + /projects/b/tsconfig.json (default) +Config:: + [/projects/a/tsconfig.json] *modified* + RetainingProjects: + /projects/a/tsconfig.json + RetainingOpenFiles: *modified* + /projects/a/a.ts + /projects/a/c/fc.ts *new* + [/projects/b/tsconfig.json] + RetainingProjects: + /projects/b/tsconfig.json + RetainingOpenFiles: + /projects/b/b.ts +Config File Names:: + [/projects/a/a.ts] + NearestConfigFileName: /projects/a/tsconfig.json + [/projects/a/c/fc.ts] *new* + NearestConfigFileName: /projects/a/tsconfig.json + [/projects/b/b.ts] + NearestConfigFileName: /projects/b/tsconfig.json + +{ + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///projects/b/c/fc.ts", + "languageId": "typescript", + "version": 0, + "text": "export const C = 42;\n" + } + } +} + +Open Files:: + [/projects/a/a.ts] + /projects/a/tsconfig.json (default) + [/projects/a/c/fc.ts] + /projects/a/tsconfig.json (default) + [/projects/b/b.ts] + /projects/b/tsconfig.json (default) + [/projects/b/c/fc.ts] *new* + /projects/b/tsconfig.json (default) +Config:: + [/projects/a/tsconfig.json] + RetainingProjects: + /projects/a/tsconfig.json + RetainingOpenFiles: + /projects/a/a.ts + /projects/a/c/fc.ts + [/projects/b/tsconfig.json] *modified* + RetainingProjects: + /projects/b/tsconfig.json + RetainingOpenFiles: *modified* + /projects/b/b.ts + /projects/b/c/fc.ts *new* +Config File Names:: + [/projects/a/a.ts] + NearestConfigFileName: /projects/a/tsconfig.json + [/projects/a/c/fc.ts] + NearestConfigFileName: /projects/a/tsconfig.json + [/projects/b/b.ts] + NearestConfigFileName: /projects/b/tsconfig.json + [/projects/b/c/fc.ts] *new* + NearestConfigFileName: /projects/b/tsconfig.json + +{ + "method": "textDocument/rename", + "params": { + "textDocument": { + "uri": "file:///projects/a/c/fc.ts" + }, + "position": { + "line": 0, + "character": 13 + }, + "newName": "?" + } +} + + + + +// === findRenameLocations === +// === /projects/a/a.ts === +// import {[|CRENAME|]} from "./c/fc"; +// console.log([|CRENAME|]) + +// === /projects/a/c/fc.ts === +// export const /*RENAME*/C = 42; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics01.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics01.baseline new file mode 100644 index 0000000000..8f1d3f66b1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics01.baseline @@ -0,0 +1,11 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,5): error TS1134: Variable declaration expected. +/a.js(1,8): error TS1109: Expression expected. + + +==== /a.js (2 errors) ==== + var ===; + ~~~ +!!! error TS1134: Variable declaration expected. + ~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics02.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics02.baseline new file mode 100644 index 0000000000..212add171e --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics02.baseline @@ -0,0 +1,23 @@ +// === Syntax and Semantic Diagnostics === +/b.js(2,8): error TS8010: Type annotations can only be used in TypeScript files. +/b.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. +/b.js(4,5): error TS1389: 'var' is not allowed as a variable declaration name. +/b.js(4,9): error TS1134: Variable declaration expected. +/b.js(4,11): error TS1134: Variable declaration expected. + + +==== /b.js (5 errors) ==== + var a = "a"; + var b: boolean = true; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function foo(): string { } + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var var = "c"; + ~~~ +!!! error TS1389: 'var' is not allowed as a variable declaration name. + ~ +!!! error TS1134: Variable declaration expected. + ~~~ +!!! error TS1134: Variable declaration expected. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics1.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics1.baseline new file mode 100644 index 0000000000..5a7ba4c6cd --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics1.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + import a = b; + ~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics10.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics10.baseline new file mode 100644 index 0000000000..d60ddbbfbc --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics10.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + function F() { } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics11.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics11.baseline new file mode 100644 index 0000000000..3cf4c936c8 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics11.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + function F(): number { } + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics12.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics12.baseline new file mode 100644 index 0000000000..36bfd049fe --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics12.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,1): error TS8009: The 'declare' modifier can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + declare var v; + ~~~~~~~ +!!! error TS8009: The 'declare' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics13.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics13.baseline new file mode 100644 index 0000000000..1a8c0bb710 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics13.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,8): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + var v: () => number; + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics14.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics14.baseline new file mode 100644 index 0000000000..508f54f165 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics14.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,13): error TS1109: Expression expected. + + +==== /a.js (1 errors) ==== + Foo(); + ~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics15.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics15.baseline new file mode 100644 index 0000000000..24708d02fe --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics15.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,12): error TS8012: Parameter modifiers can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + function F(public p) { } + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics16.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics16.baseline new file mode 100644 index 0000000000..0b9ef1cf2a --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics16.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,13): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + function F(p?) { } + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics17.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics17.baseline new file mode 100644 index 0000000000..cce3890ced --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics17.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + function F(a: number) { } + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics18.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics18.baseline new file mode 100644 index 0000000000..d92d796144 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics18.baseline @@ -0,0 +1,19 @@ +// === Syntax and Semantic Diagnostics === +/a.js(4,5): error TS8009: The 'public' modifier can only be used in TypeScript files. +/b.js(2,8): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class C { + x; // Regular property declaration allowed + static y; // static allowed + public z; // public not allowed + ~~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. + } +==== /b.js (1 errors) ==== + class C { + x: number; // Types not allowed + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics19.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics19.baseline new file mode 100644 index 0000000000..ca4729a3dc --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics19.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,6): error TS8006: 'enum' declarations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + enum E { } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics2.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics2.baseline new file mode 100644 index 0000000000..3836f76141 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics2.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,1): error TS8003: 'export =' can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + export = b; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics3.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics3.baseline new file mode 100644 index 0000000000..948e4c0a3a --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics3.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,9): error TS8004: Type parameter declarations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class C { } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics4.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics4.baseline new file mode 100644 index 0000000000..682bbd5d1c --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics4.baseline @@ -0,0 +1,11 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,1): error TS1044: 'public' modifier cannot appear on a module or namespace element. +/a.js(1,1): error TS8009: The 'public' modifier can only be used in TypeScript files. + + +==== /a.js (2 errors) ==== + public class C { } + ~~~~~~ +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. + ~~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics5.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics5.baseline new file mode 100644 index 0000000000..db5acfdd30 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics5.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,9): error TS8005: 'implements' clauses can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class C implements D { } + ~~~~~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics6.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics6.baseline new file mode 100644 index 0000000000..2f9b79d092 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics6.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,11): error TS8006: 'interface' declarations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + interface I { } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics7.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics7.baseline new file mode 100644 index 0000000000..eeddc9d453 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics7.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + module M { } + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics8.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics8.baseline new file mode 100644 index 0000000000..0e3ac10c51 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics8.baseline @@ -0,0 +1,8 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,6): error TS8008: Type aliases can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + type a = b; + ~ +!!! error TS8008: Type aliases can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics9.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics9.baseline new file mode 100644 index 0000000000..83177f4967 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/getJavaScriptSyntacticDiagnostics9.baseline @@ -0,0 +1,11 @@ +// === Syntax and Semantic Diagnostics === +/a.js(1,1): error TS1044: 'public' modifier cannot appear on a module or namespace element. +/a.js(1,1): error TS8009: The 'public' modifier can only be used in TypeScript files. + + +==== /a.js (2 errors) ==== + public function F() { } + ~~~~~~ +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. + ~~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences1.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences1.baseline new file mode 100644 index 0000000000..d1c8c10329 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences1.baseline @@ -0,0 +1,10 @@ +// === Syntax and Semantic Diagnostics === +/packages/main/src/index.ts(1,16): error TS2878: This import path is unsafe to rewrite because it resolves to another project, and the relative path between the projects' output files is not the same as the relative path between its input files. + + +==== /packages/common/src/index.ts (0 errors) ==== + export {}; +==== /packages/main/src/index.ts (1 errors) ==== + import {} from "../../common/src/index.ts"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2878: This import path is unsafe to rewrite because it resolves to another project, and the relative path between the projects' output files is not the same as the relative path between its input files. \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences2.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences2.baseline new file mode 100644 index 0000000000..786b9b4a67 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences2.baseline @@ -0,0 +1,7 @@ +// === Syntax and Semantic Diagnostics === + + +==== /src/compiler/parser.ts (0 errors) ==== + export {}; +==== /src/services/services.ts (0 errors) ==== + import {} from "../compiler/parser.ts"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences3.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences3.baseline new file mode 100644 index 0000000000..786b9b4a67 --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/rewriteRelativeImportExtensionsProjectReferences3.baseline @@ -0,0 +1,7 @@ +// === Syntax and Semantic Diagnostics === + + +==== /src/compiler/parser.ts (0 errors) ==== + export {}; +==== /src/services/services.ts (0 errors) ==== + import {} from "../compiler/parser.ts"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/typeErrorAfterStringCompletionsInNestedCall2.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/typeErrorAfterStringCompletionsInNestedCall2.baseline new file mode 100644 index 0000000000..3a2bd6eedd --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/typeErrorAfterStringCompletionsInNestedCall2.baseline @@ -0,0 +1,68 @@ +// === Syntax and Semantic Diagnostics === +/typeErrorAfterStringCompletionsInNestedCall2.ts(40,5): error TS2322: Type '{ ({ event }: { event: { type: "FOO"; }; }): void; _out_TEvent?: { type: "BARx"; } | undefined; }' is not assignable to type 'ActionFunction<{ type: "FOO"; }, { type: "FOO"; } | { type: "BAR"; }>'. + Types of property '_out_TEvent' are incompatible. + Type '{ type: "BARx"; } | undefined' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'. + Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'. + Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; }'. + Type '{ type: "BARx"; }' is not assignable to type '{ type: "BAR"; }'. + Types of property 'type' are incompatible. + Type '"BARx"' is not assignable to type '"BAR"'. + + +==== /typeErrorAfterStringCompletionsInNestedCall2.ts (1 errors) ==== + type ActionFunction< + TExpressionEvent extends { type: string }, + out TEvent extends { type: string } + > = { + ({ event }: { event: TExpressionEvent }): void; + _out_TEvent?: TEvent; + }; + + interface MachineConfig { + types: { + events: TEvent; + }; + on: { + [K in TEvent["type"]]?: ActionFunction< + Extract, + TEvent + >; + }; + } + + declare function raise< + TExpressionEvent extends { type: string }, + TEvent extends { type: string } + >( + resolve: ({ event }: { event: TExpressionEvent }) => TEvent + ): { + ({ event }: { event: TExpressionEvent }): void; + _out_TEvent?: TEvent; + }; + + declare function createMachine( + config: MachineConfig + ): void; + + createMachine({ + types: { + events: {} as { type: "FOO" } | { type: "BAR" }, + }, + on: { + FOO: raise(({ event }) => { + ~~~ +!!! error TS2322: Type '{ ({ event }: { event: { type: "FOO"; }; }): void; _out_TEvent?: { type: "BARx"; } | undefined; }' is not assignable to type 'ActionFunction<{ type: "FOO"; }, { type: "FOO"; } | { type: "BAR"; }>'. +!!! error TS2322: Types of property '_out_TEvent' are incompatible. +!!! error TS2322: Type '{ type: "BARx"; } | undefined' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'. +!!! error TS2322: Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; } | undefined'. +!!! error TS2322: Type '{ type: "BARx"; }' is not assignable to type '{ type: "FOO"; } | { type: "BAR"; }'. +!!! error TS2322: Type '{ type: "BARx"; }' is not assignable to type '{ type: "BAR"; }'. +!!! error TS2322: Types of property 'type' are incompatible. +!!! error TS2322: Type '"BARx"' is not assignable to type '"BAR"'. +!!! related TS2322 /typeErrorAfterStringCompletionsInNestedCall2.ts:13:7: The expected type comes from property 'FOO' which is declared here on type '{ BAR?: ActionFunction<{ type: "BAR"; }, { type: "FOO"; } | { type: "BAR"; }> | undefined; FOO?: ActionFunction<{ type: "FOO"; }, { type: "FOO"; } | { type: "BAR"; }> | undefined; }' + return { + type: "BARx" as const, + }; + }), + }, + }); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/unreachableCodeDiagnostics.baseline b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/unreachableCodeDiagnostics.baseline new file mode 100644 index 0000000000..1e9ae53f6f --- /dev/null +++ b/testdata/baselines/reference/fourslash/syntaxandSemanticDiagnostics/unreachableCodeDiagnostics.baseline @@ -0,0 +1,11 @@ +// === Syntax and Semantic Diagnostics === +/unreachableCodeDiagnostics.ts(3,1): warning TS7027: Unreachable code detected. + + +==== /unreachableCodeDiagnostics.ts (1 errors) ==== + throw new Error(); + + (() => {})(); + ~~~~~~~~~~~~~ +!!! warning TS7027: Unreachable code detected. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js index de90b96724..ce29e2fa65 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js @@ -85,6 +85,11 @@ watchMain(); //// [APISample_Watch.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript-wiki/blob/master/Using-the-Compiler-API.md#writing-an-incremental-program-watcher + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); const formatHost = { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff deleted file mode 100644 index 499c77d7d5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.APISample_Watch.js -+++ new.APISample_Watch.js -@@= skipped -84, +84 lines =@@ - - //// [APISample_Watch.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript-wiki/blob/master/Using-the-Compiler-API.md#writing-an-incremental-program-watcher -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("typescript"); -+const ts = require("typescript"); - const formatHost = { - getCanonicalFileName: path => path, - getCurrentDirectory: ts.sys.getCurrentDirectory, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js index d5b1a505ba..eda1e3f02b 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js @@ -58,6 +58,10 @@ watchMain(); //// [APISample_WatchWithDefaults.js] "use strict"; +/* + * Note: This test is a public API sample. This uses default sys interface without having to pass anything + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); function watchMain() { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff deleted file mode 100644 index 495001bf42..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.APISample_WatchWithDefaults.js -+++ new.APISample_WatchWithDefaults.js -@@= skipped -57, +57 lines =@@ - - //// [APISample_WatchWithDefaults.js] - "use strict"; --/* -- * Note: This test is a public API sample. This uses default sys interface without having to pass anything -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("typescript"); -+const ts = require("typescript"); - function watchMain() { - const configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json"); - if (!configPath) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js index 8e48f3cffc..915dc80a83 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js @@ -65,6 +65,10 @@ watchMain(); //// [APISample_WatchWithOwnWatchHost.js] "use strict"; +/* + * Note: This test is a public API sample. This sample verifies creating abstract builder to watch list of root files + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); function watchMain() { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff deleted file mode 100644 index 25d0f11df7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.APISample_WatchWithOwnWatchHost.js -+++ new.APISample_WatchWithOwnWatchHost.js -@@= skipped -64, +64 lines =@@ - - //// [APISample_WatchWithOwnWatchHost.js] - "use strict"; --/* -- * Note: This test is a public API sample. This sample verifies creating abstract builder to watch list of root files -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("typescript"); -+const ts = require("typescript"); - function watchMain() { - // get list of files and compiler options somehow - const files = []; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_compile.js b/testdata/baselines/reference/submodule/compiler/APISample_compile.js index 20616a8c0c..fdf4166c68 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_compile.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_compile.js @@ -48,6 +48,11 @@ compile(process.argv.slice(2), { //// [APISample_compile.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.compile = compile; const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff deleted file mode 100644 index b2e0459c6f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.APISample_compile.js -+++ new.APISample_compile.js -@@= skipped -47, +47 lines =@@ - - //// [APISample_compile.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.compile = compile; --var ts = require("typescript"); -+const ts = require("typescript"); - function compile(fileNames, options) { - var program = ts.createProgram(fileNames, options); - var emitResult = program.emit(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js index e9c98da1e3..a641c88257 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js @@ -123,8 +123,47 @@ function getSomeOtherTags(node: ts.Node) { //// [APISample_jsdoc.js] "use strict"; +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const ts = require("typescript"); +const ts = __importStar(require("typescript")); // excerpted from https://github.com/YousefED/typescript-json-schema // (converted from a method and modified; for example, `this: any` to compensate, among other changes) function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff deleted file mode 100644 index 939a10fa62..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.APISample_jsdoc.js -+++ new.APISample_jsdoc.js -@@= skipped -122, +122 lines =@@ - - //// [APISample_jsdoc.js] - "use strict"; --/* -- * Note: This test is a public API sample. The original sources can be found -- * at: https://github.com/YousefED/typescript-json-schema -- * https://github.com/vega/ts-json-schema-generator -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("typescript"); -+const ts = require("typescript"); - // excerpted from https://github.com/YousefED/typescript-json-schema - // (converted from a method and modified; for example, `this: any` to compensate, among other changes) - function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_linter.js b/testdata/baselines/reference/submodule/compiler/APISample_linter.js index 81cba71e70..b0ed0df036 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_linter.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_linter.js @@ -74,9 +74,47 @@ fileNames.forEach(fileName => { //// [APISample_linter.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.delint = delint; -const ts = require("typescript"); +const ts = __importStar(require("typescript")); function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff deleted file mode 100644 index 2f9b2b9e1f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.APISample_linter.js -+++ new.APISample_linter.js -@@= skipped -73, +73 lines =@@ - - //// [APISample_linter.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.delint = delint; --var ts = require("typescript"); -+const ts = require("typescript"); - function delint(sourceFile) { - delintNode(sourceFile); - function delintNode(node) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js index 2d4cb20590..4359a0c275 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js @@ -46,6 +46,11 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string): //// [APISample_parseConfig.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createProgram = createProgram; const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff deleted file mode 100644 index aa2225246a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.APISample_parseConfig.js -+++ new.APISample_parseConfig.js -@@= skipped -45, +45 lines =@@ - - //// [APISample_parseConfig.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.createProgram = createProgram; --var ts = require("typescript"); -+const ts = require("typescript"); - function printError(error) { - if (!error) { - return; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_transform.js b/testdata/baselines/reference/submodule/compiler/APISample_transform.js index c462a864e7..38b2ccd05a 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_transform.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_transform.js @@ -26,8 +26,46 @@ console.log(JSON.stringify(result)); //// [APISample_transform.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const ts = require("typescript"); +const ts = __importStar(require("typescript")); const source = "let x: string = 'string'"; let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); console.log(JSON.stringify(result)); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff deleted file mode 100644 index 62ddcd3067..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.APISample_transform.js -+++ new.APISample_transform.js -@@= skipped -25, +25 lines =@@ - - //// [APISample_transform.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("typescript"); -+const ts = require("typescript"); - const source = "let x: string = 'string'"; - let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); - console.log(JSON.stringify(result)); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js index 0b04a6309e..cf3cef8653 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js @@ -121,8 +121,46 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); //// [APISample_watcher.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const ts = require("typescript"); +const ts = __importStar(require("typescript")); function watch(rootFileNames, options) { const files = {}; // initialize the list of files diff --git a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff deleted file mode 100644 index 7872ebf267..0000000000 --- a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.APISample_watcher.js -+++ new.APISample_watcher.js -@@= skipped -120, +120 lines =@@ - - //// [APISample_watcher.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("typescript"); -+const ts = require("typescript"); - function watch(rootFileNames, options) { - const files = {}; - // initialize the list of files \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js.diff index 8998fe2750..043b393a91 100644 --- a/testdata/baselines/reference/submodule/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js.diff +++ b/testdata/baselines/reference/submodule/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js.diff @@ -1,15 +1,9 @@ --- old.ClassDeclarationWithInvalidConstOnPropertyDeclaration.js +++ new.ClassDeclarationWithInvalidConstOnPropertyDeclaration.js -@@= skipped -5, +5 lines =@@ - } +@@= skipped -6, +6 lines =@@ //// [ClassDeclarationWithInvalidConstOnPropertyDeclaration.js] --let AtomicNumbers = (() => { -- class AtomicNumbers { -- } -- AtomicNumbers.H = 1; -- return AtomicNumbers; --})(); -+class AtomicNumbers { + class AtomicNumbers { + static H = 1; -+} \ No newline at end of file + } +-AtomicNumbers.H = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js b/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js index 5b984c8e15..9af7284f07 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js +++ b/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js @@ -11,7 +11,6 @@ function foo() { //// [abstractIdentifierNameStrict.js] var abstract = true; function foo() { - "use strict"; "use strict"; var abstract = true; } diff --git a/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js.diff b/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js.diff deleted file mode 100644 index e00add3eff..0000000000 --- a/testdata/baselines/reference/submodule/compiler/abstractIdentifierNameStrict.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.abstractIdentifierNameStrict.js -+++ new.abstractIdentifierNameStrict.js -@@= skipped -11, +11 lines =@@ - var abstract = true; - function foo() { - "use strict"; -+ "use strict"; - var abstract = true; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js b/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js index 880775b115..078acc69b8 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js +++ b/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js @@ -25,9 +25,6 @@ class C extends B { //// [abstractPropertyBasics.js] class B { - prop; - raw; - ro; } class C extends B { get prop() { return "foo"; } diff --git a/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js.diff b/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js.diff index d87f347912..d9c3141acd 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js.diff +++ b/testdata/baselines/reference/submodule/compiler/abstractPropertyBasics.js.diff @@ -1,12 +1,7 @@ --- old.abstractPropertyBasics.js +++ new.abstractPropertyBasics.js -@@= skipped -24, +24 lines =@@ - - //// [abstractPropertyBasics.js] +@@= skipped -26, +26 lines =@@ class B { -+ prop; -+ raw; -+ ro; } class C extends B { - constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js b/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js index f9fb98e23f..eee21c3894 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js +++ b/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js @@ -111,8 +111,6 @@ class AbstractClass { // OK, references are to another instance other.cb(other.prop); } - prop; - cb; other = this.prop; fn = () => this.prop; method2() { @@ -151,8 +149,6 @@ class User { } } class C1 { - x; - y; constructor() { let self = this; // ok let { x, y: y1 } = this; // error diff --git a/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js.diff b/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js.diff index 16fbbd728c..88ce203aa3 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js.diff +++ b/testdata/baselines/reference/submodule/compiler/abstractPropertyInConstructor.js.diff @@ -13,8 +13,6 @@ // OK, references are to another instance other.cb(other.prop); } -+ prop; -+ cb; + other = this.prop; + fn = () => this.prop; method2() { @@ -29,7 +27,7 @@ // there is no implementation of 'prop' in any base class this.cb(this.prop.toLowerCase()); this.method(1); -@@= skipped -17, +21 lines =@@ +@@= skipped -17, +19 lines =@@ } } class Implementation extends DerivedAbstractClass { @@ -42,16 +40,7 @@ this.cb(this.prop); } method(n) { -@@= skipped -19, +19 lines =@@ - } - } - class C1 { -+ x; -+ y; - constructor() { - let self = this; // ok - let { x, y: y1 } = this; // error -@@= skipped -7, +9 lines =@@ +@@= skipped -26, +26 lines =@@ } } class C2 { diff --git a/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js b/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js index 7f7c99c4d6..e6256c968f 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js +++ b/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js @@ -47,17 +47,13 @@ abstract class AbstractAccessorMismatch { //// [abstractPropertyNegative.js] class B { - prop; - ro; } class C extends B { ro = "readonly please"; - notAllowed; } let c = new C(); c.ro = "error: lhs of assignment can't be readonly"; class WrongTypeProperty { - num; } class WrongTypePropertyImpl extends WrongTypeProperty { num = "nope, wrong"; diff --git a/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js.diff b/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js.diff index d8883c1c17..2bacb101ee 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js.diff +++ b/testdata/baselines/reference/submodule/compiler/abstractPropertyNegative.js.diff @@ -1,11 +1,7 @@ --- old.abstractPropertyNegative.js +++ new.abstractPropertyNegative.js -@@= skipped -46, +46 lines =@@ - - //// [abstractPropertyNegative.js] +@@= skipped -48, +48 lines =@@ class B { -+ prop; -+ ro; } class C extends B { - constructor() { @@ -14,12 +10,10 @@ - } - get concreteWithNoBody() { } + ro = "readonly please"; -+ notAllowed; } let c = new C(); c.ro = "error: lhs of assignment can't be readonly"; class WrongTypeProperty { -+ num; } class WrongTypePropertyImpl extends WrongTypeProperty { - constructor() { @@ -30,7 +24,7 @@ } class WrongTypeAccessor { } -@@= skipped -24, +21 lines =@@ +@@= skipped -22, +15 lines =@@ get num() { return "nope, wrong"; } } class WrongTypeAccessorImpl2 extends WrongTypeAccessor { diff --git a/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js b/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js index 17d93eeb21..8c0911a932 100644 --- a/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js +++ b/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js @@ -22,6 +22,7 @@ f.register(s, null); f.unregister(s); //// [acceptSymbolAsWeakType.js] +"use strict"; const s = Symbol('s'); const ws = new WeakSet([s]); ws.add(s); diff --git a/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js.diff b/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js.diff deleted file mode 100644 index 8ab51120fd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/acceptSymbolAsWeakType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.acceptSymbolAsWeakType.js -+++ new.acceptSymbolAsWeakType.js -@@= skipped -21, +21 lines =@@ - f.unregister(s); - - //// [acceptSymbolAsWeakType.js] --"use strict"; - const s = Symbol('s'); - const ws = new WeakSet([s]); - ws.add(s); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.errors.txt b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.errors.txt deleted file mode 100644 index c9351f69f7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -accessorInAmbientContextES5.ts(25,14): error TS18045: Properties with the 'accessor' modifier are only available when targeting ECMAScript 2015 and higher. - - -==== accessorInAmbientContextES5.ts (1 errors) ==== - // Should allow accessor in ambient contexts even when targeting ES5 - - declare class AmbientClass { - accessor prop1: string; - static accessor prop2: number; - private accessor prop3: boolean; - private static accessor prop4: symbol; - } - - declare namespace AmbientNamespace { - class C { - accessor prop: string; - } - } - - // Should also work in .d.ts files (simulated with declare) - declare module "some-module" { - export class ExportedClass { - accessor value: any; - } - } - - // Regular class should still error when targeting ES5 - class RegularClass { - accessor shouldError: string; // Should still error - ~~~~~~~~~~~ -!!! error TS18045: Properties with the 'accessor' modifier are only available when targeting ECMAScript 2015 and higher. - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js index 6632073318..88a35b31b6 100644 --- a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js +++ b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js @@ -29,6 +29,7 @@ class RegularClass { } //// [accessorInAmbientContextES5.js] +// Should allow accessor in ambient contexts even when targeting ES5 // Regular class should still error when targeting ES5 class RegularClass { accessor shouldError; // Should still error diff --git a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff index 5a989ff971..e1bf7b98fc 100644 --- a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff +++ b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff @@ -1,10 +1,9 @@ --- old.accessorInAmbientContextES5.js +++ new.accessorInAmbientContextES5.js -@@= skipped -28, +28 lines =@@ - } +@@= skipped -29, +29 lines =@@ //// [accessorInAmbientContextES5.js] --// Should allow accessor in ambient contexts even when targeting ES5 + // Should allow accessor in ambient contexts even when targeting ES5 -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); diff --git a/testdata/baselines/reference/submodule/compiler/aliasAssignments.js.diff b/testdata/baselines/reference/submodule/compiler/aliasAssignments.js.diff index bd54a55b29..581976bdb6 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasAssignments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasAssignments.js.diff @@ -7,11 +7,4 @@ + someData; } exports.someClass = someClass; - //// [aliasAssignments_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasAssignments_moduleA"); -+const moduleA = require("./aliasAssignments_moduleA"); - var x = moduleA; - x = 1; // Should be error - var y = 1; \ No newline at end of file + //// [aliasAssignments_1.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasDoesNotDuplicateSignatures.js.diff b/testdata/baselines/reference/submodule/compiler/aliasDoesNotDuplicateSignatures.js.diff deleted file mode 100644 index 78ff4b84b6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/aliasDoesNotDuplicateSignatures.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.aliasDoesNotDuplicateSignatures.js -+++ new.aliasDoesNotDuplicateSignatures.js -@@= skipped -16, +16 lines =@@ - //// [user.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var demoModule_1 = require("demoModule"); -+const demoModule_1 = require("demoModule"); - // Assign an incorrect type here to see the type of 'f'. - let x1 = demoNS.f; - let x2 = demoModule_1.f; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js index c0459a91af..4164d719ef 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js +++ b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js @@ -14,6 +14,7 @@ e as ErrAlias; //// [aliasInstantiationExpressionGenericIntersectionNoCrash1.js] +"use strict"; class ErrImpl { e; } diff --git a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js.diff b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js.diff index 99893034bd..b2d839a00c 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash1.js.diff @@ -1,10 +1,8 @@ --- old.aliasInstantiationExpressionGenericIntersectionNoCrash1.js +++ new.aliasInstantiationExpressionGenericIntersectionNoCrash1.js -@@= skipped -13, +13 lines =@@ - - +@@= skipped -15, +15 lines =@@ //// [aliasInstantiationExpressionGenericIntersectionNoCrash1.js] --"use strict"; + "use strict"; class ErrImpl { + e; } diff --git a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js index 4033cf49f7..0755056e2d 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js +++ b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js @@ -19,4 +19,5 @@ wat as Wat; //// [aliasInstantiationExpressionGenericIntersectionNoCrash2.js] +"use strict"; wat; diff --git a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js.diff b/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js.diff deleted file mode 100644 index 27309f73ad..0000000000 --- a/testdata/baselines/reference/submodule/compiler/aliasInstantiationExpressionGenericIntersectionNoCrash2.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.aliasInstantiationExpressionGenericIntersectionNoCrash2.js -+++ new.aliasInstantiationExpressionGenericIntersectionNoCrash2.js -@@= skipped -18, +18 lines =@@ - - - //// [aliasInstantiationExpressionGenericIntersectionNoCrash2.js] --"use strict"; - wat; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js index 3b810f99c3..b9243024a9 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js +++ b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js @@ -36,6 +36,8 @@ let check3: test3 = "y"; //// [aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js] +"use strict"; +// the type printback for every `test` below should be "y" let check = "y"; let check1 = "y"; let check2 = "y"; diff --git a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff deleted file mode 100644 index 5f3c71a237..0000000000 --- a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js -+++ new.aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js -@@= skipped -35, +35 lines =@@ - - - //// [aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js] --"use strict"; --// the type printback for every `test` below should be "y" - let check = "y"; - let check1 = "y"; - let check2 = "y"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInAccessorsOfClass.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInAccessorsOfClass.js.diff index e816863525..3081aa94b0 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInAccessorsOfClass.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInAccessorsOfClass.js.diff @@ -8,19 +8,9 @@ } exports.Model = Model; //// [aliasUsage1_moduleA.js] - "use strict"; +@@= skipped -15, +16 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsage1_backbone"); -+const Backbone = require("./aliasUsage1_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsage1_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsage1_moduleA"); -+const moduleA = require("./aliasUsage1_moduleA"); + const moduleA = require("./aliasUsage1_moduleA"); class C2 { + x; get A() { diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInArray.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInArray.js.diff index 7db6c429c0..973a486287 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInArray.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInArray.js.diff @@ -7,19 +7,4 @@ + someData; } exports.Model = Model; - //// [aliasUsageInArray_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInArray_backbone"); -+const Backbone = require("./aliasUsageInArray_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInArray_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInArray_moduleA"); -+const moduleA = require("./aliasUsageInArray_moduleA"); - var xs = [moduleA]; - var xs2 = [moduleA]; \ No newline at end of file + //// [aliasUsageInArray_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInFunctionExpression.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInFunctionExpression.js.diff index cc771acb3a..ca249740f6 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInFunctionExpression.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInFunctionExpression.js.diff @@ -7,19 +7,4 @@ + someData; } exports.Model = Model; - //// [aliasUsageInFunctionExpression_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInFunctionExpression_backbone"); -+const Backbone = require("./aliasUsageInFunctionExpression_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInFunctionExpression_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInFunctionExpression_moduleA"); -+const moduleA = require("./aliasUsageInFunctionExpression_moduleA"); - var f = (x) => x; - f = (x) => moduleA; \ No newline at end of file + //// [aliasUsageInFunctionExpression_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInGenericFunction.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInGenericFunction.js.diff index 5de3c24e3f..fe13be5cc5 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInGenericFunction.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInGenericFunction.js.diff @@ -7,20 +7,4 @@ + someData; } exports.Model = Model; - //// [aliasUsageInGenericFunction_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInGenericFunction_backbone"); -+const Backbone = require("./aliasUsageInGenericFunction_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInGenericFunction_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInGenericFunction_moduleA"); -+const moduleA = require("./aliasUsageInGenericFunction_moduleA"); - function foo(x) { - return x; - } \ No newline at end of file + //// [aliasUsageInGenericFunction_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInIndexerOfClass.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInIndexerOfClass.js.diff index 32d8707f5d..fcda875c2c 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInIndexerOfClass.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInIndexerOfClass.js.diff @@ -8,19 +8,9 @@ } exports.Model = Model; //// [aliasUsageInIndexerOfClass_moduleA.js] - "use strict"; +@@= skipped -15, +16 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInIndexerOfClass_backbone"); -+const Backbone = require("./aliasUsageInIndexerOfClass_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInIndexerOfClass_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); -+const moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); + const moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); class N { - constructor() { - this.x = moduleA; diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInObjectLiteral.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInObjectLiteral.js.diff index 906bac9bc4..1dc622e0c1 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInObjectLiteral.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInObjectLiteral.js.diff @@ -7,20 +7,4 @@ + someData; } exports.Model = Model; - //// [aliasUsageInObjectLiteral_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInObjectLiteral_backbone"); -+const Backbone = require("./aliasUsageInObjectLiteral_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInObjectLiteral_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInObjectLiteral_moduleA"); -+const moduleA = require("./aliasUsageInObjectLiteral_moduleA"); - var a = { x: moduleA }; - var b = { x: moduleA }; - var c = { y: { z: moduleA } }; \ No newline at end of file + //// [aliasUsageInObjectLiteral_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInOrExpression.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInOrExpression.js.diff index 2770714897..9ef8e17d24 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInOrExpression.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInOrExpression.js.diff @@ -7,20 +7,4 @@ + someData; } exports.Model = Model; - //// [aliasUsageInOrExpression_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInOrExpression_backbone"); -+const Backbone = require("./aliasUsageInOrExpression_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInOrExpression_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInOrExpression_moduleA"); -+const moduleA = require("./aliasUsageInOrExpression_moduleA"); - var i; - var d1 = i || moduleA; - var d2 = i || moduleA; \ No newline at end of file + //// [aliasUsageInOrExpression_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInTypeArgumentOfExtendsClause.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInTypeArgumentOfExtendsClause.js.diff index 47986a8d15..9227a0eaa8 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInTypeArgumentOfExtendsClause.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInTypeArgumentOfExtendsClause.js.diff @@ -8,19 +8,9 @@ } exports.Model = Model; //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.js] - "use strict"; +@@= skipped -15, +16 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); -+const Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [aliasUsageInTypeArgumentOfExtendsClause_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); -+const moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); + const moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); class C { + x; } diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsageInVarAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsageInVarAssignment.js.diff index f2b32cfcab..734bc153c7 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasUsageInVarAssignment.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasUsageInVarAssignment.js.diff @@ -7,12 +7,4 @@ + someData; } exports.Model = Model; - //// [aliasUsageInVarAssignment_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./aliasUsageInVarAssignment_backbone"); -+const Backbone = require("./aliasUsageInVarAssignment_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; \ No newline at end of file + //// [aliasUsageInVarAssignment_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/aliasUsedAsNameValue.js.diff b/testdata/baselines/reference/submodule/compiler/aliasUsedAsNameValue.js.diff deleted file mode 100644 index fae82e58f4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/aliasUsedAsNameValue.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.aliasUsedAsNameValue.js -+++ new.aliasUsedAsNameValue.js -@@= skipped -32, +32 lines =@@ - exports.a = void 0; - /// - /// --var mod = require("./aliasUsedAsNameValue_0"); --var b = require("./aliasUsedAsNameValue_1"); -+const mod = require("./aliasUsedAsNameValue_0"); -+const b = require("./aliasUsedAsNameValue_1"); - var a = function () { - //var x = mod.id; // TODO needed hack that mod is loaded - b.b(mod); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js b/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js index 1e09e38fb1..e86a028cd1 100644 --- a/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js +++ b/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js @@ -35,18 +35,24 @@ exports.zzz = 123; exports.default = exports.zzz; //// [a.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); exports.default = b_1.default; const x = { x: "" }; b_1.default; //// [index.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); const x = { x: "" }; a_1.default; -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); b_1.default; const y = x; diff --git a/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js.diff b/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js.diff deleted file mode 100644 index 467ca1a9f4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowImportClausesToMergeWithTypes.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.allowImportClausesToMergeWithTypes.js -+++ new.allowImportClausesToMergeWithTypes.js -@@= skipped -36, +36 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = void 0; --var b_1 = require("./b"); -+const b_1 = require("./b"); - exports.default = b_1.default; - const x = { x: "" }; - b_1.default; - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - const x = { x: "" }; - a_1.default; --var b_1 = require("./b"); -+const b_1 = require("./b"); - b_1.default; - const y = x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/allowJscheckJsTypeParameterNoCrash.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/allowJscheckJsTypeParameterNoCrash.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.js.diff b/testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.js.diff deleted file mode 100644 index 44a7593278..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.allowJscheckJsTypeParameterNoCrash.js -+++ new.allowJscheckJsTypeParameterNoCrash.js -@@= skipped -27, +27 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = void 0; --var func_1 = require("./func"); -+const func_1 = require("./func"); - // hover on vextend - exports.a = (0, func_1.vextend)({ - watch: { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/allowJscheckJsTypeParameterNoCrash.types.diff b/testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/allowJscheckJsTypeParameterNoCrash.types.diff rename to testdata/baselines/reference/submodule/compiler/allowJscheckJsTypeParameterNoCrash.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js index e5d33c74b7..eecb8bb251 100644 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js +++ b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js @@ -12,7 +12,10 @@ export class Foo { //// [a.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); exports.x = new b_1.default.Foo(); diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js.diff b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js.diff deleted file mode 100644 index a91de62581..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports1.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.allowSyntheticDefaultImports1.js -+++ new.allowSyntheticDefaultImports1.js -@@= skipped -13, +13 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var b_1 = require("./b"); -+const b_1 = require("./b"); - exports.x = new b_1.default.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports10.js.diff b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports10.js.diff deleted file mode 100644 index 85ecbe9ed6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports10.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.allowSyntheticDefaultImports10.js -+++ new.allowSyntheticDefaultImports10.js -@@= skipped -12, +12 lines =@@ - //// [a.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var Foo = require("./b"); -+const Foo = require("./b"); - Foo.default.bar(); - Foo.default.default.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js index 95657fc337..a6ec766c41 100644 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js +++ b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js @@ -13,7 +13,10 @@ export var x = new Foo(); //// [a.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); exports.x = new b_1.default(); diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js.diff b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js.diff deleted file mode 100644 index 87f7d45681..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports4.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.allowSyntheticDefaultImports4.js -+++ new.allowSyntheticDefaultImports4.js -@@= skipped -14, +14 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var b_1 = require("./b"); -+const b_1 = require("./b"); - exports.x = new b_1.default(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js index 14cdb26657..cc99033f91 100644 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js +++ b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js @@ -12,7 +12,10 @@ Foo.foo(); //// [a.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); b_1.default.bar(); b_1.default.foo(); diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js.diff b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js.diff deleted file mode 100644 index 95bd4aba2c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports9.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.allowSyntheticDefaultImports9.js -+++ new.allowSyntheticDefaultImports9.js -@@= skipped -12, +12 lines =@@ - //// [a.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var b_1 = require("./b"); -+const b_1 = require("./b"); - b_1.default.bar(); - b_1.default.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImportsCanPaintCrossModuleDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImportsCanPaintCrossModuleDeclaration.js.diff deleted file mode 100644 index 6c8338cf1e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImportsCanPaintCrossModuleDeclaration.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.allowSyntheticDefaultImportsCanPaintCrossModuleDeclaration.js -+++ new.allowSyntheticDefaultImportsCanPaintCrossModuleDeclaration.js -@@= skipped -21, +21 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.A = void 0; --var file1_1 = require("./file1"); -+const file1_1 = require("./file1"); - exports.A = (0, file1_1.styled)(); - diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrict.js b/testdata/baselines/reference/submodule/compiler/alwaysStrict.js index 900fcecea2..29755b6126 100644 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrict.js +++ b/testdata/baselines/reference/submodule/compiler/alwaysStrict.js @@ -6,6 +6,7 @@ function f() { } //// [alwaysStrict.js] +"use strict"; function f() { var arguments = []; } diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrict.js.diff b/testdata/baselines/reference/submodule/compiler/alwaysStrict.js.diff deleted file mode 100644 index bfa0b6b775..0000000000 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrict.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.alwaysStrict.js -+++ new.alwaysStrict.js -@@= skipped -5, +5 lines =@@ - } - - //// [alwaysStrict.js] --"use strict"; - function f() { - var arguments = []; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js b/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js index cca94a41d1..7afe1bc0f1 100644 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js +++ b/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js @@ -6,6 +6,7 @@ function f() { } //// [alwaysStrictES6.js] +"use strict"; function f() { var arguments = []; } diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js.diff b/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js.diff deleted file mode 100644 index d35f8ef4b9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictES6.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.alwaysStrictES6.js -+++ new.alwaysStrictES6.js -@@= skipped -5, +5 lines =@@ - } - - //// [alwaysStrictES6.js] --"use strict"; - function f() { - var arguments = []; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js b/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js index 1dd397d5f4..8d1a406d4b 100644 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js +++ b/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js @@ -8,6 +8,7 @@ module M { } //// [alwaysStrictModule.js] +"use strict"; var M; (function (M) { function f() { diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js.diff b/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js.diff deleted file mode 100644 index c4983e9e5f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.alwaysStrictModule.js -+++ new.alwaysStrictModule.js -@@= skipped -7, +7 lines =@@ - } - - //// [alwaysStrictModule.js] --"use strict"; - var M; - (function (M) { - function f() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.errors.txt b/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.errors.txt deleted file mode 100644 index eae1ba1ed9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -a.ts(3,13): error TS1100: Invalid use of 'arguments' in strict mode. -b.ts(3,13): error TS1100: Invalid use of 'arguments' in strict mode. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (1 errors) ==== - module M { - export function f() { - var arguments = []; - ~~~~~~~~~ -!!! error TS1100: Invalid use of 'arguments' in strict mode. - } - } - -==== b.ts (1 errors) ==== - module M { - export function f2() { - var arguments = []; - ~~~~~~~~~ -!!! error TS1100: Invalid use of 'arguments' in strict mode. - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.symbols b/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.symbols deleted file mode 100644 index 43ad606a40..0000000000 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.symbols +++ /dev/null @@ -1,25 +0,0 @@ -//// [tests/cases/compiler/alwaysStrictModule2.ts] //// - -=== a.ts === -module M { ->M : Symbol(M, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0)) - - export function f() { ->f : Symbol(f, Decl(a.ts, 0, 10)) - - var arguments = []; ->arguments : Symbol(arguments, Decl(a.ts, 2, 11)) - } -} - -=== b.ts === -module M { ->M : Symbol(M, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0)) - - export function f2() { ->f2 : Symbol(f2, Decl(b.ts, 0, 10)) - - var arguments = []; ->arguments : Symbol(arguments, Decl(b.ts, 2, 11)) - } -} diff --git a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.types b/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.types deleted file mode 100644 index ddf13f957e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/alwaysStrictModule2.types +++ /dev/null @@ -1,27 +0,0 @@ -//// [tests/cases/compiler/alwaysStrictModule2.ts] //// - -=== a.ts === -module M { ->M : typeof M - - export function f() { ->f : () => void - - var arguments = []; ->arguments : any[] ->[] : undefined[] - } -} - -=== b.ts === -module M { ->M : typeof M - - export function f2() { ->f2 : () => void - - var arguments = []; ->arguments : any[] ->[] : undefined[] - } -} diff --git a/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.errors.txt b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.errors.txt new file mode 100644 index 0000000000..f8f07f10a8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.errors.txt @@ -0,0 +1,19 @@ +ambientExternalModuleInAnotherExternalModule.ts(4,16): error TS2664: Invalid module name in augmentation, module 'ext' cannot be found. +ambientExternalModuleInAnotherExternalModule.ts(9,22): error TS2307: Cannot find module 'ext' or its corresponding type declarations. + + +==== ambientExternalModuleInAnotherExternalModule.ts (2 errors) ==== + class D { } + export = D; + + declare module "ext" { + ~~~~~ +!!! error TS2664: Invalid module name in augmentation, module 'ext' cannot be found. + export class C { } + } + + // Cannot resolve this ext module reference + import ext = require("ext"); + ~~~~~ +!!! error TS2307: Cannot find module 'ext' or its corresponding type declarations. + var x = ext; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.js b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.js new file mode 100644 index 0000000000..44a551ba0f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts] //// + +//// [ambientExternalModuleInAnotherExternalModule.ts] +class D { } +export = D; + +declare module "ext" { + export class C { } +} + +// Cannot resolve this ext module reference +import ext = require("ext"); +var x = ext; + +//// [ambientExternalModuleInAnotherExternalModule.js] +"use strict"; +class D { +} +// Cannot resolve this ext module reference +const ext = require("ext"); +var x = ext; +module.exports = D; diff --git a/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.symbols b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.symbols new file mode 100644 index 0000000000..e8d7e6ebd3 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.symbols @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts] //// + +=== ambientExternalModuleInAnotherExternalModule.ts === +class D { } +>D : Symbol(D, Decl(ambientExternalModuleInAnotherExternalModule.ts, 0, 0)) + +export = D; +>D : Symbol(D, Decl(ambientExternalModuleInAnotherExternalModule.ts, 0, 0)) + +declare module "ext" { +>"ext" : Symbol("ext", Decl(ambientExternalModuleInAnotherExternalModule.ts, 1, 11)) + + export class C { } +>C : Symbol(C, Decl(ambientExternalModuleInAnotherExternalModule.ts, 3, 22)) +} + +// Cannot resolve this ext module reference +import ext = require("ext"); +>ext : Symbol(ext, Decl(ambientExternalModuleInAnotherExternalModule.ts, 5, 1)) + +var x = ext; +>x : Symbol(x, Decl(ambientExternalModuleInAnotherExternalModule.ts, 9, 3)) +>ext : Symbol(ext, Decl(ambientExternalModuleInAnotherExternalModule.ts, 5, 1)) + diff --git a/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.types b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.types new file mode 100644 index 0000000000..2f25de3758 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/ambientExternalModuleInAnotherExternalModule.types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts] //// + +=== ambientExternalModuleInAnotherExternalModule.ts === +class D { } +>D : D + +export = D; +>D : D + +declare module "ext" { +>"ext" : typeof import("ext") + + export class C { } +>C : C +} + +// Cannot resolve this ext module reference +import ext = require("ext"); +>ext : any + +var x = ext; +>x : any +>ext : any + diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js index c84dcda198..e12e847485 100644 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js +++ b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js @@ -8,7 +8,7 @@ m1.f(); //// [amdDependencyComment1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const m1 = require("m2"); m1.f(); diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff deleted file mode 100644 index 848a44ccbb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.amdDependencyComment1.js -+++ new.amdDependencyComment1.js -@@= skipped -7, +7 lines =@@ - - //// [amdDependencyComment1.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); --var m1 = require("m2"); -+/// -+const m1 = require("m2"); - m1.f(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js index e57a4276fe..7538bd86ee 100644 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js +++ b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js @@ -8,7 +8,7 @@ m1.f(); //// [amdDependencyCommentName1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const m1 = require("m2"); m1.f(); diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff deleted file mode 100644 index 71ca61c44d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.amdDependencyCommentName1.js -+++ new.amdDependencyCommentName1.js -@@= skipped -7, +7 lines =@@ - - //// [amdDependencyCommentName1.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); --var m1 = require("m2"); -+/// -+const m1 = require("m2"); - m1.f(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt index 1fafa07a86..6914d14363 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt @@ -1,6 +1,4 @@ ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. -ExtendedClass.js(17,12): error TS2339: Property 'exports' does not exist on type '{}'. -ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type '{}'. ==== typing.d.ts (0 errors) ==== @@ -12,7 +10,7 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type } export = BaseClass; } -==== ExtendedClass.js (3 errors) ==== +==== ExtendedClass.js (1 errors) ==== define("lib/ExtendedClass", ["deps/BaseClass"], /** * {typeof import("deps/BaseClass")} @@ -32,9 +30,5 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type module.exports = ExtendedClass ~~~~~~ !!! error TS1231: An export assignment must be at the top level of a file or module declaration. - ~~~~~~~ -!!! error TS2339: Property 'exports' does not exist on type '{}'. return module.exports; - ~~~~~~~ -!!! error TS2339: Property 'exports' does not exist on type '{}'. }); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff similarity index 76% rename from testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff index c2a498e7f1..51c1d157e8 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff @@ -3,8 +3,6 @@ @@= skipped -0, +0 lines =@@ - +ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. -+ExtendedClass.js(17,12): error TS2339: Property 'exports' does not exist on type '{}'. -+ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type '{}'. + + +==== typing.d.ts (0 errors) ==== @@ -16,7 +14,7 @@ + } + export = BaseClass; + } -+==== ExtendedClass.js (3 errors) ==== ++==== ExtendedClass.js (1 errors) ==== + define("lib/ExtendedClass", ["deps/BaseClass"], + /** + * {typeof import("deps/BaseClass")} @@ -36,9 +34,5 @@ + module.exports = ExtendedClass + ~~~~~~ +!!! error TS1231: An export assignment must be at the top level of a file or module declaration. -+ ~~~~~~~ -+!!! error TS2339: Property 'exports' does not exist on type '{}'. + return module.exports; -+ ~~~~~~~ -+!!! error TS2339: Property 'exports' does not exist on type '{}'. + }); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.types.diff b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.types.diff rename to testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/anonClassDeclarationEmitIsAnon.js.diff b/testdata/baselines/reference/submodule/compiler/anonClassDeclarationEmitIsAnon.js.diff index 211600ef2e..2b40a28b20 100644 --- a/testdata/baselines/reference/submodule/compiler/anonClassDeclarationEmitIsAnon.js.diff +++ b/testdata/baselines/reference/submodule/compiler/anonClassDeclarationEmitIsAnon.js.diff @@ -12,11 +12,7 @@ }; } //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.TimestampedUser = exports.User = void 0; --var wrapClass_1 = require("./wrapClass"); -+const wrapClass_1 = require("./wrapClass"); +@@= skipped -14, +11 lines =@@ exports.default = (0, wrapClass_1.wrapClass)(0); // Simple class class User { diff --git a/testdata/baselines/reference/submodule/compiler/anyAndUnknownHaveFalsyComponents.js b/testdata/baselines/reference/submodule/compiler/anyAndUnknownHaveFalsyComponents.js index e793b344ad..57b2108428 100644 --- a/testdata/baselines/reference/submodule/compiler/anyAndUnknownHaveFalsyComponents.js +++ b/testdata/baselines/reference/submodule/compiler/anyAndUnknownHaveFalsyComponents.js @@ -31,26 +31,15 @@ function foo2() { //// [anyAndUnknownHaveFalsyComponents.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; const y1 = x1 && 3; function foo1() { - return __assign({ display: "block" }, (isTreeHeader1 && { + return Object.assign({ display: "block" }, (isTreeHeader1 && { display: "flex", })); } const y2 = x2 && 3; function foo2() { - return __assign({ display: "block" }, (isTreeHeader1 && { + return Object.assign({ display: "block" }, (isTreeHeader1 && { display: "flex", })); } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt index d0da78af1a..9728abd151 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt @@ -1,9 +1,8 @@ main.js(3,9): error TS2554: Expected 0 arguments, but got 3. -main.js(5,1): error TS2554: Expected 2 arguments, but got 0. -main.js(6,16): error TS2554: Expected 2 arguments, but got 3. +main.js(6,16): error TS2554: Expected 0-2 arguments, but got 3. -==== main.js (3 errors) ==== +==== main.js (2 errors) ==== function allRest() { arguments; } allRest(); allRest(1, 2, 3); @@ -11,12 +10,9 @@ main.js(6,16): error TS2554: Expected 2 arguments, but got 3. !!! error TS2554: Expected 0 arguments, but got 3. function someRest(x, y) { arguments; } someRest(); // x and y are still optional because they are in a JS file - ~~~~~~~~ -!!! error TS2554: Expected 2 arguments, but got 0. -!!! related TS6210 main.js:4:19: An argument for 'x' was not provided. someRest(1, 2, 3); ~ -!!! error TS2554: Expected 2 arguments, but got 3. +!!! error TS2554: Expected 0-2 arguments, but got 3. /** * @param {number} x - a thing diff --git a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff new file mode 100644 index 0000000000..13e92bf5ea --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.argumentsObjectCreatesRestForJs.errors.txt ++++ new.argumentsObjectCreatesRestForJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++main.js(3,9): error TS2554: Expected 0 arguments, but got 3. ++main.js(6,16): error TS2554: Expected 0-2 arguments, but got 3. ++ ++ ++==== main.js (2 errors) ==== ++ function allRest() { arguments; } ++ allRest(); ++ allRest(1, 2, 3); ++ ~~~~~~~ ++!!! error TS2554: Expected 0 arguments, but got 3. ++ function someRest(x, y) { arguments; } ++ someRest(); // x and y are still optional because they are in a JS file ++ someRest(1, 2, 3); ++ ~ ++!!! error TS2554: Expected 0-2 arguments, but got 3. ++ ++ /** ++ * @param {number} x - a thing ++ */ ++ function jsdocced(x) { arguments; } ++ jsdocced(1); ++ ++ function dontDoubleRest(x, ...y) { arguments; } ++ dontDoubleRest(1, 2, 3); ++ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode1.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode1.errors.txt index 9ff220110a..3bca806b62 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode1.errors.txt @@ -1,4 +1,4 @@ -a.js(9,7): error TS2554: Expected 1 arguments, but got 3. +a.js(9,7): error TS2554: Expected 0-1 arguments, but got 3. ==== a.js (1 errors) ==== @@ -12,5 +12,5 @@ a.js(9,7): error TS2554: Expected 1 arguments, but got 3. f2(1, 2, 3); ~~~~ -!!! error TS2554: Expected 1 arguments, but got 3. +!!! error TS2554: Expected 0-1 arguments, but got 3. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt index c887f9f9bf..6f3d779512 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt @@ -1,4 +1,4 @@ -a.js(5,6): error TS2554: Expected 1 arguments, but got 3. +a.js(5,6): error TS2554: Expected 0-1 arguments, but got 3. ==== a.js (1 errors) ==== @@ -8,5 +8,5 @@ a.js(5,6): error TS2554: Expected 1 arguments, but got 3. f(1, 2, 3); ~~~~ -!!! error TS2554: Expected 1 arguments, but got 3. +!!! error TS2554: Expected 0-1 arguments, but got 3. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt.diff new file mode 100644 index 0000000000..3a8c657d10 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.argumentsPropertyNameInJsMode2.errors.txt ++++ new.argumentsPropertyNameInJsMode2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(5,6): error TS2554: Expected 0-1 arguments, but got 3. ++ ++ ++==== a.js (1 errors) ==== ++ function f(x) { ++ arguments; ++ } ++ ++ f(1, 2, 3); ++ ~~~~ ++!!! error TS2554: Expected 0-1 arguments, but got 3. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsPropertyNameInJsMode2.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsPropertyNameInJsMode2.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsPropertyNameInJsMode2.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor6_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor6_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor6_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor6_Js.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt index fecdd50367..21fcf854a8 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt @@ -1,5 +1,5 @@ index.js(1,25): error TS7006: Parameter 'f' implicitly has an 'any' type. -index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f: any]'. +index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any]'. ==== index.js (2 errors) ==== @@ -19,6 +19,6 @@ index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable t const debuglog = function() { return format.apply(null, arguments); ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f: any]'. +!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any]'. }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInFunction1_Js.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt.diff similarity index 89% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInFunction1_Js.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt.diff index fd91514e04..2d9239a61e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInFunction1_Js.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.errors.txt.diff @@ -3,7 +3,7 @@ @@= skipped -0, +0 lines =@@ index.js(1,25): error TS7006: Parameter 'f' implicitly has an 'any' type. -index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any, ...any[]]'. -+index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f: any]'. ++index.js(13,29): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any]'. ==== index.js (2 errors) ==== @@ -12,6 +12,6 @@ return format.apply(null, arguments); ~~~~~~~~~ -!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any, ...any[]]'. -+!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f: any]'. ++!!! error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[f?: any]'. }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInFunction1_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInFunction1_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInFunction1_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod6_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod6_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod6_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod6_Js.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod7_Js.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod7_Js.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod7_Js.types.diff rename to testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod7_Js.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt b/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt index c44c91fa63..c22688b1bd 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt @@ -1,6 +1,6 @@ arrayAssignmentTest1.ts(46,5): error TS2741: Property 'IM1' is missing in type 'undefined[]' but required in type 'I1'. arrayAssignmentTest1.ts(47,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C1': IM1, C1M1 -arrayAssignmentTest1.ts(48,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': IM1, C1M1, C2M1 +arrayAssignmentTest1.ts(48,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': C2M1, IM1, C1M1 arrayAssignmentTest1.ts(49,5): error TS2741: Property 'CM3M1' is missing in type 'undefined[]' but required in type 'C3'. arrayAssignmentTest1.ts(60,1): error TS2322: Type 'C3[]' is not assignable to type 'I1[]'. Property 'IM1' is missing in type 'C3' but required in type 'I1'. @@ -11,9 +11,9 @@ arrayAssignmentTest1.ts(65,1): error TS2322: Type 'C3[]' is not assignable to ty arrayAssignmentTest1.ts(68,1): error TS2322: Type 'C1[]' is not assignable to type 'C2[]'. Property 'C2M1' is missing in type 'C1' but required in type 'C2'. arrayAssignmentTest1.ts(69,1): error TS2322: Type 'I1[]' is not assignable to type 'C2[]'. - Type 'I1' is missing the following properties from type 'C2': C1M1, C2M1 + Type 'I1' is missing the following properties from type 'C2': C2M1, C1M1 arrayAssignmentTest1.ts(70,1): error TS2322: Type 'C3[]' is not assignable to type 'C2[]'. - Type 'C3' is missing the following properties from type 'C2': IM1, C1M1, C2M1 + Type 'C3' is missing the following properties from type 'C2': C2M1, IM1, C1M1 arrayAssignmentTest1.ts(75,1): error TS2322: Type 'C2[]' is not assignable to type 'C3[]'. Property 'CM3M1' is missing in type 'C2' but required in type 'C3'. arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is not assignable to type 'C3[]'. @@ -83,7 +83,7 @@ arrayAssignmentTest1.ts(85,1): error TS2740: Type 'I1' is missing the following !!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C1': IM1, C1M1 var c2_error: C2 = []; // should be an error - is ~~~~~~~~ -!!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': IM1, C1M1, C2M1 +!!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': C2M1, IM1, C1M1 var c3_error: C3 = []; // should be an error - is ~~~~~~~~ !!! error TS2741: Property 'CM3M1' is missing in type 'undefined[]' but required in type 'C3'. @@ -125,11 +125,11 @@ arrayAssignmentTest1.ts(85,1): error TS2740: Type 'I1' is missing the following arr_c2 = arr_i1; // should be an error - subtype relationship - is ~~~~~~ !!! error TS2322: Type 'I1[]' is not assignable to type 'C2[]'. -!!! error TS2322: Type 'I1' is missing the following properties from type 'C2': C1M1, C2M1 +!!! error TS2322: Type 'I1' is missing the following properties from type 'C2': C2M1, C1M1 arr_c2 = arr_c3; // should be an error - is ~~~~~~ !!! error TS2322: Type 'C3[]' is not assignable to type 'C2[]'. -!!! error TS2322: Type 'C3' is missing the following properties from type 'C2': IM1, C1M1, C2M1 +!!! error TS2322: Type 'C3' is missing the following properties from type 'C2': C2M1, IM1, C1M1 // "clean up bug" occurs at this point // if you move these three expressions to another file, they raise an error diff --git a/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js b/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js index 18aa7cc293..db6898e405 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js +++ b/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js @@ -18,6 +18,7 @@ function foo(arr: T[], depth: number) { } //// [arrayFakeFlatNoCrashInferenceDeclarations.js] +"use strict"; function foo(arr, depth) { return flat(arr, depth); } diff --git a/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js.diff b/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js.diff index d84d117d38..c80fd1609f 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js.diff +++ b/testdata/baselines/reference/submodule/compiler/arrayFakeFlatNoCrashInferenceDeclarations.js.diff @@ -1,10 +1,6 @@ --- old.arrayFakeFlatNoCrashInferenceDeclarations.js +++ new.arrayFakeFlatNoCrashInferenceDeclarations.js -@@= skipped -17, +17 lines =@@ - } - - //// [arrayFakeFlatNoCrashInferenceDeclarations.js] --"use strict"; +@@= skipped -21, +21 lines =@@ function foo(arr, depth) { return flat(arr, depth); } diff --git a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js b/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js index 83acd1af97..2836b5b6c8 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js +++ b/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js @@ -6,6 +6,7 @@ function foo(arr: T[], depth: number) { } //// [arrayFlatNoCrashInference.js] +"use strict"; function foo(arr, depth) { return arr.flat(depth); } diff --git a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js.diff b/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js.diff deleted file mode 100644 index 6f424abae4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.arrayFlatNoCrashInference.js -+++ new.arrayFlatNoCrashInference.js -@@= skipped -5, +5 lines =@@ - } - - //// [arrayFlatNoCrashInference.js] --"use strict"; - function foo(arr, depth) { - return arr.flat(depth); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js b/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js index 01f1a34afc..b5aaeaed99 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js +++ b/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js @@ -6,6 +6,7 @@ function foo(arr: T[], depth: number) { } //// [arrayFlatNoCrashInferenceDeclarations.js] +"use strict"; function foo(arr, depth) { return arr.flat(depth); } diff --git a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js.diff b/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js.diff deleted file mode 100644 index 89e78ce769..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrayFlatNoCrashInferenceDeclarations.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.arrayFlatNoCrashInferenceDeclarations.js -+++ new.arrayFlatNoCrashInferenceDeclarations.js -@@= skipped -5, +5 lines =@@ - } - - //// [arrayFlatNoCrashInferenceDeclarations.js] --"use strict"; - function foo(arr, depth) { - return arr.flat(depth); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrayFrom.js b/testdata/baselines/reference/submodule/compiler/arrayFrom.js index fc8159f804..477082fedc 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayFrom.js +++ b/testdata/baselines/reference/submodule/compiler/arrayFrom.js @@ -39,6 +39,8 @@ function getEither (in1: Iterable, in2: ArrayLike) { //// [arrayFrom.js] +// Tests fix for #20432, ensures Array.from accepts all valid inputs +// Also tests for #19682 const inputA = []; const inputB = []; const inputALike = { length: 0 }; diff --git a/testdata/baselines/reference/submodule/compiler/arrayFrom.js.diff b/testdata/baselines/reference/submodule/compiler/arrayFrom.js.diff deleted file mode 100644 index 9386f60d71..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrayFrom.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.arrayFrom.js -+++ new.arrayFrom.js -@@= skipped -38, +38 lines =@@ - - - //// [arrayFrom.js] --// Tests fix for #20432, ensures Array.from accepts all valid inputs --// Also tests for #19682 - const inputA = []; - const inputB = []; - const inputALike = { length: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js b/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js index abd758c14e..11f0c6c93f 100644 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js +++ b/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js @@ -33,14 +33,80 @@ Debug.assert(true); Object.defineProperty(exports, "__esModule", { value: true }); //// [ts.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Debug = void 0; -const Debug = require("../debug"); +const Debug = __importStar(require("../debug")); exports.Debug = Debug; //// [foo.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const ts = require("./_namespaces/ts"); +const ts = __importStar(require("./_namespaces/ts")); const ts_1 = require("./_namespaces/ts"); ts.Debug.assert(true); ts_1.Debug.assert(true); @@ -64,8 +130,41 @@ Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("../../core/_namespaces/ts"), exports); //// [bar.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const ts = require("./_namespaces/ts"); +const ts = __importStar(require("./_namespaces/ts")); const ts_1 = require("./_namespaces/ts"); ts.Debug.assert(true); ts_1.Debug.assert(true); diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js.diff b/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js.diff deleted file mode 100644 index 7f6eaed5b7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport1.js.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.assertionFunctionWildcardImport1.js -+++ new.assertionFunctionWildcardImport1.js -@@= skipped -34, +34 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Debug = void 0; --var Debug = require("../debug"); -+const Debug = require("../debug"); - exports.Debug = Debug; - //// [foo.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("./_namespaces/ts"); --var ts_1 = require("./_namespaces/ts"); -+const ts = require("./_namespaces/ts"); -+const ts_1 = require("./_namespaces/ts"); - ts.Debug.assert(true); - ts_1.Debug.assert(true); - //// [ts.js] -@@= skipped -30, +30 lines =@@ - //// [bar.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var ts = require("./_namespaces/ts"); --var ts_1 = require("./_namespaces/ts"); -+const ts = require("./_namespaces/ts"); -+const ts_1 = require("./_namespaces/ts"); - ts.Debug.assert(true); - ts_1.Debug.assert(true); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js b/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js index 17ad223160..25edf1e2fe 100644 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js +++ b/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js @@ -31,8 +31,41 @@ function isNonNullable(obj) { } //// [test.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const asserts = require("./asserts"); +const asserts = __importStar(require("./asserts")); function test(obj) { asserts.isNonNullable(obj); obj.trim(); diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js.diff b/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js.diff deleted file mode 100644 index dde0e4fc73..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionWildcardImport2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.assertionFunctionWildcardImport2.js -+++ new.assertionFunctionWildcardImport2.js -@@= skipped -31, +31 lines =@@ - //// [test.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var asserts = require("./asserts"); -+const asserts = require("./asserts"); - function test(obj) { - asserts.isNonNullable(obj); - obj.trim(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js index 2812044f16..4979a83b35 100644 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js +++ b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js @@ -27,6 +27,7 @@ animalOrUndef.canMeow; // since is cat, should not be an error //// [assertionFunctionsCanNarrowByDiscriminant.js] +"use strict"; const animal = { type: 'cat', canMeow: true }; assertEqual(animal.type, 'cat'); animal.canMeow; // since is cat, should not be an error diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff deleted file mode 100644 index bed1d3aed5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assertionFunctionsCanNarrowByDiscriminant.js -+++ new.assertionFunctionsCanNarrowByDiscriminant.js -@@= skipped -26, +26 lines =@@ - - - //// [assertionFunctionsCanNarrowByDiscriminant.js] --"use strict"; - const animal = { type: 'cat', canMeow: true }; - assertEqual(animal.type, 'cat'); - animal.canMeow; // since is cat, should not be an error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js index 46abecf4fc..96bae1d84f 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js @@ -33,6 +33,7 @@ fn(a => { }); //// [assignmentCompatability_checking-apply-member-off-of-function-interface.js] +// 3.8.4 Assignment Compatibility var x; // Should fail x = ''; diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js.diff deleted file mode 100644 index 1f469916de..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assignmentCompatability_checking-apply-member-off-of-function-interface.js -+++ new.assignmentCompatability_checking-apply-member-off-of-function-interface.js -@@= skipped -32, +32 lines =@@ - - - //// [assignmentCompatability_checking-apply-member-off-of-function-interface.js] --// 3.8.4 Assignment Compatibility - var x; - // Should fail - x = ''; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js index 42551f45cb..f4d2de50fc 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js @@ -33,6 +33,7 @@ fn(a => { }); //// [assignmentCompatability_checking-call-member-off-of-function-interface.js] +// 3.8.4 Assignment Compatibility var x; // Should fail x = ''; diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js.diff deleted file mode 100644 index d61f6de7b5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assignmentCompatability_checking-call-member-off-of-function-interface.js -+++ new.assignmentCompatability_checking-call-member-off-of-function-interface.js -@@= skipped -32, +32 lines =@@ - - - //// [assignmentCompatability_checking-call-member-off-of-function-interface.js] --// 3.8.4 Assignment Compatibility - var x; - // Should fail - x = ''; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js b/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js index d944f22f09..18c161118e 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js @@ -14,6 +14,7 @@ getValue2 = () => 1234; //// [assignmentToInstantiationExpression.js] +"use strict"; let obj = {}; obj.fn = () => 1234; let getValue; diff --git a/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js.diff index e110519ee1..b9235ee022 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js.diff +++ b/testdata/baselines/reference/submodule/compiler/assignmentToInstantiationExpression.js.diff @@ -1,10 +1,8 @@ --- old.assignmentToInstantiationExpression.js +++ new.assignmentToInstantiationExpression.js -@@= skipped -13, +13 lines =@@ - - +@@= skipped -15, +15 lines =@@ //// [assignmentToInstantiationExpression.js] --"use strict"; + "use strict"; let obj = {}; -(obj.fn) = () => 1234; +obj.fn = () => 1234; diff --git a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js b/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js index ac1a06dee4..c652c79aa7 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js @@ -26,6 +26,7 @@ function g(x) { } //// [assignmentToReferenceTypes.js] +// Should all be allowed M = null; class C { } diff --git a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js.diff deleted file mode 100644 index 569d50de4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assignmentToReferenceTypes.js -+++ new.assignmentToReferenceTypes.js -@@= skipped -25, +25 lines =@@ - } - - //// [assignmentToReferenceTypes.js] --// Should all be allowed - M = null; - class C { - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/asyncArrowInClassES5.js.diff b/testdata/baselines/reference/submodule/compiler/asyncArrowInClassES5.js.diff index 27a288a967..27259ce322 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncArrowInClassES5.js.diff +++ b/testdata/baselines/reference/submodule/compiler/asyncArrowInClassES5.js.diff @@ -4,14 +4,9 @@ //// [asyncArrowInClassES5.js] // https://github.com/Microsoft/TypeScript/issues/16924 // Should capture `this` --let Test = (() => { -- var _a; -- class Test { -- } -- _a = Test; -- Test.member = (x) => __awaiter(_a, void 0, void 0, function* () { }); -- return Test; --})(); -+class Test { +-var _a; + class Test { + static member = async (x) => { }; -+} \ No newline at end of file + } +-_a = Test; +-Test.member = (x) => __awaiter(_a, void 0, void 0, function* () { }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js b/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js index 724662231c..e687c0f612 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js +++ b/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js @@ -35,6 +35,7 @@ const increment2: ( //// [asyncFunctionContextuallyTypedReturns.js] +"use strict"; f(v => v ? [0] : Promise.reject()); f(async v => v ? [0] : Promise.reject()); g(v => v ? "contextuallyTypable" : Promise.reject()); diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js.diff b/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js.diff index 46d0ddd374..de95f84107 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js.diff +++ b/testdata/baselines/reference/submodule/compiler/asyncFunctionContextuallyTypedReturns.js.diff @@ -1,10 +1,9 @@ --- old.asyncFunctionContextuallyTypedReturns.js +++ new.asyncFunctionContextuallyTypedReturns.js -@@= skipped -34, +34 lines =@@ - +@@= skipped -35, +35 lines =@@ //// [asyncFunctionContextuallyTypedReturns.js] --"use strict"; + "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionReturnExpressionErrorSpans.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/asyncFunctionReturnExpressionErrorSpans.errors.txt.diff deleted file mode 100644 index 72beb7473c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionReturnExpressionErrorSpans.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.asyncFunctionReturnExpressionErrorSpans.errors.txt -+++ new.asyncFunctionReturnExpressionErrorSpans.errors.txt -@@= skipped -0, +0 lines =@@ --asyncFunctionReturnExpressionErrorSpans.ts(11,28): error TS2705: An async function or method in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. - asyncFunctionReturnExpressionErrorSpans.ts(16,21): error TS2322: Type 'number' is not assignable to type 'string'. - - --==== asyncFunctionReturnExpressionErrorSpans.ts (2 errors) ==== -+==== asyncFunctionReturnExpressionErrorSpans.ts (1 errors) ==== - interface Foo { - bar: { - baz: { -@@= skipped -13, +12 lines =@@ - } - - async function asyncFoo(): Promise { -- ~~~~~~~~~~~~ --!!! error TS2705: An async function or method in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. - return { - bar: { - baz: { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js index 2668ace0b0..45c06fe734 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js +++ b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js @@ -6,6 +6,7 @@ async ({ foo, bar, ...rest }) => bar(await foo); //// [asyncFunctionTempVariableScoping.js] +// https://github.com/Microsoft/TypeScript/issues/19187 var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) @@ -17,7 +18,6 @@ var __rest = (this && this.__rest) || function (s, e) { } return t; }; -// https://github.com/Microsoft/TypeScript/issues/19187 async (_a) => { var { foo, bar } = _a, rest = __rest(_a, ["foo", "bar"]); return bar(await foo); diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff index c50a92ee97..8e68b6a276 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff +++ b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff @@ -1,10 +1,9 @@ --- old.asyncFunctionTempVariableScoping.js +++ new.asyncFunctionTempVariableScoping.js -@@= skipped -5, +5 lines =@@ - async ({ foo, bar, ...rest }) => bar(await foo); +@@= skipped -6, +6 lines =@@ //// [asyncFunctionTempVariableScoping.js] --// https://github.com/Microsoft/TypeScript/issues/19187 + // https://github.com/Microsoft/TypeScript/issues/19187 -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { @@ -17,12 +16,11 @@ var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) -@@= skipped -21, +11 lines =@@ +@@= skipped -20, +11 lines =@@ } return t; }; -(_a) => __awaiter(this, void 0, void 0, function* () { -+// https://github.com/Microsoft/TypeScript/issues/19187 +async (_a) => { var { foo, bar } = _a, rest = __rest(_a, ["foo", "bar"]); - return bar(yield foo); diff --git a/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js b/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js index 31ea3415b2..5ed024a4a5 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js +++ b/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js @@ -6,6 +6,39 @@ async function* foo() { } //// [asyncImportNestedYield.js] +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); async function* foo() { - Promise.resolve(`${(await Promise.resolve(`${yield "foo"}`).then(s => require(s))).default}`).then(s => require(s)); + Promise.resolve(`${(await Promise.resolve(`${yield "foo"}`).then(s => __importStar(require(s)))).default}`).then(s => __importStar(require(s))); } diff --git a/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js.diff b/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js.diff index 4e0ed2c606..499a337e4f 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js.diff +++ b/testdata/baselines/reference/submodule/compiler/asyncImportNestedYield.js.diff @@ -1,9 +1,9 @@ --- old.asyncImportNestedYield.js +++ new.asyncImportNestedYield.js -@@= skipped -5, +5 lines =@@ - } - - //// [asyncImportNestedYield.js] +@@= skipped -38, +38 lines =@@ + return result; + }; + })(); -var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } -var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -19,8 +19,8 @@ -}; -function foo() { - return __asyncGenerator(this, arguments, function* foo_1() { -- Promise.resolve("".concat((yield __await(Promise.resolve("".concat(yield yield __await("foo"))).then(function (s) { return require(s); }))).default)).then(function (s) { return require(s); }); +- Promise.resolve(`${(yield __await(Promise.resolve(`${yield yield __await("foo")}`).then(s => __importStar(require(s))))).default}`).then(s => __importStar(require(s))); - }); +async function* foo() { -+ Promise.resolve(`${(await Promise.resolve(`${yield "foo"}`).then(s => require(s))).default}`).then(s => require(s)); ++ Promise.resolve(`${(await Promise.resolve(`${yield "foo"}`).then(s => __importStar(require(s)))).default}`).then(s => __importStar(require(s))); } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.errors.txt b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.errors.txt new file mode 100644 index 0000000000..390b069468 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.errors.txt @@ -0,0 +1,25 @@ +file2.ts(5,16): error TS2671: Cannot augment module './file1' because it resolves to a non-module entity. +file3.ts(3,8): error TS2503: Cannot find namespace 'x'. + + +==== file3.ts (1 errors) ==== + import x = require("./file1"); + import "./file2"; + let a: x.A; // should not work + ~ +!!! error TS2503: Cannot find namespace 'x'. +==== file1.ts (0 errors) ==== + var x = 1; + export = x; + +==== file2.ts (1 errors) ==== + import x = require("./file1"); + + // augmentation for './file1' + // should error since './file1' does not have namespace meaning + declare module "./file1" { + ~~~~~~~~~ +!!! error TS2671: Cannot augment module './file1' because it resolves to a non-module entity. + interface A { a } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.js b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.js new file mode 100644 index 0000000000..f5d241153b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/augmentExportEquals1.ts] //// + +//// [file1.ts] +var x = 1; +export = x; + +//// [file2.ts] +import x = require("./file1"); + +// augmentation for './file1' +// should error since './file1' does not have namespace meaning +declare module "./file1" { + interface A { a } +} + +//// [file3.ts] +import x = require("./file1"); +import "./file2"; +let a: x.A; // should not work + +//// [file1.js] +"use strict"; +var x = 1; +module.exports = x; +//// [file2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [file3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./file2"); +let a; // should not work diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.symbols b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.symbols new file mode 100644 index 0000000000..2a49028ee9 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/augmentExportEquals1.ts] //// + +=== file3.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file3.ts, 0, 0)) + +import "./file2"; +let a: x.A; // should not work +>a : Symbol(a, Decl(file3.ts, 2, 3)) +>x : Symbol(x) +>A : Symbol(x.A) + +=== file1.ts === +var x = 1; +>x : Symbol(x, Decl(file1.ts, 0, 3)) + +export = x; +>x : Symbol(x, Decl(file1.ts, 0, 3)) + +=== file2.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +// augmentation for './file1' +// should error since './file1' does not have namespace meaning +declare module "./file1" { +>"./file1" : Symbol("./file1", Decl(file2.ts, 0, 30)) + + interface A { a } +>A : Symbol(A, Decl(file2.ts, 4, 26)) +>a : Symbol(A.a, Decl(file2.ts, 5, 17)) +} + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.types new file mode 100644 index 0000000000..46bd32b257 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals1.types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/augmentExportEquals1.ts] //// + +=== file3.ts === +import x = require("./file1"); +>x : number + +import "./file2"; +let a: x.A; // should not work +>a : x.A +>x : any + +=== file1.ts === +var x = 1; +>x : number +>1 : 1 + +export = x; +>x : number + +=== file2.ts === +import x = require("./file1"); +>x : number + +// augmentation for './file1' +// should error since './file1' does not have namespace meaning +declare module "./file1" { +>"./file1" : any + + interface A { a } +>a : any +} + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.errors.txt.diff new file mode 100644 index 0000000000..6344d4199e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.augmentExportEquals2.errors.txt ++++ new.augmentExportEquals2.errors.txt +@@= skipped -0, +0 lines =@@ +-file2.ts(4,16): error TS2671: Cannot augment module './file1' because it resolves to a non-module entity. +-file3.ts(3,8): error TS2503: Cannot find namespace 'x'. +- +- +-==== file3.ts (1 errors) ==== +- import x = require("./file1"); +- import "./file2"; +- let a: x.A; // should not work +- ~ +-!!! error TS2503: Cannot find namespace 'x'. +-==== file1.ts (0 errors) ==== +- function foo() {} +- export = foo; +- +-==== file2.ts (1 errors) ==== +- import x = require("./file1"); +- +- // should error since './file1' does not have namespace meaning +- declare module "./file1" { +- ~~~~~~~~~ +-!!! error TS2671: Cannot augment module './file1' because it resolves to a non-module entity. +- interface A { a } +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.js b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.js new file mode 100644 index 0000000000..bd4ceebc7b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/augmentExportEquals2.ts] //// + +//// [file1.ts] +function foo() {} +export = foo; + +//// [file2.ts] +import x = require("./file1"); + +// should error since './file1' does not have namespace meaning +declare module "./file1" { + interface A { a } +} + +//// [file3.ts] + +//// [file3.ts] +import x = require("./file1"); +import "./file2"; +let a: x.A; // should not work + +//// [file3.js] diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.js.diff b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.js.diff new file mode 100644 index 0000000000..163783e142 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.js.diff @@ -0,0 +1,24 @@ +--- old.augmentExportEquals2.js ++++ new.augmentExportEquals2.js +@@= skipped -12, +12 lines =@@ + } + + //// [file3.ts] ++ ++//// [file3.ts] + import x = require("./file1"); + import "./file2"; + let a: x.A; // should not work + +-//// [file1.js] +-"use strict"; +-function foo() { } +-module.exports = foo; +-//// [file2.js] +-"use strict"; +-Object.defineProperty(exports, "__esModule", { value: true }); + //// [file3.js] +-"use strict"; +-Object.defineProperty(exports, "__esModule", { value: true }); +-require("./file2"); +-let a; // should not work \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.symbols b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.symbols new file mode 100644 index 0000000000..1f758cf8e6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.symbols @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/augmentExportEquals2.ts] //// + +=== file3.ts === + +import x = require("./file1"); +import "./file2"; +let a: x.A; // should not work +=== file3.ts === + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.symbols.diff b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.symbols.diff new file mode 100644 index 0000000000..9794f4388d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.symbols.diff @@ -0,0 +1,36 @@ +--- old.augmentExportEquals2.symbols ++++ new.augmentExportEquals2.symbols +@@= skipped -0, +0 lines =@@ + //// [tests/cases/compiler/augmentExportEquals2.ts] //// + + === file3.ts === ++ + import x = require("./file1"); +->x : Symbol(x, Decl(file3.ts, 0, 0)) +- + import "./file2"; + let a: x.A; // should not work +->a : Symbol(a, Decl(file3.ts, 2, 3)) +->x : Symbol(x) +->A : Symbol(x.A) +- +-=== file1.ts === +-function foo() {} +->foo : Symbol(foo, Decl(file1.ts, 0, 0)) +- +-export = foo; +->foo : Symbol(foo, Decl(file1.ts, 0, 0)) +- +-=== file2.ts === +-import x = require("./file1"); +->x : Symbol(x, Decl(file2.ts, 0, 0)) +- +-// should error since './file1' does not have namespace meaning +-declare module "./file1" { +->"./file1" : Symbol("./file1", Decl(file2.ts, 0, 30)) +- +- interface A { a } +->A : Symbol(A, Decl(file2.ts, 3, 26)) +->a : Symbol(A.a, Decl(file2.ts, 4, 17)) +-} ++=== file3.ts === diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.types new file mode 100644 index 0000000000..1f758cf8e6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.types @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/augmentExportEquals2.ts] //// + +=== file3.ts === + +import x = require("./file1"); +import "./file2"; +let a: x.A; // should not work +=== file3.ts === + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.types.diff b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.types.diff new file mode 100644 index 0000000000..da4189e2e6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals2.types.diff @@ -0,0 +1,34 @@ +--- old.augmentExportEquals2.types ++++ new.augmentExportEquals2.types +@@= skipped -0, +0 lines =@@ + //// [tests/cases/compiler/augmentExportEquals2.ts] //// + + === file3.ts === ++ + import x = require("./file1"); +->x : () => void +- + import "./file2"; + let a: x.A; // should not work +->a : x.A +->x : any +- +-=== file1.ts === +-function foo() {} +->foo : () => void +- +-export = foo; +->foo : () => void +- +-=== file2.ts === +-import x = require("./file1"); +->x : () => void +- +-// should error since './file1' does not have namespace meaning +-declare module "./file1" { +->"./file1" : any +- +- interface A { a } +->a : any +-} ++=== file3.ts === diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.js b/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.js new file mode 100644 index 0000000000..8fb564804f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.js @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/augmentExportEquals3.ts] //// + +//// [file1.ts] +function foo() {} +namespace foo { + export var v = 1; +} +export = foo; + +//// [file2.ts] +import x = require("./file1"); +x.b = 1; + +// OK - './file1' is a namespace +declare module "./file1" { + interface A { a } + let b: number; +} + +//// [file3.ts] +import * as x from "./file1"; +import "./file2"; +let a: x.A; +let b = x.b; + +//// [file1.js] +"use strict"; +function foo() { } +(function (foo) { + foo.v = 1; +})(foo || (foo = {})); +module.exports = foo; +//// [file2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const x = require("./file1"); +x.b = 1; +//// [file3.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +const x = __importStar(require("./file1")); +require("./file2"); +let a; +let b = x.b; diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.symbols b/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.symbols new file mode 100644 index 0000000000..765e4342e4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.symbols @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/augmentExportEquals3.ts] //// + +=== file1.ts === +function foo() {} +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 17), Decl(file2.ts, 1, 8)) + +namespace foo { +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 17), Decl(file2.ts, 1, 8)) + + export var v = 1; +>v : Symbol(v, Decl(file1.ts, 2, 14)) +} +export = foo; +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 17), Decl(file2.ts, 1, 8)) + +=== file2.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +x.b = 1; +>x.b : Symbol(x.b, Decl(file2.ts, 6, 7)) +>x : Symbol(x, Decl(file2.ts, 0, 0)) +>b : Symbol(x.b, Decl(file2.ts, 6, 7)) + +// OK - './file1' is a namespace +declare module "./file1" { +>"./file1" : Symbol(x, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 17), Decl(file2.ts, 1, 8)) + + interface A { a } +>A : Symbol(A, Decl(file2.ts, 4, 26)) +>a : Symbol(A.a, Decl(file2.ts, 5, 17)) + + let b: number; +>b : Symbol(b, Decl(file2.ts, 6, 7)) +} + +=== file3.ts === +import * as x from "./file1"; +>x : Symbol(x, Decl(file3.ts, 0, 6)) + +import "./file2"; +let a: x.A; +>a : Symbol(a, Decl(file3.ts, 2, 3)) +>x : Symbol(x, Decl(file3.ts, 0, 6)) +>A : Symbol(x.A, Decl(file2.ts, 4, 26)) + +let b = x.b; +>b : Symbol(b, Decl(file3.ts, 3, 3)) +>x.b : Symbol(x.b, Decl(file2.ts, 6, 7)) +>x : Symbol(x, Decl(file3.ts, 0, 6)) +>b : Symbol(x.b, Decl(file2.ts, 6, 7)) + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.types new file mode 100644 index 0000000000..d5274780fb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals3.types @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/augmentExportEquals3.ts] //// + +=== file1.ts === +function foo() {} +>foo : typeof import("file1.ts") + +namespace foo { +>foo : typeof import("file1.ts") + + export var v = 1; +>v : number +>1 : 1 +} +export = foo; +>foo : typeof import("file1.ts") + +=== file2.ts === +import x = require("./file1"); +>x : typeof x + +x.b = 1; +>x.b = 1 : 1 +>x.b : number +>x : typeof x +>b : number +>1 : 1 + +// OK - './file1' is a namespace +declare module "./file1" { +>"./file1" : typeof x + + interface A { a } +>a : any + + let b: number; +>b : number +} + +=== file3.ts === +import * as x from "./file1"; +>x : typeof x + +import "./file2"; +let a: x.A; +>a : x.A +>x : any + +let b = x.b; +>b : number +>x.b : number +>x : typeof x +>b : number + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.js b/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.js new file mode 100644 index 0000000000..411afefd7a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.js @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/augmentExportEquals4.ts] //// + +//// [file1.ts] +class foo {} +namespace foo { + export var v = 1; +} +export = foo; + +//// [file2.ts] +import x = require("./file1"); +x.b = 1; + +// OK - './file1' is a namespace +declare module "./file1" { + interface A { a } + let b: number; +} + +//// [file3.ts] +import * as x from "./file1"; +import "./file2"; +let a: x.A; +let b = x.b; + +//// [file1.js] +"use strict"; +class foo { +} +(function (foo) { + foo.v = 1; +})(foo || (foo = {})); +module.exports = foo; +//// [file2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const x = require("./file1"); +x.b = 1; +//// [file3.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +const x = __importStar(require("./file1")); +require("./file2"); +let a; +let b = x.b; diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.symbols b/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.symbols new file mode 100644 index 0000000000..1c03321f69 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.symbols @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/augmentExportEquals4.ts] //// + +=== file1.ts === +class foo {} +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 8)) + +namespace foo { +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 8)) + + export var v = 1; +>v : Symbol(v, Decl(file1.ts, 2, 14)) +} +export = foo; +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 8)) + +=== file2.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +x.b = 1; +>x.b : Symbol(x.b, Decl(file2.ts, 6, 7)) +>x : Symbol(x, Decl(file2.ts, 0, 0)) +>b : Symbol(x.b, Decl(file2.ts, 6, 7)) + +// OK - './file1' is a namespace +declare module "./file1" { +>"./file1" : Symbol(x, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 8)) + + interface A { a } +>A : Symbol(A, Decl(file2.ts, 4, 26)) +>a : Symbol(A.a, Decl(file2.ts, 5, 17)) + + let b: number; +>b : Symbol(b, Decl(file2.ts, 6, 7)) +} + +=== file3.ts === +import * as x from "./file1"; +>x : Symbol(x, Decl(file3.ts, 0, 6)) + +import "./file2"; +let a: x.A; +>a : Symbol(a, Decl(file3.ts, 2, 3)) +>x : Symbol(x, Decl(file3.ts, 0, 6)) +>A : Symbol(x.A, Decl(file2.ts, 4, 26)) + +let b = x.b; +>b : Symbol(b, Decl(file3.ts, 3, 3)) +>x.b : Symbol(x.b, Decl(file2.ts, 6, 7)) +>x : Symbol(x, Decl(file3.ts, 0, 6)) +>b : Symbol(x.b, Decl(file2.ts, 6, 7)) + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.types new file mode 100644 index 0000000000..d0ff6e614d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals4.types @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/augmentExportEquals4.ts] //// + +=== file1.ts === +class foo {} +>foo : import("file1.ts") + +namespace foo { +>foo : typeof import("file1.ts") + + export var v = 1; +>v : number +>1 : 1 +} +export = foo; +>foo : import("file1.ts") + +=== file2.ts === +import x = require("./file1"); +>x : typeof x + +x.b = 1; +>x.b = 1 : 1 +>x.b : number +>x : typeof x +>b : number +>1 : 1 + +// OK - './file1' is a namespace +declare module "./file1" { +>"./file1" : typeof x + + interface A { a } +>a : any + + let b: number; +>b : number +} + +=== file3.ts === +import * as x from "./file1"; +>x : typeof x + +import "./file2"; +let a: x.A; +>a : x.A +>x : any + +let b = x.b; +>b : number +>x.b : number +>x : typeof x +>b : number + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.js b/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.js new file mode 100644 index 0000000000..c316fdb891 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.js @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/augmentExportEquals5.ts] //// + +//// [express.d.ts] +declare module Express { + export interface Request { } + export interface Response { } + export interface Application { } +} + +declare module "express" { + function e(): e.Express; + namespace e { + interface IRoute { + all(...handler: RequestHandler[]): IRoute; + } + + interface IRouterMatcher { + (name: string|RegExp, ...handlers: RequestHandler[]): T; + } + + interface IRouter extends RequestHandler { + route(path: string): IRoute; + } + + export function Router(options?: any): Router; + + export interface Router extends IRouter {} + + interface Errback { (err: Error): void; } + + interface Request extends Express.Request { + + get (name: string): string; + } + + interface Response extends Express.Response { + charset: string; + } + + interface ErrorRequestHandler { + (err: any, req: Request, res: Response, next: Function): any; + } + + interface RequestHandler { + (req: Request, res: Response, next: Function): any; + } + + interface Handler extends RequestHandler {} + + interface RequestParamHandler { + (req: Request, res: Response, next: Function, param: any): any; + } + + interface Application extends IRouter, Express.Application { + routes: any; + } + + interface Express extends Application { + createApplication(): Application; + } + + var static: any; + } + + export = e; +} + +//// [augmentation.ts] +/// +import * as e from "express"; +declare module "express" { + interface Request { + id: number; + } +} + +//// [consumer.ts] +import { Request } from "express"; +import "./augmentation"; +let x: Request; +const y = x.id; + +//// [augmentation.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [consumer.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./augmentation"); +let x; +const y = x.id; diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.symbols b/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.symbols new file mode 100644 index 0000000000..b2bcb83b6f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.symbols @@ -0,0 +1,198 @@ +//// [tests/cases/compiler/augmentExportEquals5.ts] //// + +=== express.d.ts === +declare module Express { +>Express : Symbol(Express, Decl(express.d.ts, 0, 0)) + + export interface Request { } +>Request : Symbol(Request, Decl(express.d.ts, 0, 24)) + + export interface Response { } +>Response : Symbol(Response, Decl(express.d.ts, 1, 32)) + + export interface Application { } +>Application : Symbol(Application, Decl(express.d.ts, 2, 33)) +} + +declare module "express" { +>"express" : Symbol("express", Decl(express.d.ts, 4, 1)) + + function e(): e.Express; +>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) +>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) +>Express : Symbol(e.Express, Decl(express.d.ts, 52, 9)) + + namespace e { +>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) + + interface IRoute { +>IRoute : Symbol(IRoute, Decl(express.d.ts, 8, 17)) + + all(...handler: RequestHandler[]): IRoute; +>all : Symbol(IRoute.all, Decl(express.d.ts, 9, 26)) +>handler : Symbol(handler, Decl(express.d.ts, 10, 16)) +>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 38, 9)) +>IRoute : Symbol(IRoute, Decl(express.d.ts, 8, 17)) + } + + interface IRouterMatcher { +>IRouterMatcher : Symbol(IRouterMatcher, Decl(express.d.ts, 11, 9)) +>T : Symbol(T, Decl(express.d.ts, 13, 33)) + + (name: string|RegExp, ...handlers: RequestHandler[]): T; +>name : Symbol(name, Decl(express.d.ts, 14, 13)) +>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>handlers : Symbol(handlers, Decl(express.d.ts, 14, 33)) +>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 38, 9)) +>T : Symbol(T, Decl(express.d.ts, 13, 33)) + } + + interface IRouter extends RequestHandler { +>IRouter : Symbol(IRouter, Decl(express.d.ts, 15, 9)) +>T : Symbol(T, Decl(express.d.ts, 17, 26)) +>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 38, 9)) + + route(path: string): IRoute; +>route : Symbol(IRouter.route, Decl(express.d.ts, 17, 53)) +>path : Symbol(path, Decl(express.d.ts, 18, 18)) +>IRoute : Symbol(IRoute, Decl(express.d.ts, 8, 17)) + } + + export function Router(options?: any): Router; +>Router : Symbol(Router, Decl(express.d.ts, 19, 9), Decl(express.d.ts, 21, 54)) +>options : Symbol(options, Decl(express.d.ts, 21, 31)) +>Router : Symbol(Router, Decl(express.d.ts, 19, 9), Decl(express.d.ts, 21, 54)) + + export interface Router extends IRouter {} +>Router : Symbol(Router, Decl(express.d.ts, 19, 9), Decl(express.d.ts, 21, 54)) +>IRouter : Symbol(IRouter, Decl(express.d.ts, 15, 9)) +>Router : Symbol(Router, Decl(express.d.ts, 19, 9), Decl(express.d.ts, 21, 54)) + + interface Errback { (err: Error): void; } +>Errback : Symbol(Errback, Decl(express.d.ts, 23, 58)) +>err : Symbol(err, Decl(express.d.ts, 25, 29)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + interface Request extends Express.Request { +>Request : Symbol(Request, Decl(express.d.ts, 25, 49), Decl(augmentation.ts, 2, 26)) +>Express.Request : Symbol(Express.Request, Decl(express.d.ts, 0, 24)) +>Express : Symbol(Express, Decl(express.d.ts, 0, 0)) +>Request : Symbol(Express.Request, Decl(express.d.ts, 0, 24)) + + get (name: string): string; +>get : Symbol(Request.get, Decl(express.d.ts, 27, 51)) +>name : Symbol(name, Decl(express.d.ts, 29, 17)) + } + + interface Response extends Express.Response { +>Response : Symbol(Response, Decl(express.d.ts, 30, 9)) +>Express.Response : Symbol(Express.Response, Decl(express.d.ts, 1, 32)) +>Express : Symbol(Express, Decl(express.d.ts, 0, 0)) +>Response : Symbol(Express.Response, Decl(express.d.ts, 1, 32)) + + charset: string; +>charset : Symbol(Response.charset, Decl(express.d.ts, 32, 53)) + } + + interface ErrorRequestHandler { +>ErrorRequestHandler : Symbol(ErrorRequestHandler, Decl(express.d.ts, 34, 9)) + + (err: any, req: Request, res: Response, next: Function): any; +>err : Symbol(err, Decl(express.d.ts, 37, 13)) +>req : Symbol(req, Decl(express.d.ts, 37, 22)) +>Request : Symbol(Request, Decl(express.d.ts, 25, 49), Decl(augmentation.ts, 2, 26)) +>res : Symbol(res, Decl(express.d.ts, 37, 36)) +>Response : Symbol(Response, Decl(express.d.ts, 30, 9)) +>next : Symbol(next, Decl(express.d.ts, 37, 51)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + + interface RequestHandler { +>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 38, 9)) + + (req: Request, res: Response, next: Function): any; +>req : Symbol(req, Decl(express.d.ts, 41, 13)) +>Request : Symbol(Request, Decl(express.d.ts, 25, 49), Decl(augmentation.ts, 2, 26)) +>res : Symbol(res, Decl(express.d.ts, 41, 26)) +>Response : Symbol(Response, Decl(express.d.ts, 30, 9)) +>next : Symbol(next, Decl(express.d.ts, 41, 41)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + + interface Handler extends RequestHandler {} +>Handler : Symbol(Handler, Decl(express.d.ts, 42, 9)) +>RequestHandler : Symbol(RequestHandler, Decl(express.d.ts, 38, 9)) + + interface RequestParamHandler { +>RequestParamHandler : Symbol(RequestParamHandler, Decl(express.d.ts, 44, 51)) + + (req: Request, res: Response, next: Function, param: any): any; +>req : Symbol(req, Decl(express.d.ts, 47, 13)) +>Request : Symbol(Request, Decl(express.d.ts, 25, 49), Decl(augmentation.ts, 2, 26)) +>res : Symbol(res, Decl(express.d.ts, 47, 26)) +>Response : Symbol(Response, Decl(express.d.ts, 30, 9)) +>next : Symbol(next, Decl(express.d.ts, 47, 41)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>param : Symbol(param, Decl(express.d.ts, 47, 57)) + } + + interface Application extends IRouter, Express.Application { +>Application : Symbol(Application, Decl(express.d.ts, 48, 9)) +>IRouter : Symbol(IRouter, Decl(express.d.ts, 15, 9)) +>Application : Symbol(Application, Decl(express.d.ts, 48, 9)) +>Express.Application : Symbol(Express.Application, Decl(express.d.ts, 2, 33)) +>Express : Symbol(Express, Decl(express.d.ts, 0, 0)) +>Application : Symbol(Express.Application, Decl(express.d.ts, 2, 33)) + + routes: any; +>routes : Symbol(Application.routes, Decl(express.d.ts, 50, 81)) + } + + interface Express extends Application { +>Express : Symbol(Express, Decl(express.d.ts, 52, 9)) +>Application : Symbol(Application, Decl(express.d.ts, 48, 9)) + + createApplication(): Application; +>createApplication : Symbol(Express.createApplication, Decl(express.d.ts, 54, 47)) +>Application : Symbol(Application, Decl(express.d.ts, 48, 9)) + } + + var static: any; +>static : Symbol(static, Decl(express.d.ts, 58, 11)) + } + + export = e; +>e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) +} + +=== augmentation.ts === +/// +import * as e from "express"; +>e : Symbol(e, Decl(augmentation.ts, 1, 6)) + +declare module "express" { +>"express" : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) + + interface Request { +>Request : Symbol(Request, Decl(express.d.ts, 25, 49), Decl(augmentation.ts, 2, 26)) + + id: number; +>id : Symbol(Request.id, Decl(augmentation.ts, 3, 23)) + } +} + +=== consumer.ts === +import { Request } from "express"; +>Request : Symbol(Request, Decl(consumer.ts, 0, 8)) + +import "./augmentation"; +let x: Request; +>x : Symbol(x, Decl(consumer.ts, 2, 3)) +>Request : Symbol(Request, Decl(consumer.ts, 0, 8)) + +const y = x.id; +>y : Symbol(y, Decl(consumer.ts, 3, 5)) +>x.id : Symbol(Request.id, Decl(augmentation.ts, 3, 23)) +>x : Symbol(x, Decl(consumer.ts, 2, 3)) +>id : Symbol(Request.id, Decl(augmentation.ts, 3, 23)) + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.types new file mode 100644 index 0000000000..342c2a172e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals5.types @@ -0,0 +1,134 @@ +//// [tests/cases/compiler/augmentExportEquals5.ts] //// + +=== express.d.ts === +declare module Express { + export interface Request { } + export interface Response { } + export interface Application { } +} + +declare module "express" { +>"express" : typeof import("express") + + function e(): e.Express; +>e : typeof import("express.d.ts") +>e : any + + namespace e { +>e : typeof import("express.d.ts") + + interface IRoute { + all(...handler: RequestHandler[]): IRoute; +>all : (...handler: RequestHandler[]) => IRoute +>handler : RequestHandler[] + } + + interface IRouterMatcher { + (name: string|RegExp, ...handlers: RequestHandler[]): T; +>name : string | RegExp +>handlers : RequestHandler[] + } + + interface IRouter extends RequestHandler { + route(path: string): IRoute; +>route : (path: string) => IRoute +>path : string + } + + export function Router(options?: any): Router; +>Router : (options?: any) => Router +>options : any + + export interface Router extends IRouter {} + + interface Errback { (err: Error): void; } +>err : Error + + interface Request extends Express.Request { +>Express : any + + get (name: string): string; +>get : (name: string) => string +>name : string + } + + interface Response extends Express.Response { +>Express : any + + charset: string; +>charset : string + } + + interface ErrorRequestHandler { + (err: any, req: Request, res: Response, next: Function): any; +>err : any +>req : Request +>res : Response +>next : Function + } + + interface RequestHandler { + (req: Request, res: Response, next: Function): any; +>req : Request +>res : Response +>next : Function + } + + interface Handler extends RequestHandler {} + + interface RequestParamHandler { + (req: Request, res: Response, next: Function, param: any): any; +>req : Request +>res : Response +>next : Function +>param : any + } + + interface Application extends IRouter, Express.Application { +>Express : any + + routes: any; +>routes : any + } + + interface Express extends Application { + createApplication(): Application; +>createApplication : () => Application + } + + var static: any; +>static : any + } + + export = e; +>e : typeof import("express.d.ts") +} + +=== augmentation.ts === +/// +import * as e from "express"; +>e : typeof e + +declare module "express" { +>"express" : typeof import("express") + + interface Request { + id: number; +>id : number + } +} + +=== consumer.ts === +import { Request } from "express"; +>Request : any + +import "./augmentation"; +let x: Request; +>x : Request + +const y = x.id; +>y : number +>x.id : number +>x : Request +>id : number + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.js b/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.js new file mode 100644 index 0000000000..b55de356a7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.js @@ -0,0 +1,88 @@ +//// [tests/cases/compiler/augmentExportEquals6.ts] //// + +//// [file1.ts] +class foo {} +namespace foo { + export class A {} + export namespace B { export let a; } +} +export = foo; + +//// [file2.ts] +import x = require("./file1"); +x.B.b = 1; + +// OK - './file1' is a namespace +declare module "./file1" { + interface A { a: number } + namespace B { + export let b: number; + } +} + +//// [file3.ts] +import * as x from "./file1"; +import "./file2"; +let a: x.A; +let b = a.a; +let c = x.B.b; + +//// [file1.js] +"use strict"; +class foo { +} +(function (foo) { + class A { + } + foo.A = A; + let B; + (function (B) { + })(B = foo.B || (foo.B = {})); +})(foo || (foo = {})); +module.exports = foo; +//// [file2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const x = require("./file1"); +x.B.b = 1; +//// [file3.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +const x = __importStar(require("./file1")); +require("./file2"); +let a; +let b = a.a; +let c = x.B.b; diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.symbols b/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.symbols new file mode 100644 index 0000000000..3174f41445 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.symbols @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/augmentExportEquals6.ts] //// + +=== file1.ts === +class foo {} +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 10)) + +namespace foo { +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 10)) + + export class A {} +>A : Symbol(A, Decl(file1.ts, 1, 15), Decl(file2.ts, 4, 26)) + + export namespace B { export let a; } +>B : Symbol(B, Decl(file1.ts, 2, 21), Decl(file2.ts, 5, 29)) +>a : Symbol(a, Decl(file1.ts, 3, 35)) +} +export = foo; +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 10)) + +=== file2.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +x.B.b = 1; +>x.B.b : Symbol(x.B.b, Decl(file2.ts, 7, 18)) +>x.B : Symbol(x.B, Decl(file1.ts, 2, 21), Decl(file2.ts, 5, 29)) +>x : Symbol(x, Decl(file2.ts, 0, 0)) +>B : Symbol(x.B, Decl(file1.ts, 2, 21), Decl(file2.ts, 5, 29)) +>b : Symbol(x.B.b, Decl(file2.ts, 7, 18)) + +// OK - './file1' is a namespace +declare module "./file1" { +>"./file1" : Symbol(x, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 10)) + + interface A { a: number } +>A : Symbol(A, Decl(file1.ts, 1, 15), Decl(file2.ts, 4, 26)) +>a : Symbol(A.a, Decl(file2.ts, 5, 17)) + + namespace B { +>B : Symbol(B, Decl(file1.ts, 2, 21), Decl(file2.ts, 5, 29)) + + export let b: number; +>b : Symbol(b, Decl(file2.ts, 7, 18)) + } +} + +=== file3.ts === +import * as x from "./file1"; +>x : Symbol(x, Decl(file3.ts, 0, 6)) + +import "./file2"; +let a: x.A; +>a : Symbol(a, Decl(file3.ts, 2, 3)) +>x : Symbol(x, Decl(file3.ts, 0, 6)) +>A : Symbol(x.A, Decl(file1.ts, 1, 15), Decl(file2.ts, 4, 26)) + +let b = a.a; +>b : Symbol(b, Decl(file3.ts, 3, 3)) +>a.a : Symbol(x.A.a, Decl(file2.ts, 5, 17)) +>a : Symbol(a, Decl(file3.ts, 2, 3)) +>a : Symbol(x.A.a, Decl(file2.ts, 5, 17)) + +let c = x.B.b; +>c : Symbol(c, Decl(file3.ts, 4, 3)) +>x.B.b : Symbol(x.B.b, Decl(file2.ts, 7, 18)) +>x.B : Symbol(x.B, Decl(file1.ts, 2, 21), Decl(file2.ts, 5, 29)) +>x : Symbol(x, Decl(file3.ts, 0, 6)) +>B : Symbol(x.B, Decl(file1.ts, 2, 21), Decl(file2.ts, 5, 29)) +>b : Symbol(x.B.b, Decl(file2.ts, 7, 18)) + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.types new file mode 100644 index 0000000000..bf067695df --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals6.types @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/augmentExportEquals6.ts] //// + +=== file1.ts === +class foo {} +>foo : import("file1.ts") + +namespace foo { +>foo : typeof import("file1.ts") + + export class A {} +>A : A + + export namespace B { export let a; } +>B : typeof B +>a : any +} +export = foo; +>foo : import("file1.ts") + +=== file2.ts === +import x = require("./file1"); +>x : typeof x + +x.B.b = 1; +>x.B.b = 1 : 1 +>x.B.b : number +>x.B : typeof x.B +>x : typeof x +>B : typeof x.B +>b : number +>1 : 1 + +// OK - './file1' is a namespace +declare module "./file1" { +>"./file1" : typeof x + + interface A { a: number } +>a : number + + namespace B { +>B : typeof B + + export let b: number; +>b : number + } +} + +=== file3.ts === +import * as x from "./file1"; +>x : typeof x + +import "./file2"; +let a: x.A; +>a : x.A +>x : any + +let b = a.a; +>b : number +>a.a : number +>a : x.A +>a : number + +let c = x.B.b; +>c : number +>x.B.b : number +>x.B : typeof x.B +>x : typeof x +>B : typeof x.B +>b : number + diff --git a/testdata/baselines/reference/submodule/compiler/augmentExportEquals7.types b/testdata/baselines/reference/submodule/compiler/augmentExportEquals7.types index fdc26b6a99..3e593cce90 100644 --- a/testdata/baselines/reference/submodule/compiler/augmentExportEquals7.types +++ b/testdata/baselines/reference/submodule/compiler/augmentExportEquals7.types @@ -10,7 +10,7 @@ export = lib; === /node_modules/@types/lib-extender/index.d.ts === import * as lib from "lib"; ->lib : () => void +>lib : { default: () => void; } declare module "lib" { >"lib" : typeof import("lib") diff --git a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js b/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js index 0ada4a51d6..0d3698bb39 100644 --- a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js +++ b/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js @@ -36,6 +36,7 @@ interface i4 { //import i4 = require(''); // error //// [augmentedTypesInterface.js] +// interface then interface class i2 { bar() { return 1; diff --git a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js.diff b/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js.diff deleted file mode 100644 index cae881d4fe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.augmentedTypesInterface.js -+++ new.augmentedTypesInterface.js -@@= skipped -35, +35 lines =@@ - //import i4 = require(''); // error - - //// [augmentedTypesInterface.js] --// interface then interface - class i2 { - bar() { - return 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/autolift4.js.diff b/testdata/baselines/reference/submodule/compiler/autolift4.js.diff index 425be45ce6..142cca6b30 100644 --- a/testdata/baselines/reference/submodule/compiler/autolift4.js.diff +++ b/testdata/baselines/reference/submodule/compiler/autolift4.js.diff @@ -1,34 +1,21 @@ --- old.autolift4.js +++ new.autolift4.js -@@= skipped -25, +25 lines =@@ - +@@= skipped -26, +26 lines =@@ //// [autolift4.js] --let Point = (() => { -- class Point { -- constructor(x, y) { -- this.x = x; -- this.y = y; -- } -- getDist() { -- return Math.sqrt(this.x * this.x + this.y * this.y); -- } -- } -- Point.origin = new Point(0, 0); -- return Point; --})(); -+class Point { + class Point { + x; + y; -+ constructor(x, y) { -+ this.x = x; -+ this.y = y; -+ } -+ getDist() { -+ return Math.sqrt(this.x * this.x + this.y * this.y); -+ } + constructor(x, y) { + this.x = x; + this.y = y; +@@= skipped -7, +9 lines =@@ + getDist() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + static origin = new Point(0, 0); -+} + } +-Point.origin = new Point(0, 0); class Point3D extends Point { + z; constructor(x, y, z, m) { diff --git a/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.errors.txt b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.errors.txt new file mode 100644 index 0000000000..3e8f387229 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.errors.txt @@ -0,0 +1,12 @@ +badExternalModuleReference.ts(1,21): error TS2307: Cannot find module 'garbage' or its corresponding type declarations. + + +==== badExternalModuleReference.ts (1 errors) ==== + import a1 = require("garbage"); + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'garbage' or its corresponding type declarations. + export declare var a: { + test1: a1.connectModule; + (): a1.connectExport; + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.js b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.js new file mode 100644 index 0000000000..017e5d940f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/badExternalModuleReference.ts] //// + +//// [badExternalModuleReference.ts] +import a1 = require("garbage"); +export declare var a: { + test1: a1.connectModule; + (): a1.connectExport; +}; + + +//// [badExternalModuleReference.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.symbols b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.symbols new file mode 100644 index 0000000000..ab6bf58442 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/badExternalModuleReference.ts] //// + +=== badExternalModuleReference.ts === +import a1 = require("garbage"); +>a1 : Symbol(a1, Decl(badExternalModuleReference.ts, 0, 0)) + +export declare var a: { +>a : Symbol(a, Decl(badExternalModuleReference.ts, 1, 18)) + + test1: a1.connectModule; +>test1 : Symbol(test1, Decl(badExternalModuleReference.ts, 1, 23)) +>a1 : Symbol(a1, Decl(badExternalModuleReference.ts, 0, 0)) +>connectModule : Symbol(a1.connectModule) + + (): a1.connectExport; +>a1 : Symbol(a1, Decl(badExternalModuleReference.ts, 0, 0)) +>connectExport : Symbol(a1.connectExport) + +}; + diff --git a/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.types b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.types new file mode 100644 index 0000000000..54e647d16d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/badExternalModuleReference.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/badExternalModuleReference.ts] //// + +=== badExternalModuleReference.ts === +import a1 = require("garbage"); +>a1 : any + +export declare var a: { +>a : { (): a1.connectExport; test1: a1.connectModule; } + + test1: a1.connectModule; +>test1 : a1.connectModule +>a1 : any + + (): a1.connectExport; +>a1 : any + +}; + diff --git a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js b/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js index f59d46d642..ef3170d82a 100644 --- a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js +++ b/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js @@ -26,6 +26,7 @@ goofus((a: string) => ({ dog: function() { return a; } })); //// [badInferenceLowerPriorityThanGoodInference.js] +// Repro from #13118 const result = canYouInferThis(() => ({ a: { BLAH: 33 }, b: x => { } diff --git a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js.diff b/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js.diff deleted file mode 100644 index c2f7f0e6f4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.badInferenceLowerPriorityThanGoodInference.js -+++ new.badInferenceLowerPriorityThanGoodInference.js -@@= skipped -25, +25 lines =@@ - - - //// [badInferenceLowerPriorityThanGoodInference.js] --// Repro from #13118 - const result = canYouInferThis(() => ({ - a: { BLAH: 33 }, - b: x => { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js b/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js index 28fff13203..0b625e5da5 100644 --- a/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js +++ b/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js @@ -1299,6 +1299,7 @@ const foo = function (this: any) { }; //// [binaryArithmeticControlFlowGraphNotTooLarge.js] +"use strict"; // Repro from #29926 (expanded 10x for good measure) const foo = function () { var a, b, c, d, ab, bc, cd, da, blocks = this.blocks; diff --git a/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js.diff b/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js.diff deleted file mode 100644 index 0f3f03b632..0000000000 --- a/testdata/baselines/reference/submodule/compiler/binaryArithmeticControlFlowGraphNotTooLarge.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.binaryArithmeticControlFlowGraphNotTooLarge.js -+++ new.binaryArithmeticControlFlowGraphNotTooLarge.js -@@= skipped -1298, +1298 lines =@@ - }; - - //// [binaryArithmeticControlFlowGraphNotTooLarge.js] --"use strict"; - // Repro from #29926 (expanded 10x for good measure) - const foo = function () { - var a, b, c, d, ab, bc, cd, da, blocks = this.blocks; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js b/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js index 8758b32496..11519f936a 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js +++ b/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js @@ -11,7 +11,6 @@ declare function use(n: number): void; //// [blockScopedBindingsReassignedInLoop1.js] (function () { - 'use strict'; 'use strict'; for (let i = 0; i < 9; ++i) { (() => use(++i))(); diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js.diff b/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js.diff deleted file mode 100644 index 058b92665d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedBindingsReassignedInLoop1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.blockScopedBindingsReassignedInLoop1.js -+++ new.blockScopedBindingsReassignedInLoop1.js -@@= skipped -11, +11 lines =@@ - //// [blockScopedBindingsReassignedInLoop1.js] - (function () { - 'use strict'; -+ 'use strict'; - for (let i = 0; i < 9; ++i) { - (() => use(++i))(); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.errors.txt b/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.errors.txt deleted file mode 100644 index ea94961d68..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== c.ts (0 errors) ==== - let foo: typeof C; -==== b.ts (0 errors) ==== - class C { } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.symbols b/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.symbols deleted file mode 100644 index 4fa4569b62..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.symbols +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts] //// - -=== c.ts === -let foo: typeof C; ->foo : Symbol(foo, Decl(c.ts, 0, 3)) ->C : Symbol(C, Decl(b.ts, 0, 0)) - -=== b.ts === -class C { } ->C : Symbol(C, Decl(b.ts, 0, 0)) - diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.types b/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.types deleted file mode 100644 index 1da2a72801..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedClassDeclarationAcrossFiles.types +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts] //// - -=== c.ts === -let foo: typeof C; ->foo : typeof C ->C : typeof C - -=== b.ts === -class C { } ->C : C - diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff deleted file mode 100644 index a92cdeb5e1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.blockScopedFunctionDeclarationInStrictClass.errors.txt -+++ new.blockScopedFunctionDeclarationInStrictClass.errors.txt -@@= skipped -0, +0 lines =@@ --blockScopedFunctionDeclarationInStrictClass.ts(4,22): error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode. - blockScopedFunctionDeclarationInStrictClass.ts(7,9): error TS2304: Cannot find name 'foo'. - - --==== blockScopedFunctionDeclarationInStrictClass.ts (2 errors) ==== -+==== blockScopedFunctionDeclarationInStrictClass.ts (1 errors) ==== - class c { - method() { - if (true) { - function foo() { } -- ~~~ --!!! error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode. - foo(); // ok - } - foo(); // not ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt new file mode 100644 index 0000000000..f958ba0e05 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt @@ -0,0 +1,12 @@ +blockScopedFunctionDeclarationInStrictModule.ts(6,10): error TS2304: Cannot find name 'foo'. + + +==== blockScopedFunctionDeclarationInStrictModule.ts (1 errors) ==== + if (true) { + function foo() { } + foo(); // ok + } + + export = foo; // not ok + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.js b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.js new file mode 100644 index 0000000000..e7c00bb07a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts] //// + +//// [blockScopedFunctionDeclarationInStrictModule.ts] +if (true) { + function foo() { } + foo(); // ok +} + +export = foo; // not ok + +//// [blockScopedFunctionDeclarationInStrictModule.js] +"use strict"; +if (true) { + function foo() { } + foo(); // ok +} +module.exports = foo; diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.symbols b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.symbols new file mode 100644 index 0000000000..b21eec9de5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts] //// + +=== blockScopedFunctionDeclarationInStrictModule.ts === +if (true) { + function foo() { } +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationInStrictModule.ts, 0, 11)) + + foo(); // ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationInStrictModule.ts, 0, 11)) +} + +export = foo; // not ok diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.types b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.types new file mode 100644 index 0000000000..8adbd07915 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.types @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts] //// + +=== blockScopedFunctionDeclarationInStrictModule.ts === +if (true) { +>true : true + + function foo() { } +>foo : () => void + + foo(); // ok +>foo() : void +>foo : () => void +} + +export = foo; // not ok +>foo : any + diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff deleted file mode 100644 index 9c8c1bcd6c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.blockScopedFunctionDeclarationStrictES5.errors.txt -+++ new.blockScopedFunctionDeclarationStrictES5.errors.txt -@@= skipped -0, +0 lines =@@ --blockScopedFunctionDeclarationStrictES5.ts(3,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - blockScopedFunctionDeclarationStrictES5.ts(6,1): error TS2304: Cannot find name 'foo'. - - --==== blockScopedFunctionDeclarationStrictES5.ts (2 errors) ==== -+==== blockScopedFunctionDeclarationStrictES5.ts (1 errors) ==== - "use strict"; - if (true) { - function foo() { } // Error to declare function in block scope -- ~~~ --!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - foo(); // This call should be ok - } - foo(); // Error to find name foo \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff deleted file mode 100644 index dcc648a56c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.blockScopedSameNameFunctionDeclarationStrictES5.errors.txt -+++ new.blockScopedSameNameFunctionDeclarationStrictES5.errors.txt -@@= skipped -0, +0 lines =@@ --blockScopedSameNameFunctionDeclarationStrictES5.ts(4,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - blockScopedSameNameFunctionDeclarationStrictES5.ts(6,13): error TS2554: Expected 0 arguments, but got 1. --blockScopedSameNameFunctionDeclarationStrictES5.ts(9,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - blockScopedSameNameFunctionDeclarationStrictES5.ts(11,13): error TS2554: Expected 0 arguments, but got 1. - blockScopedSameNameFunctionDeclarationStrictES5.ts(14,5): error TS2554: Expected 1 arguments, but got 0. - blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): error TS2554: Expected 1 arguments, but got 0. - - --==== blockScopedSameNameFunctionDeclarationStrictES5.ts (6 errors) ==== -+==== blockScopedSameNameFunctionDeclarationStrictES5.ts (4 errors) ==== - "use strict"; - function foo(a: number) { - if (a === 1) { - function foo() { } // Error to declare function in block scope -- ~~~ --!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - foo(); - foo(10); // not ok - ~~ -@@= skipped -19, +15 lines =@@ - } - else { - function foo() { } // Error to declare function in block scope -- ~~~ --!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - foo(); - foo(10); // not ok - ~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedVariablesUseBeforeDef.js.diff b/testdata/baselines/reference/submodule/compiler/blockScopedVariablesUseBeforeDef.js.diff index 6ccdd13b93..643fa59775 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedVariablesUseBeforeDef.js.diff +++ b/testdata/baselines/reference/submodule/compiler/blockScopedVariablesUseBeforeDef.js.diff @@ -66,15 +66,10 @@ let x; } function foo10() { -- let A = (() => { -- class A { -- } -- A.a = x; -- return A; -- })(); -+ class A { + class A { + static a = x; -+ } + } +- A.a = x; let x; } function foo11() { @@ -98,7 +93,7 @@ constructor() { this.a = x; } -@@= skipped -81, +69 lines =@@ +@@= skipped -78, +69 lines =@@ let [a] = (() => a)(); } function foo17() { diff --git a/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js b/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js index 74a0feb9ef..3dccb04149 100644 --- a/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js +++ b/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js @@ -27,6 +27,7 @@ let attrs2 = { optionalBool: true as true, mandatoryFn: () => { } } let Success = () => //// [booleanLiteralsContextuallyTypedFromUnion.jsx] +"use strict"; const isIt = Math.random() > 0.5; const c = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 }; const cc = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; diff --git a/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js.diff b/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js.diff deleted file mode 100644 index ac480824b4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/booleanLiteralsContextuallyTypedFromUnion.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.booleanLiteralsContextuallyTypedFromUnion.js -+++ new.booleanLiteralsContextuallyTypedFromUnion.js -@@= skipped -26, +26 lines =@@ - let Success = () => - - //// [booleanLiteralsContextuallyTypedFromUnion.jsx] --"use strict"; - const isIt = Math.random() > 0.5; - const c = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 }; - const cc = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/builtinIterator.js b/testdata/baselines/reference/submodule/compiler/builtinIterator.js index 4632864112..a22b5baa67 100644 --- a/testdata/baselines/reference/submodule/compiler/builtinIterator.js +++ b/testdata/baselines/reference/submodule/compiler/builtinIterator.js @@ -76,6 +76,7 @@ declare const iter2: IteratorObject; const iter3 = iter2.flatMap(() => g1); //// [builtinIterator.js] +"use strict"; const iterator = Iterator.from([0, 1, 2]); const mapped = iterator.map(String); const filtered = iterator.filter(x => x > 0); diff --git a/testdata/baselines/reference/submodule/compiler/builtinIterator.js.diff b/testdata/baselines/reference/submodule/compiler/builtinIterator.js.diff deleted file mode 100644 index beed4020ca..0000000000 --- a/testdata/baselines/reference/submodule/compiler/builtinIterator.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.builtinIterator.js -+++ new.builtinIterator.js -@@= skipped -75, +75 lines =@@ - const iter3 = iter2.flatMap(() => g1); - - //// [builtinIterator.js] --"use strict"; - const iterator = Iterator.from([0, 1, 2]); - const mapped = iterator.map(String); - const filtered = iterator.filter(x => x > 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.errors.txt b/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.errors.txt deleted file mode 100644 index dea88727d4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== index.ts (0 errors) ==== - export * from "./nested"; - -==== nested/base.ts (0 errors) ==== - import { B } from "./shared"; - - export function f() { - return new B(); - } - -==== nested/derived.ts (0 errors) ==== - import { f } from "./base"; - - export function g() { - return f(); - } - -==== nested/index.ts (0 errors) ==== - export * from "./base"; - - export * from "./derived"; - export * from "./shared"; - -==== nested/shared.ts (0 errors) ==== - export class B {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.symbols b/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.symbols deleted file mode 100644 index be9a646ce5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.symbols +++ /dev/null @@ -1,39 +0,0 @@ -//// [tests/cases/compiler/bundledDtsLateExportRenaming.ts] //// - -=== index.ts === - -export * from "./nested"; - -=== nested/base.ts === -import { B } from "./shared"; ->B : Symbol(B, Decl(base.ts, 0, 8)) - -export function f() { ->f : Symbol(f, Decl(base.ts, 0, 29)) - - return new B(); ->B : Symbol(B, Decl(base.ts, 0, 8)) -} - -=== nested/derived.ts === -import { f } from "./base"; ->f : Symbol(f, Decl(derived.ts, 0, 8)) - -export function g() { ->g : Symbol(g, Decl(derived.ts, 0, 27)) - - return f(); ->f : Symbol(f, Decl(derived.ts, 0, 8)) -} - -=== nested/index.ts === - -export * from "./base"; - -export * from "./derived"; -export * from "./shared"; - -=== nested/shared.ts === -export class B {} ->B : Symbol(B, Decl(shared.ts, 0, 0)) - diff --git a/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.types b/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.types deleted file mode 100644 index b9593cea1a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/bundledDtsLateExportRenaming.types +++ /dev/null @@ -1,41 +0,0 @@ -//// [tests/cases/compiler/bundledDtsLateExportRenaming.ts] //// - -=== index.ts === - -export * from "./nested"; - -=== nested/base.ts === -import { B } from "./shared"; ->B : typeof B - -export function f() { ->f : () => B - - return new B(); ->new B() : B ->B : typeof B -} - -=== nested/derived.ts === -import { f } from "./base"; ->f : () => import("index").B - -export function g() { ->g : () => import("index").B - - return f(); ->f() : import("index").B ->f : () => import("index").B -} - -=== nested/index.ts === - -export * from "./base"; - -export * from "./derived"; -export * from "./shared"; - -=== nested/shared.ts === -export class B {} ->B : B - diff --git a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js b/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js index 378671931c..c15c8506ae 100644 --- a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js +++ b/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js @@ -26,6 +26,7 @@ createInstance(MenuWorkbenchToolBar, { //// [cachedContextualTypes.js] "use strict"; +// Repro from #52198 Object.defineProperty(exports, "__esModule", { value: true }); class MenuWorkbenchToolBar { constructor(options) { } diff --git a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js.diff b/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js.diff deleted file mode 100644 index 6236676ccd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.cachedContextualTypes.js -+++ new.cachedContextualTypes.js -@@= skipped -25, +25 lines =@@ - - //// [cachedContextualTypes.js] - "use strict"; --// Repro from #52198 - Object.defineProperty(exports, "__esModule", { value: true }); - class MenuWorkbenchToolBar { - constructor(options) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.errors.txt b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.errors.txt deleted file mode 100644 index ad281922cc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - -==== /a/b/foo.d.ts (0 errors) ==== - export declare let x: number - -==== /a/b/c/d/e/app.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - -==== /a/b/c/lib.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.errors.txt.diff deleted file mode 100644 index 4ea4f7b5fc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.cachedModuleResolution3.errors.txt -+++ new.cachedModuleResolution3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+ -+ -+==== /a/b/foo.d.ts (0 errors) ==== -+ export declare let x: number -+ -+==== /a/b/c/d/e/app.ts (1 errors) ==== -+ import {x} from "foo"; -+ ~~~~~ -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+ -+==== /a/b/c/lib.ts (1 errors) ==== -+ import {x} from "foo"; -+ ~~~~~ -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.js b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.js deleted file mode 100644 index 3fce23e3f2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution3.ts] //// - -//// [foo.d.ts] -export declare let x: number - -//// [app.ts] -import {x} from "foo"; - -//// [lib.ts] -import {x} from "foo"; - -//// [app.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//// [lib.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.symbols b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.symbols deleted file mode 100644 index cce7b24eb2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.symbols +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution3.ts] //// - -=== /a/b/foo.d.ts === -export declare let x: number ->x : Symbol(x, Decl(foo.d.ts, 0, 18)) - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(app.ts, 0, 8)) - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(lib.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.trace.json b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.trace.json deleted file mode 100644 index 8090b18e29..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.trace.json +++ /dev/null @@ -1,54 +0,0 @@ -======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/d/e/package.json' does not exist. -File '/a/b/c/d/package.json' does not exist. -File '/a/b/c/package.json' does not exist. -File '/a/b/package.json' does not exist. -File '/a/package.json' does not exist. -File '/package.json' does not exist. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/e/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== -======== Resolving module 'foo' from '/a/b/c/lib.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/package.json' does not exist according to earlier cached lookups. -File '/a/b/package.json' does not exist according to earlier cached lookups. -File '/a/package.json' does not exist according to earlier cached lookups. -File '/package.json' does not exist according to earlier cached lookups. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.types b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.types deleted file mode 100644 index 141f909a5c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.types +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution3.ts] //// - -=== /a/b/foo.d.ts === -export declare let x: number ->x : number - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : any - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : any - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.types.diff b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.types.diff deleted file mode 100644 index 32e0765a47..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution3.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.cachedModuleResolution3.types -+++ new.cachedModuleResolution3.types -@@= skipped -5, +5 lines =@@ - - === /a/b/c/d/e/app.ts === - import {x} from "foo"; -->x : number -+>x : any - - === /a/b/c/lib.ts === - import {x} from "foo"; -->x : number -+>x : any diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.errors.txt b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.errors.txt deleted file mode 100644 index 7a9cb71715..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - -==== /a/b/foo.d.ts (0 errors) ==== - export declare let x: number - -==== /a/b/c/lib.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - -==== /a/b/c/d/e/app.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.errors.txt.diff deleted file mode 100644 index fec64eb7a9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.cachedModuleResolution4.errors.txt -+++ new.cachedModuleResolution4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+ -+ -+==== /a/b/foo.d.ts (0 errors) ==== -+ export declare let x: number -+ -+==== /a/b/c/lib.ts (1 errors) ==== -+ import {x} from "foo"; -+ ~~~~~ -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+ -+==== /a/b/c/d/e/app.ts (1 errors) ==== -+ import {x} from "foo"; -+ ~~~~~ -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.js b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.js deleted file mode 100644 index 2236fdf34c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.js +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution4.ts] //// - -//// [foo.d.ts] -export declare let x: number - -//// [lib.ts] -import {x} from "foo"; - -//// [app.ts] -import {x} from "foo"; - - -//// [lib.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//// [app.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.symbols b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.symbols deleted file mode 100644 index a377de8c86..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.symbols +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution4.ts] //// - -=== /a/b/foo.d.ts === -export declare let x: number ->x : Symbol(x, Decl(foo.d.ts, 0, 18)) - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(lib.ts, 0, 8)) - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(app.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.trace.json b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.trace.json deleted file mode 100644 index aa92ef4940..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.trace.json +++ /dev/null @@ -1,54 +0,0 @@ -======== Resolving module 'foo' from '/a/b/c/lib.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/package.json' does not exist. -File '/a/b/package.json' does not exist. -File '/a/package.json' does not exist. -File '/package.json' does not exist. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== -======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/d/e/package.json' does not exist. -File '/a/b/c/d/package.json' does not exist. -File '/a/b/c/package.json' does not exist according to earlier cached lookups. -File '/a/b/package.json' does not exist according to earlier cached lookups. -File '/a/package.json' does not exist according to earlier cached lookups. -File '/package.json' does not exist according to earlier cached lookups. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/e/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.types b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.types deleted file mode 100644 index b2088fa5ef..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.types +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution4.ts] //// - -=== /a/b/foo.d.ts === -export declare let x: number ->x : number - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : any - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : any - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.types.diff b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.types.diff deleted file mode 100644 index bc816a5ea7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution4.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.cachedModuleResolution4.types -+++ new.cachedModuleResolution4.types -@@= skipped -5, +5 lines =@@ - - === /a/b/c/lib.ts === - import {x} from "foo"; -->x : number -+>x : any - - === /a/b/c/d/e/app.ts === - import {x} from "foo"; -->x : number -+>x : any diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.errors.txt b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.errors.txt deleted file mode 100644 index e80de6969f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - -==== /a/b/c/d/e/app.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - -==== /a/b/c/lib.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.errors.txt.diff deleted file mode 100644 index bd593cdfe9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.cachedModuleResolution8.errors.txt -+++ new.cachedModuleResolution8.errors.txt -@@= skipped -0, +0 lines =@@ --/a/b/c/d/e/app.ts(1,17): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? --/a/b/c/lib.ts(1,17): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - - ==== /a/b/c/d/e/app.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ --!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - ==== /a/b/c/lib.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ --!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.js b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.js deleted file mode 100644 index c071c1dbf9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.js +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution8.ts] //// - -//// [app.ts] -import {x} from "foo"; - -//// [lib.ts] -import {x} from "foo"; - -//// [app.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//// [lib.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.symbols b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.symbols deleted file mode 100644 index 73d8ce998f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.symbols +++ /dev/null @@ -1,10 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution8.ts] //// - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(app.ts, 0, 8)) - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(lib.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.trace.json b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.trace.json deleted file mode 100644 index 8090b18e29..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.trace.json +++ /dev/null @@ -1,54 +0,0 @@ -======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/d/e/package.json' does not exist. -File '/a/b/c/d/package.json' does not exist. -File '/a/b/c/package.json' does not exist. -File '/a/b/package.json' does not exist. -File '/a/package.json' does not exist. -File '/package.json' does not exist. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/e/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== -======== Resolving module 'foo' from '/a/b/c/lib.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/package.json' does not exist according to earlier cached lookups. -File '/a/b/package.json' does not exist according to earlier cached lookups. -File '/a/package.json' does not exist according to earlier cached lookups. -File '/package.json' does not exist according to earlier cached lookups. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.types b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.types deleted file mode 100644 index 8ccd2f6024..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution8.types +++ /dev/null @@ -1,10 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution8.ts] //// - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : any - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : any - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.errors.txt b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.errors.txt deleted file mode 100644 index 0dc795af6b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - -==== /a/b/c/lib.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - -==== /a/b/c/d/e/app.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.errors.txt.diff deleted file mode 100644 index d820f0f522..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.cachedModuleResolution9.errors.txt -+++ new.cachedModuleResolution9.errors.txt -@@= skipped -0, +0 lines =@@ --/a/b/c/d/e/app.ts(1,17): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? --/a/b/c/lib.ts(1,17): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -+/a/b/c/lib.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - - ==== /a/b/c/lib.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ --!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - - - ==== /a/b/c/d/e/app.ts (1 errors) ==== - import {x} from "foo"; - ~~~~~ --!!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.js b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.js deleted file mode 100644 index 17ef035df3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.js +++ /dev/null @@ -1,16 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution9.ts] //// - -//// [lib.ts] -import {x} from "foo"; - - -//// [app.ts] -import {x} from "foo"; - - -//// [lib.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//// [app.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.symbols b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.symbols deleted file mode 100644 index 266ca70eaf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.symbols +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution9.ts] //// - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(lib.ts, 0, 8)) - - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : Symbol(x, Decl(app.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.trace.json b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.trace.json deleted file mode 100644 index aa92ef4940..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.trace.json +++ /dev/null @@ -1,54 +0,0 @@ -======== Resolving module 'foo' from '/a/b/c/lib.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/package.json' does not exist. -File '/a/b/package.json' does not exist. -File '/a/package.json' does not exist. -File '/package.json' does not exist. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== -======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ======== -Explicitly specified module resolution kind: 'Bundler'. -Resolving in CJS mode with conditions 'require', 'types'. -File '/a/b/c/d/e/package.json' does not exist. -File '/a/b/c/d/package.json' does not exist. -File '/a/b/c/package.json' does not exist according to earlier cached lookups. -File '/a/b/package.json' does not exist according to earlier cached lookups. -File '/a/package.json' does not exist according to earlier cached lookups. -File '/package.json' does not exist according to earlier cached lookups. -Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. -Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/e/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules/@types' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules/@types' does not exist, skipping all lookups in it. -Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON. -Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it. -Directory '/a/b/node_modules' does not exist, skipping all lookups in it. -Directory '/a/node_modules' does not exist, skipping all lookups in it. -Directory '/node_modules' does not exist, skipping all lookups in it. -======== Module name 'foo' was not resolved. ======== diff --git a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.types b/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.types deleted file mode 100644 index e448995d1a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedModuleResolution9.types +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/cachedModuleResolution9.ts] //// - -=== /a/b/c/lib.ts === -import {x} from "foo"; ->x : any - - -=== /a/b/c/d/e/app.ts === -import {x} from "foo"; ->x : any - diff --git a/testdata/baselines/reference/submodule/compiler/callsOnComplexSignatures.js.diff b/testdata/baselines/reference/submodule/compiler/callsOnComplexSignatures.js.diff deleted file mode 100644 index 2f48bfa689..0000000000 --- a/testdata/baselines/reference/submodule/compiler/callsOnComplexSignatures.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.callsOnComplexSignatures.js -+++ new.callsOnComplexSignatures.js -@@= skipped -112, +112 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var react_1 = __importDefault(require("react")); -+const react_1 = __importDefault(require("react")); - // Simple calls from real usecases - function test1() { - function test(t) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js b/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js index a6dfbc5311..92d4504710 100644 --- a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js +++ b/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js @@ -19,14 +19,12 @@ //// [capturedLetConstInLoop12.js] (function () { - "use strict"; "use strict"; for (let i = 0; i < 4; i++) { (() => [i] = [i + 1])(); } })(); (function () { - "use strict"; "use strict"; for (let i = 0; i < 4; i++) { (() => ({ a: i } = { a: i + 1 }))(); diff --git a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js.diff b/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js.diff deleted file mode 100644 index ef038f19f1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop12.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.capturedLetConstInLoop12.js -+++ new.capturedLetConstInLoop12.js -@@= skipped -19, +19 lines =@@ - //// [capturedLetConstInLoop12.js] - (function () { - "use strict"; -+ "use strict"; - for (let i = 0; i < 4; i++) { - (() => [i] = [i + 1])(); - } - })(); - (function () { -+ "use strict"; - "use strict"; - for (let i = 0; i < 4; i++) { - (() => ({ a: i } = { a: i + 1 }))(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js b/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js index ac4b57f6df..58e2471fa9 100644 --- a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js +++ b/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js @@ -17,6 +17,7 @@ function foo(x: number) { //// [capturedLetConstInLoop14.js] +"use strict"; function use(v) { } function foo(x) { var v = 1; diff --git a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js.diff b/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js.diff deleted file mode 100644 index 049deb24aa..0000000000 --- a/testdata/baselines/reference/submodule/compiler/capturedLetConstInLoop14.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.capturedLetConstInLoop14.js -+++ new.capturedLetConstInLoop14.js -@@= skipped -16, +16 lines =@@ - - - //// [capturedLetConstInLoop14.js] --"use strict"; - function use(v) { } - function foo(x) { - var v = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/capturedParametersInInitializers2.js.diff b/testdata/baselines/reference/submodule/compiler/capturedParametersInInitializers2.js.diff index e208cc7efa..b8e7399dfd 100644 --- a/testdata/baselines/reference/submodule/compiler/capturedParametersInInitializers2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/capturedParametersInInitializers2.js.diff @@ -8,15 +8,18 @@ - if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; - return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); -}; --function foo(y = (_a = class { -- get [x]() { return x; } -- constructor() { x; } -- [z]() { return z; } -- }, -- __setFunctionName(_a, "y"), -- _a.c = x, -- _a), x = 1, z = 2) { +-function foo(y, x, z) { - var _a; +- if (y === void 0) { y = (_a = class { +- get [x]() { return x; } +- constructor() { x; } +- [z]() { return z; } +- }, +- __setFunctionName(_a, "y"), +- _a.c = x, +- _a); } +- if (x === void 0) { x = 1; } +- if (z === void 0) { z = 2; } +function foo(y = class { + static c = x; + get [x]() { return x; } @@ -25,14 +28,16 @@ +}, x = 1, z = 2) { y.c; } --function foo2(y = (_a = class { -- constructor() { -- this[_b] = x; -- } -- }, -- _b = x, -- _a), x = 1) { -- var _b, _a; +-function foo2(y, x) { +- var _a, _b; +- if (y === void 0) { y = (_b = class { +- constructor() { +- this[_a] = x; +- } +- }, +- _a = x, +- _b); } +- if (x === void 0) { x = 1; } +function foo2(y = class { + [x] = x; +}, x = 1) { diff --git a/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt index 66e34d66b4..6679063d1a 100644 --- a/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt @@ -1,5 +1,5 @@ chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,64): error TS2741: Property 'z' is missing in type 'B' but required in type 'C'. -chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': y, z +chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': z, y ==== chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (2 errors) ==== @@ -27,5 +27,5 @@ chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS !!! related TS2728 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:15:5: 'z' is declared here. !!! related TS6502 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature. ~~~~~ -!!! error TS2739: Type 'A' is missing the following properties from type 'C': y, z +!!! error TS2739: Type 'A' is missing the following properties from type 'C': z, y !!! related TS6502 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/chainedImportAlias.js.diff b/testdata/baselines/reference/submodule/compiler/chainedImportAlias.js.diff index d1d1a1bbbd..aeaadd6c45 100644 --- a/testdata/baselines/reference/submodule/compiler/chainedImportAlias.js.diff +++ b/testdata/baselines/reference/submodule/compiler/chainedImportAlias.js.diff @@ -1,10 +1,8 @@ --- old.chainedImportAlias.js +++ new.chainedImportAlias.js -@@= skipped -22, +22 lines =@@ - //// [chainedImportAlias_file1.js] +@@= skipped -23, +23 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); --var x = require("./chainedImportAlias_file0"); + const x = require("./chainedImportAlias_file0"); -var y = x; -+const x = require("./chainedImportAlias_file0"); y.m.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt deleted file mode 100644 index 91e5fd5a6c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? -weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. -weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== weird.js (3 errors) ==== - someFunction(function(BaseClass) { - ~~~~~~~~~~~~ -!!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? -!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~~ -!!! error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. - 'use strict'; - const DEFAULT_MESSAGE = "nop!"; - class Hello extends BaseClass { - constructor() { - super(); - this.foo = "bar"; - } - _render(error) { - ~~~~~ -!!! error TS7006: Parameter 'error' implicitly has an 'any' type. - const message = error.message || DEFAULT_MESSAGE; - } - } - }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.symbols b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.symbols deleted file mode 100644 index 99ddd57e9d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.symbols +++ /dev/null @@ -1,33 +0,0 @@ -//// [tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts] //// - -=== weird.js === -someFunction(function(BaseClass) { ->BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) - - 'use strict'; - const DEFAULT_MESSAGE = "nop!"; ->DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) - - class Hello extends BaseClass { ->Hello : Symbol(Hello, Decl(weird.js, 2, 35)) ->BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) - - constructor() { - super(); - this.foo = "bar"; ->this.foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) ->this : Symbol(Hello, Decl(weird.js, 2, 35)) ->foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) - } - _render(error) { ->_render : Symbol(Hello._render, Decl(weird.js, 7, 9)) ->error : Symbol(error, Decl(weird.js, 8, 16)) - - const message = error.message || DEFAULT_MESSAGE; ->message : Symbol(message, Decl(weird.js, 9, 17)) ->error : Symbol(error, Decl(weird.js, 8, 16)) ->DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) - } - } -}); - diff --git a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.types b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.types deleted file mode 100644 index 7f98768cc3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.types +++ /dev/null @@ -1,47 +0,0 @@ -//// [tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts] //// - -=== weird.js === -someFunction(function(BaseClass) { ->someFunction(function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }}) : any ->someFunction : any ->function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }} : (BaseClass: any) => void ->BaseClass : any - - 'use strict'; ->'use strict' : "use strict" - - const DEFAULT_MESSAGE = "nop!"; ->DEFAULT_MESSAGE : "nop!" ->"nop!" : "nop!" - - class Hello extends BaseClass { ->Hello : Hello ->BaseClass : any - - constructor() { - super(); ->super() : void ->super : any - - this.foo = "bar"; ->this.foo = "bar" : "bar" ->this.foo : any ->this : this ->foo : any ->"bar" : "bar" - } - _render(error) { ->_render : (error: any) => void ->error : any - - const message = error.message || DEFAULT_MESSAGE; ->message : any ->error.message || DEFAULT_MESSAGE : any ->error.message : any ->error : any ->message : any ->DEFAULT_MESSAGE : "nop!" - } - } -}); - diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js index 9d5385bd49..d54c2d7666 100644 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js +++ b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js @@ -20,6 +20,8 @@ values = values2; //// [checkInfiniteExpansionTermination.js] +// Regression test for #1002 +// Before fix this code would cause infinite loop var values; var values2; values = values2; diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js.diff b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js.diff deleted file mode 100644 index a144218a54..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.checkInfiniteExpansionTermination.js -+++ new.checkInfiniteExpansionTermination.js -@@= skipped -19, +19 lines =@@ - - - //// [checkInfiniteExpansionTermination.js] --// Regression test for #1002 --// Before fix this code would cause infinite loop - var values; - var values2; - values = values2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js index c442b12a44..9726e78404 100644 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js +++ b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js @@ -20,6 +20,8 @@ function fn() { //// [checkInfiniteExpansionTermination2.js] +// Regression test for #1002 +// Before fix this code would cause infinite loop function fn() { var values = []; // Hang when using , but not diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js.diff b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js.diff deleted file mode 100644 index 77a7641e48..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.checkInfiniteExpansionTermination2.js -+++ new.checkInfiniteExpansionTermination2.js -@@= skipped -19, +19 lines =@@ - - - //// [checkInfiniteExpansionTermination2.js] --// Regression test for #1002 --// Before fix this code would cause infinite loop - function fn() { - var values = []; - // Hang when using , but not \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralIndexSignatures.types.diff b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralIndexSignatures.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralIndexSignatures.types.diff rename to testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralIndexSignatures.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt deleted file mode 100644 index 855d7577c6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== file.ts (0 errors) ==== - class Foo { - x: number; - } - - declare global { - var module: any; // Just here to remove unrelated error from test - } - - export = Foo; -==== something.js (1 errors) ==== - /** @typedef {typeof import("./file")} Foo */ - - /** @typedef {(foo: Foo) => string} FooFun */ - - module.exports = /** @type {FooFun} */(void 0); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols index c90d580369..7fa07cda56 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols @@ -25,6 +25,6 @@ export = Foo; module.exports = /** @type {FooFun} */(void 0); >module.exports : Symbol(export=, Decl(something.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("something", Decl(something.js, 0, 0)) >exports : Symbol(export=, Decl(something.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols.diff b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols.diff index 17636a88ef..813dfd8e80 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.symbols.diff @@ -7,5 +7,5 @@ ->module.exports : Symbol(module.exports, Decl(something.js, 0, 0)) ->module : Symbol(export=, Decl(something.js, 0, 0)) +>module.exports : Symbol(export=, Decl(something.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("something", Decl(something.js, 0, 0)) >exports : Symbol(export=, Decl(something.js, 0, 0)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff rename to testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js index 0a413dc368..ad2d034a27 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js @@ -20,16 +20,19 @@ a; //// [checkJsdocTypeTagOnExportAssignment1.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {boolean} a * @property {boolean} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { c: false }; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); a_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff deleted file mode 100644 index cb001a666b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment1.js -+++ new.checkJsdocTypeTagOnExportAssignment1.js -@@= skipped -19, +19 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment1.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {boolean} a - * @property {boolean} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { c: false }; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - a_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js index b7428a229c..cb7d1e31ee 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js @@ -28,6 +28,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { c: false }; //// [c.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); b_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js.diff deleted file mode 100644 index f4362a6e7c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment2.js -+++ new.checkJsdocTypeTagOnExportAssignment2.js -@@= skipped -28, +28 lines =@@ - //// [c.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var b_1 = require("./b"); -+const b_1 = require("./b"); - b_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js index 6bf97fedfe..f97a3ac134 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js @@ -22,17 +22,20 @@ a; //// [checkJsdocTypeTagOnExportAssignment3.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {boolean} a * @property {boolean} b */ +Object.defineProperty(exports, "__esModule", { value: true }); const bar = { c: 1 }; /** @type {Foo} */ exports.default = bar; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); a_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff deleted file mode 100644 index fc0499aae9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment3.js -+++ new.checkJsdocTypeTagOnExportAssignment3.js -@@= skipped -21, +21 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment3.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {boolean} a - * @property {boolean} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - const bar = { c: 1 }; - /** @type {Foo} */ - exports.default = bar; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - a_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff rename to testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js index a4067800e7..3e280248f4 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js @@ -15,9 +15,9 @@ export default ""; //// [checkJsdocTypeTagOnExportAssignment4.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {number} Foo */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = ""; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js.diff deleted file mode 100644 index aa2903966c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment4.js -+++ new.checkJsdocTypeTagOnExportAssignment4.js -@@= skipped -14, +14 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment4.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {number} Foo - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = ""; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js index bd15e36ff4..88badb94e9 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js @@ -20,16 +20,19 @@ a; //// [checkJsdocTypeTagOnExportAssignment5.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {number} a * @property {number} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { a: 1, b: 1 }; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); a_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff deleted file mode 100644 index 280223a9e8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment5.js -+++ new.checkJsdocTypeTagOnExportAssignment5.js -@@= skipped -19, +19 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment5.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {number} a - * @property {number} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { a: 1, b: 1 }; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - a_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js index e2b514d833..dbdd725c30 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js @@ -20,16 +20,19 @@ a; //// [checkJsdocTypeTagOnExportAssignment6.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {number} a * @property {number} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { a: 1, b: 1, c: 1 }; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); a_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff deleted file mode 100644 index 57ee0893a0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment6.js -+++ new.checkJsdocTypeTagOnExportAssignment6.js -@@= skipped -19, +19 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment6.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {number} a - * @property {number} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { a: 1, b: 1, c: 1 }; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - a_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js index 481aeef891..c77ce904d2 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js @@ -22,17 +22,20 @@ a; //// [checkJsdocTypeTagOnExportAssignment7.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {number} a * @property {number} b */ +Object.defineProperty(exports, "__esModule", { value: true }); const abc = { a: 1, b: 1, c: 1 }; /** @type {Foo} */ exports.default = abc; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); a_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff deleted file mode 100644 index d61e82ff4d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment7.js -+++ new.checkJsdocTypeTagOnExportAssignment7.js -@@= skipped -21, +21 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment7.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {number} a - * @property {number} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - const abc = { a: 1, b: 1, c: 1 }; - /** @type {Foo} */ - exports.default = abc; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - a_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff rename to testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js index a13517d674..b63560b276 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js @@ -19,12 +19,12 @@ export default { //// [checkJsdocTypeTagOnExportAssignment8.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef Foo * @property {string} a * @property {'b'} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { a: 'a', diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js.diff deleted file mode 100644 index f6124fcb3a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment8.js -+++ new.checkJsdocTypeTagOnExportAssignment8.js -@@= skipped -18, +18 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment8.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef Foo - * @property {string} a - * @property {'b'} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { - a: 'a', \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js b/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js index c5c1f56860..27e6c7df59 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js @@ -17,6 +17,9 @@ const Foo = () => (
foo
); exports.default = Foo; //// [bar.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const foo_1 = require("/foo"); +const foo_1 = __importDefault(require("/foo")); const a = ; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js.diff deleted file mode 100644 index 553d172c82..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsxNotSetError.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.checkJsxNotSetError.js -+++ new.checkJsxNotSetError.js -@@= skipped -17, +17 lines =@@ - //// [bar.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var foo_1 = require("/foo"); -+const foo_1 = require("/foo"); - const a = ; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.types.diff b/testdata/baselines/reference/submodule/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.types.diff rename to testdata/baselines/reference/submodule/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js b/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js index 52ee51d25f..5f976ec06b 100644 --- a/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js +++ b/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js @@ -29,6 +29,7 @@ type T3 = { //// [circularAccessorAnnotations.js] +"use strict"; //// [circularAccessorAnnotations.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js.diff b/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js.diff deleted file mode 100644 index 5026ee20d6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/circularAccessorAnnotations.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.circularAccessorAnnotations.js -+++ new.circularAccessorAnnotations.js -@@= skipped -28, +28 lines =@@ - - - //// [circularAccessorAnnotations.js] --"use strict"; - - - //// [circularAccessorAnnotations.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js index 32ab8f146f..189c47ffd3 100644 --- a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js +++ b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js @@ -20,6 +20,8 @@ interface Y extends X { //// [circularBaseTypes.js] +"use strict"; +// Repro from #38098 ; // Error function f(m) { return m.value; diff --git a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff deleted file mode 100644 index f11e8e382f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.circularBaseTypes.js -+++ new.circularBaseTypes.js -@@= skipped -19, +19 lines =@@ - - - //// [circularBaseTypes.js] --"use strict"; --// Repro from #38098 - ; // Error - function f(m) { - return m.value; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js b/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js index 2f81785ed4..125fdbe026 100644 --- a/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js +++ b/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js @@ -22,6 +22,7 @@ reproduce({ //// [circularContextualMappedType.js] +"use strict"; reproduce({ name: () => { return 123; } }); diff --git a/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js.diff b/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js.diff deleted file mode 100644 index 57a3aa4aed..0000000000 --- a/testdata/baselines/reference/submodule/compiler/circularContextualMappedType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.circularContextualMappedType.js -+++ new.circularContextualMappedType.js -@@= skipped -21, +21 lines =@@ - - - //// [circularContextualMappedType.js] --"use strict"; - reproduce({ - name: () => { return 123; } - }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js index 7c94aba465..c410f8bfc1 100644 --- a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js +++ b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js @@ -11,6 +11,7 @@ Object.freeze({ //// [circularContextualReturnType.js] +"use strict"; // Repro from #17711 Object.freeze({ foo() { diff --git a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js.diff b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js.diff deleted file mode 100644 index 3408515fe9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.circularContextualReturnType.js -+++ new.circularContextualReturnType.js -@@= skipped -10, +10 lines =@@ - - - //// [circularContextualReturnType.js] --"use strict"; - // Repro from #17711 - Object.freeze({ - foo() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt index d7fdcefcfd..2629296c6b 100644 --- a/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt @@ -1,7 +1,8 @@ circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias 'A'. +circularModuleImports.ts(7,5): error TS2303: Circular definition of import alias 'B'. -==== circularModuleImports.ts (1 errors) ==== +==== circularModuleImports.ts (2 errors) ==== module M { @@ -11,6 +12,8 @@ circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias !!! error TS2303: Circular definition of import alias 'A'. import B = A; + ~~~~~~~~~~~~~ +!!! error TS2303: Circular definition of import alias 'B'. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff new file mode 100644 index 0000000000..dd48f7b787 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.circularModuleImports.errors.txt ++++ new.circularModuleImports.errors.txt +@@= skipped -0, +0 lines =@@ + circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias 'A'. +- +- +-==== circularModuleImports.ts (1 errors) ==== ++circularModuleImports.ts(7,5): error TS2303: Circular definition of import alias 'B'. ++ ++ ++==== circularModuleImports.ts (2 errors) ==== + module M + + { +@@= skipped -10, +11 lines =@@ + !!! error TS2303: Circular definition of import alias 'A'. + + import B = A; ++ ~~~~~~~~~~~~~ ++!!! error TS2303: Circular definition of import alias 'B'. + + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/class2.js.diff b/testdata/baselines/reference/submodule/compiler/class2.js.diff index 77299a1995..16c2b84804 100644 --- a/testdata/baselines/reference/submodule/compiler/class2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/class2.js.diff @@ -1,17 +1,9 @@ --- old.class2.js +++ new.class2.js -@@= skipped -3, +3 lines =@@ - class foo { constructor() { static f = 3; } } - +@@= skipped -5, +5 lines =@@ //// [class2.js] --let foo = (() => { -- class foo { -- constructor() { } -- } -- foo.f = 3; -- return foo; --})(); -+class foo { -+ constructor() { } + class foo { + constructor() { } + static f = 3; -+} \ No newline at end of file + } +-foo.f = 3; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js b/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js index 7b9e0a6cbd..60da0b173d 100644 --- a/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js +++ b/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js @@ -31,6 +31,7 @@ class MyClass2 { //// [classAttributeInferenceTemplate.js] +"use strict"; class MyClass { property; property2; diff --git a/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js.diff b/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js.diff deleted file mode 100644 index d45b50c6ce..0000000000 --- a/testdata/baselines/reference/submodule/compiler/classAttributeInferenceTemplate.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.classAttributeInferenceTemplate.js -+++ new.classAttributeInferenceTemplate.js -@@= skipped -30, +30 lines =@@ - - - //// [classAttributeInferenceTemplate.js] --"use strict"; - class MyClass { - property; - property2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classBlockScoping.js.diff b/testdata/baselines/reference/submodule/compiler/classBlockScoping.js.diff index 567f5e7605..17f2c3b975 100644 --- a/testdata/baselines/reference/submodule/compiler/classBlockScoping.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classBlockScoping.js.diff @@ -29,27 +29,16 @@ new Foo(); } else { -- let Foo = (() => { -- class Foo { -- static x() { -- new Foo(); -- } -- m() { -- new Foo(); -- } -- } -- Foo.y = new Foo(); -- return Foo; -- })(); -+ class Foo { + class Foo { + static y = new Foo(); -+ static x() { -+ new Foo(); -+ } -+ m() { -+ new Foo(); -+ } -+ } + static x() { + new Foo(); + } +@@= skipped -24, +23 lines =@@ + new Foo(); + } + } +- Foo.y = new Foo(); new Foo(); } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.js.diff b/testdata/baselines/reference/submodule/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.js.diff index 7801fd670c..e4a37da834 100644 --- a/testdata/baselines/reference/submodule/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.js.diff @@ -4,29 +4,23 @@ //// [classDeclarationShouldBeOutOfScopeInComputedNames.js] --let A = (() => { -- var _a, _b; -- class A { -- constructor() { -- this[_b] = 0; -- } -- static [(_a = A.p1, A.p2)]() { return 0; } -- ; -- [A.p1]() { } +-var _a, _b; + class A { +- constructor() { +- this[_b] = 0; - } -- _b = A.p2; -- A.p1 = Symbol(); -- A.p2 = Symbol(); -+class A { +- static [(_a = A.p1, A.p2)]() { return 0; } + static p1 = Symbol(); + static p2 = Symbol(); - // All of the below should be out of scope or TDZ - `A` has not finished being constructed as they are executed -- A[_a] = 0; -- return A; --})(); ++ // All of the below should be out of scope or TDZ - `A` has not finished being constructed as they are executed + static [A.p1] = 0; + static [A.p2]() { return 0; } -+ ; -+ [A.p1]() { } + ; + [A.p1]() { } + [A.p2] = 0; -+} \ No newline at end of file + } +-_b = A.p2; +-A.p1 = Symbol(); +-A.p2 = Symbol(); +-// All of the below should be out of scope or TDZ - `A` has not finished being constructed as they are executed +-A[_a] = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classExpressionInClassStaticDeclarations.js.diff b/testdata/baselines/reference/submodule/compiler/classExpressionInClassStaticDeclarations.js.diff index a9267943fe..83f7c77a2a 100644 --- a/testdata/baselines/reference/submodule/compiler/classExpressionInClassStaticDeclarations.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classExpressionInClassStaticDeclarations.js.diff @@ -1,19 +1,14 @@ --- old.classExpressionInClassStaticDeclarations.js +++ new.classExpressionInClassStaticDeclarations.js -@@= skipped -5, +5 lines =@@ - } +@@= skipped -6, +6 lines =@@ //// [classExpressionInClassStaticDeclarations.js] --let C = (() => { -- class C { -- } -- C.D = class extends C { -+class C { + class C { + static D = class extends C { - }; -- return C; --})(); -+} ++ }; + } +-C.D = class extends C { +-}; //// [classExpressionInClassStaticDeclarations.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classExpressionWithStaticProperties3.js.diff b/testdata/baselines/reference/submodule/compiler/classExpressionWithStaticProperties3.js.diff index 923d045ae3..fc596b8c32 100644 --- a/testdata/baselines/reference/submodule/compiler/classExpressionWithStaticProperties3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classExpressionWithStaticProperties3.js.diff @@ -1,10 +1,12 @@ --- old.classExpressionWithStaticProperties3.js +++ new.classExpressionWithStaticProperties3.js -@@= skipped -13, +13 lines =@@ +@@= skipped -11, +11 lines =@@ + arr.forEach(C => console.log(C.y())); + //// [classExpressionWithStaticProperties3.js] +-var _a; const arr = []; for (let i = 0; i < 3; i++) { -- let _a; - arr.push((_a = class C { - }, - _a.x = i, diff --git a/testdata/baselines/reference/submodule/compiler/classExtendsAcrossFiles.js.diff b/testdata/baselines/reference/submodule/compiler/classExtendsAcrossFiles.js.diff deleted file mode 100644 index d27eb5143d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/classExtendsAcrossFiles.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.classExtendsAcrossFiles.js -+++ new.classExtendsAcrossFiles.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.b = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); - exports.b = { - f: () => { - class A { -@@= skipped -14, +14 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = void 0; --var b_1 = require("./b"); -+const b_1 = require("./b"); - exports.a = { - f: () => { - class A { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.types.diff b/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.types.diff rename to testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js b/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js index 8b81bb0e4f..2064999854 100644 --- a/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js +++ b/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js @@ -8,6 +8,7 @@ class Test { //// [classFieldsBrokenConstructorEmitNoCrash1.js] +"use strict"; class Test { prop = 42; } diff --git a/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js.diff b/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js.diff index 46608bf469..51f1a32d08 100644 --- a/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classFieldsBrokenConstructorEmitNoCrash1.js.diff @@ -1,10 +1,8 @@ --- old.classFieldsBrokenConstructorEmitNoCrash1.js +++ new.classFieldsBrokenConstructorEmitNoCrash1.js -@@= skipped -7, +7 lines =@@ - - +@@= skipped -9, +9 lines =@@ //// [classFieldsBrokenConstructorEmitNoCrash1.js] --"use strict"; + "use strict"; class Test { - constructor() { - this.prop = 42; diff --git a/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js b/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js index 29af3e7fd6..20f28ae9b4 100644 --- a/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js +++ b/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js @@ -12,3 +12,4 @@ interface Settable { //// [classImplementsMethodWIthTupleArgs.js] +"use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js.diff b/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js.diff deleted file mode 100644 index 6b0f2a3b5f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/classImplementsMethodWIthTupleArgs.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.classImplementsMethodWIthTupleArgs.js -+++ new.classImplementsMethodWIthTupleArgs.js -@@= skipped -11, +11 lines =@@ - - - //// [classImplementsMethodWIthTupleArgs.js] --"use strict"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classInConvertedLoopES5.js.diff b/testdata/baselines/reference/submodule/compiler/classInConvertedLoopES5.js.diff index 3efec32be8..f281641cf2 100644 --- a/testdata/baselines/reference/submodule/compiler/classInConvertedLoopES5.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classInConvertedLoopES5.js.diff @@ -1,21 +1,15 @@ --- old.classInConvertedLoopES5.js +++ new.classInConvertedLoopES5.js -@@= skipped -13, +13 lines =@@ - //// [classInConvertedLoopES5.js] +@@= skipped -14, +14 lines =@@ const classesByRow = {}; for (const row of ['1', '2', '3', '4', '5']) { -- let RowClass = (() => { -- class RowClass { -- constructor() { -- this.row = row; -- } + class RowClass { +- constructor() { +- this.row = row; - } -- RowClass.factory = () => new RowClass(); -- return RowClass; -- })(); -+ class RowClass { + row = row; + static factory = () => new RowClass(); -+ } + } +- RowClass.factory = () => new RowClass(); classesByRow[row] = RowClass; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classMemberInitializerScoping.js.diff b/testdata/baselines/reference/submodule/compiler/classMemberInitializerScoping.js.diff index 8f41ee3304..a0f8ce4fe7 100644 --- a/testdata/baselines/reference/submodule/compiler/classMemberInitializerScoping.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classMemberInitializerScoping.js.diff @@ -1,25 +1,17 @@ --- old.classMemberInitializerScoping.js +++ new.classMemberInitializerScoping.js -@@= skipped -23, +23 lines =@@ - +@@= skipped -24, +24 lines =@@ //// [classMemberInitializerScoping.js] var aaa = 1; --let CCC = (() => { -- class CCC { -- constructor(aaa) { -- this.y = aaa; -- this.y = ''; // was: error, cannot assign string to number -- } -+class CCC { + class CCC { + y = aaa; + static staticY = aaa; // This shouldnt be error -+ constructor(aaa) { -+ this.y = ''; // was: error, cannot assign string to number + constructor(aaa) { +- this.y = aaa; + this.y = ''; // was: error, cannot assign string to number } -- CCC.staticY = aaa; // This shouldnt be error -- return CCC; --})(); -+} + } +-CCC.staticY = aaa; // This shouldnt be error // above is equivalent to this: var aaaa = 1; class CCCC { diff --git a/testdata/baselines/reference/submodule/compiler/classMemberInitializerWithLamdaScoping.js.diff b/testdata/baselines/reference/submodule/compiler/classMemberInitializerWithLamdaScoping.js.diff index a8bac01050..1c37fe0f95 100644 --- a/testdata/baselines/reference/submodule/compiler/classMemberInitializerWithLamdaScoping.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classMemberInitializerWithLamdaScoping.js.diff @@ -1,61 +1,51 @@ --- old.classMemberInitializerWithLamdaScoping.js +++ new.classMemberInitializerWithLamdaScoping.js -@@= skipped -32, +32 lines =@@ - } +@@= skipped -33, +33 lines =@@ //// [classMemberInitializerWithLamdaScoping.js] --let Test = (() => { -- class Test { -- constructor(field) { -- this.field = field; -- this.messageHandler = () => { -- var field = this.field; -- console.log(field); // Using field here shouldnt be error -- }; -- } -+class Test { + class Test { + field; -+ constructor(field) { -+ this.field = field; + constructor(field) { + this.field = field; +- this.messageHandler = () => { +- var field = this.field; +- console.log(field); // Using field here shouldnt be error +- }; } -- Test.staticMessageHandler = () => { + messageHandler = () => { + var field = this.field; + console.log(field); // Using field here shouldnt be error + }; + static field; + static staticMessageHandler = () => { - var field = Test.field; - console.log(field); // Using field here shouldnt be error - }; -- return Test; --})(); -+} ++ var field = Test.field; ++ console.log(field); // Using field here shouldnt be error ++ }; + } +-Test.staticMessageHandler = () => { +- var field = Test.field; +- console.log(field); // Using field here shouldnt be error +-}; var field1; --let Test1 = (() => { -- class Test1 { -- constructor(field1) { -- this.field1 = field1; -- this.messageHandler = () => { -- console.log(field1); // But this should be error as the field1 will resolve to var field1 -- // but since this code would be generated inside constructor, in generated js -- // it would resolve to private field1 and thats not what user intended here. -- }; -- } -+class Test1 { + class Test1 { + field1; -+ constructor(field1) { -+ this.field1 = field1; + constructor(field1) { + this.field1 = field1; +- this.messageHandler = () => { +- console.log(field1); // But this should be error as the field1 will resolve to var field1 +- // but since this code would be generated inside constructor, in generated js +- // it would resolve to private field1 and thats not what user intended here. +- }; } -- Test1.staticMessageHandler = () => { + messageHandler = () => { + console.log(field1); // But this should be error as the field1 will resolve to var field1 + // but since this code would be generated inside constructor, in generated js + // it would resolve to private field1 and thats not what user intended here. + }; + static staticMessageHandler = () => { - console.log(field1); // This shouldnt be error as its a static property - }; -- return Test1; --})(); -+} \ No newline at end of file ++ console.log(field1); // This shouldnt be error as its a static property ++ }; + } +-Test1.staticMessageHandler = () => { +- console.log(field1); // This shouldnt be error as its a static property +-}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js b/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js index cdd28e152e..b2f86f768c 100644 --- a/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js +++ b/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js @@ -41,6 +41,7 @@ const outsideClass: FuncType = function(val) { // compare to errors only on this } //// [classPropertyErrorOnNameOnly.js] +"use strict"; // turn on strictNullChecks class Example { insideClass = function (val) { diff --git a/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js.diff b/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js.diff index 6f0ea69d3a..ca9d8eced9 100644 --- a/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classPropertyErrorOnNameOnly.js.diff @@ -1,10 +1,7 @@ --- old.classPropertyErrorOnNameOnly.js +++ new.classPropertyErrorOnNameOnly.js -@@= skipped -40, +40 lines =@@ - } - - //// [classPropertyErrorOnNameOnly.js] --"use strict"; +@@= skipped -43, +43 lines =@@ + "use strict"; // turn on strictNullChecks class Example { - constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.js.diff index 79bc13238b..fab9d28d9f 100644 --- a/testdata/baselines/reference/submodule/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.js.diff @@ -1,22 +1,16 @@ --- old.classStaticInitializersUsePropertiesBeforeDeclaration.js +++ new.classStaticInitializersUsePropertiesBeforeDeclaration.js -@@= skipped -20, +20 lines =@@ - +@@= skipped -21, +21 lines =@@ //// [classStaticInitializersUsePropertiesBeforeDeclaration.js] --let Foo = (() => { -- class Foo { -- } -- Foo.enumMember = Enum.A; -- Foo.objLiteralMember = ObjLiteral.A; -- Foo.namespaceMember = Namespace.A; -- return Foo; --})(); -+class Foo { + class Foo { + static enumMember = Enum.A; + static objLiteralMember = ObjLiteral.A; + static namespaceMember = Namespace.A; -+} + } +-Foo.enumMember = Enum.A; +-Foo.objLiteralMember = ObjLiteral.A; +-Foo.namespaceMember = Namespace.A; var Enum; (function (Enum) { Enum[Enum["A"] = 0] = "A"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js index 0495c556ba..80ca698ed6 100644 --- a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js +++ b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js @@ -18,6 +18,7 @@ A.a //// [classStaticPropertyAccess.js] +"use strict"; class A { static "\""() { } static x = 1; diff --git a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js.diff b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js.diff index 6be9d96ae2..628c4721f1 100644 --- a/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classStaticPropertyAccess.js.diff @@ -1,25 +1,16 @@ --- old.classStaticPropertyAccess.js +++ new.classStaticPropertyAccess.js -@@= skipped -17, +17 lines =@@ - - - //// [classStaticPropertyAccess.js] --"use strict"; --let A = (() => { -- class A { -- static "\""() { } -- } -- A.x = 1; -- A.y = 1; -- A._b = 2; -- return A; --})(); -+class A { -+ static "\""() { } +@@= skipped -20, +20 lines =@@ + "use strict"; + class A { + static "\""() { } + static x = 1; + static y = 1; + static _b = 2; -+} + } +-A.x = 1; +-A.y = 1; +-A._b = 2; const a = new A(); a["\""]; // Error a['y']; // Error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js b/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js index 465891970f..8f7f6c5ec3 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js +++ b/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js @@ -17,6 +17,7 @@ class Bar { } //// [classVarianceCircularity.js] +"use strict"; // Issue #52813 function f() { const b = new Bar(); diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js.diff b/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js.diff index 5b9f6fa6f1..a49dad8f57 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classVarianceCircularity.js.diff @@ -1,14 +1,6 @@ --- old.classVarianceCircularity.js +++ new.classVarianceCircularity.js -@@= skipped -16, +16 lines =@@ - } - - //// [classVarianceCircularity.js] --"use strict"; - // Issue #52813 - function f() { - const b = new Bar(); -@@= skipped -8, +7 lines =@@ +@@= skipped -24, +24 lines =@@ console.log(b.Value); } class Bar { diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js index 8d63e1fa56..40da5220fb 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js +++ b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js @@ -12,6 +12,7 @@ declare function callme(x: Bar): Bar; declare function callme(x: object): string; //// [classVarianceResolveCircularity1.js] +"use strict"; // Issue #52813 class Bar { num; diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js.diff b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js.diff index 729c5221e5..821429add6 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity1.js.diff @@ -1,10 +1,7 @@ --- old.classVarianceResolveCircularity1.js +++ new.classVarianceResolveCircularity1.js -@@= skipped -11, +11 lines =@@ - declare function callme(x: object): string; - - //// [classVarianceResolveCircularity1.js] --"use strict"; +@@= skipped -14, +14 lines =@@ + "use strict"; // Issue #52813 class Bar { - constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js index 6b54aece8e..192219fc76 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js +++ b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js @@ -22,6 +22,7 @@ class Foo { //// [classVarianceResolveCircularity2.js] "use strict"; +// Issue #52813 Object.defineProperty(exports, "__esModule", { value: true }); class Bar { num; diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff index 46edd29106..5d873414fc 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff @@ -1,10 +1,7 @@ --- old.classVarianceResolveCircularity2.js +++ new.classVarianceResolveCircularity2.js -@@= skipped -21, +21 lines =@@ - - //// [classVarianceResolveCircularity2.js] - "use strict"; --// Issue #52813 +@@= skipped -24, +24 lines =@@ + // Issue #52813 Object.defineProperty(exports, "__esModule", { value: true }); class Bar { - constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/cloduleStaticMembers.js.diff b/testdata/baselines/reference/submodule/compiler/cloduleStaticMembers.js.diff index 97ee21132c..4e32ce7670 100644 --- a/testdata/baselines/reference/submodule/compiler/cloduleStaticMembers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/cloduleStaticMembers.js.diff @@ -1,20 +1,14 @@ --- old.cloduleStaticMembers.js +++ new.cloduleStaticMembers.js -@@= skipped -14, +14 lines =@@ - +@@= skipped -15, +15 lines =@@ //// [cloduleStaticMembers.js] --let Clod = (() => { -- class Clod { -- } -- Clod.x = 10; -- Clod.y = 10; -- return Clod; --})(); -+class Clod { + class Clod { + static x = 10; + static y = 10; -+} + } +-Clod.x = 10; +-Clod.y = 10; (function (Clod) { var p = Clod.x; var q = x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js index 11a05dfa4e..0b9a8f6641 100644 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js +++ b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js @@ -38,6 +38,7 @@ call(actionB, printFn); //// [coAndContraVariantInferences.js] +"use strict"; foo(a, fab); foo(b, fab); const actionA = { payload: 'any-string' }; diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js.diff b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js.diff index 1a8c6131e3..8c094847ae 100644 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js.diff +++ b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences.js.diff @@ -1,14 +1,6 @@ --- old.coAndContraVariantInferences.js +++ new.coAndContraVariantInferences.js -@@= skipped -37, +37 lines =@@ - - - //// [coAndContraVariantInferences.js] --"use strict"; - foo(a, fab); - foo(b, fab); - const actionA = { payload: 'any-string' }; -@@= skipped -35, +34 lines =@@ +@@= skipped -72, +72 lines =@@ declare const actionA: Action<"ACTION_A", string>; declare const actionB: Action<"ACTION_B", boolean>; declare function call(action: Action, fn: (action: Action) => any): void; diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js index 176971245f..8fef332ef4 100644 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js +++ b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js @@ -122,6 +122,7 @@ const x = tryCast(types, isNodeArray); // NodeAray //// [coAndContraVariantInferences2.js] +"use strict"; function f1(a, b) { const x1 = cast(a, isC); // cast const x2 = cast(b, isC); // cast diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js.diff b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js.diff deleted file mode 100644 index a2f51d6248..0000000000 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.coAndContraVariantInferences2.js -+++ new.coAndContraVariantInferences2.js -@@= skipped -121, +121 lines =@@ - - - //// [coAndContraVariantInferences2.js] --"use strict"; - function f1(a, b) { - const x1 = cast(a, isC); // cast - const x2 = cast(b, isC); // cast \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js index d80331eb7f..dc92a6d394 100644 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js +++ b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js @@ -126,6 +126,7 @@ function foo() { //// [coAndContraVariantInferences3.js] +"use strict"; ; buildOverload("updateImportDeclaration") .overload({ diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js.diff b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js.diff deleted file mode 100644 index 3f9ba1f3a4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences3.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.coAndContraVariantInferences3.js -+++ new.coAndContraVariantInferences3.js -@@= skipped -125, +125 lines =@@ - - - //// [coAndContraVariantInferences3.js] --"use strict"; - ; - buildOverload("updateImportDeclaration") - .overload({ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js index 0b872a1384..c7339e1af1 100644 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js +++ b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js @@ -27,6 +27,7 @@ function foo() { //// [coAndContraVariantInferences4.js] +"use strict"; function foo() { every(modifiers, isModifier); every(modifiers, isDecorator); diff --git a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js.diff b/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js.diff deleted file mode 100644 index 4e7608f607..0000000000 --- a/testdata/baselines/reference/submodule/compiler/coAndContraVariantInferences4.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.coAndContraVariantInferences4.js -+++ new.coAndContraVariantInferences4.js -@@= skipped -26, +26 lines =@@ - - - //// [coAndContraVariantInferences4.js] --"use strict"; - function foo() { - every(modifiers, isModifier); - every(modifiers, isDecorator); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionArgumentsArrowFunctions.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/collisionArgumentsArrowFunctions.errors.txt.diff deleted file mode 100644 index f96cac74e5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/collisionArgumentsArrowFunctions.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.collisionArgumentsArrowFunctions.errors.txt -+++ new.collisionArgumentsArrowFunctions.errors.txt -@@= skipped -0, +0 lines =@@ --collisionArgumentsArrowFunctions.ts(1,22): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsArrowFunctions.ts(4,12): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- -- --==== collisionArgumentsArrowFunctions.ts (2 errors) ==== -- var f1 = (i: number, ...arguments) => { //arguments is error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any[]; // no error -- } -- var f12 = (arguments: number, ...rest) => { //arguments is error -- ~~~~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments = 10; // no error -- } -- var f1NoError = (arguments: number) => { // no error -- var arguments = 10; // no error -- } -- -- var f2 = (...restParameters) => { -- var arguments = 10; // No Error -- } -- var f2NoError = () => { -- var arguments = 10; // no error -- } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionArgumentsClassConstructor.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/collisionArgumentsClassConstructor.errors.txt.diff deleted file mode 100644 index 93aee44d32..0000000000 --- a/testdata/baselines/reference/submodule/compiler/collisionArgumentsClassConstructor.errors.txt.diff +++ /dev/null @@ -1,80 +0,0 @@ ---- old.collisionArgumentsClassConstructor.errors.txt -+++ new.collisionArgumentsClassConstructor.errors.txt -@@= skipped -0, +0 lines =@@ --collisionArgumentsClassConstructor.ts(3,28): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassConstructor.ts(3,31): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(4,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(8,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassConstructor.ts(8,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassConstructor.ts(9,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(13,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(14,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(20,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(25,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassConstructor.ts(30,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassConstructor.ts(30,24): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(31,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(35,24): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(36,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(51,31): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(52,31): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassConstructor.ts(53,25): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassConstructor.ts(53,28): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(54,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(59,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(60,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(61,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassConstructor.ts(61,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassConstructor.ts(62,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(67,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassConstructor.ts(68,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -@@= skipped -28, +23 lines =@@ - collisionArgumentsClassConstructor.ts(70,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - - --==== collisionArgumentsClassConstructor.ts (29 errors) ==== -+==== collisionArgumentsClassConstructor.ts (24 errors) ==== - // Constructors - class c1 { - constructor(i: number, ...arguments) { // error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - var arguments: any[]; // no error -@@= skipped -17, +15 lines =@@ - constructor(arguments: number, ...rest) { // error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -- ~~~~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - var arguments = 10; // no error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -@@= skipped -34, +32 lines =@@ - - class c3 { - constructor(public arguments: number, ...restParameters) { //arguments is error -- ~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - var arguments = 10; // no error -@@= skipped -37, +35 lines =@@ - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - constructor(i: any, ...arguments) { // error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - var arguments: any[]; // no error -@@= skipped -20, +18 lines =@@ - constructor(arguments: any, ...rest) { // error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -- ~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - var arguments: any; // no error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionArgumentsClassMethod.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/collisionArgumentsClassMethod.errors.txt.diff deleted file mode 100644 index 7b28f2f76d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/collisionArgumentsClassMethod.errors.txt.diff +++ /dev/null @@ -1,63 +0,0 @@ ---- old.collisionArgumentsClassMethod.errors.txt -+++ new.collisionArgumentsClassMethod.errors.txt -@@= skipped -0, +0 lines =@@ --collisionArgumentsClassMethod.ts(2,27): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassMethod.ts(2,30): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(3,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(5,17): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassMethod.ts(5,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassMethod.ts(6,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(8,23): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(9,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(11,29): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(12,29): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassMethod.ts(13,23): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassMethod.ts(13,26): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(14,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(16,16): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(17,16): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(18,16): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. --collisionArgumentsClassMethod.ts(18,16): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - collisionArgumentsClassMethod.ts(19,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(21,22): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - collisionArgumentsClassMethod.ts(22,22): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -@@= skipped -23, +19 lines =@@ - collisionArgumentsClassMethod.ts(46,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - - --==== collisionArgumentsClassMethod.ts (24 errors) ==== -+==== collisionArgumentsClassMethod.ts (20 errors) ==== - class c1 { - public foo(i: number, ...arguments) { //arguments is error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - var arguments: any[]; // no error -@@= skipped -14, +12 lines =@@ - public foo1(arguments: number, ...rest) { //arguments is error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -- ~~~~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - var arguments = 10; // no error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -@@= skipped -20, +18 lines =@@ - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - public f4(i: any, ...arguments) { // error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. - var arguments: any[]; // no error -@@= skipped -17, +15 lines =@@ - public f41(arguments: any, ...rest) { // error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -- ~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. - var arguments: any; // no error - ~~~~~~~~~ - !!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionArgumentsFunction.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/collisionArgumentsFunction.errors.txt.diff deleted file mode 100644 index d7fd771020..0000000000 --- a/testdata/baselines/reference/submodule/compiler/collisionArgumentsFunction.errors.txt.diff +++ /dev/null @@ -1,63 +0,0 @@ ---- old.collisionArgumentsFunction.errors.txt -+++ new.collisionArgumentsFunction.errors.txt -@@= skipped -0, +0 lines =@@ --collisionArgumentsFunction.ts(2,13): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsFunction.ts(5,25): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsFunction.ts(25,13): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsFunction.ts(30,22): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- -- --==== collisionArgumentsFunction.ts (4 errors) ==== -- // Functions -- function f1(arguments: number, ...restParameters) { //arguments is error -- ~~~~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments = 10; // no error -- } -- function f12(i: number, ...arguments) { //arguments is error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any[]; // no error -- } -- function f1NoError(arguments: number) { // no error -- var arguments = 10; // no error -- } -- -- declare function f2(i: number, ...arguments); // no error - no code gen -- declare function f21(arguments: number, ...rest); // no error - no code gen -- declare function f2NoError(arguments: number); // no error -- -- function f3(...restParameters) { -- var arguments = 10; // no error -- } -- function f3NoError() { -- var arguments = 10; // no error -- } -- -- function f4(arguments: number, ...rest); // no codegen no error -- function f4(arguments: string, ...rest); // no codegen no error -- function f4(arguments: any, ...rest) { // error -- ~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any; // No error -- } -- function f42(i: number, ...arguments); // no codegen no error -- function f42(i: string, ...arguments); // no codegen no error -- function f42(i: any, ...arguments) { // error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any[]; // No error -- } -- function f4NoError(arguments: number); // no error -- function f4NoError(arguments: string); // no error -- function f4NoError(arguments: any) { // no error -- var arguments: any; // No error -- } -- -- declare function f5(arguments: number, ...rest); // no codegen no error -- declare function f5(arguments: string, ...rest); // no codegen no error -- declare function f52(i: number, ...arguments); // no codegen no error -- declare function f52(i: string, ...arguments); // no codegen no error -- declare function f6(arguments: number); // no codegen no error -- declare function f6(arguments: string); // no codegen no error -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionArgumentsFunctionExpressions.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/collisionArgumentsFunctionExpressions.errors.txt.diff deleted file mode 100644 index b07df7399a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/collisionArgumentsFunctionExpressions.errors.txt.diff +++ /dev/null @@ -1,53 +0,0 @@ ---- old.collisionArgumentsFunctionExpressions.errors.txt -+++ new.collisionArgumentsFunctionExpressions.errors.txt -@@= skipped -0, +0 lines =@@ --collisionArgumentsFunctionExpressions.ts(2,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsFunctionExpressions.ts(5,29): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsFunctionExpressions.ts(21,17): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. --collisionArgumentsFunctionExpressions.ts(26,26): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- -- --==== collisionArgumentsFunctionExpressions.ts (4 errors) ==== -- function foo() { -- function f1(arguments: number, ...restParameters) { //arguments is error -- ~~~~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments = 10; // no error -- } -- function f12(i: number, ...arguments) { //arguments is error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any[]; // no error -- } -- function f1NoError(arguments: number) { // no error -- var arguments = 10; // no error -- } -- -- function f3(...restParameters) { -- var arguments = 10; // no error -- } -- function f3NoError() { -- var arguments = 10; // no error -- } -- -- function f4(arguments: number, ...rest); // no codegen no error -- function f4(arguments: string, ...rest); // no codegen no error -- function f4(arguments: any, ...rest) { // error -- ~~~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any; // No error -- } -- function f42(i: number, ...arguments); // no codegen no error -- function f42(i: string, ...arguments); // no codegen no error -- function f42(i: any, ...arguments) { // error -- ~~~~~~~~~~~~ --!!! error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. -- var arguments: any[]; // No error -- } -- function f4NoError(arguments: number); // no error -- function f4NoError(arguments: string); // no error -- function f4NoError(arguments: any) { // no error -- var arguments: any; // No error -- } -- } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.errors.txt b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.errors.txt new file mode 100644 index 0000000000..8a030e687c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.errors.txt @@ -0,0 +1,24 @@ +collisionExportsRequireAndAlias_file2.ts(1,8): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +collisionExportsRequireAndAlias_file2.ts(2,8): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + + +==== collisionExportsRequireAndAlias_file2.ts (2 errors) ==== + import require = require('./collisionExportsRequireAndAlias_file1'); // Error + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + import exports = require('./collisionExportsRequireAndAlias_file3333'); // Error + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + export function foo() { + require.bar(); + } + export function foo2() { + exports.bar2(); + } +==== collisionExportsRequireAndAlias_file1.ts (0 errors) ==== + export function bar() { + } + +==== collisionExportsRequireAndAlias_file3333.ts (0 errors) ==== + export function bar2() { + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.js b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.js new file mode 100644 index 0000000000..45cf142de2 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAlias.ts] //// + +//// [collisionExportsRequireAndAlias_file1.ts] +export function bar() { +} + +//// [collisionExportsRequireAndAlias_file3333.ts] +export function bar2() { +} +//// [collisionExportsRequireAndAlias_file2.ts] +import require = require('./collisionExportsRequireAndAlias_file1'); // Error +import exports = require('./collisionExportsRequireAndAlias_file3333'); // Error +export function foo() { + require.bar(); +} +export function foo2() { + exports.bar2(); +} + +//// [collisionExportsRequireAndAlias_file1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bar = bar; +function bar() { +} +//// [collisionExportsRequireAndAlias_file3333.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bar2 = bar2; +function bar2() { +} +//// [collisionExportsRequireAndAlias_file2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +exports.foo2 = foo2; +const require = require("./collisionExportsRequireAndAlias_file1"); // Error +const exports = require("./collisionExportsRequireAndAlias_file3333"); // Error +function foo() { + require.bar(); +} +function foo2() { + exports.bar2(); +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.symbols b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.symbols new file mode 100644 index 0000000000..471d8d7742 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.symbols @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAlias.ts] //// + +=== collisionExportsRequireAndAlias_file2.ts === +import require = require('./collisionExportsRequireAndAlias_file1'); // Error +>require : Symbol(require, Decl(collisionExportsRequireAndAlias_file2.ts, 0, 0)) + +import exports = require('./collisionExportsRequireAndAlias_file3333'); // Error +>exports : Symbol(exports, Decl(collisionExportsRequireAndAlias_file2.ts, 0, 68)) + +export function foo() { +>foo : Symbol(foo, Decl(collisionExportsRequireAndAlias_file2.ts, 1, 71)) + + require.bar(); +>require.bar : Symbol(require.bar, Decl(collisionExportsRequireAndAlias_file1.ts, 0, 0)) +>require : Symbol(require, Decl(collisionExportsRequireAndAlias_file2.ts, 0, 0)) +>bar : Symbol(require.bar, Decl(collisionExportsRequireAndAlias_file1.ts, 0, 0)) +} +export function foo2() { +>foo2 : Symbol(foo2, Decl(collisionExportsRequireAndAlias_file2.ts, 4, 1)) + + exports.bar2(); +>exports.bar2 : Symbol(exports.bar2, Decl(collisionExportsRequireAndAlias_file3333.ts, 0, 0)) +>exports : Symbol(exports, Decl(collisionExportsRequireAndAlias_file2.ts, 0, 68)) +>bar2 : Symbol(exports.bar2, Decl(collisionExportsRequireAndAlias_file3333.ts, 0, 0)) +} +=== collisionExportsRequireAndAlias_file1.ts === +export function bar() { +>bar : Symbol(bar, Decl(collisionExportsRequireAndAlias_file1.ts, 0, 0)) +} + +=== collisionExportsRequireAndAlias_file3333.ts === +export function bar2() { +>bar2 : Symbol(bar2, Decl(collisionExportsRequireAndAlias_file3333.ts, 0, 0)) +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.types b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.types new file mode 100644 index 0000000000..72ef2678f7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAlias.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAlias.ts] //// + +=== collisionExportsRequireAndAlias_file2.ts === +import require = require('./collisionExportsRequireAndAlias_file1'); // Error +>require : typeof require + +import exports = require('./collisionExportsRequireAndAlias_file3333'); // Error +>exports : typeof exports + +export function foo() { +>foo : () => void + + require.bar(); +>require.bar() : void +>require.bar : () => void +>require : typeof require +>bar : () => void +} +export function foo2() { +>foo2 : () => void + + exports.bar2(); +>exports.bar2() : void +>exports.bar2 : () => void +>exports : typeof exports +>bar2 : () => void +} +=== collisionExportsRequireAndAlias_file1.ts === +export function bar() { +>bar : () => void +} + +=== collisionExportsRequireAndAlias_file3333.ts === +export function bar2() { +>bar2 : () => void +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.js b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.js new file mode 100644 index 0000000000..0643e7fcff --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.js @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientClass.ts] //// + +//// [collisionExportsRequireAndAmbientClass_externalmodule.ts] +export declare class require { +} +export declare class exports { +} +declare module m1 { + class require { + } + class exports { + } +} +module m2 { + export declare class require { + } + export declare class exports { + } +} + +//// [collisionExportsRequireAndAmbientClass_globalFile.ts] +declare class require { +} +declare class exports { +} +declare module m3 { + class require { + } + class exports { + } +} +module m4 { + export declare class require { + } + export declare class exports { + } + var a = 10; +} + +//// [collisionExportsRequireAndAmbientClass_externalmodule.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var m2; +(function (m2) { +})(m2 || (m2 = {})); +//// [collisionExportsRequireAndAmbientClass_globalFile.js] +var m4; +(function (m4) { + var a = 10; +})(m4 || (m4 = {})); diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.symbols b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.symbols new file mode 100644 index 0000000000..8a6569dfdc --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.symbols @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientClass.ts] //// + +=== collisionExportsRequireAndAmbientClass_externalmodule.ts === +export declare class require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 0, 0)) +} +export declare class exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 1, 1)) +} +declare module m1 { +>m1 : Symbol(m1, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 3, 1)) + + class require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 4, 19)) + } + class exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 6, 5)) + } +} +module m2 { +>m2 : Symbol(m2, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 9, 1)) + + export declare class require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 10, 11)) + } + export declare class exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientClass_externalmodule.ts, 12, 5)) + } +} + +=== collisionExportsRequireAndAmbientClass_globalFile.ts === +declare class require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 0, 0)) +} +declare class exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 1, 1)) +} +declare module m3 { +>m3 : Symbol(m3, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 3, 1)) + + class require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 4, 19)) + } + class exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 6, 5)) + } +} +module m4 { +>m4 : Symbol(m4, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 9, 1)) + + export declare class require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 10, 11)) + } + export declare class exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 12, 5)) + } + var a = 10; +>a : Symbol(a, Decl(collisionExportsRequireAndAmbientClass_globalFile.ts, 15, 7)) +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.types b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.types new file mode 100644 index 0000000000..0405ace4d3 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientClass.types @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientClass.ts] //// + +=== collisionExportsRequireAndAmbientClass_externalmodule.ts === +export declare class require { +>require : require +} +export declare class exports { +>exports : exports +} +declare module m1 { +>m1 : typeof m1 + + class require { +>require : require + } + class exports { +>exports : exports + } +} +module m2 { +>m2 : typeof m2 + + export declare class require { +>require : require + } + export declare class exports { +>exports : exports + } +} + +=== collisionExportsRequireAndAmbientClass_globalFile.ts === +declare class require { +>require : require +} +declare class exports { +>exports : exports +} +declare module m3 { +>m3 : typeof m3 + + class require { +>require : require + } + class exports { +>exports : exports + } +} +module m4 { +>m4 : typeof m4 + + export declare class require { +>require : require + } + export declare class exports { +>exports : exports + } + var a = 10; +>a : number +>10 : 10 +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.js b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.js new file mode 100644 index 0000000000..c0014da295 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.js @@ -0,0 +1,72 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientEnum.ts] //// + +//// [collisionExportsRequireAndAmbientEnum_externalmodule.ts] +export declare enum require { + _thisVal1, + _thisVal2, +} +export declare enum exports { + _thisVal1, + _thisVal2, +} +declare module m1 { + enum require { + _thisVal1, + _thisVal2, + } + enum exports { + _thisVal1, + _thisVal2, + } +} +module m2 { + export declare enum require { + _thisVal1, + _thisVal2, + } + export declare enum exports { + _thisVal1, + _thisVal2, + } +} + +//// [collisionExportsRequireAndAmbientEnum_globalFile.ts] +declare enum require { + _thisVal1, + _thisVal2, +} +declare enum exports { + _thisVal1, + _thisVal2, +} +declare module m3 { + enum require { + _thisVal1, + _thisVal2, + } + enum exports { + _thisVal1, + _thisVal2, + } +} +module m4 { + export declare enum require { + _thisVal1, + _thisVal2, + } + export declare enum exports { + _thisVal1, + _thisVal2, + } +} + +//// [collisionExportsRequireAndAmbientEnum_externalmodule.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var m2; +(function (m2) { +})(m2 || (m2 = {})); +//// [collisionExportsRequireAndAmbientEnum_globalFile.js] +var m4; +(function (m4) { +})(m4 || (m4 = {})); diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.symbols b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.symbols new file mode 100644 index 0000000000..2e615c974d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.symbols @@ -0,0 +1,129 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientEnum.ts] //// + +=== collisionExportsRequireAndAmbientEnum_externalmodule.ts === +export declare enum require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 0, 0)) + + _thisVal1, +>_thisVal1 : Symbol(require._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 0, 29)) + + _thisVal2, +>_thisVal2 : Symbol(require._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 1, 14)) +} +export declare enum exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 3, 1)) + + _thisVal1, +>_thisVal1 : Symbol(exports._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 4, 29)) + + _thisVal2, +>_thisVal2 : Symbol(exports._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 5, 14)) +} +declare module m1 { +>m1 : Symbol(m1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 7, 1)) + + enum require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 8, 19)) + + _thisVal1, +>_thisVal1 : Symbol(require._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 9, 18)) + + _thisVal2, +>_thisVal2 : Symbol(require._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 10, 18)) + } + enum exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 12, 5)) + + _thisVal1, +>_thisVal1 : Symbol(exports._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 13, 18)) + + _thisVal2, +>_thisVal2 : Symbol(exports._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 14, 18)) + } +} +module m2 { +>m2 : Symbol(m2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 17, 1)) + + export declare enum require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 18, 11)) + + _thisVal1, +>_thisVal1 : Symbol(require._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 19, 33)) + + _thisVal2, +>_thisVal2 : Symbol(require._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 20, 18)) + } + export declare enum exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 22, 5)) + + _thisVal1, +>_thisVal1 : Symbol(exports._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 23, 33)) + + _thisVal2, +>_thisVal2 : Symbol(exports._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_externalmodule.ts, 24, 18)) + } +} + +=== collisionExportsRequireAndAmbientEnum_globalFile.ts === +declare enum require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 0, 0)) + + _thisVal1, +>_thisVal1 : Symbol(require._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 0, 22)) + + _thisVal2, +>_thisVal2 : Symbol(require._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 1, 14)) +} +declare enum exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 3, 1)) + + _thisVal1, +>_thisVal1 : Symbol(exports._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 4, 22)) + + _thisVal2, +>_thisVal2 : Symbol(exports._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 5, 14)) +} +declare module m3 { +>m3 : Symbol(m3, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 7, 1)) + + enum require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 8, 19)) + + _thisVal1, +>_thisVal1 : Symbol(require._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 9, 18)) + + _thisVal2, +>_thisVal2 : Symbol(require._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 10, 18)) + } + enum exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 12, 5)) + + _thisVal1, +>_thisVal1 : Symbol(exports._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 13, 18)) + + _thisVal2, +>_thisVal2 : Symbol(exports._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 14, 18)) + } +} +module m4 { +>m4 : Symbol(m4, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 17, 1)) + + export declare enum require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 18, 11)) + + _thisVal1, +>_thisVal1 : Symbol(require._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 19, 33)) + + _thisVal2, +>_thisVal2 : Symbol(require._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 20, 18)) + } + export declare enum exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 22, 5)) + + _thisVal1, +>_thisVal1 : Symbol(exports._thisVal1, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 23, 33)) + + _thisVal2, +>_thisVal2 : Symbol(exports._thisVal2, Decl(collisionExportsRequireAndAmbientEnum_globalFile.ts, 24, 18)) + } +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.types b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.types new file mode 100644 index 0000000000..e64df56329 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientEnum.types @@ -0,0 +1,129 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientEnum.ts] //// + +=== collisionExportsRequireAndAmbientEnum_externalmodule.ts === +export declare enum require { +>require : require + + _thisVal1, +>_thisVal1 : require._thisVal1 + + _thisVal2, +>_thisVal2 : require._thisVal2 +} +export declare enum exports { +>exports : exports + + _thisVal1, +>_thisVal1 : exports._thisVal1 + + _thisVal2, +>_thisVal2 : exports._thisVal2 +} +declare module m1 { +>m1 : typeof m1 + + enum require { +>require : require + + _thisVal1, +>_thisVal1 : require._thisVal1 + + _thisVal2, +>_thisVal2 : require._thisVal2 + } + enum exports { +>exports : exports + + _thisVal1, +>_thisVal1 : exports._thisVal1 + + _thisVal2, +>_thisVal2 : exports._thisVal2 + } +} +module m2 { +>m2 : typeof m2 + + export declare enum require { +>require : require + + _thisVal1, +>_thisVal1 : require._thisVal1 + + _thisVal2, +>_thisVal2 : require._thisVal2 + } + export declare enum exports { +>exports : exports + + _thisVal1, +>_thisVal1 : exports._thisVal1 + + _thisVal2, +>_thisVal2 : exports._thisVal2 + } +} + +=== collisionExportsRequireAndAmbientEnum_globalFile.ts === +declare enum require { +>require : require + + _thisVal1, +>_thisVal1 : require._thisVal1 + + _thisVal2, +>_thisVal2 : require._thisVal2 +} +declare enum exports { +>exports : exports + + _thisVal1, +>_thisVal1 : exports._thisVal1 + + _thisVal2, +>_thisVal2 : exports._thisVal2 +} +declare module m3 { +>m3 : typeof m3 + + enum require { +>require : require + + _thisVal1, +>_thisVal1 : require._thisVal1 + + _thisVal2, +>_thisVal2 : require._thisVal2 + } + enum exports { +>exports : exports + + _thisVal1, +>_thisVal1 : exports._thisVal1 + + _thisVal2, +>_thisVal2 : exports._thisVal2 + } +} +module m4 { +>m4 : typeof m4 + + export declare enum require { +>require : require + + _thisVal1, +>_thisVal1 : require._thisVal1 + + _thisVal2, +>_thisVal2 : require._thisVal2 + } + export declare enum exports { +>exports : exports + + _thisVal1, +>_thisVal1 : exports._thisVal1 + + _thisVal2, +>_thisVal2 : exports._thisVal2 + } +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.js b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.js new file mode 100644 index 0000000000..92782b0797 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientFunction.ts] //// + +//// [collisionExportsRequireAndAmbientFunction.ts] +export declare function exports(): number; + +export declare function require(): string[]; + +declare module m1 { + function exports(): string; + function require(): number; +} +module m2 { + export declare function exports(): string; + export declare function require(): string[]; + var a = 10; +} + +//// [collisionExportsRequireAndAmbientFunction.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var m2; +(function (m2) { + var a = 10; +})(m2 || (m2 = {})); diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.symbols b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.symbols new file mode 100644 index 0000000000..a97d0b1a31 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.symbols @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientFunction.ts] //// + +=== collisionExportsRequireAndAmbientFunction.ts === +export declare function exports(): number; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientFunction.ts, 0, 0)) + +export declare function require(): string[]; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientFunction.ts, 0, 42)) + +declare module m1 { +>m1 : Symbol(m1, Decl(collisionExportsRequireAndAmbientFunction.ts, 2, 44)) + + function exports(): string; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientFunction.ts, 4, 19)) + + function require(): number; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientFunction.ts, 5, 31)) +} +module m2 { +>m2 : Symbol(m2, Decl(collisionExportsRequireAndAmbientFunction.ts, 7, 1)) + + export declare function exports(): string; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientFunction.ts, 8, 11)) + + export declare function require(): string[]; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientFunction.ts, 9, 46)) + + var a = 10; +>a : Symbol(a, Decl(collisionExportsRequireAndAmbientFunction.ts, 11, 7)) +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.types b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.types new file mode 100644 index 0000000000..854f8d0596 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientFunction.types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientFunction.ts] //// + +=== collisionExportsRequireAndAmbientFunction.ts === +export declare function exports(): number; +>exports : () => number + +export declare function require(): string[]; +>require : () => string[] + +declare module m1 { +>m1 : typeof m1 + + function exports(): string; +>exports : () => string + + function require(): number; +>require : () => number +} +module m2 { +>m2 : typeof m2 + + export declare function exports(): string; +>exports : () => string + + export declare function require(): string[]; +>require : () => string[] + + var a = 10; +>a : number +>10 : 10 +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.js b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.js new file mode 100644 index 0000000000..65520e644e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.js @@ -0,0 +1,116 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientModule.ts] //// + +//// [collisionExportsRequireAndAmbientModule_externalmodule.ts] +export declare module require { + export interface I { + } + export class C { + } +} +export function foo(): require.I { + return null; +} +export declare module exports { + export interface I { + } + export class C { + } +} +export function foo2(): exports.I { + return null; +} +declare module m1 { + module require { + export interface I { + } + export class C { + } + } + module exports { + export interface I { + } + export class C { + } + } +} +module m2 { + export declare module require { + export interface I { + } + export class C { + } + } + export declare module exports { + export interface I { + } + export class C { + } + } + var a = 10; +} + +//// [collisionExportsRequireAndAmbientModule_globalFile.ts] +declare module require { + export interface I { + } + export class C { + } +} +declare module exports { + export interface I { + } + export class C { + } +} +declare module m3 { + module require { + export interface I { + } + export class C { + } + } + module exports { + export interface I { + } + export class C { + } + } +} +module m4 { + export declare module require { + export interface I { + } + export class C { + } + } + export declare module exports { + export interface I { + } + export class C { + } + } + + var a = 10; +} + + +//// [collisionExportsRequireAndAmbientModule_externalmodule.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +exports.foo2 = foo2; +function foo() { + return null; +} +function foo2() { + return null; +} +var m2; +(function (m2) { + var a = 10; +})(m2 || (m2 = {})); +//// [collisionExportsRequireAndAmbientModule_globalFile.js] +var m4; +(function (m4) { + var a = 10; +})(m4 || (m4 = {})); diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.symbols b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.symbols new file mode 100644 index 0000000000..063b12f4d8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.symbols @@ -0,0 +1,161 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientModule.ts] //// + +=== collisionExportsRequireAndAmbientModule_externalmodule.ts === +export declare module require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 0, 0)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 0, 31)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 2, 5)) + } +} +export function foo(): require.I { +>foo : Symbol(foo, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 5, 1)) +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 0, 0)) +>I : Symbol(require.I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 0, 31)) + + return null; +} +export declare module exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 8, 1)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 9, 31)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 11, 5)) + } +} +export function foo2(): exports.I { +>foo2 : Symbol(foo2, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 14, 1)) +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 8, 1)) +>I : Symbol(exports.I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 9, 31)) + + return null; +} +declare module m1 { +>m1 : Symbol(m1, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 17, 1)) + + module require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 18, 19)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 19, 20)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 21, 9)) + } + } + module exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 24, 5)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 25, 20)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 27, 9)) + } + } +} +module m2 { +>m2 : Symbol(m2, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 31, 1)) + + export declare module require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 32, 11)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 33, 35)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 35, 9)) + } + } + export declare module exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 38, 5)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 39, 35)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 41, 9)) + } + } + var a = 10; +>a : Symbol(a, Decl(collisionExportsRequireAndAmbientModule_externalmodule.ts, 45, 7)) +} + +=== collisionExportsRequireAndAmbientModule_globalFile.ts === +declare module require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 0, 0)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 0, 24)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 2, 5)) + } +} +declare module exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 5, 1)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 6, 24)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 8, 5)) + } +} +declare module m3 { +>m3 : Symbol(m3, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 11, 1)) + + module require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 12, 19)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 13, 20)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 15, 9)) + } + } + module exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 18, 5)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 19, 20)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 21, 9)) + } + } +} +module m4 { +>m4 : Symbol(m4, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 25, 1)) + + export declare module require { +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 26, 11)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 27, 35)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 29, 9)) + } + } + export declare module exports { +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 32, 5)) + + export interface I { +>I : Symbol(I, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 33, 35)) + } + export class C { +>C : Symbol(C, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 35, 9)) + } + } + + var a = 10; +>a : Symbol(a, Decl(collisionExportsRequireAndAmbientModule_globalFile.ts, 40, 7)) +} + diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.types b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.types new file mode 100644 index 0000000000..f4fff9019a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientModule.types @@ -0,0 +1,149 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientModule.ts] //// + +=== collisionExportsRequireAndAmbientModule_externalmodule.ts === +export declare module require { +>require : typeof require + + export interface I { + } + export class C { +>C : C + } +} +export function foo(): require.I { +>foo : () => require.I +>require : any + + return null; +} +export declare module exports { +>exports : typeof exports + + export interface I { + } + export class C { +>C : C + } +} +export function foo2(): exports.I { +>foo2 : () => exports.I +>exports : any + + return null; +} +declare module m1 { +>m1 : typeof m1 + + module require { +>require : typeof require + + export interface I { + } + export class C { +>C : C + } + } + module exports { +>exports : typeof exports + + export interface I { + } + export class C { +>C : C + } + } +} +module m2 { +>m2 : typeof m2 + + export declare module require { +>require : typeof require + + export interface I { + } + export class C { +>C : C + } + } + export declare module exports { +>exports : typeof exports + + export interface I { + } + export class C { +>C : C + } + } + var a = 10; +>a : number +>10 : 10 +} + +=== collisionExportsRequireAndAmbientModule_globalFile.ts === +declare module require { +>require : typeof require + + export interface I { + } + export class C { +>C : C + } +} +declare module exports { +>exports : typeof exports + + export interface I { + } + export class C { +>C : C + } +} +declare module m3 { +>m3 : typeof m3 + + module require { +>require : typeof require + + export interface I { + } + export class C { +>C : C + } + } + module exports { +>exports : typeof exports + + export interface I { + } + export class C { +>C : C + } + } +} +module m4 { +>m4 : typeof m4 + + export declare module require { +>require : typeof require + + export interface I { + } + export class C { +>C : C + } + } + export declare module exports { +>exports : typeof exports + + export interface I { + } + export class C { +>C : C + } + } + + var a = 10; +>a : number +>10 : 10 +} + diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.js b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.js new file mode 100644 index 0000000000..cbfed4ad76 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientVar.ts] //// + +//// [collisionExportsRequireAndAmbientVar_externalmodule.ts] +export declare var exports: number; +export declare var require: string; +declare module m1 { + var exports: string; + var require: number; +} +module m2 { + export declare var exports: number; + export declare var require: string; + var a = 10; +} + +//// [collisionExportsRequireAndAmbientVar_globalFile.ts] +declare var exports: number; +declare var require: string; +declare module m3 { + var exports: string; + var require: number; +} +module m4 { + export declare var exports: string; + export declare var require: number; + var a = 10; +} + +//// [collisionExportsRequireAndAmbientVar_externalmodule.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var m2; +(function (m2) { + var a = 10; +})(m2 || (m2 = {})); +//// [collisionExportsRequireAndAmbientVar_globalFile.js] +var m4; +(function (m4) { + var a = 10; +})(m4 || (m4 = {})); diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.symbols b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.symbols new file mode 100644 index 0000000000..2519959c57 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.symbols @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientVar.ts] //// + +=== collisionExportsRequireAndAmbientVar_externalmodule.ts === +export declare var exports: number; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 0, 18)) + +export declare var require: string; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 1, 18)) + +declare module m1 { +>m1 : Symbol(m1, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 1, 35)) + + var exports: string; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 3, 7)) + + var require: number; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 4, 7)) +} +module m2 { +>m2 : Symbol(m2, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 5, 1)) + + export declare var exports: number; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 7, 22)) + + export declare var require: string; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 8, 22)) + + var a = 10; +>a : Symbol(a, Decl(collisionExportsRequireAndAmbientVar_externalmodule.ts, 9, 7)) +} + +=== collisionExportsRequireAndAmbientVar_globalFile.ts === +declare var exports: number; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 0, 11)) + +declare var require: string; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 1, 11)) + +declare module m3 { +>m3 : Symbol(m3, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 1, 28)) + + var exports: string; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 3, 7)) + + var require: number; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 4, 7)) +} +module m4 { +>m4 : Symbol(m4, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 5, 1)) + + export declare var exports: string; +>exports : Symbol(exports, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 7, 22)) + + export declare var require: number; +>require : Symbol(require, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 8, 22)) + + var a = 10; +>a : Symbol(a, Decl(collisionExportsRequireAndAmbientVar_globalFile.ts, 9, 7)) +} diff --git a/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.types b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.types new file mode 100644 index 0000000000..d87ed7d386 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/collisionExportsRequireAndAmbientVar.types @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/collisionExportsRequireAndAmbientVar.ts] //// + +=== collisionExportsRequireAndAmbientVar_externalmodule.ts === +export declare var exports: number; +>exports : number + +export declare var require: string; +>require : string + +declare module m1 { +>m1 : typeof m1 + + var exports: string; +>exports : string + + var require: number; +>require : number +} +module m2 { +>m2 : typeof m2 + + export declare var exports: number; +>exports : number + + export declare var require: string; +>require : string + + var a = 10; +>a : number +>10 : 10 +} + +=== collisionExportsRequireAndAmbientVar_globalFile.ts === +declare var exports: number; +>exports : number + +declare var require: string; +>require : string + +declare module m3 { +>m3 : typeof m3 + + var exports: string; +>exports : string + + var require: number; +>require : number +} +module m4 { +>m4 : typeof m4 + + export declare var exports: string; +>exports : string + + export declare var require: number; +>require : number + + var a = 10; +>a : number +>10 : 10 +} diff --git a/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt b/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt index 9782db2c66..b44bd405e2 100644 --- a/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt @@ -21,9 +21,10 @@ commaOperatorLeftSideUnused.ts(38,7): error TS2695: Left side of comma operator commaOperatorLeftSideUnused.ts(39,7): error TS2695: Left side of comma operator is unused and has no side effects. commaOperatorLeftSideUnused.ts(40,7): error TS2695: Left side of comma operator is unused and has no side effects. commaOperatorLeftSideUnused.ts(41,7): error TS2695: Left side of comma operator is unused and has no side effects. +commaOperatorLeftSideUnused.ts(42,7): error TS2695: Left side of comma operator is unused and has no side effects. -==== commaOperatorLeftSideUnused.ts (23 errors) ==== +==== commaOperatorLeftSideUnused.ts (24 errors) ==== var xx: any; var yy: any; @@ -112,6 +113,8 @@ commaOperatorLeftSideUnused.ts(41,7): error TS2695: Left side of comma operator ~~~ !!! error TS2695: Left side of comma operator is unused and has no side effects. xx = (0, xx)(); + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. // OK cases xx = (xx ? x++ : 4, 10); diff --git a/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt.diff deleted file mode 100644 index bf62524147..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.commaOperatorLeftSideUnused.errors.txt -+++ new.commaOperatorLeftSideUnused.errors.txt -@@= skipped -20, +20 lines =@@ - commaOperatorLeftSideUnused.ts(39,7): error TS2695: Left side of comma operator is unused and has no side effects. - commaOperatorLeftSideUnused.ts(40,7): error TS2695: Left side of comma operator is unused and has no side effects. - commaOperatorLeftSideUnused.ts(41,7): error TS2695: Left side of comma operator is unused and has no side effects. --commaOperatorLeftSideUnused.ts(42,7): error TS2695: Left side of comma operator is unused and has no side effects. -- -- --==== commaOperatorLeftSideUnused.ts (24 errors) ==== -+ -+ -+==== commaOperatorLeftSideUnused.ts (23 errors) ==== - var xx: any; - var yy: any; - -@@= skipped -92, +91 lines =@@ - ~~~ - !!! error TS2695: Left side of comma operator is unused and has no side effects. - xx = (0, xx)(); -- ~ --!!! error TS2695: Left side of comma operator is unused and has no side effects. - - // OK cases - xx = (xx ? x++ : 4, 10); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js index 4733da1abc..9837da4c37 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js @@ -20,5 +20,9 @@ declare class E extends C { } //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js.diff deleted file mode 100644 index 87a1fe8499..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientClass1.js -+++ new.commentOnAmbientClass1.js -@@= skipped -19, +19 lines =@@ - } - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js index c95f0fc511..f6c9d92ebf 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js @@ -23,5 +23,9 @@ declare enum E { } //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js.diff deleted file mode 100644 index 8f095b3b11..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientEnum.js -+++ new.commentOnAmbientEnum.js -@@= skipped -22, +22 lines =@@ - } - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js index 921318e96a..2d43b502f2 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js @@ -25,5 +25,9 @@ declare module E { } //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js.diff deleted file mode 100644 index 8b147b4f4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientModule.js -+++ new.commentOnAmbientModule.js -@@= skipped -24, +24 lines =@@ - } - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js index 493a0cb7e8..5220f0f1b0 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js @@ -13,3 +13,7 @@ declare var v: number; declare var y: number; //// [commentOnAmbientVariable1.js] +/*!========= + Keep this pinned comment + ========= +*/ diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js.diff deleted file mode 100644 index acf7a59f1e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.commentOnAmbientVariable1.js -+++ new.commentOnAmbientVariable1.js -@@= skipped -12, +12 lines =@@ - declare var y: number; - - //// [commentOnAmbientVariable1.js] --/*!========= -- Keep this pinned comment -- ========= --*/ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js index 52a825d649..2261323694 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js @@ -17,5 +17,9 @@ declare function bar(); declare function foobar(a: typeof foo): typeof bar; //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js.diff deleted file mode 100644 index 55a2349f41..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientfunction.js -+++ new.commentOnAmbientfunction.js -@@= skipped -16, +16 lines =@@ - declare function foobar(a: typeof foo): typeof bar; - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnDecoratedClassDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnDecoratedClassDeclaration.js.diff index 59009c5314..ac7bbf9634 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnDecoratedClassDeclaration.js.diff +++ b/testdata/baselines/reference/submodule/compiler/commentOnDecoratedClassDeclaration.js.diff @@ -13,30 +13,23 @@ /** * Leading trivia */ --let Remote = (() => { -- let Remote = class Remote { -- }; -- Remote = __decorate([ -- decorator("hello") -- ], Remote); -- return Remote; --})(); +-let Remote = class Remote { +-}; +-Remote = __decorate([ +- decorator("hello") +-], Remote); +@decorator("hello") +class Remote { +} /** * Floating Comment */ --let AnotherRomote = (() => { -- let AnotherRomote = class AnotherRomote { -- constructor() { } -- }; -- AnotherRomote = __decorate([ -- decorator("hi") -- ], AnotherRomote); -- return AnotherRomote; --})(); +-let AnotherRomote = class AnotherRomote { +@decorator("hi") +class AnotherRomote { -+ constructor() { } + constructor() { } +-}; +-AnotherRomote = __decorate([ +- decorator("hi") +-], AnotherRomote); +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js b/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js index 3b7d9b4daf..72585e6a9e 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js @@ -20,5 +20,9 @@ module ElidedModule3 { } //// [a.js] +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js.diff deleted file mode 100644 index 861acd202b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnElidedModule1.js -+++ new.commentOnElidedModule1.js -@@= skipped -19, +19 lines =@@ - } - - //// [a.js] --/*!================= -- Keep this pinned -- ================= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.errors.txt b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.errors.txt new file mode 100644 index 0000000000..4e5cb3b10c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.errors.txt @@ -0,0 +1,10 @@ +commentOnImportStatement1.ts(3,22): error TS2307: Cannot find module './foo' or its corresponding type declarations. + + +==== commentOnImportStatement1.ts (1 errors) ==== + /* Copyright */ + + import foo = require('./foo'); + ~~~~~~~ +!!! error TS2307: Cannot find module './foo' or its corresponding type declarations. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.js b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.js new file mode 100644 index 0000000000..93eb14b9a4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/commentOnImportStatement1.ts] //// + +//// [commentOnImportStatement1.ts] +/* Copyright */ + +import foo = require('./foo'); + + +//// [commentOnImportStatement1.js] +"use strict"; +/* Copyright */ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.symbols b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.symbols new file mode 100644 index 0000000000..b1ece547be --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/commentOnImportStatement1.ts] //// + +=== commentOnImportStatement1.ts === +/* Copyright */ + +import foo = require('./foo'); +>foo : Symbol(foo, Decl(commentOnImportStatement1.ts, 0, 0)) + diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.types b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.types new file mode 100644 index 0000000000..2409882770 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement1.types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/commentOnImportStatement1.ts] //// + +=== commentOnImportStatement1.ts === +/* Copyright */ + +import foo = require('./foo'); +>foo : any + diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js index 6968403a0a..96d1f097e3 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js @@ -8,4 +8,5 @@ import foo = require('./foo'); //// [commentOnImportStatement3.js] "use strict"; +/* copyright */ Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js.diff deleted file mode 100644 index 1dcd831942..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.commentOnImportStatement3.js -+++ new.commentOnImportStatement3.js -@@= skipped -7, +7 lines =@@ - - //// [commentOnImportStatement3.js] - "use strict"; --/* copyright */ - Object.defineProperty(exports, "__esModule", { value: true }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js b/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js index c80760d1e9..c51658e2df 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js @@ -20,5 +20,9 @@ interface I3 { } //// [a.js] +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js.diff deleted file mode 100644 index 44a1d8f99c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnInterface1.js -+++ new.commentOnInterface1.js -@@= skipped -19, +19 lines =@@ - } - - //// [a.js] --/*!================= -- Keep this pinned -- ================= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js b/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js index 63845a5bd0..637e3b25b9 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js @@ -38,6 +38,10 @@ function foo2(a: any): void { } //// [a.js] +/*!================= + Keep this pinned + ================= +*/ function foo(a) { } class c { diff --git a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js.diff deleted file mode 100644 index bb4c48fea0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.commentOnSignature1.js -+++ new.commentOnSignature1.js -@@= skipped -37, +37 lines =@@ - } - - //// [a.js] --/*!================= -- Keep this pinned -- ================= --*/ - function foo(a) { - } - class c { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js b/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js index 7c8e9a8c04..a19ad80982 100644 --- a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js +++ b/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js @@ -10,9 +10,9 @@ export class SomeAutoGeneratedThing {} //// [commentWithUnreasonableIndentationLevel01.js] "use strict"; +// Repro from #41223 Object.defineProperty(exports, "__esModule", { value: true }); exports.SomeAutoGeneratedThing = void 0; -// Repro from #41223 /** * This is a comment with dumb indentation for some auto-generated thing. */ diff --git a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js.diff b/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js.diff deleted file mode 100644 index 0392624fbc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.commentWithUnreasonableIndentationLevel01.js -+++ new.commentWithUnreasonableIndentationLevel01.js -@@= skipped -9, +9 lines =@@ - - //// [commentWithUnreasonableIndentationLevel01.js] - "use strict"; --// Repro from #41223 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.SomeAutoGeneratedThing = void 0; -+// Repro from #41223 - /** - * This is a comment with dumb indentation for some auto-generated thing. - */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentsExternalModules3.js.diff b/testdata/baselines/reference/submodule/compiler/commentsExternalModules3.js.diff deleted file mode 100644 index 3f34288af9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentsExternalModules3.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.commentsExternalModules3.js -+++ new.commentsExternalModules3.js -@@= skipped -122, +122 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.newVar2 = exports.newVar = void 0; - /**This is on import declaration*/ --var extMod = require("./commentsExternalModules2_0"); // trailing comment 1 -+const extMod = require("./commentsExternalModules2_0"); // trailing comment 1 - extMod.m1.fooExport(); - exports.newVar = new extMod.m1.m2.c(); - extMod.m4.fooExport(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=auto).js.diff b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=auto).js.diff index 1eb2d90098..1fba1956c2 100644 --- a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=auto).js.diff +++ b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=auto).js.diff @@ -1,11 +1,7 @@ --- old.commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=auto).js +++ new.commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=auto).js -@@= skipped -24, +24 lines =@@ - //// [commentsOnJSXExpressionsArePreserved.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_runtime_1 = require("react/jsx-runtime"); -+const jsx_runtime_1 = require("react/jsx-runtime"); +@@= skipped -27, +27 lines =@@ + const jsx_runtime_1 = require("react/jsx-runtime"); class Component { render() { - return (0, jsx_runtime_1.jsx)("div", { children: null /* preserved */ }); diff --git a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=force).js.diff b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=force).js.diff index 8b8005dbda..67267be814 100644 --- a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=force).js.diff +++ b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=force).js.diff @@ -1,11 +1,7 @@ --- old.commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=force).js +++ new.commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=force).js -@@= skipped -24, +24 lines =@@ - //// [commentsOnJSXExpressionsArePreserved.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_runtime_1 = require("react/jsx-runtime"); -+const jsx_runtime_1 = require("react/jsx-runtime"); +@@= skipped -27, +27 lines =@@ + const jsx_runtime_1 = require("react/jsx-runtime"); class Component { render() { - return (0, jsx_runtime_1.jsx)("div", { children: null /* preserved */ }); diff --git a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=auto).js.diff b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=auto).js.diff index 7560c57ff2..07559a37d1 100644 --- a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=auto).js.diff +++ b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=auto).js.diff @@ -1,11 +1,6 @@ --- old.commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=auto).js +++ new.commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=auto).js -@@= skipped -24, +24 lines =@@ - //// [commentsOnJSXExpressionsArePreserved.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); -+const jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); +@@= skipped -28, +28 lines =@@ const _jsxFileName = "commentsOnJSXExpressionsArePreserved.tsx"; class Component { render() { diff --git a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=force).js.diff b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=force).js.diff index b1974f086e..a95f44e68d 100644 --- a/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=force).js.diff +++ b/testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=force).js.diff @@ -1,11 +1,6 @@ --- old.commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=force).js +++ new.commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=force).js -@@= skipped -24, +24 lines =@@ - //// [commentsOnJSXExpressionsArePreserved.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); -+const jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); +@@= skipped -28, +28 lines =@@ const _jsxFileName = "commentsOnJSXExpressionsArePreserved.tsx"; class Component { render() { diff --git a/testdata/baselines/reference/submodule/compiler/commentsOnStaticMembers.js.diff b/testdata/baselines/reference/submodule/compiler/commentsOnStaticMembers.js.diff index 582a4f9338..3dac35b818 100644 --- a/testdata/baselines/reference/submodule/compiler/commentsOnStaticMembers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/commentsOnStaticMembers.js.diff @@ -1,31 +1,31 @@ --- old.commentsOnStaticMembers.js +++ new.commentsOnStaticMembers.js -@@= skipped -21, +21 lines =@@ - } +@@= skipped -22, +22 lines =@@ //// [commentsOnStaticMembers.js] --let test = (() => { -- class test { -- } -+class test { - /** - * p1 comment appears in output - */ -- test.p1 = ""; + class test { ++ /** ++ * p1 comment appears in output ++ */ + static p1 = ""; + /** + * p2 comment does not appear in output + */ + static p2; - /** - * p3 comment appears in output - */ -- test.p3 = ""; -- return test; --})(); ++ /** ++ * p3 comment appears in output ++ */ + static p3 = ""; + /** + * p4 comment does not appear in output + */ + static p4; -+} \ No newline at end of file + } +-/** +- * p1 comment appears in output +- */ +-test.p1 = ""; +-/** +- * p3 comment appears in output +- */ +-test.p3 = ""; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/commonJsExportTypeDeclarationError.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/commonJsExportTypeDeclarationError.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js index 5679730a15..6120833035 100644 --- a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js +++ b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js @@ -19,9 +19,6 @@ export type test = test; //// [test.js] -export = { - message: "" -}; module.exports = { message: "" }; diff --git a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js.diff b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js.diff deleted file mode 100644 index 699c658648..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commonJsExportTypeDeclarationError.js -+++ new.commonJsExportTypeDeclarationError.js -@@= skipped -18, +18 lines =@@ - - - //// [test.js] -+export = { -+ message: "" -+}; - module.exports = { - message: "" - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols index 1af9d4e786..de91cecb7b 100644 --- a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols +++ b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols @@ -3,7 +3,7 @@ === test.js === module.exports = { >module.exports : Symbol(export=, Decl(test.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("test", Decl(test.js, 0, 0)) >exports : Symbol(export=, Decl(test.js, 0, 0)) message: "" diff --git a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols.diff b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols.diff index 5e8d38822d..85970bee8a 100644 --- a/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.symbols.diff @@ -9,7 +9,7 @@ ->module.exports : Symbol(module.exports, Decl(test.js, 0, 0)) ->module : Symbol(export=, Decl(test.js, 0, 0)) +>module.exports : Symbol(export=, Decl(test.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("test", Decl(test.js, 0, 0)) >exports : Symbol(export=, Decl(test.js, 0, 0)) message: "" diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/commonJsExportTypeDeclarationError.types.diff b/testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/commonJsExportTypeDeclarationError.types.diff rename to testdata/baselines/reference/submodule/compiler/commonJsExportTypeDeclarationError.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js index b716571608..78c3261794 100644 --- a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js +++ b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js @@ -6,6 +6,5 @@ var x = 1 //// [index.js] -export = {}; module.exports = {}; var x = 1; diff --git a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js.diff b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js.diff deleted file mode 100644 index b1da817386..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.commonJsIsolatedModules.js -+++ new.commonJsIsolatedModules.js -@@= skipped -5, +5 lines =@@ - - - //// [index.js] -+export = {}; - module.exports = {}; - var x = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols index dc49742761..09356557f8 100644 --- a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols +++ b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols @@ -3,7 +3,7 @@ === index.js === module.exports = {} >module.exports : Symbol(export=, Decl(index.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 0)) var x = 1 diff --git a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols.diff b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols.diff index c71f401a4e..65ee97be44 100644 --- a/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.symbols.diff @@ -8,7 +8,7 @@ ->module : Symbol(module, Decl(index.js, 0, 0)) ->exports : Symbol(module.exports, Decl(index.js, 0, 0)) +>module.exports : Symbol(export=, Decl(index.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("index", Decl(index.js, 0, 0)) +>exports : Symbol(export=, Decl(index.js, 0, 0)) var x = 1 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/commonJsIsolatedModules.types.diff b/testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/commonJsIsolatedModules.types.diff rename to testdata/baselines/reference/submodule/compiler/commonJsIsolatedModules.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff deleted file mode 100644 index 4dda025c31..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commonSourceDirectory.js -+++ new.commonSourceDirectory.js -@@= skipped -18, +18 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var foo_1 = require("foo"); --var bar_1 = require("bar"); -+const foo_1 = require("foo"); -+const bar_1 = require("bar"); - foo_1.x + bar_1.y; - //# sourceMappingURL=../myMapRoot/index.js.map diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.map.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.map.diff deleted file mode 100644 index cd5687b3c7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.map.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.commonSourceDirectory.js.map -+++ new.commonSourceDirectory.js.map -@@= skipped -0, +0 lines =@@ - //// [/app/bin/index.js.map] --{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,0DAA0D;AAC1D,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} --//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL3R5cGVzL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4NCnZhciBmb29fMSA9IHJlcXVpcmUoImZvbyIpOw0KdmFyIGJhcl8xID0gcmVxdWlyZSgiYmFyIik7DQpmb29fMS54ICsgYmFyXzEueTsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPS4uL215TWFwUm9vdC9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsiaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwREFBMEQ7QUFDMUQsMkJBQXdCO0FBQ3hCLDJCQUF3QjtBQUN4QixPQUFDLEdBQUcsT0FBQyxDQUFDIn0=,ZXhwb3J0IGNvbnN0IHggPSAwOwo= -+{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,0DAA0D;AAC1D,6BAAwB;AACxB,6BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} -+//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL3R5cGVzL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4NCmNvbnN0IGZvb18xID0gcmVxdWlyZSgiZm9vIik7DQpjb25zdCBiYXJfMSA9IHJlcXVpcmUoImJhciIpOw0KZm9vXzEueCArIGJhcl8xLnk7DQovLyMgc291cmNlTWFwcGluZ1VSTD0uLi9teU1hcFJvb3QvaW5kZXguanMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsiaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwREFBMEQ7QUFDMUQsNkJBQXdCO0FBQ3hCLDZCQUF3QjtBQUN4QixPQUFDLEdBQUcsT0FBQyxDQUFDIn0=,ZXhwb3J0IGNvbnN0IHggPSAwOwo= \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.sourcemap.txt.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.sourcemap.txt.diff deleted file mode 100644 index 24cb164301..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.sourcemap.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.commonSourceDirectory.sourcemap.txt -+++ new.commonSourceDirectory.sourcemap.txt -@@= skipped -17, +17 lines =@@ - 1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) - 2 >Emitted(3, 59) Source(1, 59) + SourceIndex(0) - --- -->>>var foo_1 = require("foo"); -+>>>const foo_1 = require("foo"); - 1 > --2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^ --3 > ^-> -+2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+3 > ^-> - 1 > - > - 2 >import { x } from "foo"; - 1 >Emitted(4, 1) Source(2, 1) + SourceIndex(0) --2 >Emitted(4, 28) Source(2, 25) + SourceIndex(0) -+2 >Emitted(4, 30) Source(2, 25) + SourceIndex(0) - --- -->>>var bar_1 = require("bar"); -+>>>const bar_1 = require("bar"); - 1-> --2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 1-> - > - 2 >import { y } from "bar"; - 1->Emitted(5, 1) Source(3, 1) + SourceIndex(0) --2 >Emitted(5, 28) Source(3, 25) + SourceIndex(0) -+2 >Emitted(5, 30) Source(3, 25) + SourceIndex(0) - --- - >>>foo_1.x + bar_1.y; - 1 > \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/commonjsAccessExports.types.diff b/testdata/baselines/reference/submodule/compiler/commonjsAccessExports.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/commonjsAccessExports.types.diff rename to testdata/baselines/reference/submodule/compiler/commonjsAccessExports.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/commonjsSafeImport.js.diff b/testdata/baselines/reference/submodule/compiler/commonjsSafeImport.js.diff deleted file mode 100644 index 20ccf77735..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commonjsSafeImport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.commonjsSafeImport.js -+++ new.commonjsSafeImport.js -@@= skipped -16, +16 lines =@@ - //// [main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var _10_lib_1 = require("./10_lib"); -+const _10_lib_1 = require("./10_lib"); - (0, _10_lib_1.Foo)(); - diff --git a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.errors.txt deleted file mode 100644 index 94b49e0bd2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.symbols b/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.symbols deleted file mode 100644 index c179362dd2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.symbols +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/compilerOptionsOutAndNoEmit.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.types b/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.types deleted file mode 100644 index a1e7ad2bf0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutAndNoEmit.types +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/compilerOptionsOutAndNoEmit.ts] //// - -=== a.ts === -class c { ->c : c -} - diff --git a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.errors.txt deleted file mode 100644 index 94b49e0bd2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.symbols b/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.symbols deleted file mode 100644 index 28ffa627f3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.symbols +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/compilerOptionsOutFileAndNoEmit.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.types b/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.types deleted file mode 100644 index 4338a5bb8d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compilerOptionsOutFileAndNoEmit.types +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/compilerOptionsOutFileAndNoEmit.ts] //// - -=== a.ts === -class c { ->c : c -} - diff --git a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js index 4bfa399af9..a6142ff0ec 100644 --- a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js +++ b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js @@ -563,9 +563,9 @@ export function viewFactory_AppComponent0(viewUtils:any,parentInjector:any,decla //// [complexNarrowingWithAny.js] "use strict"; +// Repro from #10869 Object.defineProperty(exports, "__esModule", { value: true }); exports.viewFactory_AppComponent0 = viewFactory_AppComponent0; -// Repro from #10869 /** * This file is generated by the Angular 2 template compiler. * Do not edit. diff --git a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff index 07df85e517..62ebb990bc 100644 --- a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff +++ b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff @@ -1,17 +1,6 @@ --- old.complexNarrowingWithAny.js +++ new.complexNarrowingWithAny.js -@@= skipped -562, +562 lines =@@ - - //// [complexNarrowingWithAny.js] - "use strict"; --// Repro from #10869 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.viewFactory_AppComponent0 = viewFactory_AppComponent0; -+// Repro from #10869 - /** - * This file is generated by the Angular 2 template compiler. - * Do not edit. -@@= skipped -130, +130 lines =@@ +@@= skipped -692, +692 lines =@@ import51.ControlContainer = ControlContainer; })(import51 || (import51 = {})); class _View_AppComponent0 { diff --git a/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js b/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js index b614cd40d8..881d98bd71 100644 --- a/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js +++ b/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js @@ -24,6 +24,7 @@ Func({ }); //// [complicatedIndexesOfIntersectionsAreInferencable.js] +"use strict"; Func({ initialValues: { foo: "" diff --git a/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js.diff b/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js.diff deleted file mode 100644 index 9ac3616e3a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/complicatedIndexesOfIntersectionsAreInferencable.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.complicatedIndexesOfIntersectionsAreInferencable.js -+++ new.complicatedIndexesOfIntersectionsAreInferencable.js -@@= skipped -23, +23 lines =@@ - }); - - //// [complicatedIndexesOfIntersectionsAreInferencable.js] --"use strict"; - Func({ - initialValues: { - foo: "" \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/compositeWithNodeModulesSourceFile.js.diff b/testdata/baselines/reference/submodule/compiler/compositeWithNodeModulesSourceFile.js.diff deleted file mode 100644 index 4657390583..0000000000 --- a/testdata/baselines/reference/submodule/compiler/compositeWithNodeModulesSourceFile.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.compositeWithNodeModulesSourceFile.js -+++ new.compositeWithNodeModulesSourceFile.js -@@= skipped -11, +11 lines =@@ - //// [test.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var myModule = require("myModule"); -+const myModule = require("myModule"); - new myModule.c(); - diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js index c8afaaee30..5c613f080d 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js +++ b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js @@ -80,6 +80,7 @@ val2 = MyDeclaredEnum.B; //// [computedEnumTypeWidening.js] +"use strict"; var E; (function (E) { E["A"] = computed(0); diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff index 835664175c..c8c9a8d25a 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff +++ b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff @@ -1,10 +1,7 @@ --- old.computedEnumTypeWidening.js +++ new.computedEnumTypeWidening.js -@@= skipped -79, +79 lines =@@ - - - //// [computedEnumTypeWidening.js] --"use strict"; +@@= skipped -82, +82 lines =@@ + "use strict"; var E; (function (E) { - E[E["A"] = computed(0)] = "A"; @@ -22,7 +19,7 @@ })(E || (E = {})); function f1() { const c1 = E.B; // Fresh E.B -@@= skipped -51, +54 lines =@@ +@@= skipped -48, +52 lines =@@ let v1 = E.B; let v2 = E.B; class C { diff --git a/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js b/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js index afefa5b297..6c61698aa0 100644 --- a/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js +++ b/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js @@ -24,6 +24,7 @@ foo[k] = ['foo']; //// [a.js] +"use strict"; const k = Symbol(); foo.k = ['foo']; foo['k'] = ['foo']; diff --git a/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js.diff deleted file mode 100644 index 4d21258595..0000000000 --- a/testdata/baselines/reference/submodule/compiler/computedPropertiesWithSetterAssignment.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.computedPropertiesWithSetterAssignment.js -+++ new.computedPropertiesWithSetterAssignment.js -@@= skipped -23, +23 lines =@@ - - - //// [a.js] --"use strict"; - const k = Symbol(); - foo.k = ['foo']; - foo['k'] = ['foo']; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/computedPropertyNameWithImportedKey.js.diff b/testdata/baselines/reference/submodule/compiler/computedPropertyNameWithImportedKey.js.diff deleted file mode 100644 index 3012b0c7f0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/computedPropertyNameWithImportedKey.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.computedPropertyNameWithImportedKey.js -+++ new.computedPropertyNameWithImportedKey.js -@@= skipped -18, +18 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.fn = fn; --var a_1 = require("./a"); -+const a_1 = require("./a"); - function fn({ [a_1.a]: value }) { - return value; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js index 5bc77ce228..6afd67dd25 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js @@ -10,3 +10,4 @@ type WithSpec = T type R = WithSpec // should not error //// [conditionalTypeAnyUnion.js] +// repro from #52568 diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js.diff deleted file mode 100644 index 77c26d5e6a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.conditionalTypeAnyUnion.js -+++ new.conditionalTypeAnyUnion.js -@@= skipped -9, +9 lines =@@ - type R = WithSpec // should not error - - //// [conditionalTypeAnyUnion.js] --// repro from #52568 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js index 970bd0ee51..a28d273b29 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js @@ -18,6 +18,7 @@ good1({ when: value => false }); good2({ when: value => false }); //// [conditionalTypeContextualTypeSimplificationsSuceeds.js] +"use strict"; function bad(attrs) { } function good1(attrs) { } function good2(attrs) { } diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js.diff deleted file mode 100644 index 6be09e1a0e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeContextualTypeSimplificationsSuceeds.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.conditionalTypeContextualTypeSimplificationsSuceeds.js -+++ new.conditionalTypeContextualTypeSimplificationsSuceeds.js -@@= skipped -17, +17 lines =@@ - good2({ when: value => false }); - - //// [conditionalTypeContextualTypeSimplificationsSuceeds.js] --"use strict"; - function bad(attrs) { } - function good1(attrs) { } - function good2(attrs) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js index 5a1a9a3a72..7bd8d8ae64 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js @@ -121,9 +121,9 @@ export enum PubSubRecordIsStoredInRedisAsA { const PubSubRecordType = buildPubSubRecordType({}); //// [conditionalTypeDoesntSpinForever.js] -export { PubSubRecordIsStoredInRedisAsA }; // A *self-contained* demonstration of the problem follows... // Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. +export { PubSubRecordIsStoredInRedisAsA }; var PubSubRecordIsStoredInRedisAsA; (function (PubSubRecordIsStoredInRedisAsA) { PubSubRecordIsStoredInRedisAsA["redisHash"] = "redisHash"; diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff index be33872f0c..849909b8f9 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff @@ -1,13 +1,11 @@ --- old.conditionalTypeDoesntSpinForever.js +++ new.conditionalTypeDoesntSpinForever.js -@@= skipped -120, +120 lines =@@ - const PubSubRecordType = buildPubSubRecordType({}); - +@@= skipped -122, +122 lines =@@ //// [conditionalTypeDoesntSpinForever.js] -+export { PubSubRecordIsStoredInRedisAsA }; // A *self-contained* demonstration of the problem follows... // Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. -export var PubSubRecordIsStoredInRedisAsA; ++export { PubSubRecordIsStoredInRedisAsA }; +var PubSubRecordIsStoredInRedisAsA; (function (PubSubRecordIsStoredInRedisAsA) { PubSubRecordIsStoredInRedisAsA["redisHash"] = "redisHash"; diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js index 0b6beefa7d..611917d268 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js @@ -14,3 +14,4 @@ interface AnySchemaType, V> extends AbstractS //// [conditionalTypeSimplification.js] +// Repro from #30794 diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js.diff deleted file mode 100644 index ff19785ecc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.conditionalTypeSimplification.js -+++ new.conditionalTypeSimplification.js -@@= skipped -13, +13 lines =@@ - - - //// [conditionalTypeSimplification.js] --// Repro from #30794 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js b/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js index bd47ca6308..cc958056c2 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js @@ -10,6 +10,7 @@ interface JSONSchema4 { //// [conditionalTypesASI.js] +// Repro from #21637 //// [conditionalTypesASI.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js.diff deleted file mode 100644 index 51579daebe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.conditionalTypesASI.js -+++ new.conditionalTypesASI.js -@@= skipped -9, +9 lines =@@ - - - //// [conditionalTypesASI.js] --// Repro from #21637 - - - //// [conditionalTypesASI.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js b/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js index 658eead44e..4d6889f499 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js @@ -68,6 +68,7 @@ const zee = z!!!; // since x is `any`, `x extends null | undefined` should be bo //// [conditionalTypesSimplifyWhenTrivial.js] +"use strict"; const fn1 = (params) => params; function fn2(x) { var y = x; diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js.diff deleted file mode 100644 index 6f01d300a4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypesSimplifyWhenTrivial.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.conditionalTypesSimplifyWhenTrivial.js -+++ new.conditionalTypesSimplifyWhenTrivial.js -@@= skipped -67, +67 lines =@@ - - - //// [conditionalTypesSimplifyWhenTrivial.js] --"use strict"; - const fn1 = (params) => params; - function fn2(x) { - var y = x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js b/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js index c018dd7b69..06d5681d4b 100644 --- a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js +++ b/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js @@ -31,8 +31,41 @@ export const pick = () => pick(); //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.pick = void 0; -const pick = require("lodash/pick"); +const pick = __importStar(require("lodash/pick")); const pick = () => (0, exports.pick)(); exports.pick = pick; diff --git a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js.diff b/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js.diff deleted file mode 100644 index e854b89c8d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.conflictingDeclarationsImportFromNamespace1.js -+++ new.conflictingDeclarationsImportFromNamespace1.js -@@= skipped -32, +32 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.pick = void 0; --var pick = require("lodash/pick"); -+const pick = require("lodash/pick"); - const pick = () => (0, exports.pick)(); - exports.pick = pick; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js b/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js index da6b1bd9dc..b8dcdab16c 100644 --- a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js +++ b/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js @@ -31,8 +31,41 @@ export const pick = () => pick(); //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.pick = void 0; -const pick = require("lodash/pick"); +const pick = __importStar(require("lodash/pick")); const pick = () => (0, exports.pick)(); exports.pick = pick; diff --git a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js.diff b/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js.diff deleted file mode 100644 index 018d6fa105..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conflictingDeclarationsImportFromNamespace2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.conflictingDeclarationsImportFromNamespace2.js -+++ new.conflictingDeclarationsImportFromNamespace2.js -@@= skipped -32, +32 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.pick = void 0; --var pick = require("lodash/pick"); -+const pick = require("lodash/pick"); - const pick = () => (0, exports.pick)(); - exports.pick = pick; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js index 92c53c8d92..f511bb55b1 100644 --- a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js +++ b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js @@ -38,9 +38,9 @@ class Item extends BaseClass { //// [conflictingTypeParameterSymbolTransfer.js] "use strict"; +// @strict Object.defineProperty(exports, "__esModule", { value: true }); exports.C2 = void 0; -// @strict // Via #56620 class Base { } diff --git a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff index a9203fd8cd..81a3b724a3 100644 --- a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff +++ b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff @@ -1,14 +1,6 @@ --- old.conflictingTypeParameterSymbolTransfer.js +++ new.conflictingTypeParameterSymbolTransfer.js -@@= skipped -37, +37 lines =@@ - - //// [conflictingTypeParameterSymbolTransfer.js] - "use strict"; --// @strict - Object.defineProperty(exports, "__esModule", { value: true }); - exports.C2 = void 0; -+// @strict - // Via #56620 +@@= skipped -44, +44 lines =@@ class Base { } class C2 extends Base { @@ -16,7 +8,7 @@ constructor(T) { super(); // Should not error -@@= skipped -20, +21 lines =@@ +@@= skipped -13, +14 lines =@@ class Leg { } class Foo extends Leg { diff --git a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js b/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js index f23204a27f..9e3fd4f274 100644 --- a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js +++ b/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js @@ -43,6 +43,9 @@ function mixed4(x: Record<'a', T>, y: Record2) { //// [consistentAliasVsNonAliasRecordBehavior.js] +// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being +// by incorrect variance-based relationships +// Ref: https://github.com/Microsoft/TypeScript/issues/29698 function defaultRecord(x, y) { x = y; // no error, but error expected. } diff --git a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js.diff b/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js.diff deleted file mode 100644 index 58122a9e9e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.consistentAliasVsNonAliasRecordBehavior.js -+++ new.consistentAliasVsNonAliasRecordBehavior.js -@@= skipped -42, +42 lines =@@ - - - //// [consistentAliasVsNonAliasRecordBehavior.js] --// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being --// by incorrect variance-based relationships --// Ref: https://github.com/Microsoft/TypeScript/issues/29698 - function defaultRecord(x, y) { - x = y; // no error, but error expected. - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.errors.txt b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.errors.txt new file mode 100644 index 0000000000..9900daf98b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.errors.txt @@ -0,0 +1,50 @@ +constDeclarations_access_2.ts(4,1): error TS2322: Type '1' is not assignable to type '0'. + + +==== constDeclarations_access_2.ts (1 errors) ==== + /// + import m = require('./constDeclarations_access_1'); + // Errors + m.x = 1; + ~~~ +!!! error TS2322: Type '1' is not assignable to type '0'. + m.x += 2; + m.x -= 3; + m.x *= 4; + m.x /= 5; + m.x %= 6; + m.x <<= 7; + m.x >>= 8; + m.x >>>= 9; + m.x &= 10; + m.x |= 11; + m.x ^= 12; + m + m.x++; + m.x--; + ++m.x; + --m.x; + + ++((m.x)); + + m["x"] = 0; + + // OK + var a = m.x + 1; + + function f(v: number) { } + f(m.x); + + if (m.x) { } + + m.x; + (m.x); + + -m.x; + +m.x; + + m.x.toString(); + +==== constDeclarations_access_1.ts (0 errors) ==== + export const x = 0; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.errors.txt.diff new file mode 100644 index 0000000000..9d1bfa7cd5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.errors.txt.diff @@ -0,0 +1,93 @@ +--- old.constDeclarations-access5.errors.txt ++++ new.constDeclarations-access5.errors.txt +@@= skipped -0, +0 lines =@@ +-constDeclarations_access_2.ts(4,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(5,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(6,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(7,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(8,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(9,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(10,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(11,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(12,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(13,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(14,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(15,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(17,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(18,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(19,5): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(20,5): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(22,7): error TS2540: Cannot assign to 'x' because it is a read-only property. +-constDeclarations_access_2.ts(24,3): error TS2540: Cannot assign to 'x' because it is a read-only property. +- +- +-==== constDeclarations_access_2.ts (18 errors) ==== ++constDeclarations_access_2.ts(4,1): error TS2322: Type '1' is not assignable to type '0'. ++ ++ ++==== constDeclarations_access_2.ts (1 errors) ==== + /// + import m = require('./constDeclarations_access_1'); + // Errors + m.x = 1; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. ++ ~~~ ++!!! error TS2322: Type '1' is not assignable to type '0'. + m.x += 2; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x -= 3; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x *= 4; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x /= 5; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x %= 6; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x <<= 7; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x >>= 8; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x >>>= 9; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x &= 10; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x |= 11; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x ^= 12; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m + m.x++; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + m.x--; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + ++m.x; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + --m.x; +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + + ++((m.x)); +- ~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + + m["x"] = 0; +- ~~~ +-!!! error TS2540: Cannot assign to 'x' because it is a read-only property. + + // OK + var a = m.x + 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.js b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.js new file mode 100644 index 0000000000..4e5ca86aad --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.js @@ -0,0 +1,88 @@ +//// [tests/cases/compiler/constDeclarations-access5.ts] //// + +//// [constDeclarations_access_1.ts] +export const x = 0; + +//// [constDeclarations_access_2.ts] +/// +import m = require('./constDeclarations_access_1'); +// Errors +m.x = 1; +m.x += 2; +m.x -= 3; +m.x *= 4; +m.x /= 5; +m.x %= 6; +m.x <<= 7; +m.x >>= 8; +m.x >>>= 9; +m.x &= 10; +m.x |= 11; +m.x ^= 12; +m +m.x++; +m.x--; +++m.x; +--m.x; + +++((m.x)); + +m["x"] = 0; + +// OK +var a = m.x + 1; + +function f(v: number) { } +f(m.x); + +if (m.x) { } + +m.x; +(m.x); + +-m.x; ++m.x; + +m.x.toString(); + + +//// [constDeclarations_access_1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 0; +//// [constDeclarations_access_2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +const m = require("./constDeclarations_access_1"); +// Errors +m.x = 1; +m.x += 2; +m.x -= 3; +m.x *= 4; +m.x /= 5; +m.x %= 6; +m.x <<= 7; +m.x >>= 8; +m.x >>>= 9; +m.x &= 10; +m.x |= 11; +m.x ^= 12; +m; +m.x++; +m.x--; +++m.x; +--m.x; +++((m.x)); +m["x"] = 0; +// OK +var a = m.x + 1; +function f(v) { } +f(m.x); +if (m.x) { } +m.x; +(m.x); +-m.x; ++m.x; +m.x.toString(); diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.symbols b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.symbols new file mode 100644 index 0000000000..59d9f3ed8c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.symbols @@ -0,0 +1,153 @@ +//// [tests/cases/compiler/constDeclarations-access5.ts] //// + +=== constDeclarations_access_2.ts === +/// +import m = require('./constDeclarations_access_1'); +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) + +// Errors +m.x = 1; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x += 2; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x -= 3; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x *= 4; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x /= 5; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x %= 6; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x <<= 7; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x >>= 8; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x >>>= 9; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x &= 10; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x |= 11; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x ^= 12; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) + +m.x++; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x--; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +++m.x; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +--m.x; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +++((m.x)); +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m["x"] = 0; +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>"x" : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +// OK +var a = m.x + 1; +>a : Symbol(a, Decl(constDeclarations_access_2.ts, 26, 3)) +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +function f(v: number) { } +>f : Symbol(f, Decl(constDeclarations_access_2.ts, 26, 16)) +>v : Symbol(v, Decl(constDeclarations_access_2.ts, 28, 11)) + +f(m.x); +>f : Symbol(f, Decl(constDeclarations_access_2.ts, 26, 16)) +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +if (m.x) { } +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +(m.x); +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +-m.x; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + ++m.x; +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) + +m.x.toString(); +>m.x.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>m.x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>m : Symbol(m, Decl(constDeclarations_access_2.ts, 0, 0)) +>x : Symbol(m.x, Decl(constDeclarations_access_1.ts, 0, 12)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + +=== constDeclarations_access_1.ts === +export const x = 0; +>x : Symbol(x, Decl(constDeclarations_access_1.ts, 0, 12)) + diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.types b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.types new file mode 100644 index 0000000000..822381ead2 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.types @@ -0,0 +1,195 @@ +//// [tests/cases/compiler/constDeclarations-access5.ts] //// + +=== constDeclarations_access_2.ts === +/// +import m = require('./constDeclarations_access_1'); +>m : typeof m + +// Errors +m.x = 1; +>m.x = 1 : 1 +>m.x : 0 +>m : typeof m +>x : 0 +>1 : 1 + +m.x += 2; +>m.x += 2 : number +>m.x : number +>m : typeof m +>x : number +>2 : 2 + +m.x -= 3; +>m.x -= 3 : number +>m.x : number +>m : typeof m +>x : number +>3 : 3 + +m.x *= 4; +>m.x *= 4 : number +>m.x : number +>m : typeof m +>x : number +>4 : 4 + +m.x /= 5; +>m.x /= 5 : number +>m.x : number +>m : typeof m +>x : number +>5 : 5 + +m.x %= 6; +>m.x %= 6 : number +>m.x : number +>m : typeof m +>x : number +>6 : 6 + +m.x <<= 7; +>m.x <<= 7 : number +>m.x : number +>m : typeof m +>x : number +>7 : 7 + +m.x >>= 8; +>m.x >>= 8 : number +>m.x : number +>m : typeof m +>x : number +>8 : 8 + +m.x >>>= 9; +>m.x >>>= 9 : number +>m.x : number +>m : typeof m +>x : number +>9 : 9 + +m.x &= 10; +>m.x &= 10 : number +>m.x : number +>m : typeof m +>x : number +>10 : 10 + +m.x |= 11; +>m.x |= 11 : number +>m.x : number +>m : typeof m +>x : number +>11 : 11 + +m.x ^= 12; +>m.x ^= 12 : number +>m.x : number +>m : typeof m +>x : number +>12 : 12 + +m +>m : typeof m + +m.x++; +>m.x++ : number +>m.x : number +>m : typeof m +>x : number + +m.x--; +>m.x-- : number +>m.x : number +>m : typeof m +>x : number + +++m.x; +>++m.x : number +>m.x : number +>m : typeof m +>x : number + +--m.x; +>--m.x : number +>m.x : number +>m : typeof m +>x : number + +++((m.x)); +>++((m.x)) : number +>((m.x)) : number +>(m.x) : number +>m.x : number +>m : typeof m +>x : number + +m["x"] = 0; +>m["x"] = 0 : 0 +>m["x"] : 0 +>m : typeof m +>"x" : "x" +>0 : 0 + +// OK +var a = m.x + 1; +>a : number +>m.x + 1 : number +>m.x : 0 +>m : typeof m +>x : 0 +>1 : 1 + +function f(v: number) { } +>f : (v: number) => void +>v : number + +f(m.x); +>f(m.x) : void +>f : (v: number) => void +>m.x : 0 +>m : typeof m +>x : 0 + +if (m.x) { } +>m.x : 0 +>m : typeof m +>x : 0 + +m.x; +>m.x : 0 +>m : typeof m +>x : 0 + +(m.x); +>(m.x) : 0 +>m.x : 0 +>m : typeof m +>x : 0 + +-m.x; +>-m.x : number +>m.x : 0 +>m : typeof m +>x : 0 + ++m.x; +>+m.x : number +>m.x : 0 +>m : typeof m +>x : 0 + +m.x.toString(); +>m.x.toString() : string +>m.x.toString : (radix?: number) => string +>m.x : 0 +>m : typeof m +>x : 0 +>toString : (radix?: number) => string + +=== constDeclarations_access_1.ts === +export const x = 0; +>x : 0 +>0 : 0 + diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.types.diff b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.types.diff new file mode 100644 index 0000000000..e14da40efa --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constDeclarations-access5.types.diff @@ -0,0 +1,167 @@ +--- old.constDeclarations-access5.types ++++ new.constDeclarations-access5.types +@@= skipped -7, +7 lines =@@ + // Errors + m.x = 1; + >m.x = 1 : 1 +->m.x : any ++>m.x : 0 + >m : typeof m +->x : any ++>x : 0 + >1 : 1 + + m.x += 2; +->m.x += 2 : any +->m.x : any ++>m.x += 2 : number ++>m.x : number + >m : typeof m +->x : any ++>x : number + >2 : 2 + + m.x -= 3; + >m.x -= 3 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >3 : 3 + + m.x *= 4; + >m.x *= 4 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >4 : 4 + + m.x /= 5; + >m.x /= 5 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >5 : 5 + + m.x %= 6; + >m.x %= 6 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >6 : 6 + + m.x <<= 7; + >m.x <<= 7 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >7 : 7 + + m.x >>= 8; + >m.x >>= 8 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >8 : 8 + + m.x >>>= 9; + >m.x >>>= 9 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >9 : 9 + + m.x &= 10; + >m.x &= 10 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >10 : 10 + + m.x |= 11; + >m.x |= 11 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >11 : 11 + + m.x ^= 12; + >m.x ^= 12 : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + >12 : 12 + + m +@@= skipped -87, +87 lines =@@ + + m.x++; + >m.x++ : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + + m.x--; + >m.x-- : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + + ++m.x; + >++m.x : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + + --m.x; + >--m.x : number +->m.x : any ++>m.x : number + >m : typeof m +->x : any ++>x : number + + ++((m.x)); + >++((m.x)) : number +->((m.x)) : any +->(m.x) : any +->m.x : any ++>((m.x)) : number ++>(m.x) : number ++>m.x : number + >m : typeof m +->x : any ++>x : number + + m["x"] = 0; + >m["x"] = 0 : 0 +->m["x"] : any ++>m["x"] : 0 + >m : typeof m + >"x" : "x" + >0 : 0 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.errors.txt b/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.errors.txt deleted file mode 100644 index 18f82cd7e6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== file1.ts (0 errors) ==== - c; - -==== file2.ts (0 errors) ==== - const c = 0; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.symbols b/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.symbols deleted file mode 100644 index aa905a40d2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.symbols +++ /dev/null @@ -1,10 +0,0 @@ -//// [tests/cases/compiler/constDeclarations-useBeforeDefinition2.ts] //// - -=== file1.ts === -c; ->c : Symbol(c, Decl(file2.ts, 0, 5)) - -=== file2.ts === -const c = 0; ->c : Symbol(c, Decl(file2.ts, 0, 5)) - diff --git a/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.types b/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.types deleted file mode 100644 index 168dc54da6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constDeclarations-useBeforeDefinition2.types +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/constDeclarations-useBeforeDefinition2.ts] //// - -=== file1.ts === -c; ->c : 0 - -=== file2.ts === -const c = 0; ->c : 0 ->0 : 0 - diff --git a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js b/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js index e29818d9ad..234e0c3045 100644 --- a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js +++ b/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js @@ -32,8 +32,41 @@ var ConstFooEnum; function fooFunc() { } //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const Foo = require("./foo"); +const Foo = __importStar(require("./foo")); function check(x) { switch (x) { case Foo.ConstFooEnum.Some: diff --git a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js.diff b/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js.diff deleted file mode 100644 index 641b693b5a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js -+++ new.constEnumNamespaceReferenceCausesNoImport(isolatedmodules=true).js -@@= skipped -32, +32 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var Foo = require("./foo"); -+const Foo = require("./foo"); - function check(x) { - switch (x) { - case Foo.ConstFooEnum.Some: \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js b/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js index 19bf2acc7d..c7fecdfa82 100644 --- a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js +++ b/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js @@ -37,7 +37,40 @@ var ConstEnumOnlyModule; })(ConstEnumOnlyModule || (exports.ConstEnumOnlyModule = ConstEnumOnlyModule = {})); //// [reexport.js] "use strict"; -const Foo = require("./foo"); +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +const Foo = __importStar(require("./foo")); module.exports = Foo.ConstEnumOnlyModule; //// [index.js] "use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js.diff b/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js.diff deleted file mode 100644 index 83b57bd3ed..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constEnumNamespaceReferenceCausesNoImport2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.constEnumNamespaceReferenceCausesNoImport2.js -+++ new.constEnumNamespaceReferenceCausesNoImport2.js -@@= skipped -36, +36 lines =@@ - })(ConstEnumOnlyModule || (exports.ConstEnumOnlyModule = ConstEnumOnlyModule = {})); - //// [reexport.js] - "use strict"; --var Foo = require("./foo"); -+const Foo = require("./foo"); - module.exports = Foo.ConstEnumOnlyModule; - //// [index.js] - "use strict"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constEnumPreserveEmitReexport.js.diff b/testdata/baselines/reference/submodule/compiler/constEnumPreserveEmitReexport.js.diff index d60104cb07..6c82ad07fc 100644 --- a/testdata/baselines/reference/submodule/compiler/constEnumPreserveEmitReexport.js.diff +++ b/testdata/baselines/reference/submodule/compiler/constEnumPreserveEmitReexport.js.diff @@ -1,13 +1,6 @@ --- old.constEnumPreserveEmitReexport.js +++ new.constEnumPreserveEmitReexport.js -@@= skipped -23, +23 lines =@@ - //// [ImportExport.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var ConstEnum_1 = require("./ConstEnum"); -+const ConstEnum_1 = require("./ConstEnum"); - exports.default = ConstEnum_1.MyConstEnum; - //// [ReExport.js] +@@= skipped -29, +29 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; diff --git a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js b/testdata/baselines/reference/submodule/compiler/constWithNonNull.js index d8c2c37962..6cf38ad519 100644 --- a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js +++ b/testdata/baselines/reference/submodule/compiler/constWithNonNull.js @@ -8,4 +8,5 @@ x!++; //// [constWithNonNull.js] +// Fixes #21848 x++; diff --git a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js.diff b/testdata/baselines/reference/submodule/compiler/constWithNonNull.js.diff deleted file mode 100644 index 5cfb298b89..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.constWithNonNull.js -+++ new.constWithNonNull.js -@@= skipped -7, +7 lines =@@ - - - //// [constWithNonNull.js] --// Fixes #21848 - x++; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js b/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js index 434ab25a15..d7c43c002a 100644 --- a/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js +++ b/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js @@ -25,4 +25,5 @@ export interface IImmutableMap2> extends Map(v: V) => void>() { //// [constraintReferencingTypeParameterFromSameTypeParameterList.js] +// used to be valid, now an error to do this function f() { } function foo() { diff --git a/testdata/baselines/reference/submodule/compiler/constraintReferencingTypeParameterFromSameTypeParameterList.js.diff b/testdata/baselines/reference/submodule/compiler/constraintReferencingTypeParameterFromSameTypeParameterList.js.diff deleted file mode 100644 index b0ad009519..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constraintReferencingTypeParameterFromSameTypeParameterList.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.constraintReferencingTypeParameterFromSameTypeParameterList.js -+++ new.constraintReferencingTypeParameterFromSameTypeParameterList.js -@@= skipped -26, +26 lines =@@ - - - //// [constraintReferencingTypeParameterFromSameTypeParameterList.js] --// used to be valid, now an error to do this - function f() { - } - function foo() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js b/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js index e5ca06533f..213c85210b 100644 --- a/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js +++ b/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js @@ -49,7 +49,6 @@ class B { exposedField; #privateField; constructor(arg, exposedField) { - "prologue"; "prologue"; this.exposedField = exposedField; ({ key: this.#privateField } = arg); diff --git a/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js.diff b/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js.diff index cf2a626f16..ba5ab16029 100644 --- a/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js.diff +++ b/testdata/baselines/reference/submodule/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.js.diff @@ -39,7 +39,6 @@ constructor(arg, exposedField) { "prologue"; - var _a; -+ "prologue"; this.exposedField = exposedField; - _B_privateField.set(this, void 0); - (_a = this, { key: ({ set value(_b) { __classPrivateFieldSet(_a, _B_privateField, _b, "f"); } }).value } = arg); diff --git a/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js b/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js index a791c6ea5c..f85416cd26 100644 --- a/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js +++ b/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js @@ -29,7 +29,6 @@ class A { } class B extends A { constructor() { - "ngInject"; "ngInject"; console.log("B"); super(); diff --git a/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js.diff b/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js.diff deleted file mode 100644 index 68182998cf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constructorWithSuperAndPrologue.es5.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.constructorWithSuperAndPrologue.es5.js -+++ new.constructorWithSuperAndPrologue.es5.js -@@= skipped -29, +29 lines =@@ - class B extends A { - constructor() { - "ngInject"; -+ "ngInject"; - console.log("B"); - super(); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js index 418ea01336..e32e8fd2ec 100644 --- a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js +++ b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js @@ -60,6 +60,8 @@ test( //// [contextSensitiveReturnTypeInference.js] +"use strict"; +// Repro from #34849 const DEPS = { foo: 1 }; diff --git a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff deleted file mode 100644 index e92610a536..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.contextSensitiveReturnTypeInference.js -+++ new.contextSensitiveReturnTypeInference.js -@@= skipped -59, +59 lines =@@ - - - //// [contextSensitiveReturnTypeInference.js] --"use strict"; --// Repro from #34849 - const DEPS = { - foo: 1 - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js b/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js index 567fd08b02..a0f3f907a3 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js +++ b/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js @@ -18,6 +18,7 @@ const obj: {field: Rule} = { }; //// [contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js] +"use strict"; const obj = { field: { validate: (_t, _p, _s) => false, diff --git a/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js.diff b/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js.diff deleted file mode 100644 index 88df8f2a7d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js -+++ new.contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js -@@= skipped -17, +17 lines =@@ - }; - - //// [contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js] --"use strict"; - const obj = { - field: { - validate: (_t, _p, _s) => false, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js b/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js index 73c02a4083..1c6a523b6e 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js +++ b/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js @@ -8,4 +8,5 @@ f({ data: 0 }, { data(value, key) {} }); //// [contextualPropertyOfGenericMappedType.js] +// Repro for #24694 f({ data: 0 }, { data(value, key) { } }); diff --git a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js.diff b/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js.diff deleted file mode 100644 index b79e469d24..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.contextualPropertyOfGenericMappedType.js -+++ new.contextualPropertyOfGenericMappedType.js -@@= skipped -7, +7 lines =@@ - - - //// [contextualPropertyOfGenericMappedType.js] --// Repro for #24694 - f({ data: 0 }, { data(value, key) { } }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js index a52165a583..d895846b55 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js +++ b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js @@ -22,6 +22,8 @@ const banana5 = fruitFactory5(Banana) // Banana<"foo"> //// [contextualSignatureInstantiation4.js] +"use strict"; +// Repros from #32976 const banana1 = fruitFactory1(Banana); // Banana const banana2 = fruitFactory2(Banana); // Banana const banana3 = fruitFactory3(Banana); // Banana<"foo"> diff --git a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff deleted file mode 100644 index be8fb6e1e8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.contextualSignatureInstantiation4.js -+++ new.contextualSignatureInstantiation4.js -@@= skipped -21, +21 lines =@@ - - - //// [contextualSignatureInstantiation4.js] --"use strict"; --// Repros from #32976 - const banana1 = fruitFactory1(Banana); // Banana - const banana2 = fruitFactory2(Banana); // Banana - const banana3 = fruitFactory3(Banana); // Banana<"foo"> \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js b/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js index 393a01bd29..8b564dcecc 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js @@ -24,6 +24,7 @@ eacher((...args) => { //// [contextualTupleTypeParameterReadonly.js] +"use strict"; const cases = [ [1, '1'], [2, '2'], diff --git a/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js.diff deleted file mode 100644 index 3bc70edc1a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTupleTypeParameterReadonly.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTupleTypeParameterReadonly.js -+++ new.contextualTupleTypeParameterReadonly.js -@@= skipped -23, +23 lines =@@ - - - //// [contextualTupleTypeParameterReadonly.js] --"use strict"; - const cases = [ - [1, '1'], - [2, '2'], \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js b/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js index 0bc5c637f4..a159ea2f9c 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js @@ -12,6 +12,7 @@ function fst({ s } = t) { } //// [contextualTypeForInitalizedVariablesFiltersUndefined.js] +"use strict"; const fInferred = ({ a = 0 } = {}) => a; // const fInferred: ({ a }?: { a?: number; }) => number const fAnnotated = ({ a = 0 } = {}) => a; diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js.diff deleted file mode 100644 index f77b42cc2c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTypeForInitalizedVariablesFiltersUndefined.js -+++ new.contextualTypeForInitalizedVariablesFiltersUndefined.js -@@= skipped -11, +11 lines =@@ - - - //// [contextualTypeForInitalizedVariablesFiltersUndefined.js] --"use strict"; - const fInferred = ({ a = 0 } = {}) => a; - // const fInferred: ({ a }?: { a?: number; }) => number - const fAnnotated = ({ a = 0 } = {}) => a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js b/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js index 6f0ffa1045..8e8a78daec 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js @@ -12,6 +12,7 @@ const i3: Iterable | 1[] = [2]; //// [contextualTypeIterableUnions.js] +"use strict"; new DMap([["1", 2]]); const i1 = [{ a: true }]; const i2 = [{ b: false }]; diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js.diff deleted file mode 100644 index 104dd1cebe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeIterableUnions.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTypeIterableUnions.js -+++ new.contextualTypeIterableUnions.js -@@= skipped -11, +11 lines =@@ - - - //// [contextualTypeIterableUnions.js] --"use strict"; - new DMap([["1", 2]]); - const i1 = [{ a: true }]; - const i2 = [{ b: false }]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeObjectSpreadExpression.js b/testdata/baselines/reference/submodule/compiler/contextualTypeObjectSpreadExpression.js index 032928668e..dc90049321 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeObjectSpreadExpression.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeObjectSpreadExpression.js @@ -9,16 +9,5 @@ i = { ...{ a: "a" } }; //// [contextualTypeObjectSpreadExpression.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; let i; -i = __assign({ a: "a" }); +i = Object.assign({ a: "a" }); diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js b/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js index 2de29f37f8..6a69d37f5c 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js @@ -18,6 +18,7 @@ function g< //// [contextualTypeOfIndexedAccessParameter.js] +"use strict"; f("a", { cb: p => p, }); diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js.diff deleted file mode 100644 index 08a5f1b9dd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeOfIndexedAccessParameter.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTypeOfIndexedAccessParameter.js -+++ new.contextualTypeOfIndexedAccessParameter.js -@@= skipped -17, +17 lines =@@ - - - //// [contextualTypeOfIndexedAccessParameter.js] --"use strict"; - f("a", { - cb: p => p, - }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js b/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js index 8b7f4e2cdf..f74537871f 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js @@ -8,6 +8,7 @@ const f: FuncOrGeneratorFunc = function*() { } //// [contextualTypeOnYield1.js] +"use strict"; const f = function* () { yield (num) => console.log(num); // `num` should be inferred to have type `number`. }; diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js.diff deleted file mode 100644 index d3edf7d964..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTypeOnYield1.js -+++ new.contextualTypeOnYield1.js -@@= skipped -7, +7 lines =@@ - } - - //// [contextualTypeOnYield1.js] --"use strict"; - const f = function* () { - yield (num) => console.log(num); // `num` should be inferred to have type `number`. - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js b/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js index 58d8710b40..370c774edc 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js @@ -7,6 +7,7 @@ const g: OrGen = function* () { } //// [contextualTypeOnYield2.js] +"use strict"; const g = function* () { return (num) => console.log(num); }; diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js.diff deleted file mode 100644 index 496c4c6232..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeOnYield2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTypeOnYield2.js -+++ new.contextualTypeOnYield2.js -@@= skipped -6, +6 lines =@@ - } - - //// [contextualTypeOnYield2.js] --"use strict"; - const g = function* () { - return (num) => console.log(num); - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js b/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js index d9107649ee..126f39a35b 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js +++ b/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js @@ -125,6 +125,7 @@ const test: TestGeneric = { //// [contextualTypeShouldBeLiteral.js] +"use strict"; function foo(bar) { } foo({ type: 'y', diff --git a/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js.diff b/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js.diff deleted file mode 100644 index 7d0a087e6f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualTypeShouldBeLiteral.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextualTypeShouldBeLiteral.js -+++ new.contextualTypeShouldBeLiteral.js -@@= skipped -124, +124 lines =@@ - - - //// [contextualTypeShouldBeLiteral.js] --"use strict"; - function foo(bar) { } - foo({ - type: 'y', \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypeArgumentsKeyword.types.diff b/testdata/baselines/reference/submodule/compiler/contextuallyTypeArgumentsKeyword.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypeArgumentsKeyword.types.diff rename to testdata/baselines/reference/submodule/compiler/contextuallyTypeArgumentsKeyword.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js index 496cc2c0d8..24d24c8422 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js @@ -30,6 +30,8 @@ const x: Observable = observable(false); //// [contextuallyTypedBooleanLiterals.js] +"use strict"; +// Repro from #48363 const bn1 = box(0); // Box const bn2 = box(0); // Ok const bb1 = box(false); // Box diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff deleted file mode 100644 index 65bad0af4d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.contextuallyTypedBooleanLiterals.js -+++ new.contextuallyTypedBooleanLiterals.js -@@= skipped -29, +29 lines =@@ - - - //// [contextuallyTypedBooleanLiterals.js] --"use strict"; --// Repro from #48363 - const bn1 = box(0); // Box - const bn2 = box(0); // Ok - const bb1 = box(false); // Box \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff rename to testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js b/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js index 3f40d48d0c..021c485e83 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js @@ -23,6 +23,7 @@ const x: { [sym: symbol]: (p: string) => void } = { [A]: s => s.length }; //// [contextuallyTypedSymbolNamedProperties.js] +"use strict"; // Repros from #43628 const A = Symbol("A"); const B = Symbol("B"); diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js.diff b/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js.diff deleted file mode 100644 index 319e9b6cc5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedSymbolNamedProperties.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contextuallyTypedSymbolNamedProperties.js -+++ new.contextuallyTypedSymbolNamedProperties.js -@@= skipped -22, +22 lines =@@ - - - //// [contextuallyTypedSymbolNamedProperties.js] --"use strict"; - // Repros from #43628 - const A = Symbol("A"); - const B = Symbol("B"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js b/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js index 4422b51fd4..1aacf64eaf 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js +++ b/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js @@ -30,6 +30,7 @@ const x: List = filter1; // $ExpectType List //// [contravariantInferenceAndTypeGuard.js] +"use strict"; const list2 = new List(); const filter1 = list2.filter(function (item, node, list) { this.b; // $ExpectType string diff --git a/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js.diff b/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js.diff deleted file mode 100644 index 34ab385ad2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contravariantInferenceAndTypeGuard.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contravariantInferenceAndTypeGuard.js -+++ new.contravariantInferenceAndTypeGuard.js -@@= skipped -29, +29 lines =@@ - - - //// [contravariantInferenceAndTypeGuard.js] --"use strict"; - const list2 = new List(); - const filter1 = list2.filter(function (item, node, list) { - this.b; // $ExpectType string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff rename to testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff rename to testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js b/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js index e6652a0828..b08a35696c 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js +++ b/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js @@ -21,6 +21,7 @@ bar(g1, g2); //// [contravariantTypeAliasInference.js] +"use strict"; foo(f1, f2); bar(f1, f2); bar(g1, g2); diff --git a/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js.diff b/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js.diff deleted file mode 100644 index 491dbfbc03..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contravariantTypeAliasInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.contravariantTypeAliasInference.js -+++ new.contravariantTypeAliasInference.js -@@= skipped -20, +20 lines =@@ - - - //// [contravariantTypeAliasInference.js] --"use strict"; - foo(f1, f2); - bar(f1, f2); - bar(g1, g2); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js b/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js index 33122da61e..9d75fd38cb 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js @@ -117,6 +117,7 @@ function bindingPatternInParameter({ data: data1, isSuccess: isSuccess1 }: UseQu //// [controlFlowAliasedDiscriminants.js] +"use strict"; function useQuery() { return { isSuccess: false, diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js.diff deleted file mode 100644 index 0b0f8e4b9d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowAliasedDiscriminants.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowAliasedDiscriminants.js -+++ new.controlFlowAliasedDiscriminants.js -@@= skipped -116, +116 lines =@@ - - - //// [controlFlowAliasedDiscriminants.js] --"use strict"; - function useQuery() { - return { - isSuccess: false, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js b/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js index 3f5e5cf5ed..cf5c597c9f 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js @@ -15,6 +15,7 @@ function bar(this: string | number) { } //// [controlFlowAnalysisOnBareThisKeyword.js] +"use strict"; function bigger() { if (isBig(this)) { this.big; // Expect property to exist diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js.diff deleted file mode 100644 index 3f3cc51104..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowAnalysisOnBareThisKeyword.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowAnalysisOnBareThisKeyword.js -+++ new.controlFlowAnalysisOnBareThisKeyword.js -@@= skipped -14, +14 lines =@@ - } - - //// [controlFlowAnalysisOnBareThisKeyword.js] --"use strict"; - function bigger() { - if (isBig(this)) { - this.big; // Expect property to exist \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js b/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js index c594f32aef..c106226250 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js @@ -61,6 +61,7 @@ Example5.value++; //// [controlFlowAutoAccessor1.js] +"use strict"; class Example { accessor test; constructor(test) { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js.diff deleted file mode 100644 index c880e3e82f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowAutoAccessor1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowAutoAccessor1.js -+++ new.controlFlowAutoAccessor1.js -@@= skipped -60, +60 lines =@@ - - - //// [controlFlowAutoAccessor1.js] --"use strict"; - class Example { - accessor test; - constructor(test) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js b/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js index 80954b2b28..5db00d60d8 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js @@ -18,6 +18,7 @@ user; //// [controlFlowBreakContinueWithLabel.js] +"use strict"; var User; (function (User) { User[User["A"] = 0] = "A"; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js.diff deleted file mode 100644 index c7f07f7901..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowBreakContinueWithLabel.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowBreakContinueWithLabel.js -+++ new.controlFlowBreakContinueWithLabel.js -@@= skipped -17, +17 lines =@@ - - - //// [controlFlowBreakContinueWithLabel.js] --"use strict"; - var User; - (function (User) { - User[User["A"] = 0] = "A"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js b/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js index 41b3829b9c..f45d2ca5a9 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js @@ -10,6 +10,7 @@ function foo2(param: number | null | undefined): number | null { } //// [controlFlowCommaExpressionAssertionWithinTernary.js] +"use strict"; function foo2(param) { const val = param !== undefined; return val ? (assert(param !== undefined), param) : null; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js.diff deleted file mode 100644 index 759213b84b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowCommaExpressionAssertionWithinTernary.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowCommaExpressionAssertionWithinTernary.js -+++ new.controlFlowCommaExpressionAssertionWithinTernary.js -@@= skipped -9, +9 lines =@@ - } - - //// [controlFlowCommaExpressionAssertionWithinTernary.js] --"use strict"; - function foo2(param) { - const val = param !== undefined; - return val ? (assert(param !== undefined), param) : null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js index 6c3d9fe7d5..6650a641c0 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js @@ -25,6 +25,8 @@ function foo(things: Val[]): void { } //// [controlFlowDestructuringLoop.js] +"use strict"; +// Repro from #28758 function isNumVal(x) { return typeof x.val === 'number'; } diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff deleted file mode 100644 index 69009d6440..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.controlFlowDestructuringLoop.js -+++ new.controlFlowDestructuringLoop.js -@@= skipped -24, +24 lines =@@ - } - - //// [controlFlowDestructuringLoop.js] --"use strict"; --// Repro from #28758 - function isNumVal(x) { - return typeof x.val === 'number'; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js index 15e72f45fe..431c13a5a8 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js @@ -24,6 +24,7 @@ e; //// [controlFlowDestructuringVariablesInTryCatch.js] +"use strict"; try { var a = f1(); var [b] = f2(); diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js.diff deleted file mode 100644 index 21a1816de1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringVariablesInTryCatch.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowDestructuringVariablesInTryCatch.js -+++ new.controlFlowDestructuringVariablesInTryCatch.js -@@= skipped -23, +23 lines =@@ - - - //// [controlFlowDestructuringVariablesInTryCatch.js] --"use strict"; - try { - var a = f1(); - var [b] = f2(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js b/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js index 5a466d0b74..2a1b81ff2e 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js @@ -17,6 +17,7 @@ try { console.log(a); // <- error here //// [controlFlowFinallyNoCatchAssignments.js] +"use strict"; let x; x = Math.random(); let a; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js.diff deleted file mode 100644 index d7f5ee37b4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowFinallyNoCatchAssignments.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowFinallyNoCatchAssignments.js -+++ new.controlFlowFinallyNoCatchAssignments.js -@@= skipped -16, +16 lines =@@ - console.log(a); // <- error here - - //// [controlFlowFinallyNoCatchAssignments.js] --"use strict"; - let x; - x = Math.random(); - let a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js b/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js index ed399a1757..d21dce672f 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js @@ -43,6 +43,7 @@ class Foo { } //// [controlFlowForCatchAndFinally.js] +"use strict"; async function test() { let browser = undefined; let page = undefined; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js.diff index e59a5d6292..4178936a99 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js.diff +++ b/testdata/baselines/reference/submodule/compiler/controlFlowForCatchAndFinally.js.diff @@ -1,10 +1,9 @@ --- old.controlFlowForCatchAndFinally.js +++ new.controlFlowForCatchAndFinally.js -@@= skipped -42, +42 lines =@@ - } +@@= skipped -43, +43 lines =@@ //// [controlFlowForCatchAndFinally.js] --"use strict"; + "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js b/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js index b109f9be6a..03146831f5 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js @@ -9,4 +9,5 @@ const { //// [controlFlowInitializedDestructuringVariables.js] +"use strict"; const { a = "0", b = +a, } = obj; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js.diff deleted file mode 100644 index 53de216b59..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowInitializedDestructuringVariables.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.controlFlowInitializedDestructuringVariables.js -+++ new.controlFlowInitializedDestructuringVariables.js -@@= skipped -8, +8 lines =@@ - - - //// [controlFlowInitializedDestructuringVariables.js] --"use strict"; - const { a = "0", b = +a, } = obj; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.types.diff b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.types.diff rename to testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.errors.txt b/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.errors.txt deleted file mode 100644 index 5bb0b8e7eb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.errors.txt +++ /dev/null @@ -1,113 +0,0 @@ -error TS5055: Cannot write file 'controlFlowJavascript.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'controlFlowJavascript.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== controlFlowJavascript.js (0 errors) ==== - let cond = true; - - // CFA for 'let' and no initializer - function f1() { - let x; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | undefined - } - - // CFA for 'let' and 'undefined' initializer - function f2() { - let x = undefined; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | undefined - } - - // CFA for 'let' and 'null' initializer - function f3() { - let x = null; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | null - } - - // CFA for 'var' with no initializer - function f5() { - var x; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | undefined - } - - // CFA for 'var' with 'undefined' initializer - function f6() { - var x = undefined; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | undefined - } - - // CFA for 'var' with 'null' initializer - function f7() { - var x = null; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | null - } - - // No CFA for captured outer variables - function f9() { - let x; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | undefined - function f() { - const z = x; // any - } - } - - // No CFA for captured outer variables - function f10() { - let x; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // string | number | undefined - const f = () => { - const z = x; // any - }; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.symbols b/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.symbols deleted file mode 100644 index fc5feaf282..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.symbols +++ /dev/null @@ -1,217 +0,0 @@ -//// [tests/cases/compiler/controlFlowJavascript.ts] //// - -=== controlFlowJavascript.js === -let cond = true; ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - -// CFA for 'let' and no initializer -function f1() { ->f1 : Symbol(f1, Decl(controlFlowJavascript.js, 0, 16)) - - let x; ->x : Symbol(x, Decl(controlFlowJavascript.js, 4, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 4, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 4, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowJavascript.js, 11, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 4, 7)) -} - -// CFA for 'let' and 'undefined' initializer -function f2() { ->f2 : Symbol(f2, Decl(controlFlowJavascript.js, 12, 1)) - - let x = undefined; ->x : Symbol(x, Decl(controlFlowJavascript.js, 16, 7)) ->undefined : Symbol(undefined) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 16, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 16, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowJavascript.js, 23, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 16, 7)) -} - -// CFA for 'let' and 'null' initializer -function f3() { ->f3 : Symbol(f3, Decl(controlFlowJavascript.js, 24, 1)) - - let x = null; ->x : Symbol(x, Decl(controlFlowJavascript.js, 28, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 28, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 28, 7)) - } - const y = x; // string | number | null ->y : Symbol(y, Decl(controlFlowJavascript.js, 35, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 28, 7)) -} - -// CFA for 'var' with no initializer -function f5() { ->f5 : Symbol(f5, Decl(controlFlowJavascript.js, 36, 1)) - - var x; ->x : Symbol(x, Decl(controlFlowJavascript.js, 40, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 40, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 40, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowJavascript.js, 47, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 40, 7)) -} - -// CFA for 'var' with 'undefined' initializer -function f6() { ->f6 : Symbol(f6, Decl(controlFlowJavascript.js, 48, 1)) - - var x = undefined; ->x : Symbol(x, Decl(controlFlowJavascript.js, 52, 7)) ->undefined : Symbol(undefined) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 52, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 52, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowJavascript.js, 59, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 52, 7)) -} - -// CFA for 'var' with 'null' initializer -function f7() { ->f7 : Symbol(f7, Decl(controlFlowJavascript.js, 60, 1)) - - var x = null; ->x : Symbol(x, Decl(controlFlowJavascript.js, 64, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 64, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 64, 7)) - } - const y = x; // string | number | null ->y : Symbol(y, Decl(controlFlowJavascript.js, 71, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 64, 7)) -} - -// No CFA for captured outer variables -function f9() { ->f9 : Symbol(f9, Decl(controlFlowJavascript.js, 72, 1)) - - let x; ->x : Symbol(x, Decl(controlFlowJavascript.js, 76, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 76, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 76, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowJavascript.js, 83, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 76, 7)) - - function f() { ->f : Symbol(f, Decl(controlFlowJavascript.js, 83, 16)) - - const z = x; // any ->z : Symbol(z, Decl(controlFlowJavascript.js, 85, 13)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 76, 7)) - } -} - -// No CFA for captured outer variables -function f10() { ->f10 : Symbol(f10, Decl(controlFlowJavascript.js, 87, 1)) - - let x; ->x : Symbol(x, Decl(controlFlowJavascript.js, 91, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = 1; ->x : Symbol(x, Decl(controlFlowJavascript.js, 91, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowJavascript.js, 0, 3)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowJavascript.js, 91, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowJavascript.js, 98, 9)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 91, 7)) - - const f = () => { ->f : Symbol(f, Decl(controlFlowJavascript.js, 99, 9)) - - const z = x; // any ->z : Symbol(z, Decl(controlFlowJavascript.js, 100, 13)) ->x : Symbol(x, Decl(controlFlowJavascript.js, 91, 7)) - - }; -} - diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.types b/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.types deleted file mode 100644 index dfae20707c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowJavascript.types +++ /dev/null @@ -1,251 +0,0 @@ -//// [tests/cases/compiler/controlFlowJavascript.ts] //// - -=== controlFlowJavascript.js === -let cond = true; ->cond : boolean ->true : true - -// CFA for 'let' and no initializer -function f1() { ->f1 : () => void - - let x; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | undefined ->y : any ->x : any -} - -// CFA for 'let' and 'undefined' initializer -function f2() { ->f2 : () => void - - let x = undefined; ->x : any ->undefined : undefined - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | undefined ->y : any ->x : any -} - -// CFA for 'let' and 'null' initializer -function f3() { ->f3 : () => void - - let x = null; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | null ->y : any ->x : any -} - -// CFA for 'var' with no initializer -function f5() { ->f5 : () => void - - var x; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | undefined ->y : any ->x : any -} - -// CFA for 'var' with 'undefined' initializer -function f6() { ->f6 : () => void - - var x = undefined; ->x : any ->undefined : undefined - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | undefined ->y : any ->x : any -} - -// CFA for 'var' with 'null' initializer -function f7() { ->f7 : () => void - - var x = null; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | null ->y : any ->x : any -} - -// No CFA for captured outer variables -function f9() { ->f9 : () => void - - let x; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | undefined ->y : any ->x : any - - function f() { ->f : () => void - - const z = x; // any ->z : any ->x : any - } -} - -// No CFA for captured outer variables -function f10() { ->f10 : () => void - - let x; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // string | number | undefined ->y : any ->x : any - - const f = () => { ->f : () => void ->() => { const z = x; // any } : () => void - - const z = x; // any ->z : any ->x : any - - }; -} - diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js b/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js index ce3e295c31..c3f2c72d7a 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js @@ -66,6 +66,7 @@ if (state) { //// [controlFlowManyCallExpressionStatementsPerf.js] +"use strict"; function test(x) { return x; } let state = true; if (state) { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js.diff deleted file mode 100644 index bd2f24bb1d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowManyCallExpressionStatementsPerf.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowManyCallExpressionStatementsPerf.js -+++ new.controlFlowManyCallExpressionStatementsPerf.js -@@= skipped -65, +65 lines =@@ - - - //// [controlFlowManyCallExpressionStatementsPerf.js] --"use strict"; - function test(x) { return x; } - let state = true; - if (state) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js b/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js index 33121c7481..85c349ec83 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js @@ -27,6 +27,7 @@ function f(x: number | null) { //// [controlFlowNullTypeAndLiteral.js] +"use strict"; // Repros from #23771 const myNull = null; const objWithValMaybeNull = { val: 1 }; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js.diff deleted file mode 100644 index 55ade78c08..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowNullTypeAndLiteral.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowNullTypeAndLiteral.js -+++ new.controlFlowNullTypeAndLiteral.js -@@= skipped -26, +26 lines =@@ - - - //// [controlFlowNullTypeAndLiteral.js] --"use strict"; - // Repros from #23771 - const myNull = null; - const objWithValMaybeNull = { val: 1 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js b/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js index 5639d48451..d5fe9d959f 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js @@ -29,6 +29,7 @@ class Example2 { } //// [controlFlowPrivateClassField.js] +"use strict"; class Example { #test; constructor(test) { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js.diff deleted file mode 100644 index 346d8b4291..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowPrivateClassField.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowPrivateClassField.js -+++ new.controlFlowPrivateClassField.js -@@= skipped -28, +28 lines =@@ - } - - //// [controlFlowPrivateClassField.js] --"use strict"; - class Example { - #test; - constructor(test) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js index 0c2e32cb74..af657b632d 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js @@ -152,6 +152,7 @@ export class StyleParser { //// [controlFlowPropertyDeclarations.js] "use strict"; +// Repro from ##8913 Object.defineProperty(exports, "__esModule", { value: true }); exports.StyleParser = exports.HTMLtoJSX = void 0; var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff index c0f009b46e..3efc353dd3 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff +++ b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff @@ -1,14 +1,6 @@ --- old.controlFlowPropertyDeclarations.js +++ new.controlFlowPropertyDeclarations.js -@@= skipped -151, +151 lines =@@ - - //// [controlFlowPropertyDeclarations.js] - "use strict"; --// Repro from ##8913 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.StyleParser = exports.HTMLtoJSX = void 0; - var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); -@@= skipped -87, +86 lines =@@ +@@= skipped -238, +238 lines =@@ return /^\d+px$/.test(value); } class HTMLtoJSX { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js b/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js index 70cf0436ee..ff82e5c972 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js @@ -124,8 +124,8 @@ function getObject(id: string | number) { //// [controlFlowSelfReferentialLoop.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // Repro from #12319 +Object.defineProperty(exports, "__esModule", { value: true }); function md5(string) { function FF(a, b, c, d, x, s, ac) { return 0; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js.diff deleted file mode 100644 index 4015bfc679..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.controlFlowSelfReferentialLoop.js -+++ new.controlFlowSelfReferentialLoop.js -@@= skipped -123, +123 lines =@@ - - //// [controlFlowSelfReferentialLoop.js] - "use strict"; --// Repro from #12319 - Object.defineProperty(exports, "__esModule", { value: true }); -+// Repro from #12319 - function md5(string) { - function FF(a, b, c, d, x, s, ac) { - return 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js b/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js index de53bab39f..5c75c3407e 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js @@ -30,6 +30,7 @@ function foo2() { } //// [controlFlowWithIncompleteTypes.js] +// Repro from #11000 function foo1() { let x = 0; while (cond) { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js.diff deleted file mode 100644 index 6e1c290db9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowWithIncompleteTypes.js -+++ new.controlFlowWithIncompleteTypes.js -@@= skipped -29, +29 lines =@@ - } - - //// [controlFlowWithIncompleteTypes.js] --// Repro from #11000 - function foo1() { - let x = 0; - while (cond) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.errors.txt b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.errors.txt new file mode 100644 index 0000000000..c091aec88b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.errors.txt @@ -0,0 +1,15 @@ +copyrightWithNewLine1.ts(5,24): error TS2307: Cannot find module './greeter' or its corresponding type declarations. + + +==== copyrightWithNewLine1.ts (1 errors) ==== + /***************************** + * (c) Copyright - Important + ****************************/ + + import model = require("./greeter") + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './greeter' or its corresponding type declarations. + var el = document.getElementById('content'); + var greeter = new model.Greeter(el); + /** things */ + greeter.start(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.js b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.js new file mode 100644 index 0000000000..42ccf6c2d5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/copyrightWithNewLine1.ts] //// + +//// [copyrightWithNewLine1.ts] +/***************************** +* (c) Copyright - Important +****************************/ + +import model = require("./greeter") +var el = document.getElementById('content'); +var greeter = new model.Greeter(el); +/** things */ +greeter.start(); + +//// [copyrightWithNewLine1.js] +"use strict"; +/***************************** +* (c) Copyright - Important +****************************/ +Object.defineProperty(exports, "__esModule", { value: true }); +const model = require("./greeter"); +var el = document.getElementById('content'); +var greeter = new model.Greeter(el); +/** things */ +greeter.start(); diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.symbols b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.symbols new file mode 100644 index 0000000000..974ef3f5da --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/copyrightWithNewLine1.ts] //// + +=== copyrightWithNewLine1.ts === +/***************************** +* (c) Copyright - Important +****************************/ + +import model = require("./greeter") +>model : Symbol(model, Decl(copyrightWithNewLine1.ts, 0, 0)) + +var el = document.getElementById('content'); +>el : Symbol(el, Decl(copyrightWithNewLine1.ts, 5, 3)) +>document.getElementById : Symbol(Document.getElementById, Decl(lib.dom.d.ts, --, --)) +>document : Symbol(document, Decl(lib.dom.d.ts, --, --)) +>getElementById : Symbol(Document.getElementById, Decl(lib.dom.d.ts, --, --)) + +var greeter = new model.Greeter(el); +>greeter : Symbol(greeter, Decl(copyrightWithNewLine1.ts, 6, 3)) +>model : Symbol(model, Decl(copyrightWithNewLine1.ts, 0, 0)) +>el : Symbol(el, Decl(copyrightWithNewLine1.ts, 5, 3)) + +/** things */ +greeter.start(); +>greeter : Symbol(greeter, Decl(copyrightWithNewLine1.ts, 6, 3)) + diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.types b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.types new file mode 100644 index 0000000000..dc3d898176 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.types @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/copyrightWithNewLine1.ts] //// + +=== copyrightWithNewLine1.ts === +/***************************** +* (c) Copyright - Important +****************************/ + +import model = require("./greeter") +>model : any + +var el = document.getElementById('content'); +>el : HTMLElement +>document.getElementById('content') : HTMLElement +>document.getElementById : (elementId: string) => HTMLElement +>document : Document +>getElementById : (elementId: string) => HTMLElement +>'content' : "content" + +var greeter = new model.Greeter(el); +>greeter : any +>new model.Greeter(el) : any +>model.Greeter : any +>model : any +>Greeter : any +>el : HTMLElement + +/** things */ +greeter.start(); +>greeter.start() : any +>greeter.start : any +>greeter : any +>start : any + diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.types.diff b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.types.diff new file mode 100644 index 0000000000..7f035155b6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithNewLine1.types.diff @@ -0,0 +1,14 @@ +--- old.copyrightWithNewLine1.types ++++ new.copyrightWithNewLine1.types +@@= skipped -10, +10 lines =@@ + var el = document.getElementById('content'); + >el : HTMLElement + >document.getElementById('content') : HTMLElement +->document.getElementById : (elementId: string) => HTMLElement | null ++>document.getElementById : (elementId: string) => HTMLElement + >document : Document +->getElementById : (elementId: string) => HTMLElement | null ++>getElementById : (elementId: string) => HTMLElement + >'content' : "content" + + var greeter = new model.Greeter(el); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.errors.txt b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.errors.txt new file mode 100644 index 0000000000..cc9d2adb14 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.errors.txt @@ -0,0 +1,14 @@ +copyrightWithoutNewLine1.ts(4,24): error TS2307: Cannot find module './greeter' or its corresponding type declarations. + + +==== copyrightWithoutNewLine1.ts (1 errors) ==== + /***************************** + * (c) Copyright - Important + ****************************/ + import model = require("./greeter") + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './greeter' or its corresponding type declarations. + var el = document.getElementById('content'); + var greeter = new model.Greeter(el); + /** things */ + greeter.start(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.js b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.js new file mode 100644 index 0000000000..1076a5c98b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/copyrightWithoutNewLine1.ts] //// + +//// [copyrightWithoutNewLine1.ts] +/***************************** +* (c) Copyright - Important +****************************/ +import model = require("./greeter") +var el = document.getElementById('content'); +var greeter = new model.Greeter(el); +/** things */ +greeter.start(); + +//// [copyrightWithoutNewLine1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/***************************** +* (c) Copyright - Important +****************************/ +const model = require("./greeter"); +var el = document.getElementById('content'); +var greeter = new model.Greeter(el); +/** things */ +greeter.start(); diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.symbols b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.symbols new file mode 100644 index 0000000000..dd0f44d65a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.symbols @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/copyrightWithoutNewLine1.ts] //// + +=== copyrightWithoutNewLine1.ts === +/***************************** +* (c) Copyright - Important +****************************/ +import model = require("./greeter") +>model : Symbol(model, Decl(copyrightWithoutNewLine1.ts, 0, 0)) + +var el = document.getElementById('content'); +>el : Symbol(el, Decl(copyrightWithoutNewLine1.ts, 4, 3)) +>document.getElementById : Symbol(Document.getElementById, Decl(lib.dom.d.ts, --, --)) +>document : Symbol(document, Decl(lib.dom.d.ts, --, --)) +>getElementById : Symbol(Document.getElementById, Decl(lib.dom.d.ts, --, --)) + +var greeter = new model.Greeter(el); +>greeter : Symbol(greeter, Decl(copyrightWithoutNewLine1.ts, 5, 3)) +>model : Symbol(model, Decl(copyrightWithoutNewLine1.ts, 0, 0)) +>el : Symbol(el, Decl(copyrightWithoutNewLine1.ts, 4, 3)) + +/** things */ +greeter.start(); +>greeter : Symbol(greeter, Decl(copyrightWithoutNewLine1.ts, 5, 3)) + diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.types b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.types new file mode 100644 index 0000000000..bd63301458 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/copyrightWithoutNewLine1.ts] //// + +=== copyrightWithoutNewLine1.ts === +/***************************** +* (c) Copyright - Important +****************************/ +import model = require("./greeter") +>model : any + +var el = document.getElementById('content'); +>el : HTMLElement +>document.getElementById('content') : HTMLElement +>document.getElementById : (elementId: string) => HTMLElement +>document : Document +>getElementById : (elementId: string) => HTMLElement +>'content' : "content" + +var greeter = new model.Greeter(el); +>greeter : any +>new model.Greeter(el) : any +>model.Greeter : any +>model : any +>Greeter : any +>el : HTMLElement + +/** things */ +greeter.start(); +>greeter.start() : any +>greeter.start : any +>greeter : any +>start : any + diff --git a/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.types.diff b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.types.diff new file mode 100644 index 0000000000..d0f7e11616 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/copyrightWithoutNewLine1.types.diff @@ -0,0 +1,14 @@ +--- old.copyrightWithoutNewLine1.types ++++ new.copyrightWithoutNewLine1.types +@@= skipped -9, +9 lines =@@ + var el = document.getElementById('content'); + >el : HTMLElement + >document.getElementById('content') : HTMLElement +->document.getElementById : (elementId: string) => HTMLElement | null ++>document.getElementById : (elementId: string) => HTMLElement + >document : Document +->getElementById : (elementId: string) => HTMLElement | null ++>getElementById : (elementId: string) => HTMLElement + >'content' : "content" + + var greeter = new model.Greeter(el); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js index f28acd85d2..b033e0dfa0 100644 --- a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js +++ b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js @@ -304,6 +304,8 @@ function getValueConcrete( //// [correlatedUnions.js] +"use strict"; +// Various repros from #30581 function processRecord(rec) { rec.f(rec.v); } diff --git a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff index 8e046ca39f..b5fbae6711 100644 --- a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff +++ b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff @@ -1,15 +1,6 @@ --- old.correlatedUnions.js +++ new.correlatedUnions.js -@@= skipped -303, +303 lines =@@ - - - //// [correlatedUnions.js] --"use strict"; --// Various repros from #30581 - function processRecord(rec) { - rec.f(rec.v); - } -@@= skipped -214, +212 lines =@@ +@@= skipped -517, +517 lines =@@ declare function createEventListener({ name, once, callback }: Ev): Ev; declare const clickEvent: { readonly name: "click"; diff --git a/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.errors.txt new file mode 100644 index 0000000000..d8e595afe5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.errors.txt @@ -0,0 +1,27 @@ +crashIntypeCheckInvocationExpression.ts(6,28): error TS2304: Cannot find name 'task'. +crashIntypeCheckInvocationExpression.ts(8,18): error TS2304: Cannot find name 'path'. +crashIntypeCheckInvocationExpression.ts(9,19): error TS2347: Untyped function calls may not accept type arguments. +crashIntypeCheckInvocationExpression.ts(10,50): error TS2304: Cannot find name 'moduleType'. + + +==== crashIntypeCheckInvocationExpression.ts (4 errors) ==== + var nake; + function doCompile(fileset: P0, moduleType: P1) { + + return undefined; + } + export var compileServer = task(() => { + ~~~~ +!!! error TS2304: Cannot find name 'task'. + + var folder = path.join(), + ~~~~ +!!! error TS2304: Cannot find name 'path'. + fileset = nake.fileSetSync(folder) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + return doCompile(fileset, moduleType); + ~~~~~~~~~~ +!!! error TS2304: Cannot find name 'moduleType'. + }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.js b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.js new file mode 100644 index 0000000000..00578e70fa --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/crashIntypeCheckInvocationExpression.ts] //// + +//// [crashIntypeCheckInvocationExpression.ts] +var nake; +function doCompile(fileset: P0, moduleType: P1) { + + return undefined; +} +export var compileServer = task(() => { + + var folder = path.join(), + fileset = nake.fileSetSync(folder) + return doCompile(fileset, moduleType); +}); + + +//// [crashIntypeCheckInvocationExpression.js] +var nake; +function doCompile(fileset, moduleType) { + return undefined; +} +export var compileServer = task(() => { + var folder = path.join(), fileset = nake.fileSetSync(folder); + return doCompile(fileset, moduleType); +}); diff --git a/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.symbols b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.symbols new file mode 100644 index 0000000000..b53dae3997 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.symbols @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/crashIntypeCheckInvocationExpression.ts] //// + +=== crashIntypeCheckInvocationExpression.ts === +var nake; +>nake : Symbol(nake, Decl(crashIntypeCheckInvocationExpression.ts, 0, 3)) + +function doCompile(fileset: P0, moduleType: P1) { +>doCompile : Symbol(doCompile, Decl(crashIntypeCheckInvocationExpression.ts, 0, 9)) +>P0 : Symbol(P0, Decl(crashIntypeCheckInvocationExpression.ts, 1, 19)) +>P1 : Symbol(P1, Decl(crashIntypeCheckInvocationExpression.ts, 1, 22)) +>P2 : Symbol(P2, Decl(crashIntypeCheckInvocationExpression.ts, 1, 26)) +>fileset : Symbol(fileset, Decl(crashIntypeCheckInvocationExpression.ts, 1, 31)) +>P0 : Symbol(P0, Decl(crashIntypeCheckInvocationExpression.ts, 1, 19)) +>moduleType : Symbol(moduleType, Decl(crashIntypeCheckInvocationExpression.ts, 1, 43)) +>P1 : Symbol(P1, Decl(crashIntypeCheckInvocationExpression.ts, 1, 22)) + + return undefined; +>undefined : Symbol(undefined) +} +export var compileServer = task(() => { +>compileServer : Symbol(compileServer, Decl(crashIntypeCheckInvocationExpression.ts, 5, 10)) +>P0 : Symbol(P0, Decl(crashIntypeCheckInvocationExpression.ts, 5, 54)) +>P1 : Symbol(P1, Decl(crashIntypeCheckInvocationExpression.ts, 5, 57)) +>P2 : Symbol(P2, Decl(crashIntypeCheckInvocationExpression.ts, 5, 61)) + + var folder = path.join(), +>folder : Symbol(folder, Decl(crashIntypeCheckInvocationExpression.ts, 7, 7)) + + fileset = nake.fileSetSync(folder) +>fileset : Symbol(fileset, Decl(crashIntypeCheckInvocationExpression.ts, 7, 29)) +>nake : Symbol(nake, Decl(crashIntypeCheckInvocationExpression.ts, 0, 3)) +>folder : Symbol(folder, Decl(crashIntypeCheckInvocationExpression.ts, 7, 7)) + + return doCompile(fileset, moduleType); +>doCompile : Symbol(doCompile, Decl(crashIntypeCheckInvocationExpression.ts, 0, 9)) +>fileset : Symbol(fileset, Decl(crashIntypeCheckInvocationExpression.ts, 7, 29)) + +}); + diff --git a/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.types b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.types new file mode 100644 index 0000000000..d35fd9a30d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/crashIntypeCheckInvocationExpression.types @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/crashIntypeCheckInvocationExpression.ts] //// + +=== crashIntypeCheckInvocationExpression.ts === +var nake; +>nake : any + +function doCompile(fileset: P0, moduleType: P1) { +>doCompile : (fileset: P0, moduleType: P1) => any +>fileset : P0 +>moduleType : P1 + + return undefined; +>undefined : undefined +} +export var compileServer = task(() => { +>compileServer : any +>task(() => { var folder = path.join(), fileset = nake.fileSetSync(folder) return doCompile(fileset, moduleType);}) : any +>task : any +>() => { var folder = path.join(), fileset = nake.fileSetSync(folder) return doCompile(fileset, moduleType);} : () => any + + var folder = path.join(), +>folder : any +>path.join() : any +>path.join : any +>path : any +>join : any + + fileset = nake.fileSetSync(folder) +>fileset : any +>nake.fileSetSync(folder) : any +>nake.fileSetSync : any +>nake : any +>fileSetSync : any +>folder : any + + return doCompile(fileset, moduleType); +>doCompile(fileset, moduleType) : any +>doCompile : (fileset: P0_1, moduleType: P1_1) => any +>fileset : any +>moduleType : any + +}); + diff --git a/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js b/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js index d8ce084ae8..9ffea6e67f 100644 --- a/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js +++ b/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js @@ -34,7 +34,6 @@ var MsPortal; (function (Util) { let TemplateEngine; (function (TemplateEngine) { - "use strict"; "use strict"; class StringTemplate { _templateStorage; diff --git a/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js.diff b/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js.diff index 30ca59df4b..9788a306ed 100644 --- a/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js.diff +++ b/testdata/baselines/reference/submodule/compiler/crashRegressionTest.js.diff @@ -11,13 +11,12 @@ + let TemplateEngine; (function (TemplateEngine) { "use strict"; -+ "use strict"; class StringTemplate { + _templateStorage; constructor(templateStorage) { this._templateStorage = templateStorage; } -@@= skipped -14, +16 lines =@@ +@@= skipped -14, +15 lines =@@ } } class TemplateStorage { diff --git a/testdata/baselines/reference/submodule/compiler/ctsFileInEsnextHelpers.js.diff b/testdata/baselines/reference/submodule/compiler/ctsFileInEsnextHelpers.js.diff index 9c35582427..561af60e67 100644 --- a/testdata/baselines/reference/submodule/compiler/ctsFileInEsnextHelpers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/ctsFileInEsnextHelpers.js.diff @@ -4,7 +4,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.foo = foo; --var tslib_1 = require("tslib"); +-const tslib_1 = require("tslib"); -function foo() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield 0; diff --git a/testdata/baselines/reference/submodule/compiler/declFileImportModuleWithExportAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/declFileImportModuleWithExportAssignment.js.diff deleted file mode 100644 index 707573c553..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declFileImportModuleWithExportAssignment.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declFileImportModuleWithExportAssignment.js -+++ new.declFileImportModuleWithExportAssignment.js -@@= skipped -33, +33 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = void 0; - /**This is on import declaration*/ --var a1 = require("./declFileImportModuleWithExportAssignment_0"); -+const a1 = require("./declFileImportModuleWithExportAssignment_0"); - exports.a = a1; - exports.a.test1(null, null, null); diff --git a/testdata/baselines/reference/submodule/compiler/declFilePrivateStatic.js.diff b/testdata/baselines/reference/submodule/compiler/declFilePrivateStatic.js.diff index 3a10a0258f..77c446c875 100644 --- a/testdata/baselines/reference/submodule/compiler/declFilePrivateStatic.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declFilePrivateStatic.js.diff @@ -1,32 +1,20 @@ --- old.declFilePrivateStatic.js +++ new.declFilePrivateStatic.js -@@= skipped -15, +15 lines =@@ - } +@@= skipped -16, +16 lines =@@ //// [declFilePrivateStatic.js] --let C = (() => { -- class C { -- static a() { } -- static b() { } -- static get c() { return 1; } -- static get d() { return 1; } -- static set e(v) { } -- static set f(v) { } -- } -- C.x = 1; -- C.y = 1; -- return C; --})(); -+class C { + class C { + static x = 1; + static y = 1; -+ static a() { } -+ static b() { } -+ static get c() { return 1; } -+ static get d() { return 1; } -+ static set e(v) { } -+ static set f(v) { } -+} + static a() { } + static b() { } + static get c() { return 1; } +@@= skipped -7, +9 lines =@@ + static set e(v) { } + static set f(v) { } + } +-C.x = 1; +-C.y = 1; //// [declFilePrivateStatic.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.errors.txt b/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.errors.txt deleted file mode 100644 index 5e2e87f6f1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -declFile.d.ts(2,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -declFile.d.ts(3,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -declFile.d.ts(5,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -declFile.d.ts(7,5): error TS1038: A 'declare' modifier cannot be used in an already ambient context. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== client.ts (0 errors) ==== - /// - var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file - -==== declFile.d.ts (4 errors) ==== - declare module M { - declare var x; - ~~~~~~~ -!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. - declare function f(); - ~~~~~~~ -!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. - - declare module N { } - ~~~~~~~ -!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. - - declare class C { } - ~~~~~~~ -!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.symbols b/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.symbols deleted file mode 100644 index 1a473d9c37..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.symbols +++ /dev/null @@ -1,27 +0,0 @@ -//// [tests/cases/compiler/declFileWithErrorsInInputDeclarationFileWithOut.ts] //// - -=== client.ts === -/// -var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file ->x : Symbol(x, Decl(client.ts, 1, 3)) ->M.C : Symbol(M.C, Decl(declFile.d.ts, 4, 24)) ->M : Symbol(M, Decl(declFile.d.ts, 0, 0)) ->C : Symbol(M.C, Decl(declFile.d.ts, 4, 24)) - -=== declFile.d.ts === -declare module M { ->M : Symbol(M, Decl(declFile.d.ts, 0, 0)) - - declare var x; ->x : Symbol(x, Decl(declFile.d.ts, 1, 15)) - - declare function f(); ->f : Symbol(f, Decl(declFile.d.ts, 1, 18)) - - declare module N { } ->N : Symbol(N, Decl(declFile.d.ts, 2, 25)) - - declare class C { } ->C : Symbol(C, Decl(declFile.d.ts, 4, 24)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.types b/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.types deleted file mode 100644 index 6ac085b0bd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declFileWithErrorsInInputDeclarationFileWithOut.types +++ /dev/null @@ -1,27 +0,0 @@ -//// [tests/cases/compiler/declFileWithErrorsInInputDeclarationFileWithOut.ts] //// - -=== client.ts === -/// -var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file ->x : M.C ->new M.C() : M.C ->M.C : typeof M.C ->M : typeof M ->C : typeof M.C - -=== declFile.d.ts === -declare module M { ->M : typeof M - - declare var x; ->x : any - - declare function f(); ->f : () => any - - declare module N { } - - declare class C { } ->C : C -} - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitAliasInlineing.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitAliasInlineing.js.diff index 4e8d8abc1b..c090f2aba6 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitAliasInlineing.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitAliasInlineing.js.diff @@ -1,17 +1,6 @@ --- old.declarationEmitAliasInlineing.js +++ new.declarationEmitAliasInlineing.js -@@= skipped -45, +45 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.fExp = exports.f = void 0; --var a_1 = require("./a"); --var aExp_1 = require("./aExp"); -+const a_1 = require("./a"); -+const aExp_1 = require("./aExp"); - exports.f = a_1.fn; - exports.fExp = aExp_1.fnExp; - -@@= skipped -11, +11 lines =@@ +@@= skipped -56, +56 lines =@@ prop: string; prop2: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js b/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js index 96def849ed..0247a9743c 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js @@ -13,9 +13,12 @@ export class C { //// [main.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -const abcdefgh_1 = require("abcdefgh"); +const abcdefgh_1 = __importDefault(require("abcdefgh")); class C { [abcdefgh_1.default.someKey]() { } ; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js.diff deleted file mode 100644 index 709671dfb3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitAnyComputedPropertyInClass.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitAnyComputedPropertyInClass.js -+++ new.declarationEmitAnyComputedPropertyInClass.js -@@= skipped -14, +14 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.C = void 0; --var abcdefgh_1 = require("abcdefgh"); -+const abcdefgh_1 = require("abcdefgh"); - class C { - [abcdefgh_1.default.someKey]() { } - ; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.errors.txt deleted file mode 100644 index 1f41036e73..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== extensions.ts (0 errors) ==== - /// - class Foo { - public: string; - } -==== core.ts (0 errors) ==== - interface Array {} - interface Boolean {} - interface Function {} - interface IArguments {} - interface Number {} - interface Object {} - interface RegExp {} - interface String {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols deleted file mode 100644 index 6f95b6b583..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols +++ /dev/null @@ -1,36 +0,0 @@ -//// [tests/cases/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.ts] //// - -=== extensions.ts === -/// -class Foo { ->Foo : Symbol(Foo, Decl(extensions.ts, 0, 0)) - - public: string; ->public : Symbol(Foo.public, Decl(extensions.ts, 1, 11)) -} -=== core.ts === -interface Array {} ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 0, 0)) ->T : Symbol(T, Decl(lib.es5.d.ts, --, --), Decl(core.ts, 0, 16)) - -interface Boolean {} ->Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 0, 21)) - -interface Function {} ->Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 1, 20)) - -interface IArguments {} ->IArguments : Symbol(IArguments, Decl(lib.es5.d.ts, --, --), Decl(core.ts, 2, 21)) - -interface Number {} ->Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 3, 23)) - -interface Object {} ->Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 4, 19)) - -interface RegExp {} ->RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 5, 19)) - -interface String {} ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 6, 19)) - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols.diff deleted file mode 100644 index 5d58541e5d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols -+++ new.declarationEmitBundlePreservesHasNoDefaultLibDirective.symbols -@@= skipped -9, +9 lines =@@ - } - === core.ts === - interface Array {} -->Array : Symbol(Array, Decl(core.ts, 0, 0)) -->T : Symbol(T, Decl(core.ts, 0, 16)) -+>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 0, 0)) -+>T : Symbol(T, Decl(lib.es5.d.ts, --, --), Decl(core.ts, 0, 16)) - - interface Boolean {} -->Boolean : Symbol(Boolean, Decl(core.ts, 0, 21)) -+>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 0, 21)) - - interface Function {} -->Function : Symbol(Function, Decl(core.ts, 1, 20)) -+>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 1, 20)) - - interface IArguments {} -->IArguments : Symbol(IArguments, Decl(core.ts, 2, 21)) -+>IArguments : Symbol(IArguments, Decl(lib.es5.d.ts, --, --), Decl(core.ts, 2, 21)) - - interface Number {} -->Number : Symbol(Number, Decl(core.ts, 3, 23)) -+>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 3, 23)) - - interface Object {} -->Object : Symbol(Object, Decl(core.ts, 4, 19)) -+>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 4, 19)) - - interface RegExp {} -->RegExp : Symbol(RegExp, Decl(core.ts, 5, 19)) -+>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 5, 19)) - - interface String {} -->String : Symbol(String, Decl(core.ts, 6, 19)) -+>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(core.ts, 6, 19)) diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.types b/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.types deleted file mode 100644 index 99e0fbcacf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.types +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/declarationEmitBundlePreservesHasNoDefaultLibDirective.ts] //// - -=== extensions.ts === -/// -class Foo { ->Foo : Foo - - public: string; ->public : string -} -=== core.ts === - -interface Array {} -interface Boolean {} -interface Function {} -interface IArguments {} -interface Number {} -interface Object {} -interface RegExp {} -interface String {} - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js index f731d32e3b..66ac428f74 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js @@ -42,6 +42,9 @@ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(somet //// [input.d.ts] +/** + * @typedef {{ } & { name?: string }} P + */ export type P = {} & { name?: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff index 3ce20e95ee..66f8165e97 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff @@ -5,6 +5,9 @@ //// [input.d.ts] -export function fn(p?: P): void; ++/** ++ * @typedef {{ } & { name?: string }} P ++ */ +export type P = {} & { + name?: string; +}; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js index 9e50d3792c..f2e51184e5 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js @@ -42,6 +42,9 @@ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(somet //// [input.d.ts] +/** + * @typedef {{ } & { name?: string }} P + */ export type P = {} & { name?: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff index ae201f753b..db186c93e4 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff @@ -5,6 +5,9 @@ //// [input.d.ts] -export function fn(p?: P): void; ++/** ++ * @typedef {{ } & { name?: string }} P ++ */ +export type P = {} & { + name?: string; +}; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff rename to testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.js.diff index edcebccf41..abbf5818ba 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.js.diff @@ -1,13 +1,7 @@ --- old.declarationEmitCommonJsModuleReferencedType.js +++ new.declarationEmitCommonJsModuleReferencedType.js -@@= skipped -27, +27 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.y = exports.x = void 0; --var foo_1 = require("foo"); --var root_1 = require("root"); -+const foo_1 = require("foo"); -+const root_1 = require("root"); +@@= skipped -31, +31 lines =@@ + const root_1 = require("root"); exports.x = (0, foo_1.foo)(); exports.y = (0, root_1.bar)(); + diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.errors.txt deleted file mode 100644 index 3c20cd1201..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /a/index.ts (0 errors) ==== - export * from "./src/" -==== /b/index.ts (0 errors) ==== - export * from "./src/" -==== /b/src/index.ts (0 errors) ==== - export class B {} -==== /a/src/index.ts (0 errors) ==== - import { B } from "b"; - - export default function () { - return new B(); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.symbols deleted file mode 100644 index 9ae3ad047f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.symbols +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.ts] //// - -=== /a/index.ts === - -export * from "./src/" -=== /b/index.ts === - -export * from "./src/" -=== /b/src/index.ts === -export class B {} ->B : Symbol(B, Decl(index.ts, 0, 0)) - -=== /a/src/index.ts === -import { B } from "b"; ->B : Symbol(B, Decl(index.ts, 0, 8)) - -export default function () { - return new B(); ->B : Symbol(B, Decl(index.ts, 0, 8)) -} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.types b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.types deleted file mode 100644 index 632806b3a0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.types +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/declarationEmitCommonSourceDirectoryDoesNotContainAllFiles.ts] //// - -=== /a/index.ts === - -export * from "./src/" -=== /b/index.ts === - -export * from "./src/" -=== /b/src/index.ts === -export class B {} ->B : B - -=== /a/src/index.ts === -import { B } from "b"; ->B : typeof B - -export default function () { - return new B(); ->new B() : B ->B : typeof B -} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameCausesImportToBePainted.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameCausesImportToBePainted.js.diff deleted file mode 100644 index 8133ac4d0b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameCausesImportToBePainted.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitComputedNameCausesImportToBePainted.js -+++ new.declarationEmitComputedNameCausesImportToBePainted.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.withContext = exports.context = void 0; --var context_1 = require("./context"); -+const context_1 = require("./context"); - exports.context = { - [context_1.Key]: 'bar', - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js b/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js index 5bc14cafc7..8dc7b39fea 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js @@ -24,8 +24,11 @@ var EnumExample; exports.default = EnumExample; //// [index.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const EnumExample_1 = require("./EnumExample"); +const EnumExample_1 = __importDefault(require("./EnumExample")); exports.default = { [EnumExample_1.default.TEST]: {}, }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js.diff deleted file mode 100644 index 74e921c071..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitComputedNameConstEnumAlias.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitComputedNameConstEnumAlias.js -+++ new.declarationEmitComputedNameConstEnumAlias.js -@@= skipped -24, +24 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var EnumExample_1 = require("./EnumExample"); -+const EnumExample_1 = require("./EnumExample"); - exports.default = { - [EnumExample_1.default.TEST]: {}, - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCrossFileCopiedGeneratedImportType.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCrossFileCopiedGeneratedImportType.js.diff deleted file mode 100644 index eba36378c1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCrossFileCopiedGeneratedImportType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitCrossFileCopiedGeneratedImportType.js -+++ new.declarationEmitCrossFileCopiedGeneratedImportType.js -@@= skipped -19, +19 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.d = void 0; --var projC_1 = require("../projC"); -+const projC_1 = require("../projC"); - exports.d = { e: projC_1.e }; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCrossFileImportTypeOfAmbientModule.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCrossFileImportTypeOfAmbientModule.js.diff deleted file mode 100644 index 2d89dfd119..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCrossFileImportTypeOfAmbientModule.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitCrossFileImportTypeOfAmbientModule.js -+++ new.declarationEmitCrossFileImportTypeOfAmbientModule.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.reeexported = void 0; --var somepackage_1 = require("../somepackage"); -+const somepackage_1 = require("../somepackage"); - exports.reeexported = somepackage_1.item; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff index 552d88daf0..fd924cc8df 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff @@ -1,24 +1,6 @@ --- old.declarationEmitDefaultExportWithStaticAssignment.js +++ new.declarationEmitDefaultExportWithStaticAssignment.js -@@= skipped -42, +42 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = Example; --var foo_1 = require("./foo"); -+const foo_1 = require("./foo"); - function Example() { } - Example.Foo = foo_1.Foo; - //// [index2.js] -@@= skipped -8, +8 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo = void 0; - exports.default = Example; --var foo_1 = require("./foo"); -+const foo_1 = require("./foo"); - Object.defineProperty(exports, "Foo", { enumerable: true, get: function () { return foo_1.Foo; } }); - function Example() { } - Example.Foo = foo_1.Foo; -@@= skipped -32, +32 lines =@@ +@@= skipped -82, +82 lines =@@ } //// [index1.d.ts] declare function Example(): void; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js index d44b34946b..0c6b49eb4a 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js @@ -32,6 +32,7 @@ class Hola { //// [test1.js] +/*! Copyright 2015 MyCompany Inc. */ class Hello { } //// [test2.js] @@ -43,6 +44,7 @@ class Hola { //// [test1.d.ts] +/*! Copyright 2015 MyCompany Inc. */ declare class Hello { } //// [test2.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js.diff deleted file mode 100644 index 702fedbaa6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.declarationEmitDetachedComment2.js -+++ new.declarationEmitDetachedComment2.js -@@= skipped -31, +31 lines =@@ - - - //// [test1.js] --/*! Copyright 2015 MyCompany Inc. */ - class Hello { - } - //// [test2.js] -@@= skipped -12, +11 lines =@@ - - - //// [test1.d.ts] --/*! Copyright 2015 MyCompany Inc. */ - declare class Hello { - } - //// [test2.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitEnumReferenceViaImportEquals.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitEnumReferenceViaImportEquals.js.diff index fb4b2e41db..33b3ee054f 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitEnumReferenceViaImportEquals.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitEnumReferenceViaImportEquals.js.diff @@ -1,12 +1,10 @@ --- old.declarationEmitEnumReferenceViaImportEquals.js +++ new.declarationEmitEnumReferenceViaImportEquals.js -@@= skipped -43, +43 lines =@@ - "use strict"; +@@= skipped -44, +44 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Test = void 0; --var translation_1 = require("./translation"); + const translation_1 = require("./translation"); -var TranslationKeyEnum = translation_1.Translation.TranslationKeyEnum; -+const translation_1 = require("./translation"); class Test { - constructor() { - this.TranslationKeyEnum = TranslationKeyEnum; @@ -14,12 +12,4 @@ + TranslationKeyEnum = TranslationKeyEnum; print() { console.log(TranslationKeyEnum.Translation1); - } -@@= skipped -14, +11 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var test_1 = require("./test"); -+const test_1 = require("./test"); - new test_1.Test().print(); - + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff index 1a0346d4ab..1abfb0de76 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitExpandoPropertyPrivateName.js +++ new.declarationEmitExpandoPropertyPrivateName.js -@@= skipped -18, +18 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.q = q; --var a_1 = require("./a"); -+const a_1 = require("./a"); - function q() { } - q.val = (0, a_1.f)(); - -@@= skipped -10, +10 lines =@@ +@@= skipped -28, +28 lines =@@ } export declare function f(): I; export {}; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js b/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js index 5a4a06b5ac..7061c8bff5 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js @@ -23,9 +23,42 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (suit, rank) => ({ suit, rank }); //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.lazyCard = void 0; -let lazyCard = () => Promise.resolve().then(() => require('./Card')).then(a => a.default); +let lazyCard = () => Promise.resolve().then(() => __importStar(require('./Card'))).then(a => a.default); exports.lazyCard = lazyCard; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js.diff deleted file mode 100644 index ef7750cdf7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitExportAliasVisibiilityMarking.js -+++ new.declarationEmitExportAliasVisibiilityMarking.js -@@= skipped -24, +24 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.lazyCard = void 0; --let lazyCard = () => Promise.resolve().then(function () { return require('./Card'); }).then(a => a.default); -+let lazyCard = () => Promise.resolve().then(() => require('./Card')).then(a => a.default); - exports.lazyCard = lazyCard; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js.diff deleted file mode 100644 index 5dc38271c6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js -+++ new.declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js -@@= skipped -47, +47 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.obj = void 0; --var get_comp_1 = require("./get-comp"); -+const get_comp_1 = require("./get-comp"); - // this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it - // This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder - exports.obj = { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignment.js.diff index 7a73d31f02..1505533561 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignment.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExportAssignment.js.diff @@ -1,12 +1,10 @@ --- old.declarationEmitExportAssignment.js +++ new.declarationEmitExportAssignment.js -@@= skipped -17, +17 lines =@@ - function bar() { } +@@= skipped -18, +18 lines =@@ //// [index.js] "use strict"; --var utils_1 = require("./utils"); + const utils_1 = require("./utils"); -module.exports = utils_1.foo; -+const utils_1 = require("./utils"); +module.exports = foo; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExportDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExportDeclaration.js.diff deleted file mode 100644 index 9446b6ee50..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExportDeclaration.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitExportDeclaration.js -+++ new.declarationEmitExportDeclaration.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.bar = void 0; --var utils_1 = require("./utils"); -+const utils_1 = require("./utils"); - Object.defineProperty(exports, "bar", { enumerable: true, get: function () { return utils_1.bar; } }); - (0, utils_1.foo)(); - let obj; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js b/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js index 0d449bd25d..7a4dcaa164 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js @@ -21,8 +21,41 @@ class Foo { exports.Foo = Foo; //// [b.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const A = require("./a"); +const A = __importStar(require("./a")); const { Foo } = A; class default_1 extends Foo { } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js.diff deleted file mode 100644 index 9419006abe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionInExtends6.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitExpressionInExtends6.js -+++ new.declarationEmitExpressionInExtends6.js -@@= skipped -21, +21 lines =@@ - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var A = require("./a"); -+const A = require("./a"); - const { Foo } = A; - class default_1 extends Foo { - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.js.diff index 8cdb6b27c2..430a3b280f 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.js +++ new.declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.A1 = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); - exports.A1 = a_1.A; - - -@@= skipped -10, +10 lines =@@ +@@= skipped -25, +25 lines =@@ }; export declare const A: AX; export {}; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.js.diff deleted file mode 100644 index fb5a33f08d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitForGlobalishSpecifierSymlink.js -+++ new.declarationEmitForGlobalishSpecifierSymlink.js -@@= skipped -37, +37 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = void 0; --var typescript_fsa_1 = require("typescript-fsa"); -+const typescript_fsa_1 = require("typescript-fsa"); - exports.a = (0, typescript_fsa_1.getA)(); - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink2.js.diff deleted file mode 100644 index ce8cbc65ab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitForGlobalishSpecifierSymlink2.js -+++ new.declarationEmitForGlobalishSpecifierSymlink2.js -@@= skipped -25, +25 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = void 0; --var typescript_fsa_1 = require("typescript-fsa"); -+const typescript_fsa_1 = require("typescript-fsa"); - exports.a = (0, typescript_fsa_1.getA)(); - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js.diff deleted file mode 100644 index b76d77ddb0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitForModuleImportingModuleAugmentationRetainsImport.js -+++ new.declarationEmitForModuleImportingModuleAugmentationRetainsImport.js -@@= skipped -23, +23 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ParentThing = void 0; --var child1_1 = require("./child1"); // this import should still exist in some form in the output, since it augments this module -+const child1_1 = require("./child1"); // this import should still exist in some form in the output, since it augments this module - class ParentThing { - } - exports.ParentThing = ParentThing; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitForTypesWhichNeedImportTypes.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitForTypesWhichNeedImportTypes.js.diff deleted file mode 100644 index 967880ec67..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitForTypesWhichNeedImportTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitForTypesWhichNeedImportTypes.js -+++ new.declarationEmitForTypesWhichNeedImportTypes.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Value = void 0; --var b_1 = require("./b"); -+const b_1 = require("./b"); - exports.Value = (0, b_1.createNamed)(); - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js b/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js index 2fe741d288..cdfdfdad11 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js @@ -7,9 +7,9 @@ export let b = [{ foo: 0, m() {} }, { bar: 1 }]; //// [declarationEmitInferredUndefinedPropFromFunctionInArray.js] "use strict"; +// repro from https://github.com/microsoft/TypeScript/issues/53914 Object.defineProperty(exports, "__esModule", { value: true }); exports.b = void 0; -// repro from https://github.com/microsoft/TypeScript/issues/53914 exports.b = [{ foo: 0, m() { } }, { bar: 1 }]; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js.diff deleted file mode 100644 index 7d4aec176a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.declarationEmitInferredUndefinedPropFromFunctionInArray.js -+++ new.declarationEmitInferredUndefinedPropFromFunctionInArray.js -@@= skipped -6, +6 lines =@@ - - //// [declarationEmitInferredUndefinedPropFromFunctionInArray.js] - "use strict"; --// repro from https://github.com/microsoft/TypeScript/issues/53914 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.b = void 0; -+// repro from https://github.com/microsoft/TypeScript/issues/53914 - exports.b = [{ foo: 0, m() { } }, { bar: 1 }]; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInlinedDistributiveConditional.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitInlinedDistributiveConditional.js.diff deleted file mode 100644 index d6791facc1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInlinedDistributiveConditional.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.declarationEmitInlinedDistributiveConditional.js -+++ new.declarationEmitInlinedDistributiveConditional.js -@@= skipped -24, +24 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.dropPrivateProps2 = exports.dropPrivateProps1 = void 0; --var internal_1 = require("./internal"); -+const internal_1 = require("./internal"); - const dropPrivateProps1 = (obj) => (0, internal_1.excludePrivateKeys1)(obj); - exports.dropPrivateProps1 = dropPrivateProps1; - const dropPrivateProps2 = (obj) => (0, internal_1.excludePrivateKeys2)(obj); -@@= skipped -8, +8 lines =@@ - //// [test.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var api_1 = require("./api"); -+const api_1 = require("./api"); - const a = (0, api_1.dropPrivateProps1)({ foo: 42, _bar: 'secret' }); // type is {foo: number} - //a._bar // error: _bar does not exist <===== as expected - const b = (0, api_1.dropPrivateProps2)({ foo: 42, _bar: 'secret' }); // type is {foo: number, _bar: string} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js index 3079c4ba18..45192f5a18 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js @@ -68,87 +68,14 @@ exports.publicProcedure = trpc.procedure; //// [index.d.ts] -export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; +export declare const middleware: >(fn: import("@trpc/server/middleware").MiddlewareFunction<{ + _config: import("@trpc/server/internals/config").RootConfig<{ + errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; }>; -}, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; +}, TNewParams>) => import("@trpc/server/middleware").MiddlewareBuilder<{ + _config: import("@trpc/server/internals/config").RootConfig<{ + errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; }>; }, TNewParams>; export declare const router: {}; export declare const publicProcedure: {}; - - -//// [DtsFileErrors] - - -index.d.ts(1,102): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. -index.d.ts(5,43): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. - - -==== node_modules/@trpc/server/internals/config.d.ts (0 errors) ==== - export interface RootConfig { - prop: T; - } -==== node_modules/@trpc/server/internals/utils.d.ts (0 errors) ==== - export interface ErrorFormatterShape { - prop: T; - } - export type PickFirstDefined = undefined extends TType - ? undefined extends TPick - ? never - : TPick - : TType; - export interface ErrorFormatter { - prop: [T, U]; - } - export interface DefaultErrorShape { - prop: T; - } -==== node_modules/@trpc/server/middleware.d.ts (0 errors) ==== - export interface MiddlewareFunction { - prop: [T, U]; - } - export interface MiddlewareBuilder { - prop: [T, U]; - } -==== node_modules/@trpc/server/index.d.ts (0 errors) ==== - import { RootConfig } from './internals/config'; - import { ErrorFormatterShape, PickFirstDefined, ErrorFormatter, DefaultErrorShape } from './internals/utils'; - declare class TRPCBuilder { - create>(): { - procedure: {}; - middleware: >(fn: import("./middleware").MiddlewareFunction<{ - _config: RootConfig<{ - errorShape: ErrorFormatterShape>>; - }>; - }, TNewParams>) => import("./middleware").MiddlewareBuilder<{ - _config: RootConfig<{ - errorShape: ErrorFormatterShape>>; - }>; - }, TNewParams>; - router: {}; - }; - } - - export declare const initTRPC: TRPCBuilder; - export {}; -==== index.d.ts (2 errors) ==== - export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ - ~~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; - }>; - }, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ - ~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; - }>; - }, TNewParams>; - export declare const router: {}; - export declare const publicProcedure: {}; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff index acd616e574..67520d73bd 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff @@ -1,99 +1,20 @@ --- old.declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js +++ new.declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js -@@= skipped -59, +59 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.publicProcedure = exports.router = exports.middleware = void 0; --var server_1 = require("@trpc/server"); -+const server_1 = require("@trpc/server"); - const trpc = server_1.initTRPC.create(); +@@= skipped -64, +64 lines =@@ exports.middleware = trpc.middleware; exports.router = trpc.router; exports.publicProcedure = trpc.procedure; + + +//// [index.d.ts] -+export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; ++export declare const middleware: >(fn: import("@trpc/server/middleware").MiddlewareFunction<{ ++ _config: import("@trpc/server/internals/config").RootConfig<{ ++ errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; + }>; -+}, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; ++}, TNewParams>) => import("@trpc/server/middleware").MiddlewareBuilder<{ ++ _config: import("@trpc/server/internals/config").RootConfig<{ ++ errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; + }>; +}, TNewParams>; +export declare const router: {}; -+export declare const publicProcedure: {}; -+ -+ -+//// [DtsFileErrors] -+ -+ -+index.d.ts(1,102): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. -+index.d.ts(5,43): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. -+ -+ -+==== node_modules/@trpc/server/internals/config.d.ts (0 errors) ==== -+ export interface RootConfig { -+ prop: T; -+ } -+==== node_modules/@trpc/server/internals/utils.d.ts (0 errors) ==== -+ export interface ErrorFormatterShape { -+ prop: T; -+ } -+ export type PickFirstDefined = undefined extends TType -+ ? undefined extends TPick -+ ? never -+ : TPick -+ : TType; -+ export interface ErrorFormatter { -+ prop: [T, U]; -+ } -+ export interface DefaultErrorShape { -+ prop: T; -+ } -+==== node_modules/@trpc/server/middleware.d.ts (0 errors) ==== -+ export interface MiddlewareFunction { -+ prop: [T, U]; -+ } -+ export interface MiddlewareBuilder { -+ prop: [T, U]; -+ } -+==== node_modules/@trpc/server/index.d.ts (0 errors) ==== -+ import { RootConfig } from './internals/config'; -+ import { ErrorFormatterShape, PickFirstDefined, ErrorFormatter, DefaultErrorShape } from './internals/utils'; -+ declare class TRPCBuilder { -+ create>(): { -+ procedure: {}; -+ middleware: >(fn: import("./middleware").MiddlewareFunction<{ -+ _config: RootConfig<{ -+ errorShape: ErrorFormatterShape>>; -+ }>; -+ }, TNewParams>) => import("./middleware").MiddlewareBuilder<{ -+ _config: RootConfig<{ -+ errorShape: ErrorFormatterShape>>; -+ }>; -+ }, TNewParams>; -+ router: {}; -+ }; -+ } -+ -+ export declare const initTRPC: TRPCBuilder; -+ export {}; -+==== index.d.ts (2 errors) ==== -+ export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; -+ }>; -+ }, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; -+ }>; -+ }, TNewParams>; -+ export declare const router: {}; -+ export declare const publicProcedure: {}; -+ \ No newline at end of file ++export declare const publicProcedure: {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.types.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.types.diff rename to testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLocalClassHasRequiredDeclare.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitLocalClassHasRequiredDeclare.js.diff index e5e32cc2f0..a46c191fc7 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLocalClassHasRequiredDeclare.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLocalClassHasRequiredDeclare.js.diff @@ -1,18 +1,13 @@ --- old.declarationEmitLocalClassHasRequiredDeclare.js +++ new.declarationEmitLocalClassHasRequiredDeclare.js -@@= skipped -22, +22 lines =@@ - exports.Y = exports.A = void 0; +@@= skipped -23, +23 lines =@@ class X { } --let A = (() => { -- class A { -- } -- A.X = X; -- return A; --})(); -+class A { + class A { + static X = X; -+} + } exports.A = A; +-A.X = X; class Y { - } \ No newline at end of file + } + exports.Y = Y; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js index 62c571420a..7481133d71 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js @@ -26,8 +26,11 @@ function fn(sliceIndex) { exports.default = { fn }; //// [reexport.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const types_1 = require("./types"); +const types_1 = __importDefault(require("./types")); exports.default = { test: types_1.default }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js.diff index 42e8128dfa..125e0e4d0c 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeDistributivityPreservesConstraints.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitMappedTypeDistributivityPreservesConstraints.js +++ new.declarationEmitMappedTypeDistributivityPreservesConstraints.js -@@= skipped -26, +26 lines =@@ - //// [reexport.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var types_1 = require("./types"); -+const types_1 = require("./types"); - exports.default = { test: types_1.default }; - - -@@= skipped -28, +28 lines =@@ +@@= skipped -57, +57 lines =@@ } ? { [K in keyof T_1]: T_1[K]; } : never; }>(sliceIndex: T) => T["x"] extends infer T_2 extends { [x: string]: (...params: unknown[]) => unknown; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js index 43466056a4..3d0bd7dd79 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js @@ -62,6 +62,7 @@ export const entriesOf = (o: o) => //// [declarationEmitMappedTypePreservesTypeParameterConstraint.js] "use strict"; +// repro from https://github.com/microsoft/TypeScript/issues/54560 Object.defineProperty(exports, "__esModule", { value: true }); exports.entriesOf = exports.buildSchema = void 0; const buildSchema = (version) => (({})); diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff index 90819e98d3..6e0f495e0e 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff @@ -1,10 +1,7 @@ --- old.declarationEmitMappedTypePreservesTypeParameterConstraint.js +++ new.declarationEmitMappedTypePreservesTypeParameterConstraint.js -@@= skipped -61, +61 lines =@@ - - //// [declarationEmitMappedTypePreservesTypeParameterConstraint.js] - "use strict"; --// repro from https://github.com/microsoft/TypeScript/issues/54560 +@@= skipped -64, +64 lines =@@ + // repro from https://github.com/microsoft/TypeScript/issues/54560 Object.defineProperty(exports, "__esModule", { value: true }); exports.entriesOf = exports.buildSchema = void 0; -const buildSchema = (version) => ({}); @@ -12,7 +9,7 @@ exports.buildSchema = buildSchema; const entriesOf = (o) => Object.entries(o); exports.entriesOf = entriesOf; -@@= skipped -31, +30 lines =@@ +@@= skipped -28, +28 lines =@@ export declare type ZodRawShape = { [k: string]: ZodTypeAny; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js index cf17422ad6..f429d2e37c 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js @@ -12,5 +12,5 @@ exports.f = ((arg) => arg)({ '0': 0 }); // Original prop uses string syntax //// [declarationEmitMappedTypePropertyFromNumericStringKey.d.ts] export declare const f: { - "0": string | number; + '0': string | number; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js.diff deleted file mode 100644 index 3d865db89d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.declarationEmitMappedTypePropertyFromNumericStringKey.js -+++ new.declarationEmitMappedTypePropertyFromNumericStringKey.js -@@= skipped -11, +11 lines =@@ - - //// [declarationEmitMappedTypePropertyFromNumericStringKey.d.ts] - export declare const f: { -- '0': string | number; -+ "0": string | number; - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types index 84bf1f59bd..04705c37ee 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types @@ -2,13 +2,13 @@ === declarationEmitMappedTypePropertyFromNumericStringKey.ts === export const f = ((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}); // Original prop uses string syntax ->f : { "0": string | number; } ->((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { "0": string | number; } +>f : { '0': string | number; } +>((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { '0': string | number; } >((arg: {[K in keyof T]: T[K] | string}) => arg) : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } >(arg: {[K in keyof T]: T[K] | string}) => arg : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } >arg : { [K in keyof T]: string | T[K]; } >arg : { [K in keyof T]: string | T[K]; } ->{'0': 0} : { "0": number; } +>{'0': 0} : { '0': number; } >'0' : number >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff index 0023a8b4b6..a26d381f10 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff @@ -1,22 +1,13 @@ --- old.declarationEmitMappedTypePropertyFromNumericStringKey.types +++ new.declarationEmitMappedTypePropertyFromNumericStringKey.types -@@= skipped -1, +1 lines =@@ - - === declarationEmitMappedTypePropertyFromNumericStringKey.ts === +@@= skipped -3, +3 lines =@@ export const f = ((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}); // Original prop uses string syntax -->f : { '0': string | number; } -->((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { '0': string | number; } + >f : { '0': string | number; } + >((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { '0': string | number; } ->((arg: {[K in keyof T]: T[K] | string}) => arg) : (arg: { [K in keyof T]: T[K] | string; }) => { [K in keyof T]: string | T[K]; } ->(arg: {[K in keyof T]: T[K] | string}) => arg : (arg: { [K in keyof T]: T[K] | string; }) => { [K in keyof T]: string | T[K]; } -->arg : { [K in keyof T]: string | T[K]; } -->arg : { [K in keyof T]: string | T[K]; } -->{'0': 0} : { '0': number; } -+>f : { "0": string | number; } -+>((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { "0": string | number; } +>((arg: {[K in keyof T]: T[K] | string}) => arg) : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } +>(arg: {[K in keyof T]: T[K] | string}) => arg : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } -+>arg : { [K in keyof T]: string | T[K]; } -+>arg : { [K in keyof T]: string | T[K]; } -+>{'0': 0} : { "0": number; } - >'0' : number - >0 : 0 + >arg : { [K in keyof T]: string | T[K]; } + >arg : { [K in keyof T]: string | T[K]; } + >{'0': 0} : { '0': number; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js index 76349c988e..6ff7ed658a 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js @@ -20,9 +20,42 @@ export const timestamp = now(); //// [b.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.timestamp = void 0; -const x = require("./a"); +const x = __importStar(require("./a")); exports.timestamp = x.now(); //// [c.js] "use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js.diff index 2b1a1bc106..1df1396ace 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.js.diff @@ -1,18 +1,8 @@ --- old.declarationEmitMappedTypeTemplateTypeofSymbol.js +++ new.declarationEmitMappedTypeTemplateTypeofSymbol.js -@@= skipped -21, +21 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -62, +62 lines =@@ exports.timestamp = void 0; --var x = require("./a"); -+const x = require("./a"); - exports.timestamp = x.now(); - //// [c.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.timestamp = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); + const a_1 = require("./a"); exports.timestamp = (0, a_1.now)(); + + diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMonorepoBaseUrl.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitMonorepoBaseUrl.errors.txt deleted file mode 100644 index f2ffc82324..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMonorepoBaseUrl.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -/tsconfig.json(6,5): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. - Use '"paths": {"*": ["./*"]}' instead. - - -==== /tsconfig.json (1 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "declaration": true, - "outDir": "temp", - "baseUrl": "." - ~~~~~~~~~ -!!! error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. -!!! error TS5102: Use '"paths": {"*": ["./*"]}' instead. - } - } - -==== /packages/compiler-core/src/index.ts (0 errors) ==== - import { PluginConfig } from "@babel/parser"; - -==== /packages/compiler-sfc/src/index.ts (0 errors) ==== - import { createPlugin } from "@babel/parser"; - export function resolveParserPlugins() { - return [createPlugin()]; - } - -==== /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser/package.json (0 errors) ==== - { - "name": "@babel/parser", - "version": "7.23.6", - "main": "./lib/index.js", - "types": "./typings/babel-parser.d.ts" - } - -==== /node_modules/.pnpm/@babel+parser@7.23.6/node_modules/@babel/parser/typings/babel-parser.d.ts (0 errors) ==== - export declare function createPlugin(): PluginConfig; - export declare class PluginConfig {} - -==== /packages/compiler-core/package.json (0 errors) ==== - { - "name": "@vue/compiler-core", - "version": "3.0.0", - "main": "./src/index.ts", - "dependencies": { - "@babel/parser": "^7.0.0" - } - } - -==== /packages/compiler-sfc/package.json (0 errors) ==== - { - "name": "@vue/compiler-sfc", - "version": "3.0.0", - "main": "./src/index.ts", - "dependencies": { - "@babel/parser": "^7.0.0", - "@vue/compiler-core": "^3.0.0" - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMonorepoBaseUrl.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMonorepoBaseUrl.js deleted file mode 100644 index de71b6c171..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMonorepoBaseUrl.js +++ /dev/null @@ -1,62 +0,0 @@ -//// [tests/cases/compiler/declarationEmitMonorepoBaseUrl.ts] //// - -//// [package.json] -{ - "name": "@babel/parser", - "version": "7.23.6", - "main": "./lib/index.js", - "types": "./typings/babel-parser.d.ts" -} - -//// [babel-parser.d.ts] -export declare function createPlugin(): PluginConfig; -export declare class PluginConfig {} - -//// [package.json] -{ - "name": "@vue/compiler-core", - "version": "3.0.0", - "main": "./src/index.ts", - "dependencies": { - "@babel/parser": "^7.0.0" - } -} - -//// [package.json] -{ - "name": "@vue/compiler-sfc", - "version": "3.0.0", - "main": "./src/index.ts", - "dependencies": { - "@babel/parser": "^7.0.0", - "@vue/compiler-core": "^3.0.0" - } -} - -//// [index.ts] -import { PluginConfig } from "@babel/parser"; - -//// [index.ts] -import { createPlugin } from "@babel/parser"; -export function resolveParserPlugins() { - return [createPlugin()]; -} - - -//// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.resolveParserPlugins = resolveParserPlugins; -const parser_1 = require("@babel/parser"); -function resolveParserPlugins() { - return [(0, parser_1.createPlugin)()]; -} - - -//// [index.d.ts] -export {}; -//// [index.d.ts] -export declare function resolveParserPlugins(): import("@babel/parser").PluginConfig[]; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitNameConflicts.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitNameConflicts.js.diff index aa67cad6dd..6018ca4ef1 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitNameConflicts.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitNameConflicts.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitNameConflicts.js +++ new.declarationEmitNameConflicts.js -@@= skipped -61, +61 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.M = void 0; --var im = require("./declarationEmit_nameConflicts_1"); -+const im = require("./declarationEmit_nameConflicts_1"); - var M; - (function (M) { - function f() { } -@@= skipped -20, +20 lines =@@ +@@= skipped -81, +81 lines =@@ M.d = im; })(M || (exports.M = M = {})); (function (M) { diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js index c74996800f..ea6e9e7e15 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js @@ -42,9 +42,12 @@ export default Object.assign(A, { //// [index.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -const styled_components_1 = require("styled-components"); +const styled_components_1 = __importDefault(require("styled-components")); const A = styled_components_1.default.div ``; const B = styled_components_1.default.div ``; exports.C = styled_components_1.default.div ``; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js.diff index c02a6ff8b7..ecdee06739 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.js.diff @@ -1,6 +1,6 @@ --- old.declarationEmitObjectAssignedDefaultExport.js +++ new.declarationEmitObjectAssignedDefaultExport.js -@@= skipped -51, +51 lines =@@ +@@= skipped -54, +54 lines =@@ B, C: exports.C }); diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js b/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js index c462e07c28..1e1256834d 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js @@ -18,8 +18,41 @@ class C { exports.D = C; //// [b.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("./a"); +const a = __importStar(require("./a")); exports.default = a.D; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js.diff deleted file mode 100644 index dcd3d7f9df..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitOfTypeofAliasedExport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitOfTypeofAliasedExport.js -+++ new.declarationEmitOfTypeofAliasedExport.js -@@= skipped -18, +18 lines =@@ - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("./a"); -+const a = require("./a"); - exports.default = a.D; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.errors.txt deleted file mode 100644 index a25077ced4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== js/versions.static.js (0 errors) ==== - export default { - "@a/b": "1.0.0", - "@a/c": "1.2.3" - }; -==== js/index.js (0 errors) ==== - import versions from './versions.static.js'; - - export { - versions - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.symbols deleted file mode 100644 index f43de7b7b7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.symbols +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/declarationEmitOutFileBundlePaths.ts] //// - -=== js/versions.static.js === -export default { - "@a/b": "1.0.0", ->"@a/b" : Symbol("@a/b", Decl(versions.static.js, 0, 16)) - - "@a/c": "1.2.3" ->"@a/c" : Symbol("@a/c", Decl(versions.static.js, 1, 20)) - -}; -=== js/index.js === -import versions from './versions.static.js'; ->versions : Symbol(versions, Decl(index.js, 0, 6)) - -export { - versions ->versions : Symbol(versions, Decl(index.js, 2, 8)) - -}; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.types b/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.types deleted file mode 100644 index bd72506d49..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitOutFileBundlePaths.types +++ /dev/null @@ -1,25 +0,0 @@ -//// [tests/cases/compiler/declarationEmitOutFileBundlePaths.ts] //// - -=== js/versions.static.js === -export default { ->{ "@a/b": "1.0.0", "@a/c": "1.2.3"} : { "@a/b": string; "@a/c": string; } - - "@a/b": "1.0.0", ->"@a/b" : string ->"1.0.0" : "1.0.0" - - "@a/c": "1.2.3" ->"@a/c" : string ->"1.2.3" : "1.2.3" - -}; -=== js/index.js === -import versions from './versions.static.js'; ->versions : { "@a/b": string; "@a/c": string; } - -export { - versions ->versions : { "@a/b": string; "@a/c": string; } - -}; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.errors.txt deleted file mode 100644 index 592759050a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -packages/b/tsconfig.json(5,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. - Use '"paths": {"*": ["./*"]}' instead. - - -==== packages/b/tsconfig.json (1 errors) ==== - { - "compilerOptions": { - "outDir": "dist", - "declaration": true, - "baseUrl": ".", - ~~~~~~~~~ -!!! error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. -!!! error TS5102: Use '"paths": {"*": ["./*"]}' instead. - "paths": { - "@ts-bug/a": ["../a"] - } - } - } - - -==== packages/b/src/index.ts (0 errors) ==== - import { a } from "@ts-bug/a"; - - export function b(text: string) { - return a(text); - } -==== packages/a/index.d.ts (0 errors) ==== - declare module "@ts-bug/a" { - export type AText = { - value: string; - }; - export function a(text: string): AText; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.js b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.js deleted file mode 100644 index d38396f12a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.js +++ /dev/null @@ -1,29 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPathMappingMonorepo.ts] //// - -//// [index.d.ts] -declare module "@ts-bug/a" { - export type AText = { - value: string; - }; - export function a(text: string): AText; - } - -//// [index.ts] -import { a } from "@ts-bug/a"; - -export function b(text: string) { - return a(text); -} - -//// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.b = b; -const a_1 = require("@ts-bug/a"); -function b(text) { - return (0, a_1.a)(text); -} - - -//// [index.d.ts] -export declare function b(text: string): import("@ts-bug/a").AText; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.js.diff deleted file mode 100644 index 1df569beed..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitPathMappingMonorepo.js -+++ new.declarationEmitPathMappingMonorepo.js -@@= skipped -18, +18 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.b = b; --var a_1 = require("@ts-bug/a"); -+const a_1 = require("@ts-bug/a"); - function b(text) { - return (0, a_1.a)(text); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.symbols deleted file mode 100644 index 5adce47bb0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.symbols +++ /dev/null @@ -1,31 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPathMappingMonorepo.ts] //// - -=== packages/b/src/index.ts === -import { a } from "@ts-bug/a"; ->a : Symbol(a, Decl(index.ts, 0, 8)) - -export function b(text: string) { ->b : Symbol(b, Decl(index.ts, 0, 30)) ->text : Symbol(text, Decl(index.ts, 2, 18)) - - return a(text); ->a : Symbol(a, Decl(index.ts, 0, 8)) ->text : Symbol(text, Decl(index.ts, 2, 18)) -} -=== packages/a/index.d.ts === -declare module "@ts-bug/a" { ->"@ts-bug/a" : Symbol("@ts-bug/a", Decl(index.d.ts, 0, 0)) - - export type AText = { ->AText : Symbol(AText, Decl(index.d.ts, 0, 28)) - - value: string; ->value : Symbol(value, Decl(index.d.ts, 1, 25)) - - }; - export function a(text: string): AText; ->a : Symbol(a, Decl(index.d.ts, 3, 6)) ->text : Symbol(text, Decl(index.d.ts, 4, 22)) ->AText : Symbol(AText, Decl(index.d.ts, 0, 28)) - } - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.types b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.types deleted file mode 100644 index 723c8c88d3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo.types +++ /dev/null @@ -1,31 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPathMappingMonorepo.ts] //// - -=== packages/b/src/index.ts === -import { a } from "@ts-bug/a"; ->a : (text: string) => import("@ts-bug/a").AText - -export function b(text: string) { ->b : (text: string) => import("@ts-bug/a").AText ->text : string - - return a(text); ->a(text) : import("@ts-bug/a").AText ->a : (text: string) => import("@ts-bug/a").AText ->text : string -} -=== packages/a/index.d.ts === -declare module "@ts-bug/a" { ->"@ts-bug/a" : typeof import("@ts-bug/a") - - export type AText = { ->AText : AText - - value: string; ->value : string - - }; - export function a(text: string): AText; ->a : (text: string) => AText ->text : string - } - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.errors.txt deleted file mode 100644 index ab846fb975..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.errors.txt +++ /dev/null @@ -1,54 +0,0 @@ -packages/lab/src/index.ts(1,31): error TS2307: Cannot find module '@ts-bug/core/utils' or its corresponding type declarations. -packages/lab/tsconfig.json(5,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. - Use '"paths": {"*": ["./../*"]}' instead. - - -==== packages/lab/tsconfig.json (1 errors) ==== - { - "compilerOptions": { - "outDir": "dist", - "declaration": true, - "baseUrl": "../", - ~~~~~~~~~ -!!! error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. -!!! error TS5102: Use '"paths": {"*": ["./../*"]}' instead. - "paths": { - "@ts-bug/core": ["./core/src"], - "@ts-bug/core/*": ["./core/src/*"], - "@ts-bug/lab": ["./lab/src"], - "@ts-bug/lab/*": ["./lab/src/*"], - "@ts-bug/styles": ["./styles/src"], - "@ts-bug/styles/*": ["./styles/src/*"] - } - } - } -==== packages/lab/src/index.ts (1 errors) ==== - import { createSvgIcon } from "@ts-bug/core/utils"; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@ts-bug/core/utils' or its corresponding type declarations. - export default createSvgIcon("Hello", "ArrowLeft"); - -==== packages/core/src/index.d.ts (0 errors) ==== - export * from "./utils"; - export { default as SvgIcon } from "./SvgIcon"; - -==== packages/core/src/SvgIcon.d.ts (0 errors) ==== - import { StyledComponentProps } from "@ts-bug/styles"; - export interface SvgIconProps extends StyledComponentProps<"root"> { - children?: string[]; - } - export interface SomeInterface { - myProp: string; - } - declare const SvgIcon: SomeInterface; - export default SvgIcon; - -==== packages/core/src/utils.d.ts (0 errors) ==== - import SvgIcon from "./SvgIcon"; - export function createSvgIcon(path: string, displayName: string): typeof SvgIcon; - -==== packages/styles/src/index.d.ts (0 errors) ==== - export interface StyledComponentProps { - classes?: Record; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.js deleted file mode 100644 index f6b97b76d2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.js +++ /dev/null @@ -1,41 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPathMappingMonorepo2.ts] //// - -//// [index.d.ts] -export * from "./utils"; -export { default as SvgIcon } from "./SvgIcon"; - -//// [SvgIcon.d.ts] -import { StyledComponentProps } from "@ts-bug/styles"; -export interface SvgIconProps extends StyledComponentProps<"root"> { - children?: string[]; -} -export interface SomeInterface { - myProp: string; -} -declare const SvgIcon: SomeInterface; -export default SvgIcon; - -//// [utils.d.ts] -import SvgIcon from "./SvgIcon"; -export function createSvgIcon(path: string, displayName: string): typeof SvgIcon; - -//// [index.d.ts] -export interface StyledComponentProps { - classes?: Record; -} - -//// [index.ts] -import { createSvgIcon } from "@ts-bug/core/utils"; -export default createSvgIcon("Hello", "ArrowLeft"); - - -//// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@ts-bug/core/utils"); -exports.default = (0, utils_1.createSvgIcon)("Hello", "ArrowLeft"); - - -//// [index.d.ts] -declare const _default: any; -export default _default; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.js.diff deleted file mode 100644 index 2230bdf2d8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.declarationEmitPathMappingMonorepo2.js -+++ new.declarationEmitPathMappingMonorepo2.js -@@= skipped -31, +31 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var utils_1 = require("@ts-bug/core/utils"); -+const utils_1 = require("@ts-bug/core/utils"); - exports.default = (0, utils_1.createSvgIcon)("Hello", "ArrowLeft"); - - - //// [index.d.ts] --declare const _default: import("@ts-bug/core/SvgIcon").SomeInterface; -+declare const _default: any; - export default _default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.symbols deleted file mode 100644 index ca75fa3b37..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.symbols +++ /dev/null @@ -1,9 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPathMappingMonorepo2.ts] //// - -=== packages/lab/src/index.ts === -import { createSvgIcon } from "@ts-bug/core/utils"; ->createSvgIcon : Symbol(createSvgIcon, Decl(index.ts, 0, 8)) - -export default createSvgIcon("Hello", "ArrowLeft"); ->createSvgIcon : Symbol(createSvgIcon, Decl(index.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.symbols.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.symbols.diff deleted file mode 100644 index fbb48fd5df..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.symbols.diff +++ /dev/null @@ -1,51 +0,0 @@ ---- old.declarationEmitPathMappingMonorepo2.symbols -+++ new.declarationEmitPathMappingMonorepo2.symbols -@@= skipped -6, +6 lines =@@ - export default createSvgIcon("Hello", "ArrowLeft"); - >createSvgIcon : Symbol(createSvgIcon, Decl(index.ts, 0, 8)) - --=== packages/core/src/SvgIcon.d.ts === --import { StyledComponentProps } from "@ts-bug/styles"; -->StyledComponentProps : Symbol(StyledComponentProps, Decl(SvgIcon.d.ts, 0, 8)) -- --export interface SvgIconProps extends StyledComponentProps<"root"> { -->SvgIconProps : Symbol(SvgIconProps, Decl(SvgIcon.d.ts, 0, 54)) -->StyledComponentProps : Symbol(StyledComponentProps, Decl(SvgIcon.d.ts, 0, 8)) -- -- children?: string[]; -->children : Symbol(SvgIconProps.children, Decl(SvgIcon.d.ts, 1, 68)) --} --export interface SomeInterface { -->SomeInterface : Symbol(SomeInterface, Decl(SvgIcon.d.ts, 3, 1)) -- -- myProp: string; -->myProp : Symbol(SomeInterface.myProp, Decl(SvgIcon.d.ts, 4, 32)) --} --declare const SvgIcon: SomeInterface; -->SvgIcon : Symbol(SvgIcon, Decl(SvgIcon.d.ts, 7, 13)) -->SomeInterface : Symbol(SomeInterface, Decl(SvgIcon.d.ts, 3, 1)) -- --export default SvgIcon; -->SvgIcon : Symbol(SvgIcon, Decl(SvgIcon.d.ts, 7, 13)) -- --=== packages/core/src/utils.d.ts === --import SvgIcon from "./SvgIcon"; -->SvgIcon : Symbol(SvgIcon, Decl(utils.d.ts, 0, 6)) -- --export function createSvgIcon(path: string, displayName: string): typeof SvgIcon; -->createSvgIcon : Symbol(createSvgIcon, Decl(utils.d.ts, 0, 32)) -->path : Symbol(path, Decl(utils.d.ts, 1, 30)) -->displayName : Symbol(displayName, Decl(utils.d.ts, 1, 43)) -->SvgIcon : Symbol(SvgIcon, Decl(utils.d.ts, 0, 6)) -- --=== packages/styles/src/index.d.ts === --export interface StyledComponentProps { -->StyledComponentProps : Symbol(StyledComponentProps, Decl(index.d.ts, 0, 0)) -->ClassKey : Symbol(ClassKey, Decl(index.d.ts, 0, 38)) -- -- classes?: Record; -->classes : Symbol(StyledComponentProps.classes, Decl(index.d.ts, 0, 64)) -->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) -->ClassKey : Symbol(ClassKey, Decl(index.d.ts, 0, 38)) --} -- \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.types b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.types deleted file mode 100644 index edd6912a35..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPathMappingMonorepo2.ts] //// - -=== packages/lab/src/index.ts === -import { createSvgIcon } from "@ts-bug/core/utils"; ->createSvgIcon : any - -export default createSvgIcon("Hello", "ArrowLeft"); ->createSvgIcon("Hello", "ArrowLeft") : any ->createSvgIcon : any ->"Hello" : "Hello" ->"ArrowLeft" : "ArrowLeft" - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.types.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.types.diff deleted file mode 100644 index 6c1d99ed73..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPathMappingMonorepo2.types.diff +++ /dev/null @@ -1,50 +0,0 @@ ---- old.declarationEmitPathMappingMonorepo2.types -+++ new.declarationEmitPathMappingMonorepo2.types -@@= skipped -1, +1 lines =@@ - - === packages/lab/src/index.ts === - import { createSvgIcon } from "@ts-bug/core/utils"; -->createSvgIcon : (path: string, displayName: string) => import("packages/core/src/SvgIcon").SomeInterface -+>createSvgIcon : any - - export default createSvgIcon("Hello", "ArrowLeft"); -->createSvgIcon("Hello", "ArrowLeft") : import("packages/core/src/SvgIcon").SomeInterface -->createSvgIcon : (path: string, displayName: string) => import("packages/core/src/SvgIcon").SomeInterface -+>createSvgIcon("Hello", "ArrowLeft") : any -+>createSvgIcon : any - >"Hello" : "Hello" - >"ArrowLeft" : "ArrowLeft" -- --=== packages/core/src/SvgIcon.d.ts === --import { StyledComponentProps } from "@ts-bug/styles"; -->StyledComponentProps : any -- --export interface SvgIconProps extends StyledComponentProps<"root"> { -- children?: string[]; -->children : string[] --} --export interface SomeInterface { -- myProp: string; -->myProp : string --} --declare const SvgIcon: SomeInterface; -->SvgIcon : SomeInterface -- --export default SvgIcon; -->SvgIcon : SomeInterface -- --=== packages/core/src/utils.d.ts === --import SvgIcon from "./SvgIcon"; -->SvgIcon : import("packages/core/src/SvgIcon").SomeInterface -- --export function createSvgIcon(path: string, displayName: string): typeof SvgIcon; -->createSvgIcon : (path: string, displayName: string) => typeof SvgIcon -->path : string -->displayName : string -->SvgIcon : import("packages/core/src/SvgIcon").SomeInterface -- --=== packages/styles/src/index.d.ts === --export interface StyledComponentProps { -- classes?: Record; -->classes : Record --} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.errors.txt deleted file mode 100644 index 2a2158debf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. -==== src/lib/operators/scalar.ts (0 errors) ==== - export interface Scalar { - (): string; - value: number; - } - - export function scalar(value: string): Scalar { - return null as any; - } -==== src/settings/spacing.ts (0 errors) ==== - import { scalar } from '../lib/operators/scalar'; - - export default { - get xs() { - return scalar("14px"); - } - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.js b/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.js deleted file mode 100644 index db59c23bec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.js +++ /dev/null @@ -1,50 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts] //// - -//// [scalar.ts] -export interface Scalar { - (): string; - value: number; -} - -export function scalar(value: string): Scalar { - return null as any; -} -//// [spacing.ts] -import { scalar } from '../lib/operators/scalar'; - -export default { - get xs() { - return scalar("14px"); - } -}; - - -//// [scalar.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.scalar = scalar; -function scalar(value) { - return null; -} -//// [spacing.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const scalar_1 = require("../lib/operators/scalar"); -exports.default = { - get xs() { - return (0, scalar_1.scalar)("14px"); - } -}; - - -//// [scalar.d.ts] -export interface Scalar { - (): string; - value: number; -} -export declare function scalar(value: string): Scalar; -//// [spacing.d.ts] -declare const _default: { - readonly xs: import("../lib/operators/scalar").Scalar; -}; -export default _default; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.js.diff deleted file mode 100644 index 16adf24359..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitPrefersPathKindBasedOnBundling.js -+++ new.declarationEmitPrefersPathKindBasedOnBundling.js -@@= skipped -28, +28 lines =@@ - //// [spacing.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var scalar_1 = require("../lib/operators/scalar"); -+const scalar_1 = require("../lib/operators/scalar"); - exports.default = { - get xs() { - return (0, scalar_1.scalar)("14px"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.symbols deleted file mode 100644 index c8a925c145..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.symbols +++ /dev/null @@ -1,31 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts] //// - -=== src/lib/operators/scalar.ts === -export interface Scalar { ->Scalar : Symbol(Scalar, Decl(scalar.ts, 0, 0)) - - (): string; - value: number; ->value : Symbol(Scalar.value, Decl(scalar.ts, 1, 12)) -} - -export function scalar(value: string): Scalar { ->scalar : Symbol(scalar, Decl(scalar.ts, 3, 1)) ->value : Symbol(value, Decl(scalar.ts, 5, 23)) ->Scalar : Symbol(Scalar, Decl(scalar.ts, 0, 0)) - - return null as any; -} -=== src/settings/spacing.ts === -import { scalar } from '../lib/operators/scalar'; ->scalar : Symbol(scalar, Decl(spacing.ts, 0, 8)) - -export default { - get xs() { ->xs : Symbol(xs, Decl(spacing.ts, 2, 16)) - - return scalar("14px"); ->scalar : Symbol(scalar, Decl(spacing.ts, 0, 8)) - } -}; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.types b/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.types deleted file mode 100644 index 5ae200962a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrefersPathKindBasedOnBundling.types +++ /dev/null @@ -1,33 +0,0 @@ -//// [tests/cases/compiler/declarationEmitPrefersPathKindBasedOnBundling.ts] //// - -=== src/lib/operators/scalar.ts === -export interface Scalar { - (): string; - value: number; ->value : number -} - -export function scalar(value: string): Scalar { ->scalar : (value: string) => Scalar ->value : string - - return null as any; ->null as any : any -} -=== src/settings/spacing.ts === -import { scalar } from '../lib/operators/scalar'; ->scalar : (value: string) => import("src/lib/operators/scalar").Scalar - -export default { ->{ get xs() { return scalar("14px"); }} : { readonly xs: import("src/lib/operators/scalar").Scalar; } - - get xs() { ->xs : import("src/lib/operators/scalar").Scalar - - return scalar("14px"); ->scalar("14px") : import("src/lib/operators/scalar").Scalar ->scalar : (value: string) => import("src/lib/operators/scalar").Scalar ->"14px" : "14px" - } -}; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPreserveReferencedImports.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPreserveReferencedImports.js.diff deleted file mode 100644 index 83b706aaeb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPreserveReferencedImports.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitPreserveReferencedImports.js -+++ new.declarationEmitPreserveReferencedImports.js -@@= skipped -26, +26 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.f = void 0; --var decl_1 = require("./decl"); -+const decl_1 = require("./decl"); - exports.f = { o: (0, decl_1.o)({ v: null }) }; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateReadonlyLiterals.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateReadonlyLiterals.js.diff index 9b324bfd28..f75495e4f1 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateReadonlyLiterals.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateReadonlyLiterals.js.diff @@ -1,26 +1,20 @@ --- old.declarationEmitPrivateReadonlyLiterals.js +++ new.declarationEmitPrivateReadonlyLiterals.js -@@= skipped -9, +9 lines =@@ - +@@= skipped -10, +10 lines =@@ //// [declarationEmitPrivateReadonlyLiterals.js] --let Foo = (() => { -- class Foo { -- constructor() { -- this.B = "b"; -- this.D = 42; -- } + class Foo { +- constructor() { +- this.B = "b"; +- this.D = 42; - } -- Foo.A = "a"; -- Foo.C = 42; -- return Foo; --})(); -+class Foo { + static A = "a"; + B = "b"; + static C = 42; + D = 42; -+} + } +-Foo.A = "a"; +-Foo.C = 42; //// [declarationEmitPrivateReadonlyLiterals.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js.diff index 68223f05a7..f4e99ebf67 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js.diff @@ -7,8 +7,7 @@ -var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); + const a_1 = require("./a"); class C { - constructor() { - this[_a] = 1; @@ -22,10 +21,8 @@ -var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.D = void 0; --var a_1 = require("./a"); --var b_1 = require("./b"); -+const a_1 = require("./a"); -+const b_1 = require("./b"); + const a_1 = require("./a"); + const b_1 = require("./b"); class D extends b_1.C { - constructor() { - super(...arguments); diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitQualifiedAliasTypeArgument.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitQualifiedAliasTypeArgument.js.diff deleted file mode 100644 index e09ce24362..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitQualifiedAliasTypeArgument.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitQualifiedAliasTypeArgument.js -+++ new.declarationEmitQualifiedAliasTypeArgument.js -@@= skipped -30, +30 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.fun2 = exports.fun = void 0; --var bbb_1 = require("./bbb"); -+const bbb_1 = require("./bbb"); - exports.fun = (0, bbb_1.create)(); - exports.fun2 = (0, bbb_1.create)(); diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js b/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js index 80863fe47d..cc545d98a2 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js @@ -33,21 +33,10 @@ function createInstance() { } //// [index.js] "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.spread = void 0; const bug_1 = require("./bug"); -exports.spread = __assign({}, (0, bug_1.createInstance)()); +exports.spread = Object.assign({}, (0, bug_1.createInstance)()); //// [bug.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js.diff index 57152bbabf..0bea973d83 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitReadonlyComputedProperty.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitReadonlyComputedProperty.js +++ new.declarationEmitReadonlyComputedProperty.js -@@= skipped -45, +45 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.spread = void 0; --var bug_1 = require("./bug"); -+const bug_1 = require("./bug"); - exports.spread = __assign({}, (0, bug_1.createInstance)()); - - -@@= skipped -10, +10 lines =@@ +@@= skipped -44, +44 lines =@@ readonly [SYMBOL]: string; } export declare function createInstance(): Interface; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference.js.diff deleted file mode 100644 index 02b2051f9a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitReexportedSymlinkReference.js -+++ new.declarationEmitReexportedSymlinkReference.js -@@= skipped -46, +46 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ADMIN = void 0; --var pkg2_1 = require("@raymondfeng/pkg2"); -+const pkg2_1 = require("@raymondfeng/pkg2"); - exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); - //// [index.js] - "use strict"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference2.js.diff index e4c91af8f8..67bb08a149 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference2.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitReexportedSymlinkReference2.js +++ new.declarationEmitReexportedSymlinkReference2.js -@@= skipped -49, +49 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ADMIN = void 0; --var pkg2_1 = require("@raymondfeng/pkg2"); -+const pkg2_1 = require("@raymondfeng/pkg2"); - exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); - //// [index.js] - "use strict"; -@@= skipped -24, +24 lines =@@ +@@= skipped -73, +73 lines =@@ //// [keys.d.ts] import { MetadataAccessor } from "@raymondfeng/pkg2"; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.js.diff index 63337a5943..b09fdf0eb0 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitReexportedSymlinkReference3.js +++ new.declarationEmitReexportedSymlinkReference3.js -@@= skipped -46, +46 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ADMIN = void 0; --var pkg2_1 = require("@raymondfeng/pkg2"); -+const pkg2_1 = require("@raymondfeng/pkg2"); - exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); - //// [index.js] - "use strict"; -@@= skipped -22, +22 lines =@@ +@@= skipped -68, +68 lines =@@ __exportStar(require("./keys"), exports); diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js b/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js index dfe577cd87..de528003e1 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js @@ -11,9 +11,42 @@ export const run = (i: () => E.Whatever): E.Whatever => E.something(i); //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; -const E = require("whatever"); +const E = __importStar(require("whatever")); const run = (i) => E.something(i); exports.run = run; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js.diff deleted file mode 100644 index 69daf85b04..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitRetainedAnnotationRetainsImportInOutput.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitRetainedAnnotationRetainsImportInOutput.js -+++ new.declarationEmitRetainedAnnotationRetainsImportInOutput.js -@@= skipped -12, +12 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.run = void 0; --var E = require("whatever"); -+const E = require("whatever"); - const run = (i) => E.something(i); - exports.run = run; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitScopeConsistency.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitScopeConsistency.js.diff deleted file mode 100644 index 3cf7d94e90..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitScopeConsistency.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitScopeConsistency.js -+++ new.declarationEmitScopeConsistency.js -@@= skipped -19, +19 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.g = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); - exports.g = a_1.f; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js b/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js index a41ed9e6ef..3bcd5e2c1e 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js @@ -6,17 +6,6 @@ export const SpotifyAgeGroupEnum = { ...AgeGroups }; //// [declarationEmitSpreadStringlyKeyedEnum.js] "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.SpotifyAgeGroupEnum = void 0; var AgeGroups; @@ -29,7 +18,7 @@ var AgeGroups; AgeGroups[AgeGroups["45-59"] = 5] = "45-59"; AgeGroups[AgeGroups["60-150"] = 6] = "60-150"; })(AgeGroups || (AgeGroups = {})); -exports.SpotifyAgeGroupEnum = __assign({}, AgeGroups); +exports.SpotifyAgeGroupEnum = Object.assign({}, AgeGroups); //// [declarationEmitSpreadStringlyKeyedEnum.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js.diff index ad0166b32d..fe7caa9b71 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitSpreadStringlyKeyedEnum.js.diff @@ -1,6 +1,6 @@ --- old.declarationEmitSpreadStringlyKeyedEnum.js +++ new.declarationEmitSpreadStringlyKeyedEnum.js -@@= skipped -43, +43 lines =@@ +@@= skipped -32, +32 lines =@@ } export declare const SpotifyAgeGroupEnum: { [x: number]: string; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js b/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js index b9e1f3e3e9..2b76c687bb 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js @@ -46,23 +46,12 @@ class A { exports.A = A; //// [index.js] "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.B = void 0; const class_1 = require("./class"); class B extends class_1.A { getA() { - return __assign(__assign({}, super.getA()), { a: '123' }); + return Object.assign(Object.assign({}, super.getA()), { a: '123' }); } } exports.B = B; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js.diff deleted file mode 100644 index 10be9dc844..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitStringEnumUsedInNonlocalSpread.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitStringEnumUsedInNonlocalSpread.js -+++ new.declarationEmitStringEnumUsedInNonlocalSpread.js -@@= skipped -58, +58 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.B = void 0; --var class_1 = require("./class"); -+const class_1 = require("./class"); - class B extends class_1.A { - getA() { - return __assign(__assign({}, super.getA()), { a: '123' }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitSymlinkPaths.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitSymlinkPaths.js.diff deleted file mode 100644 index 698bf06685..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitSymlinkPaths.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.declarationEmitSymlinkPaths.js -+++ new.declarationEmitSymlinkPaths.js -@@= skipped -34, +34 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.NotificationScenario = void 0; --var index_1 = require("search/lib/index"); --var NotificationAPIUtils_1 = require("../API/NotificationAPIUtils"); -+const index_1 = require("search/lib/index"); -+const NotificationAPIUtils_1 = require("../API/NotificationAPIUtils"); - exports.NotificationScenario = (0, index_1.test)(NotificationAPIUtils_1.getNotification); - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile.js.diff index 3ade3ca35d..78af8589f8 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile.js.diff @@ -1,15 +1,6 @@ --- old.declarationEmitTopLevelNodeFromCrossFile.js +++ new.declarationEmitTopLevelNodeFromCrossFile.js -@@= skipped -24, +24 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = exports.m = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); - exports.m = { - /** - * leading doc for prop -@@= skipped -13, +13 lines =@@ +@@= skipped -37, +37 lines =@@ //// [a.d.ts] export type X = string; export declare const fn: { diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile2.js.diff deleted file mode 100644 index 69a7035dd1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTopLevelNodeFromCrossFile2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitTopLevelNodeFromCrossFile2.js -+++ new.declarationEmitTopLevelNodeFromCrossFile2.js -@@= skipped -25, +25 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports._ = void 0; --var boxedBox_1 = require("./boxedBox"); -+const boxedBox_1 = require("./boxedBox"); - exports._ = boxedBox_1.boxedBox; - // At index 83 - /** \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.js.diff index 0b54229003..8685202443 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.js.diff @@ -1,24 +1,6 @@ --- old.declarationEmitTransitiveImportOfHtmlDeclarationItem.js +++ new.declarationEmitTransitiveImportOfHtmlDeclarationItem.js -@@= skipped -17, +17 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.func = func; --var foo_html_1 = require("./foo.html"); -+const foo_html_1 = require("./foo.html"); - function func() { - return new foo_html_1.CustomHtmlRepresentationThing(); - } -@@= skipped -8, +8 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.c = void 0; --var reexporter_1 = require("./reexporter"); -+const reexporter_1 = require("./reexporter"); - exports.c = (0, reexporter_1.func)(); - - -@@= skipped -8, +8 lines =@@ +@@= skipped -33, +33 lines =@@ import { CustomHtmlRepresentationThing } from "./foo.html"; export declare function func(): CustomHtmlRepresentationThing; //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js index 9c69967a86..ba95fc4d44 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js @@ -17,8 +17,41 @@ exports.default = C; ; //// [b.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("./a"); +const a = __importStar(require("./a")); exports.default = a.default; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js.diff deleted file mode 100644 index dd076f5639..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofDefaultExport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.declarationEmitTypeofDefaultExport.js -+++ new.declarationEmitTypeofDefaultExport.js -@@= skipped -17, +17 lines =@@ - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("./a"); -+const a = require("./a"); - exports.default = a.default; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js index cec0c160c1..14d8a5da08 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js @@ -7,6 +7,7 @@ class Foo { } //// [declarationEmitTypeofThisInClass.js] +"use strict"; class Foo { foo; bar; //Public property 'bar' of exported class has or is using private name 'this'.(4031) diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js.diff index 9da3a505c5..ba34562938 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitTypeofThisInClass.js.diff @@ -1,10 +1,8 @@ --- old.declarationEmitTypeofThisInClass.js +++ new.declarationEmitTypeofThisInClass.js -@@= skipped -6, +6 lines =@@ - } - +@@= skipped -8, +8 lines =@@ //// [declarationEmitTypeofThisInClass.js] --"use strict"; + "use strict"; class Foo { + foo; + bar; //Public property 'bar' of exported class has or is using private name 'this'.(4031) diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt index ffde8f5e80..1826289e03 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt @@ -1,9 +1,10 @@ declarationEmitUnknownImport.ts(1,1): error TS2303: Circular definition of import alias 'Foo'. declarationEmitUnknownImport.ts(1,14): error TS2304: Cannot find name 'SomeNonExistingName'. declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. +declarationEmitUnknownImport.ts(2,9): error TS2303: Circular definition of import alias 'Foo'. -==== declarationEmitUnknownImport.ts (3 errors) ==== +==== declarationEmitUnknownImport.ts (4 errors) ==== import Foo = SomeNonExistingName ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'Foo'. @@ -11,4 +12,6 @@ declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'Some !!! error TS2304: Cannot find name 'SomeNonExistingName'. ~~~~~~~~~~~~~~~~~~~ !!! error TS2503: Cannot find namespace 'SomeNonExistingName'. - export {Foo} \ No newline at end of file + export {Foo} + ~~~ +!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff new file mode 100644 index 0000000000..486c3ff82d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.declarationEmitUnknownImport.errors.txt ++++ new.declarationEmitUnknownImport.errors.txt +@@= skipped -0, +0 lines =@@ + declarationEmitUnknownImport.ts(1,1): error TS2303: Circular definition of import alias 'Foo'. + declarationEmitUnknownImport.ts(1,14): error TS2304: Cannot find name 'SomeNonExistingName'. + declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. +- +- +-==== declarationEmitUnknownImport.ts (3 errors) ==== ++declarationEmitUnknownImport.ts(2,9): error TS2303: Circular definition of import alias 'Foo'. ++ ++ ++==== declarationEmitUnknownImport.ts (4 errors) ==== + import Foo = SomeNonExistingName + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2303: Circular definition of import alias 'Foo'. +@@= skipped -11, +12 lines =@@ + ~~~~~~~~~~~~~~~~~~~ + !!! error TS2503: Cannot find namespace 'SomeNonExistingName'. + export {Foo} ++ ~~~ ++!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt index 37d7841f4b..f52b6fd9af 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt @@ -3,9 +3,10 @@ declarationEmitUnknownImport2.ts(1,12): error TS1005: '=' expected. declarationEmitUnknownImport2.ts(1,12): error TS2304: Cannot find name 'From'. declarationEmitUnknownImport2.ts(1,12): error TS2503: Cannot find namespace 'From'. declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. +declarationEmitUnknownImport2.ts(2,1): error TS2303: Circular definition of import alias 'Foo'. -==== declarationEmitUnknownImport2.ts (5 errors) ==== +==== declarationEmitUnknownImport2.ts (6 errors) ==== import Foo From './Foo'; // Syntax error ~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'Foo'. @@ -17,4 +18,6 @@ declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. !!! error TS2503: Cannot find namespace 'From'. ~~~~~~~ !!! error TS1005: ';' expected. - export default Foo \ No newline at end of file + export default Foo + ~~~~~~~~~~~~~~~~~~ +!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff new file mode 100644 index 0000000000..00d4874583 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.declarationEmitUnknownImport2.errors.txt ++++ new.declarationEmitUnknownImport2.errors.txt +@@= skipped -2, +2 lines =@@ + declarationEmitUnknownImport2.ts(1,12): error TS2304: Cannot find name 'From'. + declarationEmitUnknownImport2.ts(1,12): error TS2503: Cannot find namespace 'From'. + declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. +- +- +-==== declarationEmitUnknownImport2.ts (5 errors) ==== ++declarationEmitUnknownImport2.ts(2,1): error TS2303: Circular definition of import alias 'Foo'. ++ ++ ++==== declarationEmitUnknownImport2.ts (6 errors) ==== + import Foo From './Foo'; // Syntax error + ~~~~~~~~~~~~~~~ + !!! error TS2303: Circular definition of import alias 'Foo'. +@@= skipped -15, +16 lines =@@ + ~~~~~~~ + !!! error TS1005: ';' expected. + export default Foo ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnnessesaryTypeReferenceNotAdded.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitUnnessesaryTypeReferenceNotAdded.js.diff deleted file mode 100644 index 3aa75a2b79..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitUnnessesaryTypeReferenceNotAdded.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.declarationEmitUnnessesaryTypeReferenceNotAdded.js -+++ new.declarationEmitUnnessesaryTypeReferenceNotAdded.js -@@= skipped -33, +33 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = parseArgs; --var minimist = require("minimist"); --var process = require("process"); -+const minimist = require("minimist"); -+const process = require("process"); - function parseArgs() { - return minimist(process.argv.slice(2)); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js b/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js index 195ad857cb..ad6cdb16f5 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js @@ -25,9 +25,12 @@ exports.default = createExperiment({ }); //// [main.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.obj = void 0; -const other_1 = require("./other"); +const other_1 = __importDefault(require("./other")); exports.obj = { [other_1.default.name]: 1, }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js.diff deleted file mode 100644 index c78674f754..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitWithDefaultAsComputedName.js -+++ new.declarationEmitWithDefaultAsComputedName.js -@@= skipped -26, +26 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.obj = void 0; --var other_1 = require("./other"); -+const other_1 = require("./other"); - exports.obj = { - [other_1.default.name]: 1, - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js index 4c2abfbbda..30de49c199 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js @@ -25,9 +25,42 @@ exports.default = createExperiment({ }); //// [main.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.obj = void 0; -const other2 = require("./other"); +const other2 = __importStar(require("./other")); exports.obj = { [other2.default.name]: 1 }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js.diff deleted file mode 100644 index 150c2f5a62..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitWithDefaultAsComputedName2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitWithDefaultAsComputedName2.js -+++ new.declarationEmitWithDefaultAsComputedName2.js -@@= skipped -26, +26 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.obj = void 0; --var other2 = require("./other"); -+const other2 = require("./other"); - exports.obj = { - [other2.default.name]: 1 - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.errors.txt deleted file mode 100644 index 7d282537b9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /out.d.ts (0 errors) ==== - declare class c { - } - -==== /a.ts (0 errors) ==== - class d { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.symbols b/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.symbols deleted file mode 100644 index 37e4014855..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.symbols +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/declarationFileOverwriteErrorWithOut.ts] //// - -=== /out.d.ts === -declare class c { ->c : Symbol(c, Decl(out.d.ts, 0, 0)) -} - -=== /a.ts === -class d { ->d : Symbol(d, Decl(a.ts, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.types b/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.types deleted file mode 100644 index 782a7001f3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationFileOverwriteErrorWithOut.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/declarationFileOverwriteErrorWithOut.ts] //// - -=== /out.d.ts === -declare class c { ->c : c -} - -=== /a.ts === -class d { ->d : d -} - diff --git a/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.errors.txt deleted file mode 100644 index 6a8d2c1cec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /a/node_modules/@types/jquery/index.d.ts (0 errors) ==== - interface JQuery { - - } - -==== /a/app.ts (0 errors) ==== - /// - namespace Test { - export var x: JQuery; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.symbols b/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.symbols deleted file mode 100644 index 43deeeb86e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/declarationFilesGeneratingTypeReferences.ts] //// - -=== /a/node_modules/@types/jquery/index.d.ts === -interface JQuery { ->JQuery : Symbol(JQuery, Decl(index.d.ts, 0, 0)) - -} - -=== /a/app.ts === -/// -namespace Test { ->Test : Symbol(Test, Decl(app.ts, 0, 0)) - - export var x: JQuery; ->x : Symbol(x, Decl(app.ts, 2, 14)) ->JQuery : Symbol(JQuery, Decl(index.d.ts, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.types b/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.types deleted file mode 100644 index c75d2a039b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationFilesGeneratingTypeReferences.types +++ /dev/null @@ -1,17 +0,0 @@ -//// [tests/cases/compiler/declarationFilesGeneratingTypeReferences.ts] //// - -=== /a/node_modules/@types/jquery/index.d.ts === - -interface JQuery { - -} - -=== /a/app.ts === -/// -namespace Test { ->Test : typeof Test - - export var x: JQuery; ->x : JQuery -} - diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsMultifile.js.diff b/testdata/baselines/reference/submodule/compiler/declarationMapsMultifile.js.diff deleted file mode 100644 index 3bd4d3f673..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsMultifile.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationMapsMultifile.js -+++ new.declarationMapsMultifile.js -@@= skipped -35, +35 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo = exports.c = exports.x = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); - Object.defineProperty(exports, "Foo", { enumerable: true, get: function () { return a_1.Foo; } }); - const c = new a_1.Foo(); - exports.c = c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.errors.txt deleted file mode 100644 index a4cab2ae02..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class Foo { - doThing(x: {a: number}) { - return {b: x.a}; - } - static make() { - return new Foo(); - } - } -==== index.ts (0 errors) ==== - const c = new Foo(); - c.doThing({a: 42}); - - let x = c.doThing({a: 12}); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.symbols b/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.symbols deleted file mode 100644 index 9e84d10378..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.symbols +++ /dev/null @@ -1,42 +0,0 @@ -//// [tests/cases/compiler/declarationMapsOutFile2.ts] //// - -=== a.ts === -class Foo { ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - - doThing(x: {a: number}) { ->doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->x : Symbol(x, Decl(a.ts, 1, 12)) ->a : Symbol(a, Decl(a.ts, 1, 16)) - - return {b: x.a}; ->b : Symbol(b, Decl(a.ts, 2, 16)) ->x.a : Symbol(a, Decl(a.ts, 1, 16)) ->x : Symbol(x, Decl(a.ts, 1, 12)) ->a : Symbol(a, Decl(a.ts, 1, 16)) - } - static make() { ->make : Symbol(Foo.make, Decl(a.ts, 3, 5)) - - return new Foo(); ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - } -} -=== index.ts === -const c = new Foo(); ->c : Symbol(c, Decl(index.ts, 0, 5)) ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -c.doThing({a: 42}); ->c.doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->c : Symbol(c, Decl(index.ts, 0, 5)) ->doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->a : Symbol(a, Decl(index.ts, 1, 11)) - -let x = c.doThing({a: 12}); ->x : Symbol(x, Decl(index.ts, 3, 3)) ->c.doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->c : Symbol(c, Decl(index.ts, 0, 5)) ->doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->a : Symbol(a, Decl(index.ts, 3, 19)) - diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.types b/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.types deleted file mode 100644 index d739e4cbb4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsOutFile2.types +++ /dev/null @@ -1,51 +0,0 @@ -//// [tests/cases/compiler/declarationMapsOutFile2.ts] //// - -=== a.ts === -class Foo { ->Foo : Foo - - doThing(x: {a: number}) { ->doThing : (x: { a: number; }) => { b: number; } ->x : { a: number; } ->a : number - - return {b: x.a}; ->{b: x.a} : { b: number; } ->b : number ->x.a : number ->x : { a: number; } ->a : number - } - static make() { ->make : () => Foo - - return new Foo(); ->new Foo() : Foo ->Foo : typeof Foo - } -} -=== index.ts === -const c = new Foo(); ->c : Foo ->new Foo() : Foo ->Foo : typeof Foo - -c.doThing({a: 42}); ->c.doThing({a: 42}) : { b: number; } ->c.doThing : (x: { a: number; }) => { b: number; } ->c : Foo ->doThing : (x: { a: number; }) => { b: number; } ->{a: 42} : { a: number; } ->a : number ->42 : 42 - -let x = c.doThing({a: 12}); ->x : { b: number; } ->c.doThing({a: 12}) : { b: number; } ->c.doThing : (x: { a: number; }) => { b: number; } ->c : Foo ->doThing : (x: { a: number; }) => { b: number; } ->{a: 12} : { a: number; } ->a : number ->12 : 12 - diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.errors.txt deleted file mode 100644 index a4cab2ae02..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class Foo { - doThing(x: {a: number}) { - return {b: x.a}; - } - static make() { - return new Foo(); - } - } -==== index.ts (0 errors) ==== - const c = new Foo(); - c.doThing({a: 42}); - - let x = c.doThing({a: 12}); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.symbols b/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.symbols deleted file mode 100644 index 0111155c73..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.symbols +++ /dev/null @@ -1,42 +0,0 @@ -//// [tests/cases/compiler/declarationMapsWithSourceMap.ts] //// - -=== a.ts === -class Foo { ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - - doThing(x: {a: number}) { ->doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->x : Symbol(x, Decl(a.ts, 1, 12)) ->a : Symbol(a, Decl(a.ts, 1, 16)) - - return {b: x.a}; ->b : Symbol(b, Decl(a.ts, 2, 16)) ->x.a : Symbol(a, Decl(a.ts, 1, 16)) ->x : Symbol(x, Decl(a.ts, 1, 12)) ->a : Symbol(a, Decl(a.ts, 1, 16)) - } - static make() { ->make : Symbol(Foo.make, Decl(a.ts, 3, 5)) - - return new Foo(); ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - } -} -=== index.ts === -const c = new Foo(); ->c : Symbol(c, Decl(index.ts, 0, 5)) ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -c.doThing({a: 42}); ->c.doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->c : Symbol(c, Decl(index.ts, 0, 5)) ->doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->a : Symbol(a, Decl(index.ts, 1, 11)) - -let x = c.doThing({a: 12}); ->x : Symbol(x, Decl(index.ts, 3, 3)) ->c.doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->c : Symbol(c, Decl(index.ts, 0, 5)) ->doThing : Symbol(Foo.doThing, Decl(a.ts, 0, 11)) ->a : Symbol(a, Decl(index.ts, 3, 19)) - diff --git a/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.types b/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.types deleted file mode 100644 index c98f45dde6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationMapsWithSourceMap.types +++ /dev/null @@ -1,51 +0,0 @@ -//// [tests/cases/compiler/declarationMapsWithSourceMap.ts] //// - -=== a.ts === -class Foo { ->Foo : Foo - - doThing(x: {a: number}) { ->doThing : (x: { a: number; }) => { b: number; } ->x : { a: number; } ->a : number - - return {b: x.a}; ->{b: x.a} : { b: number; } ->b : number ->x.a : number ->x : { a: number; } ->a : number - } - static make() { ->make : () => Foo - - return new Foo(); ->new Foo() : Foo ->Foo : typeof Foo - } -} -=== index.ts === -const c = new Foo(); ->c : Foo ->new Foo() : Foo ->Foo : typeof Foo - -c.doThing({a: 42}); ->c.doThing({a: 42}) : { b: number; } ->c.doThing : (x: { a: number; }) => { b: number; } ->c : Foo ->doThing : (x: { a: number; }) => { b: number; } ->{a: 42} : { a: number; } ->a : number ->42 : 42 - -let x = c.doThing({a: 12}); ->x : { b: number; } ->c.doThing({a: 12}) : { b: number; } ->c.doThing : (x: { a: number; }) => { b: number; } ->c : Foo ->doThing : (x: { a: number; }) => { b: number; } ->{a: 12} : { a: number; } ->a : number ->12 : 12 - diff --git a/testdata/baselines/reference/submodule/compiler/declarationNoDanglingGenerics.js.diff b/testdata/baselines/reference/submodule/compiler/declarationNoDanglingGenerics.js.diff index ab998bb17c..6775d3e345 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationNoDanglingGenerics.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationNoDanglingGenerics.js.diff @@ -13,25 +13,19 @@ - }, - _a.THE_KIND = kind, - _a; --} --let Kinds = (() => { -- class Kinds { -- } -- Kinds.A = "A"; -- Kinds.B = "B"; -- Kinds.C = "C"; -- return Kinds; --})(); + return class { + static THE_KIND = kind; + kind = kind; + }; -+} -+class Kinds { + } + class Kinds { + static A = "A"; + static B = "B"; + static C = "C"; -+} + } +-Kinds.A = "A"; +-Kinds.B = "B"; +-Kinds.C = "C"; class AKind extends ClassFactory(Kinds.A) { } exports.AKind = AKind; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationsForInferredTypeFromOtherFile.js.diff b/testdata/baselines/reference/submodule/compiler/declarationsForInferredTypeFromOtherFile.js.diff deleted file mode 100644 index 832b323d4f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationsForInferredTypeFromOtherFile.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationsForInferredTypeFromOtherFile.js -+++ new.declarationsForInferredTypeFromOtherFile.js -@@= skipped -30, +30 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.bar = bar; --var file2_1 = require("./file2"); -+const file2_1 = require("./file2"); - function bar() { - return (0, file2_1.foo)(); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js index 916a7548c9..50a1fa7882 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js +++ b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js @@ -20,39 +20,45 @@ export const MyComp = Ctor.extends({foo: "bar"}); //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.MyComp = void 0; -const ns = require("mod"); +const ns = __importStar(require("mod")); const Ctor = ns.default; exports.MyComp = Ctor.extends({ foo: "bar" }); //// [index.d.ts] -import * as ns from "mod"; -export declare const MyComp: import("mod").ExtendedCtor; - - -//// [DtsFileErrors] - - -index.d.ts(2,44): error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. - - -==== node_modules/mod/ctor.d.ts (0 errors) ==== - export interface Ctor { - x: number; - } - export type ExtendedCtor = {x: number, ext: T}; - export interface CtorConstructor { - extends(x: T): ExtendedCtor; - } - export const Ctor: CtorConstructor; -==== node_modules/mod/index.d.ts (0 errors) ==== - import { Ctor } from "./ctor"; - export default Ctor; -==== index.d.ts (1 errors) ==== - import * as ns from "mod"; - export declare const MyComp: import("mod").ExtendedCtor; - ~~~~~~~~~~~~ -!!! error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. - \ No newline at end of file +export declare const MyComp: import("mod/ctor").ExtendedCtor; diff --git a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff deleted file mode 100644 index c460ba5131..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.declarationsIndirectGeneratedAliasReference.js -+++ new.declarationsIndirectGeneratedAliasReference.js -@@= skipped -21, +21 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.MyComp = void 0; --var ns = require("mod"); -+const ns = require("mod"); - const Ctor = ns.default; - exports.MyComp = Ctor.extends({ foo: "bar" }); - - - //// [index.d.ts] - import * as ns from "mod"; --export declare const MyComp: import("mod/ctor").ExtendedCtor; -+export declare const MyComp: import("mod").ExtendedCtor; -+ -+ -+//// [DtsFileErrors] -+ -+ -+index.d.ts(2,44): error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. -+ -+ -+==== node_modules/mod/ctor.d.ts (0 errors) ==== -+ export interface Ctor { -+ x: number; -+ } -+ export type ExtendedCtor = {x: number, ext: T}; -+ export interface CtorConstructor { -+ extends(x: T): ExtendedCtor; -+ } -+ export const Ctor: CtorConstructor; -+==== node_modules/mod/index.d.ts (0 errors) ==== -+ import { Ctor } from "./ctor"; -+ export default Ctor; -+==== index.d.ts (1 errors) ==== -+ import * as ns from "mod"; -+ export declare const MyComp: import("mod").ExtendedCtor; -+ ~~~~~~~~~~~~ -+!!! error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js b/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js index bf75d38e5a..eefbdc979e 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js +++ b/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js @@ -44,17 +44,8 @@ void p3.result.three; //// [declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js] "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; +// Note that both of the following have an `any` in their return type from where we bottom out the type printout +// for having too many instances of the same symbol nesting. Object.defineProperty(exports, "__esModule", { value: true }); exports.testRecFun = exports.updateIfChanged = void 0; const updateIfChanged = (t) => { @@ -71,7 +62,7 @@ exports.updateIfChanged = updateIfChanged; const testRecFun = (parent) => { return { result: parent, - deeper: (child) => (0, exports.testRecFun)(__assign(__assign({}, parent), child)) + deeper: (child) => (0, exports.testRecFun)(Object.assign(Object.assign({}, parent), child)) }; }; exports.testRecFun = testRecFun; diff --git a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js.diff b/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js.diff deleted file mode 100644 index 936f834eeb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js -+++ new.declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js -@@= skipped -43, +43 lines =@@ - - //// [declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js] - "use strict"; --// Note that both of the following have an `any` in their return type from where we bottom out the type printout --// for having too many instances of the same symbol nesting. - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataConditionalType.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataConditionalType.js.diff index 984a229851..6295e21a3b 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataConditionalType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataConditionalType.js.diff @@ -13,29 +13,19 @@ -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; --let BaseEntity = (() => { -- class BaseEntity { -- } -- __decorate([ -- d(), -- __metadata("design:type", Object) -- ], BaseEntity.prototype, "attributes", void 0); -- return BaseEntity; --})(); --let C = (() => { -- class C { -- } -- __decorate([ -- d(), -- __metadata("design:type", Boolean) -- ], C.prototype, "x", void 0); -- return C; --})(); -+class BaseEntity { + class BaseEntity { + @d() + attributes; -+} -+class C { + } +-__decorate([ +- d(), +- __metadata("design:type", Object) +-], BaseEntity.prototype, "attributes", void 0); + class C { + @d() + x; -+} \ No newline at end of file + } +-__decorate([ +- d(), +- __metadata("design:type", Boolean) +-], C.prototype, "x", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js.diff index 7c093f8747..a8d7592793 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js.diff @@ -1,28 +1,16 @@ --- old.decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js +++ new.decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js -@@= skipped -15, +15 lines =@@ - - - //// [decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js] --let MyClass = (() => { -- class MyClass { -- constructor(test, test2) { -- } -- doSomething() { -- } -- } -- __decorate([ -- decorator, -- __metadata("design:type", Function), -- __metadata("design:paramtypes", []), -- __metadata("design:returntype", void 0) -- ], MyClass.prototype, "doSomething", null); -- return MyClass; --})(); -+class MyClass { -+ constructor(test, test2) { -+ } +@@= skipped -18, +18 lines =@@ + class MyClass { + constructor(test, test2) { + } + @decorator -+ doSomething() { -+ } -+} \ No newline at end of file + doSomething() { + } + } +-__decorate([ +- decorator, +- __metadata("design:type", Function), +- __metadata("design:paramtypes", []), +- __metadata("design:returntype", void 0) +-], MyClass.prototype, "doSomething", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariable.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariable.js.diff index a244db4e3a..539bf51b76 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariable.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariable.js.diff @@ -15,17 +15,12 @@ -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; --let C = (() => { -- class C { -- } -- __decorate([ -- Decorate, -- __metadata("design:type", Object) -- ], C.prototype, "member", void 0); -- return C; --})(); -+class C { + class C { + @Decorate + member; -+} - exports.C = C; \ No newline at end of file + } + exports.C = C; +-__decorate([ +- Decorate, +- __metadata("design:type", Object) +-], C.prototype, "member", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableDefault.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableDefault.js.diff index 2b9ff874c4..c2166ee642 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableDefault.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableDefault.js.diff @@ -15,17 +15,12 @@ -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; --let C = (() => { -- class C { -- } -- __decorate([ -- Decorate, -- __metadata("design:type", Object) -- ], C.prototype, "member", void 0); -- return C; --})(); -+class C { + class C { + @Decorate + member; -+} - exports.C = C; \ No newline at end of file + } + exports.C = C; +-__decorate([ +- Decorate, +- __metadata("design:type", Object) +-], C.prototype, "member", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableInScope.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableInScope.js.diff index 3d6afafc4b..f0a4f7418e 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableInScope.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataGenericTypeVariableInScope.js.diff @@ -18,17 +18,12 @@ // Unused, but could collide with the named type argument below. class TypeVariable { } --let C = (() => { -- class C { -- } -- __decorate([ -- Decorate, -- __metadata("design:type", Object) -- ], C.prototype, "member", void 0); -- return C; --})(); -+class C { + class C { + @Decorate + member; -+} - exports.C = C; \ No newline at end of file + } + exports.C = C; +-__decorate([ +- Decorate, +- __metadata("design:type", Object) +-], C.prototype, "member", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoLibIsolatedModulesTypes.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoLibIsolatedModulesTypes.js.diff index cbe209f149..6945d65ec3 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoLibIsolatedModulesTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoLibIsolatedModulesTypes.js.diff @@ -13,20 +13,15 @@ -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; +-var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.B = void 0; --let B = (() => { -- var _a; -- class B { -- } -- __decorate([ -- Decorate, -- __metadata("design:type", typeof (_a = typeof Map !== "undefined" && Map) === "function" ? _a : Object) -- ], B.prototype, "member", void 0); -- return B; --})(); -+class B { + class B { + @Decorate + member; -+} - exports.B = B; \ No newline at end of file + } + exports.B = B; +-__decorate([ +- Decorate, +- __metadata("design:type", typeof (_a = typeof Map !== "undefined" && Map) === "function" ? _a : Object) +-], B.prototype, "member", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoStrictNull.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoStrictNull.js.diff index ef3a9eeac5..e434c0db47 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoStrictNull.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataNoStrictNull.js.diff @@ -14,22 +14,17 @@ - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; const dec = (obj, prop) => undefined; --let Foo = (() => { -- class Foo { -- } -- __decorate([ -- dec, -- __metadata("design:type", String) -- ], Foo.prototype, "foo", void 0); -- __decorate([ -- dec, -- __metadata("design:type", String) -- ], Foo.prototype, "bar", void 0); -- return Foo; --})(); -+class Foo { + class Foo { + @dec + foo; + @dec + bar; -+} \ No newline at end of file + } +-__decorate([ +- dec, +- __metadata("design:type", String) +-], Foo.prototype, "foo", void 0); +-__decorate([ +- dec, +- __metadata("design:type", String) +-], Foo.prototype, "bar", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataOnInferredType.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataOnInferredType.js.diff index be80267c83..62a64235ff 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataOnInferredType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataOnInferredType.js.diff @@ -1,23 +1,17 @@ --- old.decoratorMetadataOnInferredType.js +++ new.decoratorMetadataOnInferredType.js -@@= skipped -26, +26 lines =@@ - } +@@= skipped -27, +27 lines =@@ function decorator(target, propertyKey) { } --let B = (() => { -- class B { -- constructor() { -- this.x = new A(); -- } + class B { +- constructor() { +- this.x = new A(); - } -- __decorate([ -- decorator, -- __metadata("design:type", Object) -- ], B.prototype, "x", void 0); -- return B; --})(); -+class B { + @decorator + x = new A(); -+} - exports.B = B; \ No newline at end of file + } + exports.B = B; +-__decorate([ +- decorator, +- __metadata("design:type", Object) +-], B.prototype, "x", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataRestParameterWithImportedType.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataRestParameterWithImportedType.js.diff index fdaf69b640..6fecd8f7c1 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataRestParameterWithImportedType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataRestParameterWithImportedType.js.diff @@ -36,42 +36,34 @@ -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClassA = void 0; --var aux_1 = require("./aux"); --var aux1_1 = require("./aux1"); +-const aux_1 = require("./aux"); +-const aux1_1 = require("./aux1"); function annotation() { return (target) => { }; } function annotation1() { return (target) => { }; } --let ClassA = (() => { -- let ClassA = class ClassA { -- constructor(...init) { -- this.array = init; -- } -- foo(...args) { -- } -- }; -- __decorate([ -- annotation1(), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [aux1_1.SomeClass1]), -- __metadata("design:returntype", void 0) -- ], ClassA.prototype, "foo", null); -- ClassA = __decorate([ -- annotation(), -- __metadata("design:paramtypes", [aux_1.SomeClass]) -- ], ClassA); -- return ClassA; --})(); +-let ClassA = class ClassA { +@annotation() +class ClassA { + array; -+ constructor(...init) { -+ this.array = init; -+ } + constructor(...init) { + this.array = init; + } + @annotation1() -+ foo(...args) { -+ } + foo(...args) { + } +-}; +} - exports.ClassA = ClassA; \ No newline at end of file + exports.ClassA = ClassA; +-__decorate([ +- annotation1(), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [aux1_1.SomeClass1]), +- __metadata("design:returntype", void 0) +-], ClassA.prototype, "foo", null); +-exports.ClassA = ClassA = __decorate([ +- annotation(), +- __metadata("design:paramtypes", [aux_1.SomeClass]) +-], ClassA); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyExport.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyExport.js.diff index 9f026d745b..6810d758b3 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyExport.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyExport.js.diff @@ -15,17 +15,13 @@ -}; Object.defineProperty(exports, "__esModule", { value: true }); const Decorator = () => undefined; --let Bar = (() => { -- let Bar = class Bar { -- constructor(par) { } -- }; -- Bar = __decorate([ -- Decorator, -- __metadata("design:paramtypes", [Function]) -- ], Bar); -- return Bar; --})(); +-let Bar = class Bar { +@Decorator +class Bar { -+ constructor(par) { } + constructor(par) { } +-}; +-Bar = __decorate([ +- Decorator, +- __metadata("design:paramtypes", [Function]) +-], Bar); +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyImport.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyImport.js.diff index a49628cdf0..178e1243ec 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyImport.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataTypeOnlyImport.js.diff @@ -14,16 +14,11 @@ - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; Object.defineProperty(exports, "__esModule", { value: true }); --let Foo = (() => { -- class Foo { -- } -- __decorate([ -- Decorator, -- __metadata("design:type", Object) -- ], Foo.prototype, "myList", void 0); -- return Foo; --})(); -+class Foo { + class Foo { + @Decorator + myList; -+} \ No newline at end of file + } +-__decorate([ +- Decorator, +- __metadata("design:type", Object) +-], Foo.prototype, "myList", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithConstructorType.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithConstructorType.js.diff index 26885372e7..42987000ba 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithConstructorType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithConstructorType.js.diff @@ -1,23 +1,17 @@ --- old.decoratorMetadataWithConstructorType.js +++ new.decoratorMetadataWithConstructorType.js -@@= skipped -26, +26 lines =@@ - } +@@= skipped -27, +27 lines =@@ function decorator(target, propertyKey) { } --let B = (() => { -- class B { -- constructor() { -- this.x = new A(); -- } + class B { +- constructor() { +- this.x = new A(); - } -- __decorate([ -- decorator, -- __metadata("design:type", A) -- ], B.prototype, "x", void 0); -- return B; --})(); -+class B { + @decorator + x = new A(); -+} - exports.B = B; \ No newline at end of file + } + exports.B = B; +-__decorate([ +- decorator, +- __metadata("design:type", A) +-], B.prototype, "x", void 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision.js.diff index d2adab911a..451939e964 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision.js.diff @@ -4,29 +4,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db_1 = require("./db"); +-const db_1 = require("./db"); function someDecorator(target) { return target; } --let MyClass = (() => { -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [db_1.db]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [db_1.db]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision2.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision2.js.diff index fcc4f9fc78..ce4fc16af7 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision2.js.diff @@ -4,29 +4,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db_1 = require("./db"); +-const db_1 = require("./db"); function someDecorator(target) { return target; } --let MyClass = (() => { -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [db_1.db]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [db_1.db]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision3.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision3.js.diff index 3b7e2467b4..f7743bd292 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision3.js.diff @@ -4,29 +4,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db = require("./db"); +-const db = require("./db"); function someDecorator(target) { return target; } --let MyClass = (() => { -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [db.db]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [db.db]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.js.diff index 1874b1d5e5..f4e8746982 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.js.diff @@ -1,33 +1,28 @@ --- old.decoratorMetadataWithImportDeclarationNameCollision4.js +++ new.decoratorMetadataWithImportDeclarationNameCollision4.js -@@= skipped -35, +35 lines =@@ +@@= skipped -33, +33 lines =@@ + exports.db = db; + //// [service.js] "use strict"; +-var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db_1 = require("./db"); // error no default export +-const db_1 = __importDefault(require("./db")); // error no default export function someDecorator(target) { return target; } --let MyClass = (() => { -- var _a; -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [typeof (_a = typeof db_1.default !== "undefined" && db_1.default.db) === "function" ? _a : Object]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [typeof (_a = typeof db_1.default !== "undefined" && db_1.default.db) === "function" ? _a : Object]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision5.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision5.js.diff index 54b82621a7..8cc2adf934 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision5.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision5.js.diff @@ -4,29 +4,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db_1 = require("./db"); +-const db_1 = __importDefault(require("./db")); function someDecorator(target) { return target; } --let MyClass = (() => { -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [db_1.default]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [db_1.default]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision6.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision6.js.diff index e4e4bd26fd..73bd2dd2bc 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision6.js.diff @@ -4,29 +4,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db_1 = require("./db"); +-const db_1 = __importDefault(require("./db")); function someDecorator(target) { return target; } --let MyClass = (() => { -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [db_1.default]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [db_1.default]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision7.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision7.js.diff index 5bf4140db7..6252ef03d8 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision7.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision7.js.diff @@ -1,33 +1,28 @@ --- old.decoratorMetadataWithImportDeclarationNameCollision7.js +++ new.decoratorMetadataWithImportDeclarationNameCollision7.js -@@= skipped -34, +34 lines =@@ +@@= skipped -32, +32 lines =@@ + exports.default = db; + //// [service.js] "use strict"; +-var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var db_1 = require("./db"); +-const db_1 = __importDefault(require("./db")); function someDecorator(target) { return target; } --let MyClass = (() => { -- var _a; -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [typeof (_a = typeof db_1.default !== "undefined" && db_1.default.db) === "function" ? _a : Object]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; //error -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [typeof (_a = typeof db_1.default !== "undefined" && db_1.default.db) === "function" ? _a : Object]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision8.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision8.js.diff index 44fcb18c71..561b77d13e 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision8.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision8.js.diff @@ -4,29 +4,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; --var database = require("./db"); +-const database = require("./db"); function someDecorator(target) { return target; } --let MyClass = (() => { -- let MyClass = class MyClass { -- constructor(db) { -- this.db = db; -- this.db.doSomething(); -- } -- }; -- MyClass = __decorate([ -- someDecorator, -- __metadata("design:paramtypes", [database.db]) -- ], MyClass); -- return MyClass; --})(); +-let MyClass = class MyClass { +@someDecorator +class MyClass { + db; -+ constructor(db) { -+ this.db = db; -+ this.db.doSomething(); -+ } + constructor(db) { + this.db = db; + this.db.doSomething(); + } +-}; +} - exports.MyClass = MyClass; \ No newline at end of file + exports.MyClass = MyClass; +-exports.MyClass = MyClass = __decorate([ +- someDecorator, +- __metadata("design:paramtypes", [database.db]) +-], MyClass); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorReferenceOnOtherProperty.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorReferenceOnOtherProperty.js.diff index 9831574364..3ca0672a71 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorReferenceOnOtherProperty.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorReferenceOnOtherProperty.js.diff @@ -17,23 +17,17 @@ - return function (target, key) { decorator(target, key, paramIndex); } -}; Object.defineProperty(exports, "__esModule", { value: true }); --var yoha_1 = require("./yoha"); +-const yoha_1 = require("./yoha"); function foo(...args) { } --let Bar = (() => { -- class Bar { -- yoha(yoha, bar) { } -- } -- __decorate([ -- __param(0, foo), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object, yoha_1.Yoha]), -- __metadata("design:returntype", void 0) -- ], Bar.prototype, "yoha", null); -- return Bar; --})(); -+class Bar { -+ yoha(yoha, bar) { } -+} + class Bar { + yoha(yoha, bar) { } + } +-__decorate([ +- __param(0, foo), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object, yoha_1.Yoha]), +- __metadata("design:returntype", void 0) +-], Bar.prototype, "yoha", null); //// [index2.js] "use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -49,20 +43,14 @@ - return function (target, key) { decorator(target, key, paramIndex); } -}; Object.defineProperty(exports, "__esModule", { value: true }); --var yoha_1 = require("./yoha"); +-const yoha_1 = require("./yoha"); function foo(...args) { } --let Bar = (() => { -- class Bar { -- yoha(yoha, ...bar) { } -- } -- __decorate([ -- __param(0, foo), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object, yoha_1.Yoha]), -- __metadata("design:returntype", void 0) -- ], Bar.prototype, "yoha", null); -- return Bar; --})(); -+class Bar { -+ yoha(yoha, ...bar) { } -+} \ No newline at end of file + class Bar { + yoha(yoha, ...bar) { } + } +-__decorate([ +- __param(0, foo), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object, yoha_1.Yoha]), +- __metadata("design:returntype", void 0) +-], Bar.prototype, "yoha", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorReferences.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorReferences.js.diff index 97bd982473..461ddb8ec1 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorReferences.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorReferences.js.diff @@ -13,22 +13,18 @@ -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; --let C = (() => { -- let C = class C { -- method(x, y) { } // <-- decorator y should be resolved at the class declaration, not the parameter. -- }; -- __decorate([ -- y(null) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class -- , -- __param(0, y) -- ], C.prototype, "method", null); -- C = __decorate([ -- y(1, () => C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class -- ], C); -- return C; --})(); +-let C = class C { +@y(1, () => C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class +class C { + @y(null) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class -+ method(x, y) { } // <-- decorator y should be resolved at the class declaration, not the parameter. + method(x, y) { } // <-- decorator y should be resolved at the class declaration, not the parameter. +-}; +-__decorate([ +- y(null) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class +- , +- __param(0, y) +-], C.prototype, "method", null); +-C = __decorate([ +- y(1, () => C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class +-], C); +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorUsedBeforeDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorUsedBeforeDeclaration.js.diff index 9d4bca892f..89776def3c 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorUsedBeforeDeclaration.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorUsedBeforeDeclaration.js.diff @@ -13,150 +13,110 @@ -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; --let Greeter = (() => { -- let Greeter = class Greeter { -- constructor(message) { -- this.greeting = message; -- } -- greet() { -- return "Hello, " + this.greeting; -- } -- greet1() { -- return "Hello, " + this.greeting; -- } -- greet2(param) { -- return "Hello, " + this.greeting; -- } -- greet3(param) { -- return "Hello, " + this.greeting; -- } -- }; -- __decorate([ -- lambda(Enum.No), -- deco(Enum.No) -- ], Greeter.prototype, "greeting", void 0); -- __decorate([ -- lambda(Enum.No), -- deco(Enum.No) -- ], Greeter.prototype, "greet", null); -- __decorate([ -- lambda, -- deco -- ], Greeter.prototype, "greet1", null); -- __decorate([ -- __param(0, lambda(Enum.No)), -- __param(0, deco(Enum.No)) -- ], Greeter.prototype, "greet2", null); -- __decorate([ -- __param(0, lambda), -- __param(0, deco) -- ], Greeter.prototype, "greet3", null); -- Greeter = __decorate([ -- lambda(Enum.No), -- deco(Enum.No) -- ], Greeter); -- return Greeter; --})(); +-let Greeter = class Greeter { +@lambda(Enum.No) +@deco(Enum.No) +class Greeter { + @lambda(Enum.No) + @deco(Enum.No) + greeting; -+ constructor(message) { -+ this.greeting = message; -+ } + constructor(message) { + this.greeting = message; + } + @lambda(Enum.No) + @deco(Enum.No) -+ greet() { -+ return "Hello, " + this.greeting; -+ } + greet() { + return "Hello, " + this.greeting; + } + @lambda + @deco -+ greet1() { -+ return "Hello, " + this.greeting; -+ } -+ greet2(param) { -+ return "Hello, " + this.greeting; -+ } -+ greet3(param) { -+ return "Hello, " + this.greeting; -+ } + greet1() { + return "Hello, " + this.greeting; + } +@@= skipped -25, +25 lines =@@ + greet3(param) { + return "Hello, " + this.greeting; + } +-}; +-__decorate([ +- lambda(Enum.No), +- deco(Enum.No) +-], Greeter.prototype, "greeting", void 0); +-__decorate([ +- lambda(Enum.No), +- deco(Enum.No) +-], Greeter.prototype, "greet", null); +-__decorate([ +- lambda, +- deco +-], Greeter.prototype, "greet1", null); +-__decorate([ +- __param(0, lambda(Enum.No)), +- __param(0, deco(Enum.No)) +-], Greeter.prototype, "greet2", null); +-__decorate([ +- __param(0, lambda), +- __param(0, deco) +-], Greeter.prototype, "greet3", null); +-Greeter = __decorate([ +- lambda(Enum.No), +- deco(Enum.No) +-], Greeter); +} function deco(...args) { } var Enum; (function (Enum) { -@@= skipped -60, +33 lines =@@ +@@= skipped -32, +8 lines =@@ Enum[Enum["Yes"] = 1] = "Yes"; })(Enum || (Enum = {})); const lambda = (...args) => { }; --let Greeter1 = (() => { -- let Greeter1 = class Greeter1 { -- constructor(message) { -- this.greeting = message; -- } -- greet() { -- return "Hello, " + this.greeting; -- } -- greet1() { -- return "Hello, " + this.greeting; -- } -- greet2(param) { -- return "Hello, " + this.greeting; -- } -- greet3(param) { -- return "Hello, " + this.greeting; -- } -- }; -- __decorate([ -- lambda(Enum.No), -- deco(Enum.No) -- ], Greeter1.prototype, "greeting", void 0); -- __decorate([ -- lambda(Enum.No), -- deco(Enum.No) -- ], Greeter1.prototype, "greet", null); -- __decorate([ -- lambda, -- deco -- ], Greeter1.prototype, "greet1", null); -- __decorate([ -- __param(0, lambda(Enum.No)), -- __param(0, deco(Enum.No)) -- ], Greeter1.prototype, "greet2", null); -- __decorate([ -- __param(0, lambda), -- __param(0, deco) -- ], Greeter1.prototype, "greet3", null); -- Greeter1 = __decorate([ -- lambda(Enum.No), -- deco(Enum.No) -- ], Greeter1); -- return Greeter1; --})(); +-let Greeter1 = class Greeter1 { +@lambda(Enum.No) +@deco(Enum.No) +class Greeter1 { + @lambda(Enum.No) + @deco(Enum.No) + greeting; -+ constructor(message) { -+ this.greeting = message; -+ } + constructor(message) { + this.greeting = message; + } + @lambda(Enum.No) + @deco(Enum.No) -+ greet() { -+ return "Hello, " + this.greeting; -+ } + greet() { + return "Hello, " + this.greeting; + } + @lambda + @deco -+ greet1() { -+ return "Hello, " + this.greeting; -+ } -+ greet2(param) { -+ return "Hello, " + this.greeting; -+ } -+ greet3(param) { -+ return "Hello, " + this.greeting; -+ } + greet1() { + return "Hello, " + this.greeting; + } +@@= skipped -16, +25 lines =@@ + greet3(param) { + return "Hello, " + this.greeting; + } +-}; +-__decorate([ +- lambda(Enum.No), +- deco(Enum.No) +-], Greeter1.prototype, "greeting", void 0); +-__decorate([ +- lambda(Enum.No), +- deco(Enum.No) +-], Greeter1.prototype, "greet", null); +-__decorate([ +- lambda, +- deco +-], Greeter1.prototype, "greet1", null); +-__decorate([ +- __param(0, lambda(Enum.No)), +- __param(0, deco(Enum.No)) +-], Greeter1.prototype, "greet2", null); +-__decorate([ +- __param(0, lambda), +- __param(0, deco) +-], Greeter1.prototype, "greet3", null); +-Greeter1 = __decorate([ +- lambda(Enum.No), +- deco(Enum.No) +-], Greeter1); +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorWithNegativeLiteralTypeNoCrash.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorWithNegativeLiteralTypeNoCrash.js.diff index 3901d9ac35..0c4b632359 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorWithNegativeLiteralTypeNoCrash.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorWithNegativeLiteralTypeNoCrash.js.diff @@ -13,20 +13,15 @@ -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; --let A = (() => { -- class A { -- constructor() { -- this.field1 = -1; -- } + class A { +- constructor() { +- this.field1 = -1; - } -- __decorate([ -- decorator, -- __metadata("design:type", Number) -- ], A.prototype, "field1", void 0); -- return A; --})(); -+class A { + @decorator + field1 = -1; -+} + } +-__decorate([ +- decorator, +- __metadata("design:type", Number) +-], A.prototype, "field1", void 0); function decorator(target, field) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorWithUnderscoreMethod.js.diff b/testdata/baselines/reference/submodule/compiler/decoratorWithUnderscoreMethod.js.diff index e0bece90d5..26c25a70f7 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorWithUnderscoreMethod.js.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorWithUnderscoreMethod.js.diff @@ -1,22 +1,14 @@ --- old.decoratorWithUnderscoreMethod.js +++ new.decoratorWithUnderscoreMethod.js -@@= skipped -24, +24 lines =@@ - //propKey has three underscores as prefix, but the method has only two underscores +@@= skipped -25, +25 lines =@@ }; } --let A = (() => { -- class A { -- __foo(bar) { -- // do something with bar -- } -+class A { + class A { + @dec() -+ __foo(bar) { -+ // do something with bar + __foo(bar) { + // do something with bar } -- __decorate([ -- dec() -- ], A.prototype, "__foo", null); -- return A; --})(); -+} \ No newline at end of file + } +-__decorate([ +- dec() +-], A.prototype, "__foo", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js index 5b71459dcb..44abeb067c 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js @@ -57,6 +57,7 @@ const a2: string[][][][][][][][][][] = [[[[[[[[[[42]]]]]]]]]]; //// [deeplyNestedCheck.js] +// Repro from #14794 const x = { b: [ { diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff index 28297b816c..7ed38e2061 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff @@ -1,14 +1,6 @@ --- old.deeplyNestedCheck.js +++ new.deeplyNestedCheck.js -@@= skipped -56, +56 lines =@@ - - - //// [deeplyNestedCheck.js] --// Repro from #14794 - const x = { - b: [ - { -@@= skipped -13, +12 lines =@@ +@@= skipped -69, +69 lines =@@ { g: { h: [ diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js b/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js index f3bc77086e..2ef1d57c7d 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js @@ -109,6 +109,7 @@ type T1 = Foo; //// [deeplyNestedConditionalTypes.js] +"use strict"; //// [deeplyNestedConditionalTypes.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js.diff b/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js.diff deleted file mode 100644 index aa76336256..0000000000 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedConditionalTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.deeplyNestedConditionalTypes.js -+++ new.deeplyNestedConditionalTypes.js -@@= skipped -108, +108 lines =@@ - - - //// [deeplyNestedConditionalTypes.js] --"use strict"; - - - //// [deeplyNestedConditionalTypes.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js index a8e4d07c86..39173ad48c 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js @@ -15,6 +15,8 @@ class BufferPool> { //// [deeplyNestedConstraints.js] +"use strict"; +// Repro from #41931 class BufferPool { setArray2(_, array) { array.length; // Requires exploration of >5 levels of constraints diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff deleted file mode 100644 index aa5c1605a1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.deeplyNestedConstraints.js -+++ new.deeplyNestedConstraints.js -@@= skipped -14, +14 lines =@@ - - - //// [deeplyNestedConstraints.js] --"use strict"; --// Repro from #41931 - class BufferPool { - setArray2(_, array) { - array.length; // Requires exploration of >5 levels of constraints \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitDefaultImport.js.diff b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitDefaultImport.js.diff deleted file mode 100644 index c452d600c7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitDefaultImport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.defaultDeclarationEmitDefaultImport.js -+++ new.defaultDeclarationEmitDefaultImport.js -@@= skipped -19, +19 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.instance = void 0; --var root_1 = require("./root"); -+const root_1 = require("./root"); - exports.instance = (0, root_1.getSomething)(); - diff --git a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitNamedCorrectly.js.diff b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitNamedCorrectly.js.diff index 8ddf6a5f80..1292087ee6 100644 --- a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitNamedCorrectly.js.diff +++ b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitNamedCorrectly.js.diff @@ -1,18 +1,12 @@ --- old.defaultDeclarationEmitNamedCorrectly.js +++ new.defaultDeclarationEmitNamedCorrectly.js -@@= skipped -23, +23 lines =@@ - function make(x) { +@@= skipped -24, +24 lines =@@ return null; } --let MyComponent = (() => { -- class MyComponent { -- } -- MyComponent.create = make(MyComponent); -- return MyComponent; --})(); -+class MyComponent { + class MyComponent { + props; + static create = make(MyComponent); -+} + } +-MyComponent.create = make(MyComponent); exports.default = MyComponent; diff --git a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js index c918e21907..cadcf34d75 100644 --- a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js +++ b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js @@ -23,10 +23,43 @@ export namespace Something { //// [this.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Something = void 0; exports.make = make; -const me = require("./this"); +const me = __importStar(require("./this")); function make(x) { return null; } diff --git a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js.diff b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js.diff index 6718c3ad88..3e8205680a 100644 --- a/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js.diff +++ b/testdata/baselines/reference/submodule/compiler/defaultDeclarationEmitShadowedNamedCorrectly.js.diff @@ -1,12 +1,6 @@ --- old.defaultDeclarationEmitShadowedNamedCorrectly.js +++ new.defaultDeclarationEmitShadowedNamedCorrectly.js -@@= skipped -25, +25 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Something = void 0; - exports.make = make; --var me = require("./this"); -+const me = require("./this"); - function make(x) { +@@= skipped -63, +63 lines =@@ return null; } class MyComponent { @@ -14,7 +8,7 @@ } exports.default = MyComponent; var Something; -@@= skipped -31, +32 lines =@@ +@@= skipped -26, +27 lines =@@ props: Props; } export declare namespace Something { diff --git a/testdata/baselines/reference/submodule/compiler/defaultKeywordWithoutExport1.js.diff b/testdata/baselines/reference/submodule/compiler/defaultKeywordWithoutExport1.js.diff index 6f2ceb0597..93b578960f 100644 --- a/testdata/baselines/reference/submodule/compiler/defaultKeywordWithoutExport1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/defaultKeywordWithoutExport1.js.diff @@ -10,14 +10,11 @@ - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; --let default_1 = (() => { -- let default_1 = class { -- }; -- default_1 = __decorate([ -- decorator -- ], default_1); -- return default_1; --})(); +-let default_1 = class { +-}; +-default_1 = __decorate([ +- decorator +-], default_1); +@decorator +default class { +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.js.diff b/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.js.diff index 96490a6aa9..247f91233b 100644 --- a/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.js.diff +++ b/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.js.diff @@ -1,21 +1,10 @@ --- old.defaultPropsEmptyCurlyBecomesAnyForJs.js +++ new.defaultPropsEmptyCurlyBecomesAnyForJs.js -@@= skipped -28, +28 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -30, +30 lines =@@ exports.MyFoo = void 0; --var library_1 = require("./library"); -+const library_1 = require("./library"); + const library_1 = require("./library"); class MyFoo extends library_1.Foo { + member; } exports.MyFoo = MyFoo; - //// [typed_component.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.TypedFoo = void 0; --var component_1 = require("./component"); -+const component_1 = require("./component"); - class TypedFoo extends component_1.MyFoo { - constructor() { - super({ x: "string", y: 42 }, { value: undefined }); \ No newline at end of file + //// [typed_component.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js b/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js index 630503dd6e..206e98bd43 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js +++ b/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js @@ -56,3 +56,4 @@ type TestBit = AndBit< type TestBitRes = TestBit<1, 1>; //// [deferredConditionalTypes.js] +"use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js.diff b/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js.diff deleted file mode 100644 index 77f552b07e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/deferredConditionalTypes.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.deferredConditionalTypes.js -+++ new.deferredConditionalTypes.js -@@= skipped -55, +55 lines =@@ - type TestBitRes = TestBit<1, 1>; - - //// [deferredConditionalTypes.js] --"use strict"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js index 8edd173c99..619804bd22 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js +++ b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js @@ -29,6 +29,8 @@ function f3(x: 'a' | 'b') { //// [deferredLookupTypeResolution.js] +"use strict"; +// Repro from #17456 function f2(a) { return f1(a, 'x'); } diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff deleted file mode 100644 index 4d447e3693..0000000000 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.deferredLookupTypeResolution.js -+++ new.deferredLookupTypeResolution.js -@@= skipped -28, +28 lines =@@ - - - //// [deferredLookupTypeResolution.js] --"use strict"; --// Repro from #17456 - function f2(a) { - return f1(a, 'x'); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js index 791854dd9a..74bffc481c 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js +++ b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js @@ -25,6 +25,8 @@ type DeepOK = { true: 'true', otherwise: 'false' }[Juxtapose]; //// [deferredLookupTypeResolution2.js] +"use strict"; +// Repro from #17456 //// [deferredLookupTypeResolution2.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff deleted file mode 100644 index 7401b3875d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.deferredLookupTypeResolution2.js -+++ new.deferredLookupTypeResolution2.js -@@= skipped -24, +24 lines =@@ - - - //// [deferredLookupTypeResolution2.js] --"use strict"; --// Repro from #17456 - - - //// [deferredLookupTypeResolution2.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js b/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js index 35c06230fe..262eac6373 100644 --- a/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js +++ b/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js @@ -44,6 +44,7 @@ delete b.b //// [deleteExpressionMustBeOptional.js] +"use strict"; delete f.a; delete f.b; delete f.c; diff --git a/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js.diff b/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js.diff deleted file mode 100644 index 5378e4177e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/deleteExpressionMustBeOptional(strict=true).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.deleteExpressionMustBeOptional(strict=true).js -+++ new.deleteExpressionMustBeOptional(strict=true).js -@@= skipped -43, +43 lines =@@ - - - //// [deleteExpressionMustBeOptional.js] --"use strict"; - delete f.a; - delete f.b; - delete f.c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js b/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js index 9c1e7d2ea8..01a1a8e680 100644 --- a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js +++ b/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js @@ -39,6 +39,7 @@ try {} catch ({ a: { b: { c: { x }} }}: unknown) { x } //// [destructureCatchClause.js] +"use strict"; // These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. try { } catch ({ x }) { diff --git a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js.diff b/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js.diff deleted file mode 100644 index ea30523a36..0000000000 --- a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=false).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.destructureCatchClause(strict=true,useunknownincatchvariables=false).js -+++ new.destructureCatchClause(strict=true,useunknownincatchvariables=false).js -@@= skipped -38, +38 lines =@@ - - - //// [destructureCatchClause.js] --"use strict"; - // These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. - try { } - catch ({ x }) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js b/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js index 9c1e7d2ea8..01a1a8e680 100644 --- a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js +++ b/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js @@ -39,6 +39,7 @@ try {} catch ({ a: { b: { c: { x }} }}: unknown) { x } //// [destructureCatchClause.js] +"use strict"; // These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. try { } catch ({ x }) { diff --git a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js.diff b/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js.diff deleted file mode 100644 index de3f1c287d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/destructureCatchClause(strict=true,useunknownincatchvariables=true).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.destructureCatchClause(strict=true,useunknownincatchvariables=true).js -+++ new.destructureCatchClause(strict=true,useunknownincatchvariables=true).js -@@= skipped -38, +38 lines =@@ - - - //// [destructureCatchClause.js] --"use strict"; - // These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true. - try { } - catch ({ x }) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructuredDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/destructuredDeclarationEmit.js.diff index eb09637a97..c700d21d3e 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuredDeclarationEmit.js.diff +++ b/testdata/baselines/reference/submodule/compiler/destructuredDeclarationEmit.js.diff @@ -1,11 +1,6 @@ --- old.destructuredDeclarationEmit.js +++ new.destructuredDeclarationEmit.js -@@= skipped -33, +33 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.foo2 = exports.sec = exports.bee = exports.one = exports.ibaz = exports.baz = exports.arr = exports.foo = void 0; --var foo_1 = require("./foo"); -+const foo_1 = require("./foo"); +@@= skipped -37, +37 lines =@@ Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return foo_1.foo; } }); Object.defineProperty(exports, "arr", { enumerable: true, get: function () { return foo_1.arr; } }); const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo_1.foo; diff --git a/testdata/baselines/reference/submodule/compiler/destructuringFromUnionSpread.js b/testdata/baselines/reference/submodule/compiler/destructuringFromUnionSpread.js index 420a13ded7..0adf7740fb 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringFromUnionSpread.js +++ b/testdata/baselines/reference/submodule/compiler/destructuringFromUnionSpread.js @@ -9,15 +9,4 @@ const { a } = { ...x } // error //// [destructuringFromUnionSpread.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -const { a } = __assign({}, x); // error +const { a } = Object.assign({}, x); // error diff --git a/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js b/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js index 97d4281b50..66feadde79 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js +++ b/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js @@ -28,17 +28,7 @@ f(([_1, _2 = undefined]) => undefined) //// [destructuringInitializerContextualTypeFromContext.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; +"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) @@ -52,7 +42,7 @@ var __rest = (this && this.__rest) || function (s, e) { }; const Parent = (_a) => { var { children, name = "Artemis" } = _a, props = __rest(_a, ["children", "name"]); - return Child(__assign({ name }, props)); + return Child(Object.assign({ name }, props)); }; const Child = (_a) => { var { children, name = "Artemis" } = _a, props = __rest(_a, ["children", "name"]); diff --git a/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js.diff b/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js.diff deleted file mode 100644 index 0e60106225..0000000000 --- a/testdata/baselines/reference/submodule/compiler/destructuringInitializerContextualTypeFromContext.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.destructuringInitializerContextualTypeFromContext.js -+++ new.destructuringInitializerContextualTypeFromContext.js -@@= skipped -27, +27 lines =@@ - - - //// [destructuringInitializerContextualTypeFromContext.js] --"use strict"; - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js b/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js index 6f862cbff2..7449281228 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js +++ b/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js @@ -9,8 +9,6 @@ function test(p: any) { //// [destructuringTempOccursAfterPrologue.js] function test(p) { - 'use strict'; - 'use strong'; 'use strict'; 'use strong'; p = { prop: p } = p; diff --git a/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js.diff b/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js.diff deleted file mode 100644 index 8bbf3085eb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/destructuringTempOccursAfterPrologue.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.destructuringTempOccursAfterPrologue.js -+++ new.destructuringTempOccursAfterPrologue.js -@@= skipped -10, +10 lines =@@ - function test(p) { - 'use strict'; - 'use strong'; -+ 'use strict'; -+ 'use strong'; - p = { prop: p } = p; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructuringTuple.js b/testdata/baselines/reference/submodule/compiler/destructuringTuple.js index 02a9ff8dff..413b308f9c 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringTuple.js +++ b/testdata/baselines/reference/submodule/compiler/destructuringTuple.js @@ -17,6 +17,7 @@ const [oops2] = [1, 2, 3].reduce((acc: number[], e) => acc.concat(e), []); //// [destructuringTuple.js] +"use strict"; const [a, b, c, ...rest] = tuple; [...receiver] = tuple; // Repros from #32140 diff --git a/testdata/baselines/reference/submodule/compiler/destructuringTuple.js.diff b/testdata/baselines/reference/submodule/compiler/destructuringTuple.js.diff deleted file mode 100644 index e471f14ee5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/destructuringTuple.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.destructuringTuple.js -+++ new.destructuringTuple.js -@@= skipped -16, +16 lines =@@ - - - //// [destructuringTuple.js] --"use strict"; - const [a, b, c, ...rest] = tuple; - [...receiver] = tuple; - // Repros from #32140 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js index 0d9113f0c0..be292bf944 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js @@ -14,6 +14,8 @@ function foo

(props: Readonly

) { //// [destructuringWithConstraint.js] +"use strict"; +// Repro from #22823 function foo(props) { let { foo = false } = props; if (foo === true) { } diff --git a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff deleted file mode 100644 index 7fc47b688a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.destructuringWithConstraint.js -+++ new.destructuringWithConstraint.js -@@= skipped -13, +13 lines =@@ - - - //// [destructuringWithConstraint.js] --"use strict"; --// Repro from #22823 - function foo(props) { - let { foo = false } = props; - if (foo === true) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js b/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js index 661c001fdb..4af2028e46 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js @@ -41,6 +41,7 @@ declare function isPlainObject2( //// [discriminantNarrowingCouldBeCircular.js] +"use strict"; const o = {}; if (o) { for (const key in o) { diff --git a/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js.diff deleted file mode 100644 index 5e23b6a0f0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantNarrowingCouldBeCircular.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantNarrowingCouldBeCircular.js -+++ new.discriminantNarrowingCouldBeCircular.js -@@= skipped -40, +40 lines =@@ - - - //// [discriminantNarrowingCouldBeCircular.js] --"use strict"; - const o = {}; - if (o) { - for (const key in o) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js b/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js index 86bcb2df27..404d7e797c 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js @@ -42,6 +42,7 @@ f({ //// [discriminantPropertyInference.js] +// Repro from #41759 // simple inference f({ disc: true, diff --git a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js.diff deleted file mode 100644 index 002fbe8bab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantPropertyInference.js -+++ new.discriminantPropertyInference.js -@@= skipped -41, +41 lines =@@ - - - //// [discriminantPropertyInference.js] --// Repro from #41759 - // simple inference - f({ - disc: true, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js b/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js index e2bba7fed0..5dbe68cd7c 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js @@ -26,6 +26,7 @@ if (c !== undefined) { } //// [discriminantsAndNullOrUndefined.js] +// Repro from #10228 function never(_) { throw new Error(); } diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js.diff deleted file mode 100644 index 9d2a710e34..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantsAndNullOrUndefined.js -+++ new.discriminantsAndNullOrUndefined.js -@@= skipped -25, +25 lines =@@ - } - - //// [discriminantsAndNullOrUndefined.js] --// Repro from #10228 - function never(_) { - throw new Error(); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js b/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js index 0e7a9e50b6..db43dd7836 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js @@ -83,6 +83,7 @@ else { //// [discriminantsAndPrimitives.js] +// Repro from #10257 plus other tests function f1(x) { if (typeof x !== 'string') { switch (x.kind) { diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js.diff deleted file mode 100644 index f9f7e9b017..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantsAndPrimitives.js -+++ new.discriminantsAndPrimitives.js -@@= skipped -82, +82 lines =@@ - - - //// [discriminantsAndPrimitives.js] --// Repro from #10257 plus other tests - function f1(x) { - if (typeof x !== 'string') { - switch (x.kind) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js b/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js index 305b5a0a9f..123d88e4b6 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js @@ -34,6 +34,7 @@ function foo2(x: A | B): any { } //// [discriminantsAndTypePredicates.js] +// Repro from #10145 function isA(x) { return x.type === 'A'; } function isB(x) { return x.type === 'B'; } function foo1(x) { diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js.diff deleted file mode 100644 index e2266b751b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantsAndTypePredicates.js -+++ new.discriminantsAndTypePredicates.js -@@= skipped -33, +33 lines =@@ - } - - //// [discriminantsAndTypePredicates.js] --// Repro from #10145 - function isA(x) { return x.type === 'A'; } - function isB(x) { return x.type === 'B'; } - function foo1(x) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js b/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js index cfc7f0109a..1113d2372e 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js +++ b/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js @@ -13,6 +13,7 @@ const l: Thing3 = { toString: undefined }; // error, toFixed isn't null //// [discriminateObjectTypesOnly.js] +"use strict"; const k = { toFixed: null }; // OK, satisfies object const q = { toFixed: null }; const h = { toString: null }; // OK, satisfies object diff --git a/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js.diff b/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js.diff deleted file mode 100644 index 804f8be116..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminateObjectTypesOnly.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminateObjectTypesOnly.js -+++ new.discriminateObjectTypesOnly.js -@@= skipped -12, +12 lines =@@ - - - //// [discriminateObjectTypesOnly.js] --"use strict"; - const k = { toFixed: null }; // OK, satisfies object - const q = { toFixed: null }; - const h = { toString: null }; // OK, satisfies object \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js index 28b2bd20f1..478aef17b2 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js +++ b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js @@ -25,6 +25,8 @@ function ListItem(_data: IListItemData) { //// [discriminatedUnionJsxElement.jsx] +"use strict"; +// Repro from #46021 function Menu(data) { var _a; const listItemVariant = (_a = data.menuItemsVariant) !== null && _a !== void 0 ? _a : ListItemVariant.OneLine; diff --git a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff deleted file mode 100644 index ad545cf227..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.discriminatedUnionJsxElement.js -+++ new.discriminatedUnionJsxElement.js -@@= skipped -24, +24 lines =@@ - - - //// [discriminatedUnionJsxElement.jsx] --"use strict"; --// Repro from #46021 - function Menu(data) { - var _a; - const listItemVariant = (_a = data.menuItemsVariant) !== null && _a !== void 0 ? _a : ListItemVariant.OneLine; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js b/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js index a4a74ef3d1..2f03b6e381 100644 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js +++ b/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js @@ -27,6 +27,7 @@ //// [divergentAccessors1.js] +"use strict"; // Accessors in interfaces/types { const ihgs = null; diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js.diff b/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js.diff deleted file mode 100644 index e1199d33f8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessors1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.divergentAccessors1.js -+++ new.divergentAccessors1.js -@@= skipped -26, +26 lines =@@ - - - //// [divergentAccessors1.js] --"use strict"; - // Accessors in interfaces/types - { - const ihgs = null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js b/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js index f0d1bb8fba..bd401262c1 100644 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js +++ b/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js @@ -66,6 +66,7 @@ type Test3 = { } //// [divergentAccessorsTypes1.js] +"use strict"; class Test1 { get foo() { return ""; } set foo(s) { diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js.diff b/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js.diff deleted file mode 100644 index 61a485c952..0000000000 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.divergentAccessorsTypes1.js -+++ new.divergentAccessorsTypes1.js -@@= skipped -65, +65 lines =@@ - } - - //// [divergentAccessorsTypes1.js] --"use strict"; - class Test1 { - get foo() { return ""; } - set foo(s) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js b/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js index b8948e57d2..07b613767e 100644 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js +++ b/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js @@ -14,6 +14,7 @@ s.foo = 42; //// [divergentAccessorsTypes2.js] +"use strict"; class Test1 { get foo() { return null; } set foo(s) { diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js.diff b/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js.diff deleted file mode 100644 index ed8e8adc97..0000000000 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessorsTypes2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.divergentAccessorsTypes2.js -+++ new.divergentAccessorsTypes2.js -@@= skipped -13, +13 lines =@@ - - - //// [divergentAccessorsTypes2.js] --"use strict"; - class Test1 { - get foo() { return null; } - set foo(s) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js b/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js index a3994b3bbd..bd653d9fce 100644 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js +++ b/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js @@ -161,6 +161,7 @@ function fn() { //// [divergentAccessorsVisibility1.js] +"use strict"; class Base { get PublicPublic() { return 0; } set PublicPublic(v) { return; } diff --git a/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js.diff b/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js.diff deleted file mode 100644 index 37ec30581f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/divergentAccessorsVisibility1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.divergentAccessorsVisibility1.js -+++ new.divergentAccessorsVisibility1.js -@@= skipped -160, +160 lines =@@ - - - //// [divergentAccessorsVisibility1.js] --"use strict"; - class Base { - get PublicPublic() { return 0; } - set PublicPublic(v) { return; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff deleted file mode 100644 index 53cd185a95..0000000000 --- a/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- old.downlevelLetConst18.errors.txt -+++ new.downlevelLetConst18.errors.txt -@@= skipped -0, +0 lines =@@ --downlevelLetConst18.ts(4,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. --downlevelLetConst18.ts(8,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. -- -- --==== downlevelLetConst18.ts (2 errors) ==== -- 'use strict' -- -- for (let x; ;) { -- function foo() { x }; -- ~~~ --!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. -- } -- -- for (let x; ;) { -- function foo1() { x }; -- ~~~~ --!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. -- } -- -- for (let x; ;) { -- (() => { x })(); -- } -- -- for (const x = 1; ;) { -- (() => { x })(); -- } -- -- for (let x; ;) { -- ({ foo() { x }}) -- } -- -- for (let x; ;) { -- ({ get foo() { return x } }) -- } -- -- for (let x; ;) { -- ({ set foo(v) { x } }) -- } -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff deleted file mode 100644 index fb3eb9ab2a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.downlevelLetConst19.errors.txt -+++ new.downlevelLetConst19.errors.txt -@@= skipped -0, +0 lines =@@ --downlevelLetConst19.ts(9,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. -- -- --==== downlevelLetConst19.ts (1 errors) ==== -- 'use strict' -- declare function use(a: any); -- var x; -- function a() { -- { -- let x; -- use(x); -- -- function b() { -- ~ --!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. -- { -- let x; -- use(x); -- } -- use(x); -- } -- } -- use(x) -- } -- use(x) -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js b/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js index 99a91703a7..fe025869e4 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js @@ -15,6 +15,7 @@ let obj: { 3: string } = { 3: "three" }; obj[x]; //// [duplicateErrorAssignability.js] +"use strict"; const x = a = b; let obj = { 3: "three" }; obj[x]; diff --git a/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js.diff deleted file mode 100644 index 7cc8df4aa7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicateErrorAssignability.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.duplicateErrorAssignability.js -+++ new.duplicateErrorAssignability.js -@@= skipped -14, +14 lines =@@ - obj[x]; - - //// [duplicateErrorAssignability.js] --"use strict"; - const x = a = b; - let obj = { 3: "three" }; - obj[x]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js b/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js index f4b49fb146..49e99d2c95 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js @@ -23,6 +23,7 @@ let obj: { 3: string } = { 3: "three" }; obj[x]; //// [duplicateErrorClassExpression.js] +"use strict"; class Base { foo; } diff --git a/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js.diff index d6f782811e..788d4561af 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateErrorClassExpression.js.diff @@ -1,10 +1,8 @@ --- old.duplicateErrorClassExpression.js +++ new.duplicateErrorClassExpression.js -@@= skipped -22, +22 lines =@@ - obj[x]; - +@@= skipped -24, +24 lines =@@ //// [duplicateErrorClassExpression.js] --"use strict"; + "use strict"; class Base { + foo; } diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js index 67ad695067..6ba104adb8 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js @@ -23,5 +23,5 @@ export {}; //// [file2.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff index ce53729873..76baf49462 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff @@ -7,6 +7,4 @@ -//// [file1.js] //// [file2.js] "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// \ No newline at end of file + /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js index 634eac5395..5ca112f999 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js @@ -35,5 +35,5 @@ export {}; //// [file2.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff index 9009fe87ce..a3b62bf462 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff @@ -7,6 +7,4 @@ -//// [file1.js] //// [file2.js] "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// \ No newline at end of file + /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js index 39046d4eca..52f49c2d7e 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js @@ -347,6 +347,8 @@ export var tests: TestRunner = (function () { //// [duplicateLocalVariable1.js] "use strict"; +//import FileManager = require('filemanager'); +//import App = require('app'); Object.defineProperty(exports, "__esModule", { value: true }); exports.tests = exports.TestRunner = exports.TestCase = void 0; var TestFileDir = ".\\TempTestFiles"; diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff index 62371627fa..a7227754cb 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff @@ -1,12 +1,6 @@ --- old.duplicateLocalVariable1.js +++ new.duplicateLocalVariable1.js -@@= skipped -346, +346 lines =@@ - - //// [duplicateLocalVariable1.js] - "use strict"; --//import FileManager = require('filemanager'); --//import App = require('app'); - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -352, +352 lines =@@ exports.tests = exports.TestRunner = exports.TestCase = void 0; var TestFileDir = ".\\TempTestFiles"; class TestCase { @@ -16,7 +10,7 @@ constructor(name, test, errorMessageRegEx) { this.name = name; this.test = test; -@@= skipped -14, +15 lines =@@ +@@= skipped -8, +11 lines =@@ } exports.TestCase = TestCase; class TestRunner { diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.errors.txt new file mode 100644 index 0000000000..4760ee1c0a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.errors.txt @@ -0,0 +1,48 @@ +duplicateLocalVariable2.ts(27,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. +duplicateLocalVariable2.ts(27,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +duplicateLocalVariable2.ts(27,37): error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. + + +==== duplicateLocalVariable2.ts (3 errors) ==== + export class TestCase { + constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { + } + } + export class TestRunner { + static arrayCompare(arg1: any[], arg2: any[]): boolean { + return false; + } + + public addTest(test: TestCase) { + } + } + + export var tests: TestRunner = (function () { + var testRunner = new TestRunner(); + + testRunner.addTest(new TestCase("Check UTF8 encoding", + function () { + var fb: any; + fb.writeUtf8Bom(); + var chars = [0x0054]; + for (var i in chars) { + fb.writeUtf8CodePoint(chars[i]); + } + fb.index = 0; + var bytes = []; + for (var i = 0; i < 14; i++) { + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. +!!! related TS6203 duplicateLocalVariable2.ts:22:22: 'i' was also declared here. + ~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. + ~ +!!! error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. + bytes.push(fb.readByte()); + } + var expected = [0xEF]; + return TestRunner.arrayCompare(bytes, expected); + })); + + return testRunner; + })(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.js b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.js new file mode 100644 index 0000000000..d43d0f6af3 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/duplicateLocalVariable2.ts] //// + +//// [duplicateLocalVariable2.ts] +export class TestCase { + constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { + } +} +export class TestRunner { + static arrayCompare(arg1: any[], arg2: any[]): boolean { + return false; + } + + public addTest(test: TestCase) { + } +} + +export var tests: TestRunner = (function () { + var testRunner = new TestRunner(); + + testRunner.addTest(new TestCase("Check UTF8 encoding", + function () { + var fb: any; + fb.writeUtf8Bom(); + var chars = [0x0054]; + for (var i in chars) { + fb.writeUtf8CodePoint(chars[i]); + } + fb.index = 0; + var bytes = []; + for (var i = 0; i < 14; i++) { + bytes.push(fb.readByte()); + } + var expected = [0xEF]; + return TestRunner.arrayCompare(bytes, expected); + })); + + return testRunner; +})(); + +//// [duplicateLocalVariable2.js] +export class TestCase { + name; + test; + errorMessageRegEx; + constructor(name, test, errorMessageRegEx) { + this.name = name; + this.test = test; + this.errorMessageRegEx = errorMessageRegEx; + } +} +export class TestRunner { + static arrayCompare(arg1, arg2) { + return false; + } + addTest(test) { + } +} +export var tests = (function () { + var testRunner = new TestRunner(); + testRunner.addTest(new TestCase("Check UTF8 encoding", function () { + var fb; + fb.writeUtf8Bom(); + var chars = [0x0054]; + for (var i in chars) { + fb.writeUtf8CodePoint(chars[i]); + } + fb.index = 0; + var bytes = []; + for (var i = 0; i < 14; i++) { + bytes.push(fb.readByte()); + } + var expected = [0xEF]; + return TestRunner.arrayCompare(bytes, expected); + })); + return testRunner; +})(); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.js.diff new file mode 100644 index 0000000000..66d761a936 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.js.diff @@ -0,0 +1,12 @@ +--- old.duplicateLocalVariable2.js ++++ new.duplicateLocalVariable2.js +@@= skipped -38, +38 lines =@@ + + //// [duplicateLocalVariable2.js] + export class TestCase { ++ name; ++ test; ++ errorMessageRegEx; + constructor(name, test, errorMessageRegEx) { + this.name = name; + this.test = test; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.symbols b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.symbols new file mode 100644 index 0000000000..30f8e4a990 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.symbols @@ -0,0 +1,96 @@ +//// [tests/cases/compiler/duplicateLocalVariable2.ts] //// + +=== duplicateLocalVariable2.ts === +export class TestCase { +>TestCase : Symbol(TestCase, Decl(duplicateLocalVariable2.ts, 0, 0)) + + constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { +>name : Symbol(TestCase.name, Decl(duplicateLocalVariable2.ts, 1, 17)) +>test : Symbol(TestCase.test, Decl(duplicateLocalVariable2.ts, 1, 37)) +>errorMessageRegEx : Symbol(TestCase.errorMessageRegEx, Decl(duplicateLocalVariable2.ts, 1, 63)) + } +} +export class TestRunner { +>TestRunner : Symbol(TestRunner, Decl(duplicateLocalVariable2.ts, 3, 1)) + + static arrayCompare(arg1: any[], arg2: any[]): boolean { +>arrayCompare : Symbol(TestRunner.arrayCompare, Decl(duplicateLocalVariable2.ts, 4, 25)) +>arg1 : Symbol(arg1, Decl(duplicateLocalVariable2.ts, 5, 24)) +>arg2 : Symbol(arg2, Decl(duplicateLocalVariable2.ts, 5, 36)) + + return false; + } + + public addTest(test: TestCase) { +>addTest : Symbol(TestRunner.addTest, Decl(duplicateLocalVariable2.ts, 7, 5)) +>test : Symbol(test, Decl(duplicateLocalVariable2.ts, 9, 19)) +>TestCase : Symbol(TestCase, Decl(duplicateLocalVariable2.ts, 0, 0)) + } +} + +export var tests: TestRunner = (function () { +>tests : Symbol(tests, Decl(duplicateLocalVariable2.ts, 13, 10)) +>TestRunner : Symbol(TestRunner, Decl(duplicateLocalVariable2.ts, 3, 1)) + + var testRunner = new TestRunner(); +>testRunner : Symbol(testRunner, Decl(duplicateLocalVariable2.ts, 14, 7)) +>TestRunner : Symbol(TestRunner, Decl(duplicateLocalVariable2.ts, 3, 1)) + + testRunner.addTest(new TestCase("Check UTF8 encoding", +>testRunner.addTest : Symbol(TestRunner.addTest, Decl(duplicateLocalVariable2.ts, 7, 5)) +>testRunner : Symbol(testRunner, Decl(duplicateLocalVariable2.ts, 14, 7)) +>addTest : Symbol(TestRunner.addTest, Decl(duplicateLocalVariable2.ts, 7, 5)) +>TestCase : Symbol(TestCase, Decl(duplicateLocalVariable2.ts, 0, 0)) + + function () { + var fb: any; +>fb : Symbol(fb, Decl(duplicateLocalVariable2.ts, 18, 15)) + + fb.writeUtf8Bom(); +>fb : Symbol(fb, Decl(duplicateLocalVariable2.ts, 18, 15)) + + var chars = [0x0054]; +>chars : Symbol(chars, Decl(duplicateLocalVariable2.ts, 20, 15)) + + for (var i in chars) { +>i : Symbol(i, Decl(duplicateLocalVariable2.ts, 21, 20), Decl(duplicateLocalVariable2.ts, 26, 20)) +>chars : Symbol(chars, Decl(duplicateLocalVariable2.ts, 20, 15)) + + fb.writeUtf8CodePoint(chars[i]); +>fb : Symbol(fb, Decl(duplicateLocalVariable2.ts, 18, 15)) +>chars : Symbol(chars, Decl(duplicateLocalVariable2.ts, 20, 15)) +>i : Symbol(i, Decl(duplicateLocalVariable2.ts, 21, 20), Decl(duplicateLocalVariable2.ts, 26, 20)) + } + fb.index = 0; +>fb : Symbol(fb, Decl(duplicateLocalVariable2.ts, 18, 15)) + + var bytes = []; +>bytes : Symbol(bytes, Decl(duplicateLocalVariable2.ts, 25, 15)) + + for (var i = 0; i < 14; i++) { +>i : Symbol(i, Decl(duplicateLocalVariable2.ts, 21, 20), Decl(duplicateLocalVariable2.ts, 26, 20)) +>i : Symbol(i, Decl(duplicateLocalVariable2.ts, 21, 20), Decl(duplicateLocalVariable2.ts, 26, 20)) +>i : Symbol(i, Decl(duplicateLocalVariable2.ts, 21, 20), Decl(duplicateLocalVariable2.ts, 26, 20)) + + bytes.push(fb.readByte()); +>bytes.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>bytes : Symbol(bytes, Decl(duplicateLocalVariable2.ts, 25, 15)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>fb : Symbol(fb, Decl(duplicateLocalVariable2.ts, 18, 15)) + } + var expected = [0xEF]; +>expected : Symbol(expected, Decl(duplicateLocalVariable2.ts, 29, 15)) + + return TestRunner.arrayCompare(bytes, expected); +>TestRunner.arrayCompare : Symbol(TestRunner.arrayCompare, Decl(duplicateLocalVariable2.ts, 4, 25)) +>TestRunner : Symbol(TestRunner, Decl(duplicateLocalVariable2.ts, 3, 1)) +>arrayCompare : Symbol(TestRunner.arrayCompare, Decl(duplicateLocalVariable2.ts, 4, 25)) +>bytes : Symbol(bytes, Decl(duplicateLocalVariable2.ts, 25, 15)) +>expected : Symbol(expected, Decl(duplicateLocalVariable2.ts, 29, 15)) + + })); + + return testRunner; +>testRunner : Symbol(testRunner, Decl(duplicateLocalVariable2.ts, 14, 7)) + +})(); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.types b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.types new file mode 100644 index 0000000000..1a01a2099b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable2.types @@ -0,0 +1,129 @@ +//// [tests/cases/compiler/duplicateLocalVariable2.ts] //// + +=== duplicateLocalVariable2.ts === +export class TestCase { +>TestCase : TestCase + + constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) { +>name : string +>test : () => boolean +>errorMessageRegEx : string + } +} +export class TestRunner { +>TestRunner : TestRunner + + static arrayCompare(arg1: any[], arg2: any[]): boolean { +>arrayCompare : (arg1: any[], arg2: any[]) => boolean +>arg1 : any[] +>arg2 : any[] + + return false; +>false : false + } + + public addTest(test: TestCase) { +>addTest : (test: TestCase) => void +>test : TestCase + } +} + +export var tests: TestRunner = (function () { +>tests : TestRunner +>(function () { var testRunner = new TestRunner(); testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb: any; fb.writeUtf8Bom(); var chars = [0x0054]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF]; return TestRunner.arrayCompare(bytes, expected); })); return testRunner;})() : TestRunner +>(function () { var testRunner = new TestRunner(); testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb: any; fb.writeUtf8Bom(); var chars = [0x0054]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF]; return TestRunner.arrayCompare(bytes, expected); })); return testRunner;}) : () => TestRunner +>function () { var testRunner = new TestRunner(); testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb: any; fb.writeUtf8Bom(); var chars = [0x0054]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF]; return TestRunner.arrayCompare(bytes, expected); })); return testRunner;} : () => TestRunner + + var testRunner = new TestRunner(); +>testRunner : TestRunner +>new TestRunner() : TestRunner +>TestRunner : typeof TestRunner + + testRunner.addTest(new TestCase("Check UTF8 encoding", +>testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb: any; fb.writeUtf8Bom(); var chars = [0x0054]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF]; return TestRunner.arrayCompare(bytes, expected); })) : void +>testRunner.addTest : (test: TestCase) => void +>testRunner : TestRunner +>addTest : (test: TestCase) => void +>new TestCase("Check UTF8 encoding", function () { var fb: any; fb.writeUtf8Bom(); var chars = [0x0054]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF]; return TestRunner.arrayCompare(bytes, expected); }) : TestCase +>TestCase : typeof TestCase +>"Check UTF8 encoding" : "Check UTF8 encoding" + + function () { +>function () { var fb: any; fb.writeUtf8Bom(); var chars = [0x0054]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF]; return TestRunner.arrayCompare(bytes, expected); } : () => boolean + + var fb: any; +>fb : any + + fb.writeUtf8Bom(); +>fb.writeUtf8Bom() : any +>fb.writeUtf8Bom : any +>fb : any +>writeUtf8Bom : any + + var chars = [0x0054]; +>chars : number[] +>[0x0054] : number[] +>0x0054 : 84 + + for (var i in chars) { +>i : string +>chars : number[] + + fb.writeUtf8CodePoint(chars[i]); +>fb.writeUtf8CodePoint(chars[i]) : any +>fb.writeUtf8CodePoint : any +>fb : any +>writeUtf8CodePoint : any +>chars[i] : number +>chars : number[] +>i : string + } + fb.index = 0; +>fb.index = 0 : 0 +>fb.index : any +>fb : any +>index : any +>0 : 0 + + var bytes = []; +>bytes : any[] +>[] : undefined[] + + for (var i = 0; i < 14; i++) { +>i : string +>0 : 0 +>i < 14 : boolean +>i : string +>14 : 14 +>i++ : number +>i : string + + bytes.push(fb.readByte()); +>bytes.push(fb.readByte()) : number +>bytes.push : (...items: any[]) => number +>bytes : any[] +>push : (...items: any[]) => number +>fb.readByte() : any +>fb.readByte : any +>fb : any +>readByte : any + } + var expected = [0xEF]; +>expected : number[] +>[0xEF] : number[] +>0xEF : 239 + + return TestRunner.arrayCompare(bytes, expected); +>TestRunner.arrayCompare(bytes, expected) : boolean +>TestRunner.arrayCompare : (arg1: any[], arg2: any[]) => boolean +>TestRunner : typeof TestRunner +>arrayCompare : (arg1: any[], arg2: any[]) => boolean +>bytes : any[] +>expected : number[] + + })); + + return testRunner; +>testRunner : TestRunner + +})(); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js b/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js index 8680935d9e..e9ae01fb1f 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js @@ -46,8 +46,41 @@ var E2; })(E2 || (exports.E2 = E2 = {})); //// [b.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const keys = require("./a"); +const keys = __importStar(require("./a")); const t1 = { [keys.n]: 1, [keys.n]: 1, // duplicate diff --git a/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js.diff deleted file mode 100644 index 23e0b62965..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicateObjectLiteralProperty_computedName3.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.duplicateObjectLiteralProperty_computedName3.js -+++ new.duplicateObjectLiteralProperty_computedName3.js -@@= skipped -46, +46 lines =@@ - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var keys = require("./a"); -+const keys = require("./a"); - const t1 = { - [keys.n]: 1, - [keys.n]: 1, // duplicate \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.js.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage.js.diff deleted file mode 100644 index 2ff214f59b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.duplicatePackage.js -+++ new.duplicatePackage.js -@@= skipped -44, +44 lines =@@ - //// [a.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("a"); --var b_1 = require("b"); --var c_1 = require("c"); -+const a_1 = require("a"); -+const b_1 = require("b"); -+const c_1 = require("c"); - (0, a_1.a)(b_1.b); // Works - (0, a_1.a)(c_1.c); // Error, these are from different versions of the library. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js index 8acd17286e..46aa5fb699 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js @@ -26,6 +26,39 @@ let foo: Foo = a.foo; //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("a"); +const a = __importStar(require("a")); let foo = a.foo; diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js.diff deleted file mode 100644 index 8741077cda..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.duplicatePackage_referenceTypes.js -+++ new.duplicatePackage_referenceTypes.js -@@= skipped -26, +26 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("a"); -+const a = require("a"); - let foo = a.foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.js.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.js.diff deleted file mode 100644 index b3cf10182e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.duplicatePackage_relativeImportWithinPackage.js -+++ new.duplicatePackage_relativeImportWithinPackage.js -@@= skipped -39, +39 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var use_1 = require("foo/use"); --var a_1 = require("a"); -+const use_1 = require("foo/use"); -+const a_1 = require("a"); - (0, use_1.use)(a_1.o); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.js.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.js.diff deleted file mode 100644 index b81645b5e7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.duplicatePackage_relativeImportWithinPackage_scoped.js -+++ new.duplicatePackage_relativeImportWithinPackage_scoped.js -@@= skipped -39, +39 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var use_1 = require("@foo/bar/use"); --var a_1 = require("a"); -+const use_1 = require("@foo/bar/use"); -+const a_1 = require("a"); - (0, use_1.use)(a_1.o); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js index 65245c540b..77b9547a9c 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js @@ -29,6 +29,39 @@ const o: Foo = a.o; //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("a"); +const a = __importStar(require("a")); const o = a.o; diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js.diff deleted file mode 100644 index f1568fbcc2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.duplicatePackage_subModule.js -+++ new.duplicatePackage_subModule.js -@@= skipped -29, +29 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("a"); -+const a = require("a"); - const o = a.o; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.errors.txt new file mode 100644 index 0000000000..684a206f24 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.errors.txt @@ -0,0 +1,140 @@ +duplicateSymbolsExportMatching.ts(1,1): error TS1185: Merge conflict marker encountered. +duplicateSymbolsExportMatching.ts(3,1): error TS1185: Merge conflict marker encountered. +duplicateSymbolsExportMatching.ts(5,1): error TS1185: Merge conflict marker encountered. +duplicateSymbolsExportMatching.ts(7,1): error TS1185: Merge conflict marker encountered. +duplicateSymbolsExportMatching.ts(30,15): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. +duplicateSymbolsExportMatching.ts(31,22): error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. +duplicateSymbolsExportMatching.ts(32,22): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. +duplicateSymbolsExportMatching.ts(33,15): error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. +duplicateSymbolsExportMatching.ts(38,12): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. +duplicateSymbolsExportMatching.ts(41,19): error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. +duplicateSymbolsExportMatching.ts(48,9): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. +duplicateSymbolsExportMatching.ts(49,16): error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. +duplicateSymbolsExportMatching.ts(50,9): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. +duplicateSymbolsExportMatching.ts(51,16): error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. +duplicateSymbolsExportMatching.ts(55,12): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. +duplicateSymbolsExportMatching.ts(55,12): error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged. +duplicateSymbolsExportMatching.ts(58,21): error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. +duplicateSymbolsExportMatching.ts(62,11): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +duplicateSymbolsExportMatching.ts(63,12): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +duplicateSymbolsExportMatching.ts(64,19): error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. +duplicateSymbolsExportMatching.ts(70,11): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. +duplicateSymbolsExportMatching.ts(71,18): error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. + + +==== duplicateSymbolsExportMatching.ts (22 errors) ==== + <<<<<<< HEAD + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + module M { + ||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + namespace M { + ======= + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + namespace M { + >>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export interface E { } + interface I { } + } + module M { + export interface E { } // ok + interface I { } // ok + } + + // Doesn't match export visibility, but it's in a different parent, so it's ok + module M { + interface E { } // ok + export interface I { } // ok + } + + module N { + interface I { } + interface I { } // ok + export interface E { } + export interface E { } // ok + } + + module N2 { + interface I { } + ~ +!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. + export interface I { } // error + ~ +!!! error TS2395: Individual declarations in merged declaration 'I' must be all exported or all local. + export interface E { } + ~ +!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. + interface E { } // error + ~ +!!! error TS2395: Individual declarations in merged declaration 'E' must be all exported or all local. + } + + // Should report error only once for instantiated module + module M { + module inst { + ~~~~ +!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. + var t; + } + export module inst { // one error + ~~~~ +!!! error TS2395: Individual declarations in merged declaration 'inst' must be all exported or all local. + var t; + } + } + + // Variables of the same / different type + module M2 { + var v: string; + ~ +!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. + export var v: string; // one error (visibility) + ~ +!!! error TS2395: Individual declarations in merged declaration 'v' must be all exported or all local. + var w: number; + ~ +!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. + export var w: string; // two errors (visibility and type mismatch) + ~ +!!! error TS2395: Individual declarations in merged declaration 'w' must be all exported or all local. + } + + module M { + module F { + ~ +!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. + ~ +!!! error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged. + var t; + } + export function F() { } // Only one error for duplicate identifier (don't consider visibility) + ~ +!!! error TS2395: Individual declarations in merged declaration 'F' must be all exported or all local. + } + + module M { + class C { } + ~ +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. + module C { } + ~ +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. + export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol) + ~ +!!! error TS2395: Individual declarations in merged declaration 'C' must be all exported or all local. + var t; + } + } + + // Top level + interface D { } + ~ +!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. + export interface D { } + ~ +!!! error TS2395: Individual declarations in merged declaration 'D' must be all exported or all local. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.js b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.js new file mode 100644 index 0000000000..63924c722e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.js @@ -0,0 +1,110 @@ +//// [tests/cases/compiler/duplicateSymbolsExportMatching.ts] //// + +//// [duplicateSymbolsExportMatching.ts] +<<<<<<< HEAD +module M { +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +namespace M { +======= +namespace M { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface E { } + interface I { } +} +module M { + export interface E { } // ok + interface I { } // ok +} + +// Doesn't match export visibility, but it's in a different parent, so it's ok +module M { + interface E { } // ok + export interface I { } // ok +} + +module N { + interface I { } + interface I { } // ok + export interface E { } + export interface E { } // ok +} + +module N2 { + interface I { } + export interface I { } // error + export interface E { } + interface E { } // error +} + +// Should report error only once for instantiated module +module M { + module inst { + var t; + } + export module inst { // one error + var t; + } +} + +// Variables of the same / different type +module M2 { + var v: string; + export var v: string; // one error (visibility) + var w: number; + export var w: string; // two errors (visibility and type mismatch) +} + +module M { + module F { + var t; + } + export function F() { } // Only one error for duplicate identifier (don't consider visibility) +} + +module M { + class C { } + module C { } + export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol) + var t; + } +} + +// Top level +interface D { } +export interface D { } + +//// [duplicateSymbolsExportMatching.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// Should report error only once for instantiated module +var M; +(function (M) { + let inst; + (function (inst) { + var t; + })(inst || (inst = {})); + (function (inst) { + var t; + })(inst = M.inst || (M.inst = {})); +})(M || (M = {})); +// Variables of the same / different type +var M2; +(function (M2) { + var v; + var w; +})(M2 || (M2 = {})); +(function (M) { + let F; + (function (F) { + var t; + })(F || (F = {})); + function F() { } // Only one error for duplicate identifier (don't consider visibility) + M.F = F; +})(M || (M = {})); +(function (M) { + class C { + } + (function (C) { + var t; + })(C = M.C || (M.C = {})); +})(M || (M = {})); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.symbols b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.symbols new file mode 100644 index 0000000000..33e779c2f6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.symbols @@ -0,0 +1,143 @@ +//// [tests/cases/compiler/duplicateSymbolsExportMatching.ts] //// + +=== duplicateSymbolsExportMatching.ts === +<<<<<<< HEAD +module M { +>M : Symbol(M, Decl(duplicateSymbolsExportMatching.ts, 0, 0), Decl(duplicateSymbolsExportMatching.ts, 9, 1), Decl(duplicateSymbolsExportMatching.ts, 13, 1), Decl(duplicateSymbolsExportMatching.ts, 33, 1), Decl(duplicateSymbolsExportMatching.ts, 51, 1) ... and 1 more) + +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +namespace M { +======= +namespace M { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface E { } +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 1, 10), Decl(duplicateSymbolsExportMatching.ts, 10, 10)) + + interface I { } +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 7, 26)) +} +module M { +>M : Symbol(M, Decl(duplicateSymbolsExportMatching.ts, 0, 0), Decl(duplicateSymbolsExportMatching.ts, 9, 1), Decl(duplicateSymbolsExportMatching.ts, 13, 1), Decl(duplicateSymbolsExportMatching.ts, 33, 1), Decl(duplicateSymbolsExportMatching.ts, 51, 1) ... and 1 more) + + export interface E { } // ok +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 1, 10), Decl(duplicateSymbolsExportMatching.ts, 10, 10)) + + interface I { } // ok +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 11, 26)) +} + +// Doesn't match export visibility, but it's in a different parent, so it's ok +module M { +>M : Symbol(M, Decl(duplicateSymbolsExportMatching.ts, 0, 0), Decl(duplicateSymbolsExportMatching.ts, 9, 1), Decl(duplicateSymbolsExportMatching.ts, 13, 1), Decl(duplicateSymbolsExportMatching.ts, 33, 1), Decl(duplicateSymbolsExportMatching.ts, 51, 1) ... and 1 more) + + interface E { } // ok +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 16, 10)) + + export interface I { } // ok +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 17, 19)) +} + +module N { +>N : Symbol(N, Decl(duplicateSymbolsExportMatching.ts, 19, 1)) + + interface I { } +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 21, 10), Decl(duplicateSymbolsExportMatching.ts, 22, 19)) + + interface I { } // ok +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 21, 10), Decl(duplicateSymbolsExportMatching.ts, 22, 19)) + + export interface E { } +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 23, 19), Decl(duplicateSymbolsExportMatching.ts, 24, 26)) + + export interface E { } // ok +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 23, 19), Decl(duplicateSymbolsExportMatching.ts, 24, 26)) +} + +module N2 { +>N2 : Symbol(N2, Decl(duplicateSymbolsExportMatching.ts, 26, 1)) + + interface I { } +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 28, 11), Decl(duplicateSymbolsExportMatching.ts, 29, 19)) + + export interface I { } // error +>I : Symbol(I, Decl(duplicateSymbolsExportMatching.ts, 29, 19)) + + export interface E { } +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 30, 26)) + + interface E { } // error +>E : Symbol(E, Decl(duplicateSymbolsExportMatching.ts, 30, 26), Decl(duplicateSymbolsExportMatching.ts, 31, 26)) +} + +// Should report error only once for instantiated module +module M { +>M : Symbol(M, Decl(duplicateSymbolsExportMatching.ts, 0, 0), Decl(duplicateSymbolsExportMatching.ts, 9, 1), Decl(duplicateSymbolsExportMatching.ts, 13, 1), Decl(duplicateSymbolsExportMatching.ts, 33, 1), Decl(duplicateSymbolsExportMatching.ts, 51, 1) ... and 1 more) + + module inst { +>inst : Symbol(inst, Decl(duplicateSymbolsExportMatching.ts, 36, 10), Decl(duplicateSymbolsExportMatching.ts, 39, 5)) + + var t; +>t : Symbol(t, Decl(duplicateSymbolsExportMatching.ts, 38, 11)) + } + export module inst { // one error +>inst : Symbol(inst, Decl(duplicateSymbolsExportMatching.ts, 39, 5)) + + var t; +>t : Symbol(t, Decl(duplicateSymbolsExportMatching.ts, 41, 11)) + } +} + +// Variables of the same / different type +module M2 { +>M2 : Symbol(M2, Decl(duplicateSymbolsExportMatching.ts, 43, 1)) + + var v: string; +>v : Symbol(v, Decl(duplicateSymbolsExportMatching.ts, 47, 7), Decl(duplicateSymbolsExportMatching.ts, 48, 14)) + + export var v: string; // one error (visibility) +>v : Symbol(v, Decl(duplicateSymbolsExportMatching.ts, 48, 14)) + + var w: number; +>w : Symbol(w, Decl(duplicateSymbolsExportMatching.ts, 49, 7), Decl(duplicateSymbolsExportMatching.ts, 50, 14)) + + export var w: string; // two errors (visibility and type mismatch) +>w : Symbol(w, Decl(duplicateSymbolsExportMatching.ts, 50, 14)) +} + +module M { +>M : Symbol(M, Decl(duplicateSymbolsExportMatching.ts, 0, 0), Decl(duplicateSymbolsExportMatching.ts, 9, 1), Decl(duplicateSymbolsExportMatching.ts, 13, 1), Decl(duplicateSymbolsExportMatching.ts, 33, 1), Decl(duplicateSymbolsExportMatching.ts, 51, 1) ... and 1 more) + + module F { +>F : Symbol(F, Decl(duplicateSymbolsExportMatching.ts, 56, 5), Decl(duplicateSymbolsExportMatching.ts, 53, 10)) + + var t; +>t : Symbol(t, Decl(duplicateSymbolsExportMatching.ts, 55, 11)) + } + export function F() { } // Only one error for duplicate identifier (don't consider visibility) +>F : Symbol(F, Decl(duplicateSymbolsExportMatching.ts, 56, 5)) +} + +module M { +>M : Symbol(M, Decl(duplicateSymbolsExportMatching.ts, 0, 0), Decl(duplicateSymbolsExportMatching.ts, 9, 1), Decl(duplicateSymbolsExportMatching.ts, 13, 1), Decl(duplicateSymbolsExportMatching.ts, 33, 1), Decl(duplicateSymbolsExportMatching.ts, 51, 1) ... and 1 more) + + class C { } +>C : Symbol(C, Decl(duplicateSymbolsExportMatching.ts, 60, 10), Decl(duplicateSymbolsExportMatching.ts, 61, 15), Decl(duplicateSymbolsExportMatching.ts, 62, 16)) + + module C { } +>C : Symbol(C, Decl(duplicateSymbolsExportMatching.ts, 60, 10), Decl(duplicateSymbolsExportMatching.ts, 61, 15), Decl(duplicateSymbolsExportMatching.ts, 62, 16)) + + export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol) +>C : Symbol(C, Decl(duplicateSymbolsExportMatching.ts, 62, 16)) + + var t; +>t : Symbol(t, Decl(duplicateSymbolsExportMatching.ts, 64, 11)) + } +} + +// Top level +interface D { } +>D : Symbol(D, Decl(duplicateSymbolsExportMatching.ts, 66, 1), Decl(duplicateSymbolsExportMatching.ts, 69, 15)) + +export interface D { } +>D : Symbol(D, Decl(duplicateSymbolsExportMatching.ts, 69, 15)) + diff --git a/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.types b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.types new file mode 100644 index 0000000000..828c0f7d84 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/duplicateSymbolsExportMatching.types @@ -0,0 +1,104 @@ +//// [tests/cases/compiler/duplicateSymbolsExportMatching.ts] //// + +=== duplicateSymbolsExportMatching.ts === +<<<<<<< HEAD +module M { +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +namespace M { +======= +namespace M { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface E { } + interface I { } +} +module M { + export interface E { } // ok + interface I { } // ok +} + +// Doesn't match export visibility, but it's in a different parent, so it's ok +module M { + interface E { } // ok + export interface I { } // ok +} + +module N { + interface I { } + interface I { } // ok + export interface E { } + export interface E { } // ok +} + +module N2 { + interface I { } + export interface I { } // error + export interface E { } + interface E { } // error +} + +// Should report error only once for instantiated module +module M { +>M : typeof M + + module inst { +>inst : typeof inst + + var t; +>t : any + } + export module inst { // one error +>inst : typeof M.inst + + var t; +>t : any + } +} + +// Variables of the same / different type +module M2 { +>M2 : typeof M2 + + var v: string; +>v : string + + export var v: string; // one error (visibility) +>v : string + + var w: number; +>w : number + + export var w: string; // two errors (visibility and type mismatch) +>w : string +} + +module M { +>M : typeof M + + module F { +>F : typeof F + + var t; +>t : any + } + export function F() { } // Only one error for duplicate identifier (don't consider visibility) +>F : () => void +} + +module M { +>M : typeof M + + class C { } +>C : C + + module C { } + export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol) +>C : typeof M.C + + var t; +>t : any + } +} + +// Top level +interface D { } +export interface D { } diff --git a/testdata/baselines/reference/submodule/compiler/dynamicImportEvaluateSpecifier.js b/testdata/baselines/reference/submodule/compiler/dynamicImportEvaluateSpecifier.js index be247c57f0..d69f1eee00 100644 --- a/testdata/baselines/reference/submodule/compiler/dynamicImportEvaluateSpecifier.js +++ b/testdata/baselines/reference/submodule/compiler/dynamicImportEvaluateSpecifier.js @@ -18,14 +18,47 @@ const someFunction = async () => { //// [dynamicImportEvaluateSpecifier.js] +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); // https://github.com/microsoft/TypeScript/issues/48285 let i = 0; -Promise.resolve(`${String(i++)}`).then(s => require(s)); -Promise.resolve(`${String(i++)}`).then(s => require(s)); +Promise.resolve(`${String(i++)}`).then(s => __importStar(require(s))); +Promise.resolve(`${String(i++)}`).then(s => __importStar(require(s))); const getPath = async () => { /* in reality this would do some async FS operation, or a web request */ return "/root/my/cool/path"; }; const someFunction = async () => { - const result = await Promise.resolve(`${await getPath()}`).then(s => require(s)); + const result = await Promise.resolve(`${await getPath()}`).then(s => __importStar(require(s))); }; diff --git a/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js b/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js index 888e0e4144..60a643a6dd 100644 --- a/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js +++ b/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js @@ -9,9 +9,42 @@ export default { //// [dynamicImportInDefaultExportExpression.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { getInstance: function () { - return Promise.resolve().then(() => require('./foo2')); + return Promise.resolve().then(() => __importStar(require('./foo2'))); } }; diff --git a/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js.diff b/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js.diff deleted file mode 100644 index 1a1d525748..0000000000 --- a/testdata/baselines/reference/submodule/compiler/dynamicImportInDefaultExportExpression.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.dynamicImportInDefaultExportExpression.js -+++ new.dynamicImportInDefaultExportExpression.js -@@= skipped -11, +11 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = { - getInstance: function () { -- return Promise.resolve().then(function () { return require('./foo2'); }); -+ return Promise.resolve().then(() => require('./foo2')); - } - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js b/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js index 9e85238a27..b287fb8a3f 100644 --- a/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js +++ b/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js @@ -5,5 +5,38 @@ const path = './foo'; import(path,); //// [dynamicImportTrailingComma.js] +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); const path = './foo'; -Promise.resolve(`${path}`).then(s => require(s)); +Promise.resolve(`${path}`).then(s => __importStar(require(s))); diff --git a/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js.diff b/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js.diff deleted file mode 100644 index 147468858b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/dynamicImportTrailingComma.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.dynamicImportTrailingComma.js -+++ new.dynamicImportTrailingComma.js -@@= skipped -5, +5 lines =@@ - - //// [dynamicImportTrailingComma.js] - const path = './foo'; --Promise.resolve("".concat(path)).then(function (s) { return require(s); }); -+Promise.resolve(`${path}`).then(s => require(s)); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/elidedJSImport2(module=commonjs).js.diff b/testdata/baselines/reference/submodule/compiler/elidedJSImport2(module=commonjs).js.diff index 5568f5f597..4d40ad977d 100644 --- a/testdata/baselines/reference/submodule/compiler/elidedJSImport2(module=commonjs).js.diff +++ b/testdata/baselines/reference/submodule/compiler/elidedJSImport2(module=commonjs).js.diff @@ -1,19 +1,6 @@ --- old.elidedJSImport2(module=commonjs).js +++ new.elidedJSImport2(module=commonjs).js -@@= skipped -66, +66 lines =@@ - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var other_js_1 = require("./other.js"); --var other = __importStar(require("./other.js")); --var other_js_2 = __importDefault(require("./other.js")); -+const other_js_1 = require("./other.js"); -+const other = __importStar(require("./other.js")); -+const other_js_2 = __importDefault(require("./other.js")); - const x = new other_js_1.Foo(); - const y = other.Foo(); - const z = new other_js_2.default(); -@@= skipped -11, +11 lines =@@ +@@= skipped -77, +77 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Foo = void 0; class Foo { diff --git a/testdata/baselines/reference/submodule/compiler/elidingImportNames.js.diff b/testdata/baselines/reference/submodule/compiler/elidingImportNames.js.diff deleted file mode 100644 index 4a245e2aef..0000000000 --- a/testdata/baselines/reference/submodule/compiler/elidingImportNames.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.elidingImportNames.js -+++ new.elidingImportNames.js -@@= skipped -26, +26 lines =@@ - //// [elidingImportNames_test.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("./elidingImportNames_main"); // alias used in typeof -+const a = require("./elidingImportNames_main"); // alias used in typeof - var b = a; - var x; --var a2 = require("./elidingImportNames_main1"); // alias not used in typeof -+const a2 = require("./elidingImportNames_main1"); // alias not used in typeof - var b2 = a2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js index dcd7eb5ad3..d405fb0d4c 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js @@ -90,17 +90,17 @@ export declare class FooItem { export type Constructor = new (...args: any[]) => T; export declare function WithTags>(Base: T): { new (...args: any[]): { + tags(): void; foo(): void; name?: string; - tags(): void; }; getTags(): void; } & T; declare const Test_base: { new (...args: any[]): { + tags(): void; foo(): void; name?: string; - tags(): void; }; getTags(): void; } & typeof FooItem; diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js index 3dfa5c2c71..8a40cc2ccb 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js @@ -83,19 +83,19 @@ export declare class FooItem { export type Constructor = new (...args: any[]) => T; export declare function WithTags>(Base: T): { new (...args: any[]): { + tags(): void; foo(): void; name?: string; property: string; - tags(): void; }; getTags(): void; } & T; declare const Test_base: { new (...args: any[]): { + tags(): void; foo(): void; name?: string; property: string; - tags(): void; }; getTags(): void; } & typeof FooItem; diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff index 70ffad67fd..c62bce2f6f 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff @@ -65,19 +65,19 @@ +export type Constructor = new (...args: any[]) => T; +export declare function WithTags>(Base: T): { + new (...args: any[]): { ++ tags(): void; + foo(): void; + name?: string; + property: string; -+ tags(): void; + }; + getTags(): void; +} & T; +declare const Test_base: { + new (...args: any[]): { ++ tags(): void; + foo(): void; + name?: string; + property: string; -+ tags(): void; + }; + getTags(): void; +} & typeof FooItem; diff --git a/testdata/baselines/reference/submodule/compiler/emitClassMergedWithConstNamespaceNotElided.js.diff b/testdata/baselines/reference/submodule/compiler/emitClassMergedWithConstNamespaceNotElided.js.diff deleted file mode 100644 index 797ca26125..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitClassMergedWithConstNamespaceNotElided.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.emitClassMergedWithConstNamespaceNotElided.js -+++ new.emitClassMergedWithConstNamespaceNotElided.js -@@= skipped -20, +20 lines =@@ - //// [usage.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var enum_1 = require("./enum"); -+const enum_1 = require("./enum"); - enum_1.Clone.clone("ok"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=commonjs).js.diff b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=commonjs).js.diff index 2fc9e41e26..1d3a1524b5 100644 --- a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=commonjs).js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=commonjs).js.diff @@ -4,61 +4,56 @@ exports.C3 = C3; //// [index.js] "use strict"; +-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { +- if (k2 === undefined) k2 = k; +- var desc = Object.getOwnPropertyDescriptor(m, k); +- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { +- desc = { enumerable: true, get: function() { return m[k]; } }; +- } +- Object.defineProperty(o, k2, desc); +-}) : (function(o, m, k, k2) { +- if (k2 === undefined) k2 = k; +- o[k2] = m[k]; +-})); +-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { +- Object.defineProperty(o, "default", { enumerable: true, value: v }); +-}) : function(o, v) { +- o["default"] = v; +-}); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; +-var __importStar = (this && this.__importStar) || (function () { +- var ownKeys = function(o) { +- ownKeys = Object.getOwnPropertyNames || function (o) { +- var ar = []; +- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; +- return ar; +- }; +- return ownKeys(o); +- }; +- return function (mod) { +- if (mod && mod.__esModule) return mod; +- var result = {}; +- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); +- __setModuleDefault(result, mod); +- return result; +- }; +-})(); -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; Object.defineProperty(exports, "__esModule", { value: true }); --var t1 = require("./type1"); --var class3_1 = require("./class3"); --let HelloWorld = (() => { -- class HelloWorld { -- handleEvent1(event) { } // Error -- handleEvent2(event) { } // Ok -- handleEvent3(event) { return undefined; } // Ok, Error -- } -- __decorate([ -- EventListener('1'), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object]), -- __metadata("design:returntype", void 0) -- ], HelloWorld.prototype, "handleEvent1", null); -- __decorate([ -- EventListener('2'), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object]), -- __metadata("design:returntype", void 0) -- ], HelloWorld.prototype, "handleEvent2", null); -- __decorate([ -- EventListener('1'), -- __metadata("design:type", Object) -- ], HelloWorld.prototype, "p1", void 0); -- __decorate([ -- EventListener('1'), -- __metadata("design:type", Object) -- ], HelloWorld.prototype, "p1_ns", void 0); -- __decorate([ -- EventListener('2'), -- __metadata("design:type", Object) -- ], HelloWorld.prototype, "p2", void 0); -- __decorate([ -- EventListener('3'), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [class3_1.C3]), -- __metadata("design:returntype", Object) -- ], HelloWorld.prototype, "handleEvent3", null); -- return HelloWorld; --})(); -+class HelloWorld { +-const t1 = __importStar(require("./type1")); +-const class3_1 = require("./class3"); + class HelloWorld { + @EventListener('1') -+ handleEvent1(event) { } // Error + handleEvent1(event) { } // Error + @EventListener('2') -+ handleEvent2(event) { } // Ok + handleEvent2(event) { } // Ok + @EventListener('1') + p1; // Error + @EventListener('1') @@ -66,5 +61,35 @@ + @EventListener('2') + p2; // Ok + @EventListener('3') -+ handleEvent3(event) { return undefined; } // Ok, Error -+} \ No newline at end of file + handleEvent3(event) { return undefined; } // Ok, Error + } +-__decorate([ +- EventListener('1'), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object]), +- __metadata("design:returntype", void 0) +-], HelloWorld.prototype, "handleEvent1", null); +-__decorate([ +- EventListener('2'), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object]), +- __metadata("design:returntype", void 0) +-], HelloWorld.prototype, "handleEvent2", null); +-__decorate([ +- EventListener('1'), +- __metadata("design:type", Object) +-], HelloWorld.prototype, "p1", void 0); +-__decorate([ +- EventListener('1'), +- __metadata("design:type", Object) +-], HelloWorld.prototype, "p1_ns", void 0); +-__decorate([ +- EventListener('2'), +- __metadata("design:type", Object) +-], HelloWorld.prototype, "p2", void 0); +-__decorate([ +- EventListener('3'), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [class3_1.C3]), +- __metadata("design:returntype", Object) +-], HelloWorld.prototype, "handleEvent3", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=esnext).js.diff b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=esnext).js.diff index d6e0b1b851..8278bb05cc 100644 --- a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=esnext).js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_isolatedModules(module=esnext).js.diff @@ -15,49 +15,11 @@ -}; -import * as t1 from "./type1"; -import { C3 } from "./class3"; --let HelloWorld = (() => { -- class HelloWorld { -- handleEvent1(event) { } // Error -- handleEvent2(event) { } // Ok -- handleEvent3(event) { return undefined; } // Ok, Error -- } -- __decorate([ -- EventListener('1'), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object]), -- __metadata("design:returntype", void 0) -- ], HelloWorld.prototype, "handleEvent1", null); -- __decorate([ -- EventListener('2'), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object]), -- __metadata("design:returntype", void 0) -- ], HelloWorld.prototype, "handleEvent2", null); -- __decorate([ -- EventListener('1'), -- __metadata("design:type", Object) -- ], HelloWorld.prototype, "p1", void 0); -- __decorate([ -- EventListener('1'), -- __metadata("design:type", Object) -- ], HelloWorld.prototype, "p1_ns", void 0); -- __decorate([ -- EventListener('2'), -- __metadata("design:type", Object) -- ], HelloWorld.prototype, "p2", void 0); -- __decorate([ -- EventListener('3'), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [C3]), -- __metadata("design:returntype", Object) -- ], HelloWorld.prototype, "handleEvent3", null); -- return HelloWorld; --})(); -+class HelloWorld { + class HelloWorld { + @EventListener('1') -+ handleEvent1(event) { } // Error + handleEvent1(event) { } // Error + @EventListener('2') -+ handleEvent2(event) { } // Ok + handleEvent2(event) { } // Ok + @EventListener('1') + p1; // Error + @EventListener('1') @@ -65,6 +27,36 @@ + @EventListener('2') + p2; // Ok + @EventListener('3') -+ handleEvent3(event) { return undefined; } // Ok, Error -+} + handleEvent3(event) { return undefined; } // Ok, Error + } +-__decorate([ +- EventListener('1'), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object]), +- __metadata("design:returntype", void 0) +-], HelloWorld.prototype, "handleEvent1", null); +-__decorate([ +- EventListener('2'), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object]), +- __metadata("design:returntype", void 0) +-], HelloWorld.prototype, "handleEvent2", null); +-__decorate([ +- EventListener('1'), +- __metadata("design:type", Object) +-], HelloWorld.prototype, "p1", void 0); +-__decorate([ +- EventListener('1'), +- __metadata("design:type", Object) +-], HelloWorld.prototype, "p1_ns", void 0); +-__decorate([ +- EventListener('2'), +- __metadata("design:type", Object) +-], HelloWorld.prototype, "p2", void 0); +-__decorate([ +- EventListener('3'), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [C3]), +- __metadata("design:returntype", Object) +-], HelloWorld.prototype, "handleEvent3", null); +export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_object.js.diff b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_object.js.diff index 0da589efcf..c1437b5b01 100644 --- a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_object.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_object.js.diff @@ -13,26 +13,21 @@ -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; --let A = (() => { -- let A = class A { -- constructor(hi) { } -- method(there) { } -- }; -- __decorate([ -- MyMethodDecorator, -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object]), -- __metadata("design:returntype", void 0) -- ], A.prototype, "method", null); -- A = __decorate([ -- MyClassDecorator, -- __metadata("design:paramtypes", [Object]) -- ], A); -- return A; --})(); +-let A = class A { +@MyClassDecorator +class A { -+ constructor(hi) { } + constructor(hi) { } + @MyMethodDecorator -+ method(there) { } + method(there) { } +-}; +-__decorate([ +- MyMethodDecorator, +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object]), +- __metadata("design:returntype", void 0) +-], A.prototype, "method", null); +-A = __decorate([ +- MyClassDecorator, +- __metadata("design:paramtypes", [Object]) +-], A); +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_restArgs.js.diff b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_restArgs.js.diff index 279f00977e..cf3e674a5c 100644 --- a/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_restArgs.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitDecoratorMetadata_restArgs.js.diff @@ -13,40 +13,34 @@ -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; --let A = (() => { -- let A = class A { -- constructor(...args) { } -- method(...args) { } -- }; -- __decorate([ -- MyMethodDecorator, -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Object]), -- __metadata("design:returntype", void 0) -- ], A.prototype, "method", null); -- A = __decorate([ -- MyClassDecorator, -- __metadata("design:paramtypes", [Object]) -- ], A); -- return A; --})(); --let B = (() => { -- let B = class B { -- constructor(...args) { } -- method(...args) { } -- }; -- __decorate([ -- MyMethodDecorator, -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [String]), -- __metadata("design:returntype", void 0) -- ], B.prototype, "method", null); -- B = __decorate([ -- MyClassDecorator, -- __metadata("design:paramtypes", [Number]) -- ], B); -- return B; --})(); +-let A = class A { +- constructor(...args) { } +- method(...args) { } +-}; +-__decorate([ +- MyMethodDecorator, +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Object]), +- __metadata("design:returntype", void 0) +-], A.prototype, "method", null); +-A = __decorate([ +- MyClassDecorator, +- __metadata("design:paramtypes", [Object]) +-], A); +-let B = class B { +- constructor(...args) { } +- method(...args) { } +-}; +-__decorate([ +- MyMethodDecorator, +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [String]), +- __metadata("design:returntype", void 0) +-], B.prototype, "method", null); +-B = __decorate([ +- MyClassDecorator, +- __metadata("design:paramtypes", [Number]) +-], B); +@MyClassDecorator +class A { + constructor(...args) { } diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).errors.txt b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).errors.txt deleted file mode 100644 index 67291b1f97..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node16'. - - -!!! error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node16'. -==== a.ts (0 errors) ==== - declare var dec: any, __decorate: any; - @dec export class A { - } - - const o = { a: 1 }; - const y = { ...o }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).js.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).js.diff index 929423ee34..9886632971 100644 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node16).js.diff @@ -1,27 +1,25 @@ --- old.emitHelpersWithLocalCollisions(module=node16).js +++ new.emitHelpersWithLocalCollisions(module=node16).js -@@= skipped -9, +9 lines =@@ - +@@= skipped -10, +10 lines =@@ //// [a.js] + "use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.A = void 0; -let A = class A { -}; --A = __decorate([ -- dec --], A); --export { A }; -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.A = void 0; +@dec +class A { +} -+exports.A = A; + exports.A = A; +-exports.A = A = __decorate([ +- dec +-], A); const o = { a: 1 }; const y = Object.assign({}, o); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).errors.txt b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).errors.txt deleted file mode 100644 index 7dfd532d52..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node18'. - - -!!! error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node18'. -==== a.ts (0 errors) ==== - declare var dec: any, __decorate: any; - @dec export class A { - } - - const o = { a: 1 }; - const y = { ...o }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).js.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).js.diff index 66178e26d6..f7e3e17ef5 100644 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node18).js.diff @@ -1,27 +1,25 @@ --- old.emitHelpersWithLocalCollisions(module=node18).js +++ new.emitHelpersWithLocalCollisions(module=node18).js -@@= skipped -9, +9 lines =@@ - +@@= skipped -10, +10 lines =@@ //// [a.js] + "use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.A = void 0; -let A = class A { -}; --A = __decorate([ -- dec --], A); --export { A }; -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.A = void 0; +@dec +class A { +} -+exports.A = A; + exports.A = A; +-exports.A = A = __decorate([ +- dec +-], A); const o = { a: 1 }; const y = Object.assign({}, o); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).errors.txt b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).errors.txt deleted file mode 100644 index 68c6714749..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node20'. - - -!!! error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node20'. -==== a.ts (0 errors) ==== - declare var dec: any, __decorate: any; - @dec export class A { - } - - const o = { a: 1 }; - const y = { ...o }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).errors.txt.diff deleted file mode 100644 index 0eb8cd4584..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.emitHelpersWithLocalCollisions(module=node20).errors.txt -+++ new.emitHelpersWithLocalCollisions(module=node20).errors.txt -@@= skipped -0, +0 lines =@@ --error TS5070: Option '--resolveJsonModule' cannot be specified when 'moduleResolution' is set to 'classic'. - error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node20'. - - --!!! error TS5070: Option '--resolveJsonModule' cannot be specified when 'moduleResolution' is set to 'classic'. - !!! error TS5109: Option 'moduleResolution' must be set to 'Node16' (or left unspecified) when option 'module' is set to 'Node20'. - ==== a.ts (0 errors) ==== - declare var dec: any, __decorate: any; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).js.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).js.diff index a10aa37d78..cc9a2defb2 100644 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=node20).js.diff @@ -1,27 +1,25 @@ --- old.emitHelpersWithLocalCollisions(module=node20).js +++ new.emitHelpersWithLocalCollisions(module=node20).js -@@= skipped -9, +9 lines =@@ - +@@= skipped -10, +10 lines =@@ //// [a.js] + "use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.A = void 0; -let A = class A { -}; --A = __decorate([ -- dec --], A); --export { A }; -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.A = void 0; +@dec +class A { +} -+exports.A = A; + exports.A = A; +-exports.A = A = __decorate([ +- dec +-], A); const o = { a: 1 }; const y = Object.assign({}, o); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).errors.txt deleted file mode 100644 index 4b7e63ced9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'. - - -!!! error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'. -==== a.ts (0 errors) ==== - declare var dec: any, __decorate: any; - @dec export class A { - } - - const o = { a: 1 }; - const y = { ...o }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).errors.txt.diff deleted file mode 100644 index 9e1146fb6a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.emitHelpersWithLocalCollisions(module=nodenext).errors.txt -+++ new.emitHelpersWithLocalCollisions(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS5070: Option '--resolveJsonModule' cannot be specified when 'moduleResolution' is set to 'classic'. - error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'. - - --!!! error TS5070: Option '--resolveJsonModule' cannot be specified when 'moduleResolution' is set to 'classic'. - !!! error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'. - ==== a.ts (0 errors) ==== - declare var dec: any, __decorate: any; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).js.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).js.diff index 3a741386c0..9c16969e58 100644 --- a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=nodenext).js.diff @@ -1,27 +1,25 @@ --- old.emitHelpersWithLocalCollisions(module=nodenext).js +++ new.emitHelpersWithLocalCollisions(module=nodenext).js -@@= skipped -9, +9 lines =@@ - +@@= skipped -10, +10 lines =@@ //// [a.js] + "use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.A = void 0; -let A = class A { -}; --A = __decorate([ -- dec --], A); --export { A }; -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.A = void 0; +@dec +class A { +} -+exports.A = A; + exports.A = A; +-exports.A = A = __decorate([ +- dec +-], A); const o = { a: 1 }; const y = Object.assign({}, o); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=none).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=none).errors.txt.diff new file mode 100644 index 0000000000..5dd684f6ff --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/emitHelpersWithLocalCollisions(module=none).errors.txt.diff @@ -0,0 +1,16 @@ +--- old.emitHelpersWithLocalCollisions(module=none).errors.txt ++++ new.emitHelpersWithLocalCollisions(module=none).errors.txt +@@= skipped -0, +0 lines =@@ +-error TS5107: Option 'module=None' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-!!! error TS5107: Option 'module=None' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +-==== a.ts (0 errors) ==== +- declare var dec: any, __decorate: any; +- @dec export class A { +- } +- +- const o = { a: 1 }; +- const y = { ...o }; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js b/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js index 4c61b7d7ba..3999d213aa 100644 --- a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js +++ b/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js @@ -16,9 +16,9 @@ export const c = { //// [emitMethodCalledNew.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/55075 Object.defineProperty(exports, "__esModule", { value: true }); exports.c = exports.b = exports.a = void 0; -// https://github.com/microsoft/TypeScript/issues/55075 exports.a = { new(x) { return x + 1; } }; diff --git a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js.diff b/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js.diff deleted file mode 100644 index 3acf938c2e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.emitMethodCalledNew.js -+++ new.emitMethodCalledNew.js -@@= skipped -15, +15 lines =@@ - - //// [emitMethodCalledNew.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/55075 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.c = exports.b = exports.a = void 0; -+// https://github.com/microsoft/TypeScript/issues/55075 - exports.a = { - new(x) { return x + 1; } - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js b/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js index ca9a87b245..d50c8fc1c4 100644 --- a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js +++ b/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js @@ -10,4 +10,9 @@ var x = 10; //// [emitPinnedCommentsOnTopOfFile.js] +/*! + + multi line + comment +*/ var x = 10; diff --git a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js.diff b/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js.diff deleted file mode 100644 index 268a95d541..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.emitPinnedCommentsOnTopOfFile.js -+++ new.emitPinnedCommentsOnTopOfFile.js -@@= skipped -9, +9 lines =@@ - var x = 10; - - //// [emitPinnedCommentsOnTopOfFile.js] --/*! -- -- multi line -- comment --*/ - var x = 10; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js index 06d18caa72..5df04ebcb0 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js @@ -22,8 +22,6 @@ class A { class B extends A { x; constructor(x) { - "use strict"; - 'someStringForEgngInject'; "use strict"; 'someStringForEgngInject'; super(); diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js.diff b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js.diff index 6f1e0e132d..a44084a7f7 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js.diff @@ -12,8 +12,5 @@ class B extends A { + x; constructor(x) { -+ "use strict"; -+ 'someStringForEgngInject'; "use strict"; - 'someStringForEgngInject'; - super(); \ No newline at end of file + 'someStringForEgngInject'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js index 5be2f066d1..905a6e9e0d 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js @@ -22,8 +22,6 @@ class A { class B extends A { x; constructor(x) { - "use strict"; - 'someStringForEgngInject'; "use strict"; 'someStringForEgngInject'; super(); diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js.diff b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js.diff index 8e70ccc6b8..df5c424a39 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js.diff @@ -12,8 +12,5 @@ class B extends A { + x; constructor(x) { -+ "use strict"; -+ 'someStringForEgngInject'; "use strict"; - 'someStringForEgngInject'; - super(); \ No newline at end of file + 'someStringForEgngInject'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js index 5492998dec..e99edef88b 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js @@ -24,8 +24,6 @@ class A { class B extends A { blub = 12; constructor() { - "use strict"; - 'someStringForEgngInject'; "use strict"; 'someStringForEgngInject'; super(); diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js.diff b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js.diff index 24edb87295..fc27dd53af 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.js.diff @@ -12,8 +12,6 @@ class B extends A { + blub = 12; constructor() { -+ "use strict"; -+ 'someStringForEgngInject'; "use strict"; 'someStringForEgngInject'; super(); diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js index b4207bcc5c..7e911c20e0 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js @@ -23,7 +23,6 @@ class A { class B extends A { blub = 12; constructor() { - 'someStringForEgngInject'; 'someStringForEgngInject'; super(); } diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js.diff b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js.diff index 51ce0e6d99..847ad90db7 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js.diff @@ -12,7 +12,6 @@ class B extends A { + blub = 12; constructor() { -+ 'someStringForEgngInject'; 'someStringForEgngInject'; super(); - this.blub = 12; diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js index a4abe58369..d9f3dfd292 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js @@ -23,8 +23,6 @@ class B extends A { x; blah = 2; constructor(x) { - "use strict"; - 'someStringForEgngInject'; "use strict"; 'someStringForEgngInject'; super(); diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js.diff b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js.diff index ab9d334c74..8c968fc319 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js.diff @@ -15,8 +15,6 @@ constructor(x) { "use strict"; 'someStringForEgngInject'; -+ "use strict"; -+ 'someStringForEgngInject'; super(); this.x = x; - this.blah = 2; diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js index 59e9a7401f..a8b4c7a50b 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js @@ -23,8 +23,6 @@ class B extends A { x; blah = 2; constructor(x) { - "use strict"; - 'someStringForEgngInject'; "use strict"; 'someStringForEgngInject'; super(); diff --git a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js.diff b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js.diff index 7590ac5e30..a52e07e863 100644 --- a/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js.diff @@ -15,8 +15,6 @@ constructor(x) { "use strict"; 'someStringForEgngInject'; -+ "use strict"; -+ 'someStringForEgngInject'; super(); this.x = x; - this.blah = 2; diff --git a/testdata/baselines/reference/submodule/compiler/emptyModuleName.js b/testdata/baselines/reference/submodule/compiler/emptyModuleName.js index 24b2650b26..2646166827 100644 --- a/testdata/baselines/reference/submodule/compiler/emptyModuleName.js +++ b/testdata/baselines/reference/submodule/compiler/emptyModuleName.js @@ -7,7 +7,40 @@ class B extends A { //// [emptyModuleName.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const A = require(""); +const A = __importStar(require("")); class B extends A { } diff --git a/testdata/baselines/reference/submodule/compiler/emptyModuleName.js.diff b/testdata/baselines/reference/submodule/compiler/emptyModuleName.js.diff deleted file mode 100644 index a390512c39..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emptyModuleName.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.emptyModuleName.js -+++ new.emptyModuleName.js -@@= skipped -7, +7 lines =@@ - //// [emptyModuleName.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var A = require(""); -+const A = require(""); - class B extends A { - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols b/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols index 80be37a2c3..2e7e01a49b 100644 --- a/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols +++ b/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols @@ -8,7 +8,7 @@ const _item = require("./namespacer"); module.exports = 12; >module.exports : Symbol(export=, Decl(index.js, 0, 38)) ->module : Symbol(module.exports) +>module : Symbol("index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 38)) Object.defineProperty(module, "exports", { value: "oh no" }); @@ -29,7 +29,7 @@ A.bar = class Q {} module.exports = A; >module.exports : Symbol(A, Decl(namespacey.js, 0, 5)) ->module : Symbol(module.exports) +>module : Symbol("namespacey", Decl(namespacey.js, 0, 0)) >exports : Symbol(A, Decl(namespacey.js, 0, 5)) >A : Symbol(A, Decl(namespacey.js, 0, 5)) @@ -53,7 +53,7 @@ Object.defineProperty(B, "NS", { value: "why though", writable: true }); module.exports = B; >module.exports : Symbol(B, Decl(namespacer.js, 0, 5)) ->module : Symbol(module.exports) +>module : Symbol("namespacer", Decl(namespacer.js, 0, 0)) >exports : Symbol(B, Decl(namespacer.js, 0, 5)) >B : Symbol(B, Decl(namespacer.js, 0, 5)) diff --git a/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols.diff b/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols.diff index b61e4fb453..cbe9872090 100644 --- a/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.symbols.diff @@ -7,7 +7,7 @@ ->module.exports : Symbol(module.exports, Decl(index.js, 0, 0)) ->module : Symbol(export=, Decl(index.js, 0, 38)) +>module.exports : Symbol(export=, Decl(index.js, 0, 38)) -+>module : Symbol(module.exports) ++>module : Symbol("index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 38)) Object.defineProperty(module, "exports", { value: "oh no" }); @@ -38,7 +38,7 @@ ->exports : Symbol(export=, Decl(namespacey.js, 1, 18)) ->A : Symbol(A, Decl(namespacey.js, 0, 5), Decl(namespacey.js, 0, 12)) +>module.exports : Symbol(A, Decl(namespacey.js, 0, 5)) -+>module : Symbol(module.exports) ++>module : Symbol("namespacey", Decl(namespacey.js, 0, 0)) +>exports : Symbol(A, Decl(namespacey.js, 0, 5)) +>A : Symbol(A, Decl(namespacey.js, 0, 5)) @@ -73,6 +73,6 @@ ->exports : Symbol(export=, Decl(namespacer.js, 2, 72)) ->B : Symbol(B, Decl(namespacer.js, 0, 5), Decl(namespacer.js, 0, 12), Decl(namespacer.js, 2, 22)) +>module.exports : Symbol(B, Decl(namespacer.js, 0, 5)) -+>module : Symbol(module.exports) ++>module : Symbol("namespacer", Decl(namespacer.js, 0, 0)) +>exports : Symbol(B, Decl(namespacer.js, 0, 5)) +>B : Symbol(B, Decl(namespacer.js, 0, 5)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types.diff b/testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types.diff rename to testdata/baselines/reference/submodule/compiler/ensureNoCrashExportAssignmentDefineProperrtyPotentialMerge.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js b/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js index 92755b4824..d1380ec35a 100644 --- a/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js +++ b/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js @@ -26,6 +26,7 @@ function overloadingFunction(): second.E { } //// [enumAssignmentCompat7.js] +"use strict"; var first; (function (first) { let E; diff --git a/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js.diff b/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js.diff deleted file mode 100644 index 469f25365b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumAssignmentCompat7.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.enumAssignmentCompat7.js -+++ new.enumAssignmentCompat7.js -@@= skipped -25, +25 lines =@@ - } - - //// [enumAssignmentCompat7.js] --"use strict"; - var first; - (function (first) { - let E; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumDeclarationEmitInitializerHasImport.js.diff b/testdata/baselines/reference/submodule/compiler/enumDeclarationEmitInitializerHasImport.js.diff deleted file mode 100644 index 7ebd9dfb64..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumDeclarationEmitInitializerHasImport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.enumDeclarationEmitInitializerHasImport.js -+++ new.enumDeclarationEmitInitializerHasImport.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.value = void 0; --var provider = require("./provider"); -+const provider = require("./provider"); - exports.value = provider.Enum.Value1; - diff --git a/testdata/baselines/reference/submodule/compiler/enumFromExternalModule.js.diff b/testdata/baselines/reference/submodule/compiler/enumFromExternalModule.js.diff deleted file mode 100644 index 15b6cbbdde..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumFromExternalModule.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.enumFromExternalModule.js -+++ new.enumFromExternalModule.js -@@= skipped -21, +21 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var f = require("./enumFromExternalModule_0"); -+const f = require("./enumFromExternalModule_0"); - var x = f.Mode.Open; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js index fcc80bef33..60e41c7655 100644 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js +++ b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js @@ -52,7 +52,7 @@ export declare enum MouseButton { NO_BUTTON = 0 } export declare const DOMMouseButton: { - "-1": MouseButton; + '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js.diff deleted file mode 100644 index 99e39a42d8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js -+++ new.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js -@@= skipped -51, +51 lines =@@ - NO_BUTTON = 0 - } - export declare const DOMMouseButton: { -- '-1': MouseButton; -+ "-1": MouseButton; - "0": MouseButton; - "1": MouseButton; - "2": MouseButton; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types index 9071fcc7d4..336591545f 100644 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types +++ b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types @@ -30,8 +30,8 @@ export enum MouseButton { } export const DOMMouseButton = { ->DOMMouseButton : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } ->{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } +>DOMMouseButton : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } +>{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } '-1': MouseButton.NO_BUTTON, >'-1' : MouseButton diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types.diff b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types.diff deleted file mode 100644 index 7eca3bcfab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types -+++ new.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types -@@= skipped -29, +29 lines =@@ - } - - export const DOMMouseButton = { -->DOMMouseButton : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } -->{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } -+>DOMMouseButton : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } -+>{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } - - '-1': MouseButton.NO_BUTTON, - >'-1' : MouseButton \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff b/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff index 6c0e96ada0..bb593297ee 100644 --- a/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff +++ b/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff @@ -1,11 +1,7 @@ --- old.enumNoInitializerFollowsNonLiteralInitializer.js +++ new.enumNoInitializerFollowsNonLiteralInitializer.js -@@= skipped -48, +48 lines =@@ - //// [bad.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var helpers_1 = require("./helpers"); -+const helpers_1 = require("./helpers"); +@@= skipped -51, +51 lines =@@ + const helpers_1 = require("./helpers"); var A; (function (A) { - A[A["a"] = 2] = "a"; @@ -21,9 +17,8 @@ })(A || (A = {})); //// [good.js] "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var helpers_1 = require("./helpers"); -+const helpers_1 = require("./helpers"); +@@= skipped -12, +13 lines =@@ + const helpers_1 = require("./helpers"); var A; (function (A) { - A[A["a"] = 2] = "a"; diff --git a/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff b/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff index 86ed94ccbc..74bfbd0128 100644 --- a/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff +++ b/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff @@ -1,11 +1,7 @@ --- old.enumWithNonLiteralStringInitializer.js +++ new.enumWithNonLiteralStringInitializer.js -@@= skipped -28, +28 lines =@@ - //// [bad.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var helpers_1 = require("./helpers"); -+const helpers_1 = require("./helpers"); +@@= skipped -31, +31 lines =@@ + const helpers_1 = require("./helpers"); var A; (function (A) { - A["a"] = "bar"; @@ -14,9 +10,8 @@ })(A || (A = {})); //// [good.js] "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var helpers_1 = require("./helpers"); -+const helpers_1 = require("./helpers"); +@@= skipped -8, +9 lines =@@ + const helpers_1 = require("./helpers"); var A; (function (A) { - A["a"] = "2"; diff --git a/testdata/baselines/reference/submodule/compiler/erasableSyntaxOnly.js.diff b/testdata/baselines/reference/submodule/compiler/erasableSyntaxOnly.js.diff index 2a89f2735f..96cc7ca90d 100644 --- a/testdata/baselines/reference/submodule/compiler/erasableSyntaxOnly.js.diff +++ b/testdata/baselines/reference/submodule/compiler/erasableSyntaxOnly.js.diff @@ -52,8 +52,4 @@ +})); //// [commonjs.cjs] "use strict"; --var foo = require("./other.cjs"); -+const foo = require("./other.cjs"); - module.exports = foo; - //// [esm.mjs] - const foo = 1234; \ No newline at end of file + const foo = require("./other.cjs"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorElaboration.js b/testdata/baselines/reference/submodule/compiler/errorElaboration.js index 2665c3b3fe..01bb02177c 100644 --- a/testdata/baselines/reference/submodule/compiler/errorElaboration.js +++ b/testdata/baselines/reference/submodule/compiler/errorElaboration.js @@ -27,6 +27,7 @@ const x = ({ [foo.bar]: c }) => undefined; //// [errorElaboration.js] +// Repro for #5712 let a; foo(a); // Repro for #25498 diff --git a/testdata/baselines/reference/submodule/compiler/errorElaboration.js.diff b/testdata/baselines/reference/submodule/compiler/errorElaboration.js.diff deleted file mode 100644 index fea4b6e979..0000000000 --- a/testdata/baselines/reference/submodule/compiler/errorElaboration.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.errorElaboration.js -+++ new.errorElaboration.js -@@= skipped -26, +26 lines =@@ - - - //// [errorElaboration.js] --// Repro for #5712 - let a; - foo(a); - // Repro for #25498 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorForBareSpecifierWithImplicitModuleResolutionNone.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/errorForBareSpecifierWithImplicitModuleResolutionNone.errors.txt.diff deleted file mode 100644 index bcfc083cb7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/errorForBareSpecifierWithImplicitModuleResolutionNone.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.errorForBareSpecifierWithImplicitModuleResolutionNone.errors.txt -+++ new.errorForBareSpecifierWithImplicitModuleResolutionNone.errors.txt -@@= skipped -0, +0 lines =@@ --errorForBareSpecifierWithImplicitModuleResolutionNone.ts(3,23): error TS2792: Cannot find module 'non-existent-module'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+errorForBareSpecifierWithImplicitModuleResolutionNone.ts(3,23): error TS2307: Cannot find module 'non-existent-module' or its corresponding type declarations. - - - ==== errorForBareSpecifierWithImplicitModuleResolutionNone.ts (1 errors) ==== -@@= skipped -5, +5 lines =@@ - - import { thing } from "non-existent-module"; - ~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2792: Cannot find module 'non-existent-module'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'non-existent-module' or its corresponding type declarations. - thing() - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js b/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js index 1d8dc551be..88b1a4542d 100644 --- a/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js +++ b/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js @@ -8,6 +8,39 @@ import("./a"); //// [a.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); exports.x = void 0; -Promise.resolve().then(() => require("./a")); +Promise.resolve().then(() => __importStar(require("./a"))); module.exports = x; diff --git a/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js.diff b/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js.diff index 9707ea8dde..8ffaf96a94 100644 --- a/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js.diff +++ b/testdata/baselines/reference/submodule/compiler/errorForConflictingExportEqualsValue.js.diff @@ -1,10 +1,8 @@ --- old.errorForConflictingExportEqualsValue.js +++ new.errorForConflictingExportEqualsValue.js -@@= skipped -8, +8 lines =@@ - //// [a.js] - "use strict"; +@@= skipped -42, +42 lines =@@ + })(); exports.x = void 0; --Promise.resolve().then(function () { return require("./a"); }); + Promise.resolve().then(() => __importStar(require("./a"))); -module.exports = exports.x; -+Promise.resolve().then(() => require("./a")); +module.exports = x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js b/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js index 1c3a41ed4b..0ac0a6afb3 100644 --- a/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js +++ b/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js @@ -49,6 +49,7 @@ else { } //// [errorOnEnumReferenceInCondition.js] +"use strict"; var Nums; (function (Nums) { Nums[Nums["Zero"] = 0] = "Zero"; diff --git a/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js.diff b/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js.diff deleted file mode 100644 index 24c4ab5208..0000000000 --- a/testdata/baselines/reference/submodule/compiler/errorOnEnumReferenceInCondition.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.errorOnEnumReferenceInCondition.js -+++ new.errorOnEnumReferenceInCondition.js -@@= skipped -48, +48 lines =@@ - } - - //// [errorOnEnumReferenceInCondition.js] --"use strict"; - var Nums; - (function (Nums) { - Nums[Nums["Zero"] = 0] = "Zero"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js b/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js index 63ec409b0b..81595327fa 100644 --- a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js +++ b/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js @@ -18,4 +18,6 @@ let Foo = { Bar() { } }; let Baz = () => { }; -let x = React.createElement(Foo.Bar, null, "Hello let y = ", React.createElement(Baz, null, "Hello")); +let x = React.createElement(Foo.Bar, null, + "Hello let y = ", + React.createElement(Baz, null, "Hello")); diff --git a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js.diff b/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js.diff deleted file mode 100644 index d071260647..0000000000 --- a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.errorSpanForUnclosedJsxTag.js -+++ new.errorSpanForUnclosedJsxTag.js -@@= skipped -17, +17 lines =@@ - Bar() { } - }; - let Baz = () => { }; --let x = React.createElement(Foo.Bar, null, -- "Hello let y = ", -- React.createElement(Baz, null, "Hello")); -+let x = React.createElement(Foo.Bar, null, "Hello let y = ", React.createElement(Baz, null, "Hello")); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js index a2cd84bc39..42797cfd18 100644 --- a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js +++ b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js @@ -8,7 +8,7 @@ export async function foo() { async function foo() { } -//// [tslib.d.ts] +//// [index.d.ts] export declare function __extends(d: Function, b: Function): void; export declare function __assign(t: any, ...sources: any[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; diff --git a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js.diff b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js.diff index ec23565193..735579036f 100644 --- a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.js.diff @@ -4,7 +4,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.foo = foo; --var tslib_1 = require("tslib"); +-const tslib_1 = require("tslib"); -function foo() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - }); diff --git a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols index 0ae0e1aa6f..5781f210fb 100644 --- a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols +++ b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols @@ -10,51 +10,51 @@ async function foo() { >foo : Symbol(foo, Decl(script.ts, 0, 0)) } -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; ->__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) ->d : Symbol(d, Decl(tslib.d.ts, 0, 34)) +>__extends : Symbol(__extends, Decl(index.d.ts, 0, 0)) +>d : Symbol(d, Decl(index.d.ts, 0, 34)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->b : Symbol(b, Decl(tslib.d.ts, 0, 46)) +>b : Symbol(b, Decl(index.d.ts, 0, 46)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __assign(t: any, ...sources: any[]): any; ->__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) ->t : Symbol(t, Decl(tslib.d.ts, 1, 33)) ->sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) +>__assign : Symbol(__assign, Decl(index.d.ts, 0, 66)) +>t : Symbol(t, Decl(index.d.ts, 1, 33)) +>sources : Symbol(sources, Decl(index.d.ts, 1, 40)) export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; ->__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) ->decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) +>__decorate : Symbol(__decorate, Decl(index.d.ts, 1, 65)) +>decorators : Symbol(decorators, Decl(index.d.ts, 2, 35)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->target : Symbol(target, Decl(tslib.d.ts, 2, 58)) ->key : Symbol(key, Decl(tslib.d.ts, 2, 71)) ->desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) +>target : Symbol(target, Decl(index.d.ts, 2, 58)) +>key : Symbol(key, Decl(index.d.ts, 2, 71)) +>desc : Symbol(desc, Decl(index.d.ts, 2, 94)) export declare function __param(paramIndex: number, decorator: Function): Function; ->__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) ->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) ->decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) +>__param : Symbol(__param, Decl(index.d.ts, 2, 112)) +>paramIndex : Symbol(paramIndex, Decl(index.d.ts, 3, 32)) +>decorator : Symbol(decorator, Decl(index.d.ts, 3, 51)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __metadata(metadataKey: any, metadataValue: any): Function; ->__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) ->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) ->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) +>__metadata : Symbol(__metadata, Decl(index.d.ts, 3, 83)) +>metadataKey : Symbol(metadataKey, Decl(index.d.ts, 4, 35)) +>metadataValue : Symbol(metadataValue, Decl(index.d.ts, 4, 52)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; ->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) ->thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) ->_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) ->P : Symbol(P, Decl(tslib.d.ts, 5, 64)) +>__awaiter : Symbol(__awaiter, Decl(index.d.ts, 4, 83)) +>thisArg : Symbol(thisArg, Decl(index.d.ts, 5, 34)) +>_arguments : Symbol(_arguments, Decl(index.d.ts, 5, 47)) +>P : Symbol(P, Decl(index.d.ts, 5, 64)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) +>generator : Symbol(generator, Decl(index.d.ts, 5, 77)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __generator(body: Function): any; ->__generator : Symbol(__generator, Decl(tslib.d.ts, 5, 104)) ->body : Symbol(body, Decl(tslib.d.ts, 6, 36)) +>__generator : Symbol(__generator, Decl(index.d.ts, 5, 104)) +>body : Symbol(body, Decl(index.d.ts, 6, 36)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols.diff b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols.diff deleted file mode 100644 index 9ae0085b4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.symbols.diff +++ /dev/null @@ -1,75 +0,0 @@ ---- old.es5-importHelpersAsyncFunctions.symbols -+++ new.es5-importHelpersAsyncFunctions.symbols -@@= skipped -11, +11 lines =@@ - - === tslib.d.ts === - export declare function __extends(d: Function, b: Function): void; -->__extends : Symbol(__extends, Decl(tslib.d.ts, --, --)) -->d : Symbol(d, Decl(tslib.d.ts, --, --)) -+>__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) -+>d : Symbol(d, Decl(tslib.d.ts, 0, 34)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->b : Symbol(b, Decl(tslib.d.ts, --, --)) -+>b : Symbol(b, Decl(tslib.d.ts, 0, 46)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __assign(t: any, ...sources: any[]): any; -->__assign : Symbol(__assign, Decl(tslib.d.ts, --, --)) -->t : Symbol(t, Decl(tslib.d.ts, --, --)) -->sources : Symbol(sources, Decl(tslib.d.ts, --, --)) -+>__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) -+>t : Symbol(t, Decl(tslib.d.ts, 1, 33)) -+>sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) - - export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; -->__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --)) -->decorators : Symbol(decorators, Decl(tslib.d.ts, --, --)) -+>__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) -+>decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->target : Symbol(target, Decl(tslib.d.ts, --, --)) -->key : Symbol(key, Decl(tslib.d.ts, --, --)) -->desc : Symbol(desc, Decl(tslib.d.ts, --, --)) -+>target : Symbol(target, Decl(tslib.d.ts, 2, 58)) -+>key : Symbol(key, Decl(tslib.d.ts, 2, 71)) -+>desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) - - export declare function __param(paramIndex: number, decorator: Function): Function; -->__param : Symbol(__param, Decl(tslib.d.ts, --, --)) -->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, --, --)) -->decorator : Symbol(decorator, Decl(tslib.d.ts, --, --)) -+>__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) -+>paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) -+>decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __metadata(metadataKey: any, metadataValue: any): Function; -->__metadata : Symbol(__metadata, Decl(tslib.d.ts, --, --)) -->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, --, --)) -->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, --, --)) -+>__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) -+>metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) -+>metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; -->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, --, --)) -->thisArg : Symbol(thisArg, Decl(tslib.d.ts, --, --)) -->_arguments : Symbol(_arguments, Decl(tslib.d.ts, --, --)) -->P : Symbol(P, Decl(tslib.d.ts, --, --)) -+>__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) -+>thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) -+>_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) -+>P : Symbol(P, Decl(tslib.d.ts, 5, 64)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->generator : Symbol(generator, Decl(tslib.d.ts, --, --)) -+>generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __generator(body: Function): any; -->__generator : Symbol(__generator, Decl(tslib.d.ts, --, --)) -->body : Symbol(body, Decl(tslib.d.ts, --, --)) -+>__generator : Symbol(__generator, Decl(tslib.d.ts, 5, 104)) -+>body : Symbol(body, Decl(tslib.d.ts, 6, 36)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.types b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.types index e7d5efedac..91286a7c8e 100644 --- a/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.types +++ b/testdata/baselines/reference/submodule/compiler/es5-importHelpersAsyncFunctions.types @@ -10,7 +10,7 @@ async function foo() { >foo : () => Promise } -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; >__extends : (d: Function, b: Function) => void >d : Function diff --git a/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.errors.txt b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.errors.txt new file mode 100644 index 0000000000..8b3f425d72 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.errors.txt @@ -0,0 +1,74 @@ +es5ModuleInternalNamedImports.ts(22,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(23,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(24,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(25,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(26,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(27,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(28,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(29,5): error TS1194: Export declarations are not permitted in a namespace. +es5ModuleInternalNamedImports.ts(30,25): error TS1147: Import declarations in a namespace cannot reference a module. +es5ModuleInternalNamedImports.ts(31,20): error TS1147: Import declarations in a namespace cannot reference a module. +es5ModuleInternalNamedImports.ts(32,32): error TS1147: Import declarations in a namespace cannot reference a module. +es5ModuleInternalNamedImports.ts(34,16): error TS2307: Cannot find module 'M3' or its corresponding type declarations. + + +==== es5ModuleInternalNamedImports.ts (12 errors) ==== + export module M { + // variable + export var M_V = 0; + // interface + export interface M_I { } + //calss + export class M_C { } + // instantiated module + export module M_M { var x; } + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } + // enum + export enum M_E { } + // type + export type M_T = number; + // alias + export import M_A = M_M; + + // Reexports + export {M_V as v}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_I as i}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_C as c}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_M as m}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_MU as mu}; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_F as f}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_E as e}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + export {M_A as a}; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + import * as M2 from "M2"; + ~~~~ +!!! error TS1147: Import declarations in a namespace cannot reference a module. + import M4 from "M4"; + ~~~~ +!!! error TS1147: Import declarations in a namespace cannot reference a module. + export import M5 = require("M5"); + ~~~~ +!!! error TS1147: Import declarations in a namespace cannot reference a module. + } + import M3 from "M3"; + ~~~~ +!!! error TS2307: Cannot find module 'M3' or its corresponding type declarations. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.js b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.js new file mode 100644 index 0000000000..92b3d28ae6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.js @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/es5ModuleInternalNamedImports.ts] //// + +//// [es5ModuleInternalNamedImports.ts] +export module M { + // variable + export var M_V = 0; + // interface + export interface M_I { } + //calss + export class M_C { } + // instantiated module + export module M_M { var x; } + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } + // enum + export enum M_E { } + // type + export type M_T = number; + // alias + export import M_A = M_M; + + // Reexports + export {M_V as v}; + export {M_I as i}; + export {M_C as c}; + export {M_M as m}; + export {M_MU as mu}; + export {M_F as f}; + export {M_E as e}; + export {M_A as a}; + import * as M2 from "M2"; + import M4 from "M4"; + export import M5 = require("M5"); +} +import M3 from "M3"; + + +//// [es5ModuleInternalNamedImports.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.M = void 0; +var M; +(function (M) { + // variable + M.M_V = 0; + //calss + class M_C { + } + M.M_C = M_C; + // instantiated module + let M_M; + (function (M_M) { + var x; + })(M_M = M.M_M || (M.M_M = {})); + // function + function M_F() { } + M.M_F = M_F; + // enum + let M_E; + (function (M_E) { + })(M_E = M.M_E || (M.M_E = {})); + M.M_A = M_M; + // Reexports + export { M_V as v }; + export { M_I as i }; + export { M_C as c }; + export { M_M as m }; + export { M_MU as mu }; + export { M_F as f }; + export { M_E as e }; + export { M_A as a }; + import * as M2 from "M2"; + import M4 from "M4"; + export import M5 = require("M5"); +})(M || (exports.M = M = {})); diff --git a/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.js.diff b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.js.diff new file mode 100644 index 0000000000..714f1c29e8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.js.diff @@ -0,0 +1,21 @@ +--- old.es5ModuleInternalNamedImports.js ++++ new.es5ModuleInternalNamedImports.js +@@= skipped -60, +60 lines =@@ + let M_E; + (function (M_E) { + })(M_E = M.M_E || (M.M_E = {})); +- // alias + M.M_A = M_M; ++ // Reexports ++ export { M_V as v }; ++ export { M_I as i }; ++ export { M_C as c }; ++ export { M_M as m }; ++ export { M_MU as mu }; ++ export { M_F as f }; ++ export { M_E as e }; ++ export { M_A as a }; ++ import * as M2 from "M2"; ++ import M4 from "M4"; ++ export import M5 = require("M5"); + })(M || (exports.M = M = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.symbols b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.symbols new file mode 100644 index 0000000000..b8dc3cf4ec --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.symbols @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/es5ModuleInternalNamedImports.ts] //// + +=== es5ModuleInternalNamedImports.ts === +export module M { +>M : Symbol(M, Decl(es5ModuleInternalNamedImports.ts, 0, 0)) + + // variable + export var M_V = 0; +>M_V : Symbol(M_V, Decl(es5ModuleInternalNamedImports.ts, 2, 14)) + + // interface + export interface M_I { } +>M_I : Symbol(M_I, Decl(es5ModuleInternalNamedImports.ts, 2, 23)) + + //calss + export class M_C { } +>M_C : Symbol(M_C, Decl(es5ModuleInternalNamedImports.ts, 4, 28)) + + // instantiated module + export module M_M { var x; } +>M_M : Symbol(M_M, Decl(es5ModuleInternalNamedImports.ts, 6, 24)) +>x : Symbol(x, Decl(es5ModuleInternalNamedImports.ts, 8, 27)) + + // uninstantiated module + export module M_MU { } +>M_MU : Symbol(M_MU, Decl(es5ModuleInternalNamedImports.ts, 8, 32)) + + // function + export function M_F() { } +>M_F : Symbol(M_F, Decl(es5ModuleInternalNamedImports.ts, 10, 26)) + + // enum + export enum M_E { } +>M_E : Symbol(M_E, Decl(es5ModuleInternalNamedImports.ts, 12, 29)) + + // type + export type M_T = number; +>M_T : Symbol(M_T, Decl(es5ModuleInternalNamedImports.ts, 14, 23)) + + // alias + export import M_A = M_M; +>M_A : Symbol(M_A, Decl(es5ModuleInternalNamedImports.ts, 16, 29)) +>M_M : Symbol(M_M, Decl(es5ModuleInternalNamedImports.ts, 6, 24)) + + // Reexports + export {M_V as v}; +>M_V : Symbol(M_V, Decl(es5ModuleInternalNamedImports.ts, 2, 14)) +>v : Symbol(v, Decl(es5ModuleInternalNamedImports.ts, 21, 12)) + + export {M_I as i}; +>M_I : Symbol(M_I, Decl(es5ModuleInternalNamedImports.ts, 2, 23)) +>i : Symbol(i, Decl(es5ModuleInternalNamedImports.ts, 22, 12)) + + export {M_C as c}; +>M_C : Symbol(M_C, Decl(es5ModuleInternalNamedImports.ts, 4, 28)) +>c : Symbol(c, Decl(es5ModuleInternalNamedImports.ts, 23, 12)) + + export {M_M as m}; +>M_M : Symbol(M_M, Decl(es5ModuleInternalNamedImports.ts, 6, 24)) +>m : Symbol(m, Decl(es5ModuleInternalNamedImports.ts, 24, 12)) + + export {M_MU as mu}; +>M_MU : Symbol(M_MU, Decl(es5ModuleInternalNamedImports.ts, 8, 32)) +>mu : Symbol(mu, Decl(es5ModuleInternalNamedImports.ts, 25, 12)) + + export {M_F as f}; +>M_F : Symbol(M_F, Decl(es5ModuleInternalNamedImports.ts, 10, 26)) +>f : Symbol(f, Decl(es5ModuleInternalNamedImports.ts, 26, 12)) + + export {M_E as e}; +>M_E : Symbol(M_E, Decl(es5ModuleInternalNamedImports.ts, 12, 29)) +>e : Symbol(e, Decl(es5ModuleInternalNamedImports.ts, 27, 12)) + + export {M_A as a}; +>M_A : Symbol(M_A, Decl(es5ModuleInternalNamedImports.ts, 16, 29)) +>a : Symbol(a, Decl(es5ModuleInternalNamedImports.ts, 28, 12)) + + import * as M2 from "M2"; +>M2 : Symbol(M2, Decl(es5ModuleInternalNamedImports.ts, 29, 10)) + + import M4 from "M4"; +>M4 : Symbol(M4, Decl(es5ModuleInternalNamedImports.ts, 30, 10)) + + export import M5 = require("M5"); +>M5 : Symbol(M5, Decl(es5ModuleInternalNamedImports.ts, 30, 24)) +} +import M3 from "M3"; +>M3 : Symbol(M3, Decl(es5ModuleInternalNamedImports.ts, 33, 6)) + diff --git a/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.types b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.types new file mode 100644 index 0000000000..9c1b739548 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es5ModuleInternalNamedImports.types @@ -0,0 +1,86 @@ +//// [tests/cases/compiler/es5ModuleInternalNamedImports.ts] //// + +=== es5ModuleInternalNamedImports.ts === +export module M { +>M : typeof M + + // variable + export var M_V = 0; +>M_V : number +>0 : 0 + + // interface + export interface M_I { } + //calss + export class M_C { } +>M_C : M_C + + // instantiated module + export module M_M { var x; } +>M_M : typeof M_M +>x : any + + // uninstantiated module + export module M_MU { } + // function + export function M_F() { } +>M_F : () => void + + // enum + export enum M_E { } +>M_E : M_E + + // type + export type M_T = number; +>M_T : number + + // alias + export import M_A = M_M; +>M_A : typeof M_M +>M_M : typeof M_M + + // Reexports + export {M_V as v}; +>M_V : number +>v : number + + export {M_I as i}; +>M_I : any +>i : any + + export {M_C as c}; +>M_C : typeof M_C +>c : typeof M_C + + export {M_M as m}; +>M_M : typeof M_M +>m : typeof M_M + + export {M_MU as mu}; +>M_MU : any +>mu : any + + export {M_F as f}; +>M_F : () => void +>f : () => void + + export {M_E as e}; +>M_E : typeof M_E +>e : typeof M_E + + export {M_A as a}; +>M_A : typeof M_M +>a : typeof M_M + + import * as M2 from "M2"; +>M2 : any + + import M4 from "M4"; +>M4 : any + + export import M5 = require("M5"); +>M5 : any +} +import M3 from "M3"; +>M3 : any + diff --git a/testdata/baselines/reference/submodule/compiler/es6ClassTest.js.diff b/testdata/baselines/reference/submodule/compiler/es6ClassTest.js.diff index ed56937c71..03870ab0dc 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ClassTest.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ClassTest.js.diff @@ -8,43 +8,30 @@ prop1(x) { return x; } - constructor(n) { } +@@= skipped -7, +8 lines =@@ } // new-style class --let Foo = (() => { -- class Foo extends Bar { -- bar() { return 0; } -- boo(x) { return x; } -- constructor(x, y, z = 0) { -- super(x); -- this.y = y; -- this.z = z; -- this.gar = 0; -- this.zoo = "zoo"; -- this.x = x; -- this.gar = 5; -- } -+class Foo extends Bar { + class Foo extends Bar { + y; + z; + foo; + gar = 0; + zoo = "zoo"; + x; -+ bar() { return 0; } -+ boo(x) { return x; } + bar() { return 0; } + boo(x) { return x; } + static statVal = 0; -+ constructor(x, y, z = 0) { -+ super(x); -+ this.y = y; -+ this.z = z; -+ this.x = x; -+ this.gar = 5; + constructor(x, y, z = 0) { + super(x); + this.y = y; + this.z = z; +- this.gar = 0; +- this.zoo = "zoo"; + this.x = x; + this.gar = 5; } -- Foo.statVal = 0; -- return Foo; --})(); -+} + } +-Foo.statVal = 0; var f = new Foo(); //class GetSetMonster { // // attack(target) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ClassTest2.js.diff b/testdata/baselines/reference/submodule/compiler/es6ClassTest2.js.diff index 0615839804..7742b36811 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ClassTest2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ClassTest2.js.diff @@ -59,25 +59,17 @@ } class SuperParent { constructor(a) { -@@= skipped -24, +23 lines =@@ - super.c(); +@@= skipped -25, +24 lines =@@ } } --let Statics = (() => { -- class Statics { -- static baz() { -- return ""; -- } -+class Statics { + class Statics { + static foo = 1; + static bar; -+ static baz() { -+ return ""; + static baz() { + return ""; } -- Statics.foo = 1; -- return Statics; --})(); -+} + } +-Statics.foo = 1; var stat = new Statics(); class ImplementsInterface { + x; @@ -85,7 +77,7 @@ constructor() { this.x = 1; this.z = "foo"; -@@= skipped -19, +19 lines =@@ +@@= skipped -15, +18 lines =@@ class Visibility { foo() { } bar() { } diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAll.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ExportAll.errors.txt.diff deleted file mode 100644 index f38a770b97..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAll.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.es6ExportAll.errors.txt -+++ new.es6ExportAll.errors.txt -@@= skipped -0, +0 lines =@@ -- -+client.ts(1,15): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ -+ -+==== server.ts (0 errors) ==== -+ export class c { -+ } -+ export interface i { -+ } -+ export module m { -+ export var x = 10; -+ } -+ export var x = 10; -+ export module uninstantiated { -+ } -+ -+==== client.ts (1 errors) ==== -+ export * from "server"; -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt index e592d4375e..4a7c3f7332 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt @@ -1,5 +1,4 @@ a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -b.ts(1,20): error TS2307: Cannot find module 'a' or its corresponding type declarations. ==== a.ts (1 errors) ==== @@ -8,8 +7,6 @@ b.ts(1,20): error TS2307: Cannot find module 'a' or its corresponding type decla ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== b.ts (1 errors) ==== - import * as a from "a"; - ~~~ -!!! error TS2307: Cannot find module 'a' or its corresponding type declarations. +==== b.ts (0 errors) ==== + import * as a from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt.diff deleted file mode 100644 index dface1b1ee..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.es6ExportAssignment2.errors.txt -+++ new.es6ExportAssignment2.errors.txt -@@= skipped -0, +0 lines =@@ - a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -+b.ts(1,20): error TS2307: Cannot find module 'a' or its corresponding type declarations. - - - ==== a.ts (1 errors) ==== -@@= skipped -6, +7 lines =@@ - ~~~~~~~~~~~ - !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - --==== b.ts (0 errors) ==== -+==== b.ts (1 errors) ==== - import * as a from "a"; -+ ~~~ -+!!! error TS2307: Cannot find module 'a' or its corresponding type declarations. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.js b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.js index 3278af118c..85867d23e2 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.js +++ b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.js @@ -5,7 +5,7 @@ var a = 10; export = a; // Error: export = not allowed in ES6 //// [b.ts] -import * as a from "a"; +import * as a from "./a"; //// [a.js] diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.symbols b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.symbols index 6fa64f1a1e..ea19d84a18 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.symbols @@ -8,6 +8,6 @@ export = a; // Error: export = not allowed in ES6 >a : Symbol(a, Decl(a.ts, 0, 3)) === b.ts === -import * as a from "a"; +import * as a from "./a"; >a : Symbol(a, Decl(b.ts, 0, 6)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types index 1603e2380d..3306dcb6ca 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types +++ b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types @@ -9,6 +9,6 @@ export = a; // Error: export = not allowed in ES6 >a : number === b.ts === -import * as a from "a"; ->a : any +import * as a from "./a"; +>a : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types.diff b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types.diff deleted file mode 100644 index 017ee3d515..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment2.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.es6ExportAssignment2.types -+++ new.es6ExportAssignment2.types -@@= skipped -9, +9 lines =@@ - - === b.ts === - import * as a from "a"; -->a : number -+>a : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment3.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment3.errors.txt.diff deleted file mode 100644 index 84ef32a805..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment3.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ExportAssignment3.errors.txt -+++ new.es6ExportAssignment3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.ts(1,20): error TS2307: Cannot find module 'a' or its corresponding type declarations. -+ -+ -+==== a.d.ts (0 errors) ==== -+ declare var a: number; -+ export = a; // OK, in ambient context -+ -+==== b.ts (1 errors) ==== -+ import * as a from "a"; -+ ~~~ -+!!! error TS2307: Cannot find module 'a' or its corresponding type declarations. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment3.types.diff b/testdata/baselines/reference/submodule/compiler/es6ExportAssignment3.types.diff deleted file mode 100644 index d49967ddcc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportAssignment3.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.es6ExportAssignment3.types -+++ new.es6ExportAssignment3.types -@@= skipped -8, +8 lines =@@ - - === b.ts === - import * as a from "a"; -->a : number -+>a : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.errors.txt deleted file mode 100644 index 2010b48604..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -client.ts(1,19): error TS2307: Cannot find module 'server' or its corresponding type declarations. -client.ts(2,25): error TS2307: Cannot find module 'server' or its corresponding type declarations. -client.ts(3,44): error TS2307: Cannot find module 'server' or its corresponding type declarations. -client.ts(4,32): error TS2307: Cannot find module 'server' or its corresponding type declarations. -client.ts(5,19): error TS2307: Cannot find module 'server' or its corresponding type declarations. - - -==== server.ts (0 errors) ==== - export class c { - } - export interface i { - } - export module m { - export var x = 10; - } - export var x = 10; - export module uninstantiated { - } - -==== client.ts (5 errors) ==== - export { c } from "server"; - ~~~~~~~~ -!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. - export { c as c2 } from "server"; - ~~~~~~~~ -!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. - export { i, m as instantiatedModule } from "server"; - ~~~~~~~~ -!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. - export { uninstantiated } from "server"; - ~~~~~~~~ -!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. - export { x } from "server"; - ~~~~~~~~ -!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.errors.txt.diff deleted file mode 100644 index c50824c998..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.es6ExportClauseWithoutModuleSpecifier.errors.txt -+++ new.es6ExportClauseWithoutModuleSpecifier.errors.txt -@@= skipped -0, +0 lines =@@ -- -+client.ts(1,19): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+client.ts(2,25): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+client.ts(3,44): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+client.ts(4,32): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+client.ts(5,19): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ -+ -+==== server.ts (0 errors) ==== -+ export class c { -+ } -+ export interface i { -+ } -+ export module m { -+ export var x = 10; -+ } -+ export var x = 10; -+ export module uninstantiated { -+ } -+ -+==== client.ts (5 errors) ==== -+ export { c } from "server"; -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ export { c as c2 } from "server"; -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ export { i, m as instantiatedModule } from "server"; -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ export { uninstantiated } from "server"; -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ export { x } from "server"; -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js index cb5bd291bf..bf84f48495 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js +++ b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js @@ -13,11 +13,11 @@ export module uninstantiated { } //// [client.ts] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; //// [server.js] export class c { @@ -29,11 +29,10 @@ var m; })(m || (m = {})); export var x = 10; //// [client.js] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { m as instantiatedModule } from "./server"; +export { x } from "./server"; //// [server.d.ts] @@ -48,8 +47,8 @@ export declare var x: number; export declare namespace uninstantiated { } //// [client.d.ts] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js.diff b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js.diff index dbba79c2d7..a3df31b6ba 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.js.diff @@ -9,13 +9,4 @@ +var m; (function (m) { m.x = 10; - })(m || (m = {})); -@@= skipped -8, +9 lines =@@ - //// [client.js] - export { c } from "server"; - export { c as c2 } from "server"; --export { m as instantiatedModule } from "server"; -+export { i, m as instantiatedModule } from "server"; -+export { uninstantiated } from "server"; - export { x } from "server"; - + })(m || (m = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols index 61e90619f5..9edf7a3487 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols @@ -21,19 +21,21 @@ export module uninstantiated { } === client.ts === -export { c } from "server"; +export { c } from "./server"; >c : Symbol(c, Decl(client.ts, 0, 8)) -export { c as c2 } from "server"; +export { c as c2 } from "./server"; +>c : Symbol(c, Decl(server.ts, 0, 0)) >c2 : Symbol(c2, Decl(client.ts, 1, 8)) -export { i, m as instantiatedModule } from "server"; +export { i, m as instantiatedModule } from "./server"; >i : Symbol(i, Decl(client.ts, 2, 8)) +>m : Symbol(m, Decl(server.ts, 3, 1)) >instantiatedModule : Symbol(instantiatedModule, Decl(client.ts, 2, 11)) -export { uninstantiated } from "server"; +export { uninstantiated } from "./server"; >uninstantiated : Symbol(uninstantiated, Decl(client.ts, 3, 8)) -export { x } from "server"; +export { x } from "./server"; >x : Symbol(x, Decl(client.ts, 4, 8)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols.diff b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols.diff deleted file mode 100644 index 4582b2e773..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.es6ExportClauseWithoutModuleSpecifier.symbols -+++ new.es6ExportClauseWithoutModuleSpecifier.symbols -@@= skipped -24, +24 lines =@@ - >c : Symbol(c, Decl(client.ts, 0, 8)) - - export { c as c2 } from "server"; -->c : Symbol(c, Decl(server.ts, 0, 0)) - >c2 : Symbol(c2, Decl(client.ts, 1, 8)) - - export { i, m as instantiatedModule } from "server"; - >i : Symbol(i, Decl(client.ts, 2, 8)) -->m : Symbol(m, Decl(server.ts, 3, 1)) - >instantiatedModule : Symbol(instantiatedModule, Decl(client.ts, 2, 11)) - - export { uninstantiated } from "server"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types index a218c4c71c..05368b3c18 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types +++ b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types @@ -21,21 +21,21 @@ export module uninstantiated { } === client.ts === -export { c } from "server"; ->c : any +export { c } from "./server"; +>c : typeof import("server").c -export { c as c2 } from "server"; ->c : any ->c2 : any +export { c as c2 } from "./server"; +>c : typeof import("server").c +>c2 : typeof import("server").c -export { i, m as instantiatedModule } from "server"; +export { i, m as instantiatedModule } from "./server"; >i : any ->m : any ->instantiatedModule : any +>m : typeof import("server").m +>instantiatedModule : typeof import("server").m -export { uninstantiated } from "server"; +export { uninstantiated } from "./server"; >uninstantiated : any -export { x } from "server"; ->x : any +export { x } from "./server"; +>x : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types.diff b/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types.diff deleted file mode 100644 index 67fe5dd7d1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportClauseWithoutModuleSpecifier.types.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.es6ExportClauseWithoutModuleSpecifier.types -+++ new.es6ExportClauseWithoutModuleSpecifier.types -@@= skipped -21, +21 lines =@@ - - === client.ts === - export { c } from "server"; -->c : typeof import("server").c -+>c : any - - export { c as c2 } from "server"; -->c : typeof import("server").c -->c2 : typeof import("server").c -+>c : any -+>c2 : any - - export { i, m as instantiatedModule } from "server"; - >i : any -->m : typeof import("server").m -->instantiatedModule : typeof import("server").m -+>m : any -+>instantiatedModule : any - - export { uninstantiated } from "server"; - >uninstantiated : any - - export { x } from "server"; -->x : number -+>x : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.errors.txt.diff deleted file mode 100644 index 8120ad3982..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.errors.txt.diff +++ /dev/null @@ -1,74 +0,0 @@ ---- old.es6ExportEqualsInterop.errors.txt -+++ new.es6ExportEqualsInterop.errors.txt -@@= skipped -0, +0 lines =@@ - main.ts(15,1): error TS2693: 'z1' only refers to a type, but is being used as a value here. - main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. - main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. --main.ts(27,8): error TS1259: Module '"interface"' can only be default-imported using the 'esModuleInterop' flag --main.ts(28,8): error TS1259: Module '"variable"' can only be default-imported using the 'esModuleInterop' flag --main.ts(29,8): error TS1259: Module '"interface-variable"' can only be default-imported using the 'esModuleInterop' flag --main.ts(30,8): error TS1259: Module '"module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(31,8): error TS1259: Module '"interface-module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(32,8): error TS1259: Module '"variable-module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(33,8): error TS1259: Module '"function"' can only be default-imported using the 'esModuleInterop' flag --main.ts(34,8): error TS1259: Module '"function-module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(35,8): error TS1259: Module '"class"' can only be default-imported using the 'esModuleInterop' flag --main.ts(36,8): error TS1259: Module '"class-module"' can only be default-imported using the 'esModuleInterop' flag - main.ts(39,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - main.ts(45,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - main.ts(47,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. -@@= skipped -40, +30 lines =@@ - main.ts(106,15): error TS2498: Module '"class-module"' uses 'export =' and cannot be used with 'export *'. - - --==== main.ts (41 errors) ==== -+==== main.ts (31 errors) ==== - /// - - // import-equals -@@= skipped -34, +34 lines =@@ - - // default import - import x1 from "interface"; -- ~~ --!!! error TS1259: Module '"interface"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:6:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x2 from "variable"; -- ~~ --!!! error TS1259: Module '"variable"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:14:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x3 from "interface-variable"; -- ~~ --!!! error TS1259: Module '"interface-variable"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:26:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x4 from "module"; -- ~~ --!!! error TS1259: Module '"module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:34:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x5 from "interface-module"; -- ~~ --!!! error TS1259: Module '"interface-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:46:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x6 from "variable-module"; -- ~~ --!!! error TS1259: Module '"variable-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:60:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x7 from "function"; -- ~~ --!!! error TS1259: Module '"function"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:65:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x8 from "function-module"; -- ~~ --!!! error TS1259: Module '"function-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:74:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x9 from "class"; -- ~~ --!!! error TS1259: Module '"class"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:82:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x0 from "class-module"; -- ~~ --!!! error TS1259: Module '"class-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:94:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - - // namespace import - import * as y1 from "interface"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js index 71125ca7fe..d5fc94db32 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js +++ b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js @@ -208,6 +208,7 @@ export * from "class-module"; //// [main.js] "use strict"; +/// var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -219,6 +220,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi if (k2 === undefined) k2 = k; o[k2] = m[k]; })); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; @@ -243,15 +266,15 @@ z7.a; z8.a; z9.a; z0.a; -const y2 = require("variable"); -const y3 = require("interface-variable"); -const y4 = require("module"); -const y5 = require("interface-module"); -const y6 = require("variable-module"); -const y7 = require("function"); -const y8 = require("function-module"); -const y9 = require("class"); -const y0 = require("class-module"); +const y2 = __importStar(require("variable")); +const y3 = __importStar(require("interface-variable")); +const y4 = __importStar(require("module")); +const y5 = __importStar(require("interface-module")); +const y6 = __importStar(require("variable-module")); +const y7 = __importStar(require("function")); +const y8 = __importStar(require("function-module")); +const y9 = __importStar(require("class")); +const y0 = __importStar(require("class-module")); y1.a; y2.a; y3.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff index ae73ab1233..97c3e66eb5 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff @@ -1,91 +1,6 @@ --- old.es6ExportEqualsInterop.js +++ new.es6ExportEqualsInterop.js -@@= skipped -207, +207 lines =@@ - - //// [main.js] - "use strict"; --/// - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); -@@= skipped -17, +16 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a0 = exports.a9 = exports.a8 = exports.a7 = exports.a6 = exports.a5 = exports.a4 = exports.a3 = exports.a2 = exports.a1 = void 0; --var z2 = require("variable"); --var z3 = require("interface-variable"); --var z4 = require("module"); --var z5 = require("interface-module"); --var z6 = require("variable-module"); --var z7 = require("function"); --var z8 = require("function-module"); --var z9 = require("class"); --var z0 = require("class-module"); -+const z2 = require("variable"); -+const z3 = require("interface-variable"); -+const z4 = require("module"); -+const z5 = require("interface-module"); -+const z6 = require("variable-module"); -+const z7 = require("function"); -+const z8 = require("function-module"); -+const z9 = require("class"); -+const z0 = require("class-module"); - z1.a; - z2.a; - z3.a; -@@= skipped -19, +19 lines =@@ - z8.a; - z9.a; - z0.a; --var y2 = require("variable"); --var y3 = require("interface-variable"); --var y4 = require("module"); --var y5 = require("interface-module"); --var y6 = require("variable-module"); --var y7 = require("function"); --var y8 = require("function-module"); --var y9 = require("class"); --var y0 = require("class-module"); -+const y2 = require("variable"); -+const y3 = require("interface-variable"); -+const y4 = require("module"); -+const y5 = require("interface-module"); -+const y6 = require("variable-module"); -+const y7 = require("function"); -+const y8 = require("function-module"); -+const y9 = require("class"); -+const y0 = require("class-module"); - y1.a; - y2.a; - y3.a; -@@= skipped -20, +20 lines =@@ - y9.a; - y0.a; - // named import --var interface_1 = require("interface"); --var variable_1 = require("variable"); --var interface_variable_1 = require("interface-variable"); --var module_1 = require("module"); --var interface_module_1 = require("interface-module"); --var variable_module_1 = require("variable-module"); --var function_1 = require("function"); --var function_module_1 = require("function-module"); --var class_1 = require("class"); --var class_module_1 = require("class-module"); -+const interface_1 = require("interface"); -+const variable_1 = require("variable"); -+const interface_variable_1 = require("interface-variable"); -+const module_1 = require("module"); -+const interface_module_1 = require("interface-module"); -+const variable_module_1 = require("variable-module"); -+const function_1 = require("function"); -+const function_module_1 = require("function-module"); -+const class_1 = require("class"); -+const class_module_1 = require("class-module"); - interface_1.a; - variable_1.a; - interface_variable_1.a; -@@= skipped -21, +21 lines =@@ +@@= skipped -306, +306 lines =@@ class_1.a; class_module_1.a; // named export diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types index 6c7cac3c5a..96f4e58936 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types +++ b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types @@ -138,13 +138,13 @@ import * as y7 from "function"; >y7 : () => any import * as y8 from "function-module"; ->y8 : typeof z8 +>y8 : typeof y8 import * as y9 from "class"; >y9 : typeof z9 import * as y0 from "class-module"; ->y0 : typeof z0 +>y0 : typeof y0 y1.a; >y1.a : any @@ -183,7 +183,7 @@ y7.a; y8.a; >y8.a : number ->y8 : typeof z8 +>y8 : typeof y8 >a : number y9.a; @@ -193,7 +193,7 @@ y9.a; y0.a; >y0.a : number ->y0 : typeof z0 +>y0 : typeof y0 >a : number // named import diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types.diff b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types.diff deleted file mode 100644 index d79de05db2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- old.es6ExportEqualsInterop.types -+++ new.es6ExportEqualsInterop.types -@@= skipped -88, +88 lines =@@ - >x1 : any - - import x2 from "variable"; -->x2 : any -+>x2 : { a: number; b: number; } - - import x3 from "interface-variable"; -->x3 : any -+>x3 : { a: number; b: number; } - - import x4 from "module"; -->x4 : any -+>x4 : typeof z4 - - import x5 from "interface-module"; -->x5 : any -+>x5 : typeof z5 - - import x6 from "variable-module"; -->x6 : any -+>x6 : { a: number; b: number; } - - import x7 from "function"; -->x7 : any -+>x7 : () => any - - import x8 from "function-module"; -->x8 : any -+>x8 : typeof z8 - - import x9 from "class"; -->x9 : any -+>x9 : typeof z9 - - import x0 from "class-module"; -->x0 : any -+>x0 : typeof z0 - - // namespace import - import * as y1 from "interface"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.errors.txt deleted file mode 100644 index 6512953174..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -es6ImportDefaultBinding_1.ts(1,28): error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. -es6ImportDefaultBinding_1.ts(3,29): error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. - - -==== es6ImportDefaultBinding_0.ts (0 errors) ==== - var a = 10; - export default a; - -==== es6ImportDefaultBinding_1.ts (2 errors) ==== - import defaultBinding from "es6ImportDefaultBinding_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. - var x = defaultBinding; - import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.errors.txt.diff deleted file mode 100644 index cd37e9e408..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.es6ImportDefaultBinding.errors.txt -+++ new.es6ImportDefaultBinding.errors.txt -@@= skipped -0, +0 lines =@@ -- -+es6ImportDefaultBinding_1.ts(1,28): error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. -+es6ImportDefaultBinding_1.ts(3,29): error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. -+ -+ -+==== es6ImportDefaultBinding_0.ts (0 errors) ==== -+ var a = 10; -+ export default a; -+ -+==== es6ImportDefaultBinding_1.ts (2 errors) ==== -+ import defaultBinding from "es6ImportDefaultBinding_0"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. -+ var x = defaultBinding; -+ import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBinding_0' or its corresponding type declarations. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.js index bdc9b4b846..4dc135ea48 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.js @@ -5,16 +5,16 @@ var a = 10; export default a; //// [es6ImportDefaultBinding_1.ts] -import defaultBinding from "es6ImportDefaultBinding_0"; +import defaultBinding from "./es6ImportDefaultBinding_0"; var x = defaultBinding; -import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used //// [es6ImportDefaultBinding_0.js] var a = 10; export default a; //// [es6ImportDefaultBinding_1.js] -import defaultBinding from "es6ImportDefaultBinding_0"; +import defaultBinding from "./es6ImportDefaultBinding_0"; var x = defaultBinding; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.symbols index a5b73019ad..1b8360a6dd 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.symbols @@ -8,13 +8,13 @@ export default a; >a : Symbol(a, Decl(es6ImportDefaultBinding_0.ts, 0, 3)) === es6ImportDefaultBinding_1.ts === -import defaultBinding from "es6ImportDefaultBinding_0"; +import defaultBinding from "./es6ImportDefaultBinding_0"; >defaultBinding : Symbol(defaultBinding, Decl(es6ImportDefaultBinding_1.ts, 0, 6)) var x = defaultBinding; >x : Symbol(x, Decl(es6ImportDefaultBinding_1.ts, 1, 3)) >defaultBinding : Symbol(defaultBinding, Decl(es6ImportDefaultBinding_1.ts, 0, 6)) -import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used >defaultBinding2 : Symbol(defaultBinding2, Decl(es6ImportDefaultBinding_1.ts, 2, 6)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types index 38c14132c6..a92b38a459 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types @@ -9,13 +9,13 @@ export default a; >a : number === es6ImportDefaultBinding_1.ts === -import defaultBinding from "es6ImportDefaultBinding_0"; ->defaultBinding : any +import defaultBinding from "./es6ImportDefaultBinding_0"; +>defaultBinding : number var x = defaultBinding; ->x : any ->defaultBinding : any +>x : number +>defaultBinding : number -import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used ->defaultBinding2 : any +import defaultBinding2 from "./es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used +>defaultBinding2 : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types.diff deleted file mode 100644 index 9bcbc05cae..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBinding.types.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.es6ImportDefaultBinding.types -+++ new.es6ImportDefaultBinding.types -@@= skipped -9, +9 lines =@@ - - === es6ImportDefaultBinding_1.ts === - import defaultBinding from "es6ImportDefaultBinding_0"; -->defaultBinding : number -+>defaultBinding : any - - var x = defaultBinding; -->x : number -->defaultBinding : number -+>x : any -+>defaultBinding : any - - import defaultBinding2 from "es6ImportDefaultBinding_0"; // elide this import since defaultBinding2 is not used -->defaultBinding2 : number -+>defaultBinding2 : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js index ec87f8e3a4..4b8a2bd012 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js @@ -18,9 +18,12 @@ class c { exports.default = c; //// [client.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const server_1 = require("./server"); +const server_1 = __importDefault(require("./server")); exports.x = new server_1.default(); diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js.diff deleted file mode 100644 index e0d627696b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingDts.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportDefaultBindingDts.js -+++ new.es6ImportDefaultBindingDts.js -@@= skipped -19, +19 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var server_1 = require("./server"); -+const server_1 = require("./server"); - exports.x = new server_1.default(); - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt index f2a172092a..a581c4deac 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt @@ -1,9 +1,9 @@ -es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(1,34): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(3,36): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(5,41): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,44): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,43): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,38): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. +es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(3,27): error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? +es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(5,27): error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? +es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,27): error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? +es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,30): error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? +es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,27): error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? +es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,27): error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. Did you mean to use 'import m from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? ==== es6ImportDefaultBindingFollowedWithNamedImport1_0.ts (0 errors) ==== @@ -11,28 +11,28 @@ es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,38): error TS2307: Canno export default a; ==== es6ImportDefaultBindingFollowedWithNamedImport1_1.ts (6 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding1; - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? var x1: number = defaultBinding2; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? var x1: number = defaultBinding3; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? + ~ +!!! error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? var x1: number = defaultBinding4; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? var x1: number = defaultBinding5; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; + ~ +!!! error TS2614: Module '"./es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. Did you mean to use 'import m from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? var x1: number = defaultBinding6; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt.diff deleted file mode 100644 index 714db5ba86..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt.diff +++ /dev/null @@ -1,58 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt -@@= skipped -0, +0 lines =@@ --es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(3,27): error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? --es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(5,27): error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? --es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,27): error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? --es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,30): error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? --es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,27): error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? --es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,27): error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. Did you mean to use 'import m from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -+es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(1,34): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -+es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(3,36): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -+es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(5,41): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -+es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(7,44): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -+es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(9,43): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. -+es6ImportDefaultBindingFollowedWithNamedImport1_1.ts(11,38): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - - - ==== es6ImportDefaultBindingFollowedWithNamedImport1_0.ts (0 errors) ==== -@@= skipped -11, +11 lines =@@ - - ==== es6ImportDefaultBindingFollowedWithNamedImport1_1.ts (6 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - var x1: number = defaultBinding1; - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -- ~ --!!! error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - var x1: number = defaultBinding2; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -- ~ --!!! error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - var x1: number = defaultBinding3; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -- ~ --!!! error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -- ~ --!!! error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'a'. Did you mean to use 'import a from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - var x1: number = defaultBinding4; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -- ~ --!!! error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'x'. Did you mean to use 'import x from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - var x1: number = defaultBinding5; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -- ~ --!!! error TS2614: Module '"es6ImportDefaultBindingFollowedWithNamedImport1_0"' has no exported member 'm'. Did you mean to use 'import m from "es6ImportDefaultBindingFollowedWithNamedImport1_0"' instead? -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamedImport1_0' or its corresponding type declarations. - var x1: number = defaultBinding6; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.js index 31194c308b..985f695b6c 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.js @@ -5,17 +5,17 @@ var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding1; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding2; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding3; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding4; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding5; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1: number = defaultBinding6; @@ -23,17 +23,17 @@ var x1: number = defaultBinding6; var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1_1.js] -import defaultBinding1 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding1 from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding1; -import defaultBinding2 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding2 from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding2; -import defaultBinding3 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding3 from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding3; -import defaultBinding4 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding4 from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding4; -import defaultBinding5 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding5 from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding5; -import defaultBinding6 from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding6 from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; var x1 = defaultBinding6; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.symbols index efe22435de..db2926e102 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.symbols @@ -8,14 +8,14 @@ export default a; >a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_0.ts, 0, 3)) === es6ImportDefaultBindingFollowedWithNamedImport1_1.ts === -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; >defaultBinding1 : Symbol(defaultBinding1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 0, 6)) var x1: number = defaultBinding1; >x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 1, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 3, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 5, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 9, 3) ... and 1 more) >defaultBinding1 : Symbol(defaultBinding1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 0, 6)) -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; >defaultBinding2 : Symbol(defaultBinding2, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 2, 6)) >a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 2, 25)) @@ -23,7 +23,7 @@ var x1: number = defaultBinding2; >x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 1, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 3, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 5, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 9, 3) ... and 1 more) >defaultBinding2 : Symbol(defaultBinding2, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 2, 6)) -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; >defaultBinding3 : Symbol(defaultBinding3, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 4, 6)) >b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 4, 25)) @@ -31,7 +31,7 @@ var x1: number = defaultBinding3; >x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 1, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 3, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 5, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 9, 3) ... and 1 more) >defaultBinding3 : Symbol(defaultBinding3, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 4, 6)) -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; >defaultBinding4 : Symbol(defaultBinding4, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 6, 6)) >x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 6, 25)) >y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 6, 28)) @@ -40,7 +40,7 @@ var x1: number = defaultBinding4; >x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 1, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 3, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 5, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 9, 3) ... and 1 more) >defaultBinding4 : Symbol(defaultBinding4, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 6, 6)) -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; >defaultBinding5 : Symbol(defaultBinding5, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 8, 6)) >z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 8, 25)) @@ -48,7 +48,7 @@ var x1: number = defaultBinding5; >x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 1, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 3, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 5, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 9, 3) ... and 1 more) >defaultBinding5 : Symbol(defaultBinding5, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 8, 6)) -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; >defaultBinding6 : Symbol(defaultBinding6, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 10, 6)) >m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport1_1.ts, 10, 25)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types index b401a593f3..8e1b03d3fe 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types @@ -9,54 +9,54 @@ export default a; >a : number === es6ImportDefaultBindingFollowedWithNamedImport1_1.ts === -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; ->defaultBinding1 : any +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; +>defaultBinding1 : number var x1: number = defaultBinding1; >x1 : number ->defaultBinding1 : any +>defaultBinding1 : number -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; ->defaultBinding2 : any +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; +>defaultBinding2 : number >a : any var x1: number = defaultBinding2; >x1 : number ->defaultBinding2 : any +>defaultBinding2 : number -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; ->defaultBinding3 : any +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; +>defaultBinding3 : number >a : any >b : any var x1: number = defaultBinding3; >x1 : number ->defaultBinding3 : any +>defaultBinding3 : number -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; ->defaultBinding4 : any +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; +>defaultBinding4 : number >x : any >a : any >y : any var x1: number = defaultBinding4; >x1 : number ->defaultBinding4 : any +>defaultBinding4 : number -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; ->defaultBinding5 : any +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; +>defaultBinding5 : number >x : any >z : any var x1: number = defaultBinding5; >x1 : number ->defaultBinding5 : any +>defaultBinding5 : number -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; ->defaultBinding6 : any +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1_0"; +>defaultBinding6 : number >m : any var x1: number = defaultBinding6; >x1 : number ->defaultBinding6 : any +>defaultBinding6 : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types.diff deleted file mode 100644 index 8df8449b99..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.types.diff +++ /dev/null @@ -1,67 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImport1.types -+++ new.es6ImportDefaultBindingFollowedWithNamedImport1.types -@@= skipped -9, +9 lines =@@ - - === es6ImportDefaultBindingFollowedWithNamedImport1_1.ts === - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -->defaultBinding1 : number -+>defaultBinding1 : any - - var x1: number = defaultBinding1; - >x1 : number -->defaultBinding1 : number -+>defaultBinding1 : any - - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -->defaultBinding2 : number -+>defaultBinding2 : any - >a : any - - var x1: number = defaultBinding2; - >x1 : number -->defaultBinding2 : number -+>defaultBinding2 : any - - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -->defaultBinding3 : number -+>defaultBinding3 : any - >a : any - >b : any - - var x1: number = defaultBinding3; - >x1 : number -->defaultBinding3 : number -+>defaultBinding3 : any - - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -->defaultBinding4 : number -+>defaultBinding4 : any - >x : any - >a : any - >y : any - - var x1: number = defaultBinding4; - >x1 : number -->defaultBinding4 : number -+>defaultBinding4 : any - - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -->defaultBinding5 : number -+>defaultBinding5 : any - >x : any - >z : any - - var x1: number = defaultBinding5; - >x1 : number -->defaultBinding5 : number -+>defaultBinding5 : any - - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1_0"; -->defaultBinding6 : number -+>defaultBinding6 : any - >m : any - - var x1: number = defaultBinding6; - >x1 : number -->defaultBinding6 : number -+>defaultBinding6 : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index d68d989024..f74530ac84 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -26,18 +26,21 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; -const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; -const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; -const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; -const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; -const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js.diff deleted file mode 100644 index 685caf0363..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js -+++ new.es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js -@@= skipped -26, +26 lines =@@ - //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; --var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; --var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; --var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; --var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; --var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index 60b54f17e3..8edf88f126 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -26,19 +26,22 @@ var a = 10; exports.default = a; //// [client.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.x1 = void 0; -const server_1 = require("./server"); +const server_1 = __importDefault(require("./server")); exports.x1 = server_1.default; -const server_2 = require("./server"); +const server_2 = __importDefault(require("./server")); exports.x1 = server_2.default; -const server_3 = require("./server"); +const server_3 = __importDefault(require("./server")); exports.x1 = server_3.default; -const server_4 = require("./server"); +const server_4 = __importDefault(require("./server")); exports.x1 = server_4.default; -const server_5 = require("./server"); +const server_5 = __importDefault(require("./server")); exports.x1 = server_5.default; -const server_6 = require("./server"); +const server_6 = __importDefault(require("./server")); exports.x1 = server_6.default; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js.diff deleted file mode 100644 index 86e4d1fb7a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js -+++ new.es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js -@@= skipped -27, +27 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x1 = void 0; --var server_1 = require("./server"); -+const server_1 = require("./server"); - exports.x1 = server_1.default; --var server_2 = require("./server"); -+const server_2 = require("./server"); - exports.x1 = server_2.default; --var server_3 = require("./server"); -+const server_3 = require("./server"); - exports.x1 = server_3.default; --var server_4 = require("./server"); -+const server_4 = require("./server"); - exports.x1 = server_4.default; --var server_5 = require("./server"); -+const server_5 = require("./server"); - exports.x1 = server_5.default; --var server_6 = require("./server"); -+const server_6 = require("./server"); - exports.x1 = server_6.default; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.js.diff deleted file mode 100644 index b5b4c6dc24..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.js.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImportDts.js -+++ new.es6ImportDefaultBindingFollowedWithNamedImportDts.js -@@= skipped -48, +48 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x6 = exports.x3 = exports.x5 = exports.x4 = exports.x2 = exports.x1 = void 0; --var server_1 = require("./server"); -+const server_1 = require("./server"); - exports.x1 = new server_1.a(); --var server_2 = require("./server"); -+const server_2 = require("./server"); - exports.x2 = new server_2.a11(); --var server_3 = require("./server"); -+const server_3 = require("./server"); - exports.x4 = new server_3.x(); - exports.x5 = new server_3.a12(); --var server_4 = require("./server"); -+const server_4 = require("./server"); - exports.x3 = new server_4.x11(); --var server_5 = require("./server"); -+const server_5 = require("./server"); - exports.x6 = new server_5.m(); - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index 5487086947..34840ec432 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -26,19 +26,22 @@ class a { exports.default = a; //// [client.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.x6 = exports.x5 = exports.x4 = exports.x3 = exports.x2 = exports.x1 = void 0; -const server_1 = require("./server"); +const server_1 = __importDefault(require("./server")); exports.x1 = new server_1.default(); -const server_2 = require("./server"); +const server_2 = __importDefault(require("./server")); exports.x2 = new server_2.default(); -const server_3 = require("./server"); +const server_3 = __importDefault(require("./server")); exports.x3 = new server_3.default(); -const server_4 = require("./server"); +const server_4 = __importDefault(require("./server")); exports.x4 = new server_4.default(); -const server_5 = require("./server"); +const server_5 = __importDefault(require("./server")); exports.x5 = new server_5.default(); -const server_6 = require("./server"); +const server_6 = __importDefault(require("./server")); exports.x6 = new server_6.default(); diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js.diff deleted file mode 100644 index 0b3d243a82..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.js.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImportDts1.js -+++ new.es6ImportDefaultBindingFollowedWithNamedImportDts1.js -@@= skipped -27, +27 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x6 = exports.x5 = exports.x4 = exports.x3 = exports.x2 = exports.x1 = void 0; --var server_1 = require("./server"); -+const server_1 = require("./server"); - exports.x1 = new server_1.default(); --var server_2 = require("./server"); -+const server_2 = require("./server"); - exports.x2 = new server_2.default(); --var server_3 = require("./server"); -+const server_3 = require("./server"); - exports.x3 = new server_3.default(); --var server_4 = require("./server"); -+const server_4 = require("./server"); - exports.x4 = new server_4.default(); --var server_5 = require("./server"); -+const server_5 = require("./server"); - exports.x5 = new server_5.default(); --var server_6 = require("./server"); -+const server_6 = require("./server"); - exports.x6 = new server_6.default(); - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js.diff deleted file mode 100644 index 63f3d833b4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImportInEs5.js -+++ new.es6ImportDefaultBindingFollowedWithNamedImportInEs5.js -@@= skipped -29, +29 lines =@@ - //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); - var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; --var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); - var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; --var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); - var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; - var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; --var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); - var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; --var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); - var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt new file mode 100644 index 0000000000..08261f24e7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.errors.txt @@ -0,0 +1,58 @@ +client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +client.ts(2,1): error TS1191: An import declaration cannot have modifiers. +client.ts(3,12): error TS2323: Cannot redeclare exported variable 'x1'. +client.ts(4,1): error TS1191: An import declaration cannot have modifiers. +client.ts(5,12): error TS2323: Cannot redeclare exported variable 'x1'. +client.ts(6,1): error TS1191: An import declaration cannot have modifiers. +client.ts(7,12): error TS2323: Cannot redeclare exported variable 'x1'. +client.ts(8,12): error TS2323: Cannot redeclare exported variable 'x1'. +client.ts(9,1): error TS1191: An import declaration cannot have modifiers. +client.ts(10,12): error TS2323: Cannot redeclare exported variable 'x1'. +client.ts(11,1): error TS1191: An import declaration cannot have modifiers. +client.ts(12,12): error TS2323: Cannot redeclare exported variable 'x1'. + + +==== server.ts (0 errors) ==== + export var a = 10; + export var x = a; + export var m = a; + export default {}; + +==== client.ts (12 errors) ==== + export import defaultBinding1, { } from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export import defaultBinding2, { a } from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x1: number = a; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. + export import defaultBinding3, { a as b } from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x1: number = b; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. + export import defaultBinding4, { x, a as y } from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x1: number = x; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. + export var x1: number = y; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. + export import defaultBinding5, { x as z, } from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x1: number = z; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. + export import defaultBinding6, { m, } from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x1: number = m; + ~~ +!!! error TS2323: Cannot redeclare exported variable 'x1'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js new file mode 100644 index 0000000000..6f1755491a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts] //// + +//// [server.ts] +export var a = 10; +export var x = a; +export var m = a; +export default {}; + +//// [client.ts] +export import defaultBinding1, { } from "./server"; +export import defaultBinding2, { a } from "./server"; +export var x1: number = a; +export import defaultBinding3, { a as b } from "./server"; +export var x1: number = b; +export import defaultBinding4, { x, a as y } from "./server"; +export var x1: number = x; +export var x1: number = y; +export import defaultBinding5, { x as z, } from "./server"; +export var x1: number = z; +export import defaultBinding6, { m, } from "./server"; +export var x1: number = m; + + +//// [server.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.m = exports.x = exports.a = void 0; +exports.a = 10; +exports.x = exports.a; +exports.m = exports.a; +exports.default = {}; +//// [client.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x1 = void 0; +const server_1 = require("./server"); +exports.x1 = server_1.a; +const server_2 = require("./server"); +exports.x1 = server_2.a; +const server_3 = require("./server"); +exports.x1 = server_3.x; +exports.x1 = server_3.a; +const server_4 = require("./server"); +exports.x1 = server_4.x; +const server_5 = require("./server"); +exports.x1 = server_5.m; + + +//// [server.d.ts] +export declare var a: number; +export declare var x: number; +export declare var m: number; +declare const _default: {}; +export default _default; +//// [client.d.ts] +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; +export declare var x1: number; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.symbols new file mode 100644 index 0000000000..35bbfb8c42 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.symbols @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts] //// + +=== server.ts === +export var a = 10; +>a : Symbol(a, Decl(server.ts, 0, 10)) + +export var x = a; +>x : Symbol(x, Decl(server.ts, 1, 10)) +>a : Symbol(a, Decl(server.ts, 0, 10)) + +export var m = a; +>m : Symbol(m, Decl(server.ts, 2, 10)) +>a : Symbol(a, Decl(server.ts, 0, 10)) + +export default {}; + +=== client.ts === +export import defaultBinding1, { } from "./server"; +>defaultBinding1 : Symbol(defaultBinding1, Decl(client.ts, 0, 13)) + +export import defaultBinding2, { a } from "./server"; +>defaultBinding2 : Symbol(defaultBinding2, Decl(client.ts, 1, 13)) +>a : Symbol(a, Decl(client.ts, 1, 32)) + +export var x1: number = a; +>x1 : Symbol(x1, Decl(client.ts, 2, 10), Decl(client.ts, 4, 10), Decl(client.ts, 6, 10), Decl(client.ts, 7, 10), Decl(client.ts, 9, 10) ... and 1 more) +>a : Symbol(a, Decl(client.ts, 1, 32)) + +export import defaultBinding3, { a as b } from "./server"; +>defaultBinding3 : Symbol(defaultBinding3, Decl(client.ts, 3, 13)) +>a : Symbol(a, Decl(server.ts, 0, 10)) +>b : Symbol(b, Decl(client.ts, 3, 32)) + +export var x1: number = b; +>x1 : Symbol(x1, Decl(client.ts, 2, 10), Decl(client.ts, 4, 10), Decl(client.ts, 6, 10), Decl(client.ts, 7, 10), Decl(client.ts, 9, 10) ... and 1 more) +>b : Symbol(b, Decl(client.ts, 3, 32)) + +export import defaultBinding4, { x, a as y } from "./server"; +>defaultBinding4 : Symbol(defaultBinding4, Decl(client.ts, 5, 13)) +>x : Symbol(x, Decl(client.ts, 5, 32)) +>a : Symbol(a, Decl(server.ts, 0, 10)) +>y : Symbol(y, Decl(client.ts, 5, 35)) + +export var x1: number = x; +>x1 : Symbol(x1, Decl(client.ts, 2, 10), Decl(client.ts, 4, 10), Decl(client.ts, 6, 10), Decl(client.ts, 7, 10), Decl(client.ts, 9, 10) ... and 1 more) +>x : Symbol(x, Decl(client.ts, 5, 32)) + +export var x1: number = y; +>x1 : Symbol(x1, Decl(client.ts, 2, 10), Decl(client.ts, 4, 10), Decl(client.ts, 6, 10), Decl(client.ts, 7, 10), Decl(client.ts, 9, 10) ... and 1 more) +>y : Symbol(y, Decl(client.ts, 5, 35)) + +export import defaultBinding5, { x as z, } from "./server"; +>defaultBinding5 : Symbol(defaultBinding5, Decl(client.ts, 8, 13)) +>x : Symbol(x, Decl(server.ts, 1, 10)) +>z : Symbol(z, Decl(client.ts, 8, 32)) + +export var x1: number = z; +>x1 : Symbol(x1, Decl(client.ts, 2, 10), Decl(client.ts, 4, 10), Decl(client.ts, 6, 10), Decl(client.ts, 7, 10), Decl(client.ts, 9, 10) ... and 1 more) +>z : Symbol(z, Decl(client.ts, 8, 32)) + +export import defaultBinding6, { m, } from "./server"; +>defaultBinding6 : Symbol(defaultBinding6, Decl(client.ts, 10, 13)) +>m : Symbol(m, Decl(client.ts, 10, 32)) + +export var x1: number = m; +>x1 : Symbol(x1, Decl(client.ts, 2, 10), Decl(client.ts, 4, 10), Decl(client.ts, 6, 10), Decl(client.ts, 7, 10), Decl(client.ts, 9, 10) ... and 1 more) +>m : Symbol(m, Decl(client.ts, 10, 32)) + diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.types b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.types new file mode 100644 index 0000000000..67cfa3d851 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.types @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportWithExport.ts] //// + +=== server.ts === +export var a = 10; +>a : number +>10 : 10 + +export var x = a; +>x : number +>a : number + +export var m = a; +>m : number +>a : number + +export default {}; +>{} : {} + +=== client.ts === +export import defaultBinding1, { } from "./server"; +>defaultBinding1 : {} + +export import defaultBinding2, { a } from "./server"; +>defaultBinding2 : {} +>a : number + +export var x1: number = a; +>x1 : number +>a : number + +export import defaultBinding3, { a as b } from "./server"; +>defaultBinding3 : {} +>a : number +>b : number + +export var x1: number = b; +>x1 : number +>b : number + +export import defaultBinding4, { x, a as y } from "./server"; +>defaultBinding4 : {} +>x : number +>a : number +>y : number + +export var x1: number = x; +>x1 : number +>x : number + +export var x1: number = y; +>x1 : number +>y : number + +export import defaultBinding5, { x as z, } from "./server"; +>defaultBinding5 : {} +>x : number +>z : number + +export var x1: number = z; +>x1 : number +>z : number + +export import defaultBinding6, { m, } from "./server"; +>defaultBinding6 : {} +>m : number + +export var x1: number = m; +>x1 : number +>m : number + diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt index 61a05e784f..446b5e271d 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt @@ -1,11 +1,11 @@ -es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,52): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. +es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export. ==== es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (0 errors) ==== export var a = 10; ==== es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. + import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export. var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt.diff deleted file mode 100644 index a1ba742942..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt -@@= skipped -0, +0 lines =@@ --es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export. -+es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,52): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. - - - ==== es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (0 errors) ==== -@@= skipped -5, +5 lines =@@ - - ==== es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; -- ~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. - var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.js index 2c86e06263..e38fa303c6 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.js @@ -4,13 +4,13 @@ export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] -import * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; var x = nameSpaceBinding.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols index 52ba79bf97..f2686bc37c 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols @@ -5,11 +5,13 @@ export var a = 10; >a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts, 0, 10)) === es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; >defaultBinding : Symbol(defaultBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 0, 6)) >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 0, 22)) var x: number = nameSpaceBinding.a; >x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 1, 3)) +>nameSpaceBinding.a : Symbol(nameSpaceBinding.a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts, 0, 10)) >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 0, 22)) +>a : Symbol(nameSpaceBinding.a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts, 0, 10)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols.diff deleted file mode 100644 index 7612487421..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBinding.symbols -@@= skipped -10, +10 lines =@@ - - var x: number = nameSpaceBinding.a; - >x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 1, 3)) -->nameSpaceBinding.a : Symbol(nameSpaceBinding.a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts, 0, 10)) - >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 0, 22)) -->a : Symbol(nameSpaceBinding.a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts, 0, 10)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types index 683bb2d142..b4a1d5c201 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types @@ -6,13 +6,13 @@ export var a = 10; >10 : 10 === es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; >defaultBinding : any ->nameSpaceBinding : any +>nameSpaceBinding : typeof nameSpaceBinding var x: number = nameSpaceBinding.a; >x : number ->nameSpaceBinding.a : any ->nameSpaceBinding : any ->a : any +>nameSpaceBinding.a : number +>nameSpaceBinding : typeof nameSpaceBinding +>a : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types.diff deleted file mode 100644 index 1af7f01ae0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.types.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBinding.types -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBinding.types -@@= skipped -7, +7 lines =@@ - === es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; - >defaultBinding : any -->nameSpaceBinding : typeof nameSpaceBinding -+>nameSpaceBinding : any - - var x: number = nameSpaceBinding.a; - >x : number -->nameSpaceBinding.a : number -->nameSpaceBinding : typeof nameSpaceBinding -->a : number -+>nameSpaceBinding.a : any -+>nameSpaceBinding : any -+>a : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt deleted file mode 100644 index 76a13afad5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,52): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. - - -==== es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (0 errors) ==== - var a = 10; - export default a; - -==== es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. - var x: number = defaultBinding; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt.diff deleted file mode 100644 index 3816cb2188..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBinding1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,52): error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. -+ -+ -+==== es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts (0 errors) ==== -+ var a = 10; -+ export default a; -+ -+==== es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ==== -+ import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportDefaultBindingFollowedWithNamespaceBinding_0' or its corresponding type declarations. -+ var x: number = defaultBinding; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js index 039b4a3dce..bd12489fc9 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.js @@ -5,14 +5,14 @@ var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js] var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js] -import defaultBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; var x = defaultBinding; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.symbols index b8cac73d9a..700ee31c46 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.symbols @@ -8,7 +8,7 @@ export default a; >a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts, 0, 3)) === es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; >defaultBinding : Symbol(defaultBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 0, 6)) >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts, 0, 22)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types index 85843c7858..4299ceb3be 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types @@ -9,11 +9,11 @@ export default a; >a : number === es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; ->defaultBinding : any ->nameSpaceBinding : any +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; +>defaultBinding : number +>nameSpaceBinding : typeof nameSpaceBinding var x: number = defaultBinding; >x : number ->defaultBinding : any +>defaultBinding : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types.diff deleted file mode 100644 index 075605f1ec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBinding1.types -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBinding1.types -@@= skipped -9, +9 lines =@@ - - === es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts === - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0"; -->defaultBinding : number -->nameSpaceBinding : typeof nameSpaceBinding -+>defaultBinding : any -+>nameSpaceBinding : any - - var x: number = defaultBinding; - >x : number -->defaultBinding : number -+>defaultBinding : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index b5c95374a7..67f80174cd 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -15,8 +15,11 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +const es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js.diff deleted file mode 100644 index bcf62e08bd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js -@@= skipped -15, +15 lines =@@ - //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); -+const es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); - var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 1f83776a28..0f400c5087 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -16,9 +16,42 @@ class a { exports.a = a; //// [client.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const nameSpaceBinding = require("./server"); +const nameSpaceBinding = __importStar(require("./server")); exports.x = new nameSpaceBinding.a(); diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js.diff deleted file mode 100644 index 879976f3f2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js -@@= skipped -17, +17 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var nameSpaceBinding = require("./server"); -+const nameSpaceBinding = require("./server"); - exports.x = new nameSpaceBinding.a(); - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index ebdee2d2bc..bd4309d548 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -14,8 +14,41 @@ exports.a = void 0; exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +const nameSpaceBinding = __importStar(require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0")); var x = nameSpaceBinding.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js.diff deleted file mode 100644 index deaee87393..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js -@@= skipped -14, +14 lines =@@ - //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); -+const nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); - var x = nameSpaceBinding.a; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index 67fc498fdf..d356946540 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -14,9 +14,42 @@ exports.a = void 0; exports.a = 10; //// [client.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const nameSpaceBinding = require("./server"); +const nameSpaceBinding = __importStar(require("./server")); exports.x = nameSpaceBinding.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js.diff deleted file mode 100644 index 2b8e1e997a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var nameSpaceBinding = require("./server"); -+const nameSpaceBinding = require("./server"); - exports.x = nameSpaceBinding.a; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.errors.txt.diff deleted file mode 100644 index 2e5b58dc1b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportDefaultBindingInEs5.errors.txt -+++ new.es6ImportDefaultBindingInEs5.errors.txt -@@= skipped -0, +0 lines =@@ --es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1259: Module '"es6ImportDefaultBindingInEs5_0"' can only be default-imported using the 'esModuleInterop' flag -- -- --==== es6ImportDefaultBindingInEs5_0.ts (0 errors) ==== -- var a = 10; -- export = a; -- --==== es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== -- import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; -- ~~~~~~~~~~~~~~ --!!! error TS1259: Module '"es6ImportDefaultBindingInEs5_0"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 es6ImportDefaultBindingInEs5_0.ts:2:1: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.types.diff deleted file mode 100644 index 2ba3f20ec6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.es6ImportDefaultBindingInEs5.types -+++ new.es6ImportDefaultBindingInEs5.types -@@= skipped -9, +9 lines =@@ - - === es6ImportDefaultBindingInEs5_1.ts === - import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; -->defaultBinding : any -+>defaultBinding : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js index 2f32566b13..eeb5bbcd12 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js @@ -22,7 +22,10 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); +const es6ImportDefaultBindingMergeErrors_0_1 = __importDefault(require("./es6ImportDefaultBindingMergeErrors_0")); var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js.diff deleted file mode 100644 index 5cdb26f3f0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingMergeErrors.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportDefaultBindingMergeErrors.js -+++ new.es6ImportDefaultBindingMergeErrors.js -@@= skipped -22, +22 lines =@@ - //// [es6ImportDefaultBindingMergeErrors_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); -+const es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); - var x = es6ImportDefaultBindingMergeErrors_0_1.default; - var defaultBinding2 = "hello world"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.errors.txt new file mode 100644 index 0000000000..de33de8cda --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.errors.txt @@ -0,0 +1,16 @@ +client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +client.ts(3,1): error TS1191: An import declaration cannot have modifiers. + + +==== server.ts (0 errors) ==== + var a = 10; + export default a; + +==== client.ts (2 errors) ==== + export import defaultBinding from "./server"; + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export var x = defaultBinding; + export import defaultBinding2 from "./server"; // non referenced + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.js b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.js new file mode 100644 index 0000000000..0eabd86f4e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingWithExport.ts] //// + +//// [server.ts] +var a = 10; +export default a; + +//// [client.ts] +export import defaultBinding from "./server"; +export var x = defaultBinding; +export import defaultBinding2 from "./server"; // non referenced + +//// [server.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var a = 10; +exports.default = a; +//// [client.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +const server_1 = __importDefault(require("./server")); +exports.x = server_1.default; + + +//// [server.d.ts] +declare var a: number; +export default a; +//// [client.d.ts] +export declare var x: number; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.symbols new file mode 100644 index 0000000000..6090e8d56e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingWithExport.ts] //// + +=== server.ts === +var a = 10; +>a : Symbol(a, Decl(server.ts, 0, 3)) + +export default a; +>a : Symbol(a, Decl(server.ts, 0, 3)) + +=== client.ts === +export import defaultBinding from "./server"; +>defaultBinding : Symbol(defaultBinding, Decl(client.ts, 0, 13)) + +export var x = defaultBinding; +>x : Symbol(x, Decl(client.ts, 1, 10)) +>defaultBinding : Symbol(defaultBinding, Decl(client.ts, 0, 13)) + +export import defaultBinding2 from "./server"; // non referenced +>defaultBinding2 : Symbol(defaultBinding2, Decl(client.ts, 2, 13)) + diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.types b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.types new file mode 100644 index 0000000000..d78645a482 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingWithExport.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/es6ImportDefaultBindingWithExport.ts] //// + +=== server.ts === +var a = 10; +>a : number +>10 : 10 + +export default a; +>a : number + +=== client.ts === +export import defaultBinding from "./server"; +>defaultBinding : number + +export var x = defaultBinding; +>x : number +>defaultBinding : number + +export import defaultBinding2 from "./server"; // non referenced +>defaultBinding2 : number + diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt index 13769af4d3..fec1b354af 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt @@ -1,14 +1,14 @@ client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -client.ts(1,20): error TS2307: Cannot find module 'server' or its corresponding type declarations. +server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== client.ts (2 errors) ==== - import a = require("server"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== client.ts (1 errors) ==== + import a = require("./server"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. - ~~~~~~~~ -!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. -==== server.ts (0 errors) ==== +==== server.ts (1 errors) ==== var a = 10; export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt.diff deleted file mode 100644 index dcc1ac9645..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.es6ImportEqualsDeclaration.errors.txt -+++ new.es6ImportEqualsDeclaration.errors.txt -@@= skipped -0, +0 lines =@@ - client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. --server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -- -- --==== client.ts (1 errors) ==== -+client.ts(1,20): error TS2307: Cannot find module 'server' or its corresponding type declarations. -+ -+ -+==== client.ts (2 errors) ==== - import a = require("server"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. --==== server.ts (1 errors) ==== -+ ~~~~~~~~ -+!!! error TS2307: Cannot find module 'server' or its corresponding type declarations. -+==== server.ts (0 errors) ==== - var a = 10; - export = a; -- ~~~~~~~~~~~ --!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js index f1d1f9d352..b994bd728a 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js @@ -5,7 +5,10 @@ var a = 10; export = a; //// [client.ts] -import a = require("server"); +import a = require("./server"); +//// [server.js] +var a = 10; +export {}; //// [client.js] export {}; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js.diff deleted file mode 100644 index e5db0b42b6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.es6ImportEqualsDeclaration.js -+++ new.es6ImportEqualsDeclaration.js -@@= skipped -6, +6 lines =@@ - //// [client.ts] - import a = require("server"); - --//// [server.js] --var a = 10; --export {}; - //// [client.js] - export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols index 2cf6482767..fc301a740c 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols @@ -1,6 +1,13 @@ //// [tests/cases/compiler/es6ImportEqualsDeclaration.ts] //// === client.ts === -import a = require("server"); +import a = require("./server"); >a : Symbol(a, Decl(client.ts, 0, 0)) +=== server.ts === +var a = 10; +>a : Symbol(a, Decl(server.ts, 0, 3)) + +export = a; +>a : Symbol(a, Decl(server.ts, 0, 3)) + diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols.diff b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols.diff deleted file mode 100644 index 7ab627c945..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.symbols.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.es6ImportEqualsDeclaration.symbols -+++ new.es6ImportEqualsDeclaration.symbols -@@= skipped -3, +3 lines =@@ - import a = require("server"); - >a : Symbol(a, Decl(client.ts, 0, 0)) - --=== server.ts === --var a = 10; -->a : Symbol(a, Decl(server.ts, 0, 3)) -- --export = a; -->a : Symbol(a, Decl(server.ts, 0, 3)) -- \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types index ed27c5b0d8..2c26a91f92 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types +++ b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types @@ -1,6 +1,14 @@ //// [tests/cases/compiler/es6ImportEqualsDeclaration.ts] //// === client.ts === -import a = require("server"); ->a : any +import a = require("./server"); +>a : number + +=== server.ts === +var a = 10; +>a : number +>10 : 10 + +export = a; +>a : number diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types.diff deleted file mode 100644 index 1abfc89c8c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsDeclaration.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportEqualsDeclaration.types -+++ new.es6ImportEqualsDeclaration.types -@@= skipped -1, +1 lines =@@ - - === client.ts === - import a = require("server"); -->a : number -- --=== server.ts === --var a = 10; -->a : number -->10 : 10 -- --export = a; -->a : number -+>a : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js index 8443d4820d..e3c5f6efe7 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js @@ -18,6 +18,39 @@ class a { module.exports = a; //// [main.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const a = require("./a"); +const a = __importStar(require("./a")); a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js.diff deleted file mode 100644 index 7b1f4e4343..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportEqualsExportModuleCommonJsError.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.es6ImportEqualsExportModuleCommonJsError.js -+++ new.es6ImportEqualsExportModuleCommonJsError.js -@@= skipped -18, +18 lines =@@ - //// [main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("./a"); -+const a = require("./a"); - a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImport.js b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImport.js index ce72655687..1f01c654c8 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImport.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImport.js @@ -16,8 +16,41 @@ exports.a = void 0; exports.a = 10; //// [es6ImportNameSpaceImport_1.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const nameSpaceBinding = require("./es6ImportNameSpaceImport_0"); +const nameSpaceBinding = __importStar(require("./es6ImportNameSpaceImport_0")); var x = nameSpaceBinding.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js index dc40e156a9..1c9636e822 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js @@ -18,9 +18,42 @@ exports.c = c; ; //// [client.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const nameSpaceBinding = require("./server"); +const nameSpaceBinding = __importStar(require("./server")); exports.x = new nameSpaceBinding.c(); diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js.diff deleted file mode 100644 index fcb53273d5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportDts.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportNameSpaceImportDts.js -+++ new.es6ImportNameSpaceImportDts.js -@@= skipped -19, +19 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var nameSpaceBinding = require("./server"); -+const nameSpaceBinding = require("./server"); - exports.x = new nameSpaceBinding.c(); - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js index 3b375f2f92..dff81d3ee3 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js @@ -16,8 +16,41 @@ exports.a = void 0; exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); +const nameSpaceBinding = __importStar(require("./es6ImportNameSpaceImportInEs5_0")); var x = nameSpaceBinding.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js.diff deleted file mode 100644 index 2bbc9f5c74..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNameSpaceImportInEs5.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.es6ImportNameSpaceImportInEs5.js -+++ new.es6ImportNameSpaceImportInEs5.js -@@= skipped -16, +16 lines =@@ - //// [es6ImportNameSpaceImportInEs5_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); -+const nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); - var x = nameSpaceBinding.a; - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportDts.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportDts.js.diff deleted file mode 100644 index 26231b39d7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportDts.js.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.es6ImportNamedImportDts.js -+++ new.es6ImportNamedImportDts.js -@@= skipped -94, +94 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.z2 = exports.z111 = exports.xxxx9 = exports.xxxx8 = exports.xxxx7 = exports.xxxx6 = exports.xxxx5 = exports.xxxx4 = exports.xxxx3 = exports.xxxx2 = exports.xxxx1 = exports.xxxx = void 0; --var server_1 = require("./server"); -+const server_1 = require("./server"); - exports.xxxx = new server_1.a(); --var server_2 = require("./server"); -+const server_2 = require("./server"); - exports.xxxx1 = new server_2.a11(); --var server_3 = require("./server"); -+const server_3 = require("./server"); - exports.xxxx2 = new server_3.x(); - exports.xxxx3 = new server_3.a12(); --var server_4 = require("./server"); -+const server_4 = require("./server"); - exports.xxxx4 = new server_4.x11(); --var server_5 = require("./server"); -+const server_5 = require("./server"); - exports.xxxx5 = new server_5.m(); --var server_6 = require("./server"); -+const server_6 = require("./server"); - exports.xxxx6 = new server_6.a1(); - exports.xxxx7 = new server_6.x1(); --var server_7 = require("./server"); -+const server_7 = require("./server"); - exports.xxxx8 = new server_7.a111(); - exports.xxxx9 = new server_7.x111(); --var server_8 = require("./server"); -+const server_8 = require("./server"); - exports.z111 = new server_8.z1(); --var server_9 = require("./server"); -+const server_9 = require("./server"); - exports.z2 = new server_9.z2(); // z2 shouldn't give redeclare error - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportIdentifiersParsing.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportIdentifiersParsing.errors.txt.diff deleted file mode 100644 index 42f6dd334c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportIdentifiersParsing.errors.txt.diff +++ /dev/null @@ -1,60 +0,0 @@ ---- old.es6ImportNamedImportIdentifiersParsing.errors.txt -+++ new.es6ImportNamedImportIdentifiersParsing.errors.txt -@@= skipped -0, +0 lines =@@ - es6ImportNamedImportIdentifiersParsing.ts(1,10): error TS2300: Duplicate identifier 'yield'. --es6ImportNamedImportIdentifiersParsing.ts(1,23): error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+es6ImportNamedImportIdentifiersParsing.ts(1,23): error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - es6ImportNamedImportIdentifiersParsing.ts(2,10): error TS1003: Identifier expected. - es6ImportNamedImportIdentifiersParsing.ts(2,10): error TS2300: Duplicate identifier 'default'. --es6ImportNamedImportIdentifiersParsing.ts(2,25): error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+es6ImportNamedImportIdentifiersParsing.ts(2,25): error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - es6ImportNamedImportIdentifiersParsing.ts(3,19): error TS1003: Identifier expected. - es6ImportNamedImportIdentifiersParsing.ts(3,19): error TS2300: Duplicate identifier 'default'. --es6ImportNamedImportIdentifiersParsing.ts(3,34): error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+es6ImportNamedImportIdentifiersParsing.ts(3,34): error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - es6ImportNamedImportIdentifiersParsing.ts(4,21): error TS2300: Duplicate identifier 'yield'. --es6ImportNamedImportIdentifiersParsing.ts(4,34): error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+es6ImportNamedImportIdentifiersParsing.ts(4,34): error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - es6ImportNamedImportIdentifiersParsing.ts(5,21): error TS1003: Identifier expected. - es6ImportNamedImportIdentifiersParsing.ts(5,21): error TS2300: Duplicate identifier 'default'. --es6ImportNamedImportIdentifiersParsing.ts(5,36): error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+es6ImportNamedImportIdentifiersParsing.ts(5,36): error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - - - ==== es6ImportNamedImportIdentifiersParsing.ts (13 errors) ==== -@@= skipped -17, +17 lines =@@ - ~~~~~ - !!! error TS2300: Duplicate identifier 'yield'. - ~~~~~~~~~~~~ --!!! error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - import { default } from "somemodule"; // Error - as this is keyword that is not allowed as identifier - ~~~~~~~ - !!! error TS1003: Identifier expected. - ~~~~~~~ - !!! error TS2300: Duplicate identifier 'default'. - ~~~~~~~~~~~~ --!!! error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - import { yield as default } from "somemodule"; // error to use default as binding name - ~~~~~~~ - !!! error TS1003: Identifier expected. - ~~~~~~~ - !!! error TS2300: Duplicate identifier 'default'. - ~~~~~~~~~~~~ --!!! error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - import { default as yield } from "somemodule"; // no error - ~~~~~ - !!! error TS2300: Duplicate identifier 'yield'. - ~~~~~~~~~~~~ --!!! error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. - import { default as default } from "somemodule"; // default as is ok, error of default binding name - ~~~~~~~ - !!! error TS1003: Identifier expected. - ~~~~~~~ - !!! error TS2300: Duplicate identifier 'default'. - ~~~~~~~~~~~~ --!!! error TS2792: Cannot find module 'somemodule'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2307: Cannot find module 'somemodule' or its corresponding type declarations. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInEs5.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInEs5.js.diff deleted file mode 100644 index f7af11b31e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInEs5.js.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.es6ImportNamedImportInEs5.js -+++ new.es6ImportNamedImportInEs5.js -@@= skipped -54, +54 lines =@@ - //// [es6ImportNamedImportInEs5_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var es6ImportNamedImportInEs5_0_1 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_1 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_1.a; --var es6ImportNamedImportInEs5_0_2 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_2 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_2.a; --var es6ImportNamedImportInEs5_0_3 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_3 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_3.x; - var xxxx = es6ImportNamedImportInEs5_0_3.a; --var es6ImportNamedImportInEs5_0_4 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_4 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_4.x; --var es6ImportNamedImportInEs5_0_5 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_5 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_5.m; --var es6ImportNamedImportInEs5_0_6 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_6 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_6.a1; - var xxxx = es6ImportNamedImportInEs5_0_6.x1; --var es6ImportNamedImportInEs5_0_7 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_7 = require("./es6ImportNamedImportInEs5_0"); - var xxxx = es6ImportNamedImportInEs5_0_7.a1; - var xxxx = es6ImportNamedImportInEs5_0_7.x1; --var es6ImportNamedImportInEs5_0_8 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_8 = require("./es6ImportNamedImportInEs5_0"); - var z111 = es6ImportNamedImportInEs5_0_8.z1; --var es6ImportNamedImportInEs5_0_9 = require("./es6ImportNamedImportInEs5_0"); -+const es6ImportNamedImportInEs5_0_9 = require("./es6ImportNamedImportInEs5_0"); - var z2 = es6ImportNamedImportInEs5_0_9.z2; // z2 shouldn't give redeclare error - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInIndirectExportAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInIndirectExportAssignment.js.diff index 35e6767d87..cc9619f956 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInIndirectExportAssignment.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportInIndirectExportAssignment.js.diff @@ -1,11 +1,9 @@ --- old.es6ImportNamedImportInIndirectExportAssignment.js +++ new.es6ImportNamedImportInIndirectExportAssignment.js -@@= skipped -22, +22 lines =@@ - })(a || (exports.a = a = {})); +@@= skipped -23, +23 lines =@@ //// [es6ImportNamedImportInIndirectExportAssignment_1.js] "use strict"; --var es6ImportNamedImportInIndirectExportAssignment_0_1 = require("./es6ImportNamedImportInIndirectExportAssignment_0"); + const es6ImportNamedImportInIndirectExportAssignment_0_1 = require("./es6ImportNamedImportInIndirectExportAssignment_0"); -var x = es6ImportNamedImportInIndirectExportAssignment_0_1.a; -+const es6ImportNamedImportInIndirectExportAssignment_0_1 = require("./es6ImportNamedImportInIndirectExportAssignment_0"); module.exports = x; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportNoNamedExports.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportNoNamedExports.errors.txt index 480948746c..da972d070e 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportNoNamedExports.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportNoNamedExports.errors.txt @@ -1,5 +1,5 @@ -es6ImportNamedImportNoNamedExports_1.ts(1,10): error TS2617: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or by turning on the 'esModuleInterop' flag and using a default import. -es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2617: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or by turning on the 'esModuleInterop' flag and using a default import. +es6ImportNamedImportNoNamedExports_1.ts(1,10): error TS2616: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or a default import. +es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2616: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or a default import. ==== es6ImportNamedImportNoNamedExports_0.ts (0 errors) ==== @@ -9,7 +9,7 @@ es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2617: 'a' can only be imp ==== es6ImportNamedImportNoNamedExports_1.ts (2 errors) ==== import { a } from "./es6ImportNamedImportNoNamedExports_0"; ~ -!!! error TS2617: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or by turning on the 'esModuleInterop' flag and using a default import. +!!! error TS2616: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or a default import. import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; ~ -!!! error TS2617: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or by turning on the 'esModuleInterop' flag and using a default import. \ No newline at end of file +!!! error TS2616: 'a' can only be imported by using 'import a = require("./es6ImportNamedImportNoNamedExports_0")' or a default import. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt index 34ba5ce697..330a18d8df 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt @@ -3,8 +3,8 @@ es6ImportNamedImportParsingError_1.ts(1,10): error TS1141: String literal expect es6ImportNamedImportParsingError_1.ts(1,12): error TS1109: Expression expected. es6ImportNamedImportParsingError_1.ts(1,14): error TS1434: Unexpected keyword or identifier. es6ImportNamedImportParsingError_1.ts(1,14): error TS2304: Cannot find name 'from'. +es6ImportNamedImportParsingError_1.ts(2,8): error TS1192: Module '"es6ImportNamedImportParsingError_0"' has no default export. es6ImportNamedImportParsingError_1.ts(2,24): error TS1005: '{' expected. -es6ImportNamedImportParsingError_1.ts(2,29): error TS2307: Cannot find module 'es6ImportNamedImportParsingError_0' or its corresponding type declarations. es6ImportNamedImportParsingError_1.ts(3,1): error TS1128: Declaration or statement expected. es6ImportNamedImportParsingError_1.ts(3,8): error TS1128: Declaration or statement expected. es6ImportNamedImportParsingError_1.ts(3,16): error TS1434: Unexpected keyword or identifier. @@ -20,7 +20,7 @@ es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ';' expected. export var m = a; ==== es6ImportNamedImportParsingError_1.ts (14 errors) ==== - import { * } from "es6ImportNamedImportParsingError_0"; + import { * } from "./es6ImportNamedImportParsingError_0"; ~ !!! error TS1003: Identifier expected. ~ @@ -31,12 +31,12 @@ es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ';' expected. !!! error TS1434: Unexpected keyword or identifier. ~~~~ !!! error TS2304: Cannot find name 'from'. - import defaultBinding, from "es6ImportNamedImportParsingError_0"; + import defaultBinding, from "./es6ImportNamedImportParsingError_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportNamedImportParsingError_0"' has no default export. ~~~~ !!! error TS1005: '{' expected. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'es6ImportNamedImportParsingError_0' or its corresponding type declarations. - import , { a } from "es6ImportNamedImportParsingError_0"; + import , { a } from "./es6ImportNamedImportParsingError_0"; ~~~~~~ !!! error TS1128: Declaration or statement expected. ~ @@ -45,10 +45,10 @@ es6ImportNamedImportParsingError_1.ts(4,20): error TS1005: ';' expected. !!! error TS1434: Unexpected keyword or identifier. ~~~~ !!! error TS2304: Cannot find name 'from'. - import { a }, from "es6ImportNamedImportParsingError_0"; + import { a }, from "./es6ImportNamedImportParsingError_0"; ~ !!! error TS1005: 'from' expected. ~~~~~~ !!! error TS1141: String literal expected. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt.diff deleted file mode 100644 index fdfad12a59..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.es6ImportNamedImportParsingError.errors.txt -+++ new.es6ImportNamedImportParsingError.errors.txt -@@= skipped -2, +2 lines =@@ - es6ImportNamedImportParsingError_1.ts(1,12): error TS1109: Expression expected. - es6ImportNamedImportParsingError_1.ts(1,14): error TS1434: Unexpected keyword or identifier. - es6ImportNamedImportParsingError_1.ts(1,14): error TS2304: Cannot find name 'from'. --es6ImportNamedImportParsingError_1.ts(2,8): error TS1192: Module '"es6ImportNamedImportParsingError_0"' has no default export. - es6ImportNamedImportParsingError_1.ts(2,24): error TS1005: '{' expected. -+es6ImportNamedImportParsingError_1.ts(2,29): error TS2307: Cannot find module 'es6ImportNamedImportParsingError_0' or its corresponding type declarations. - es6ImportNamedImportParsingError_1.ts(3,1): error TS1128: Declaration or statement expected. - es6ImportNamedImportParsingError_1.ts(3,8): error TS1128: Declaration or statement expected. - es6ImportNamedImportParsingError_1.ts(3,16): error TS1434: Unexpected keyword or identifier. -@@= skipped -29, +29 lines =@@ - ~~~~ - !!! error TS2304: Cannot find name 'from'. - import defaultBinding, from "es6ImportNamedImportParsingError_0"; -- ~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportNamedImportParsingError_0"' has no default export. - ~~~~ - !!! error TS1005: '{' expected. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'es6ImportNamedImportParsingError_0' or its corresponding type declarations. - import , { a } from "es6ImportNamedImportParsingError_0"; - ~~~~~~ - !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.js b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.js index 76f14f91ff..733e5c2d14 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.js +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.js @@ -6,10 +6,10 @@ export var x = a; export var m = a; //// [es6ImportNamedImportParsingError_1.ts] -import { * } from "es6ImportNamedImportParsingError_0"; -import defaultBinding, from "es6ImportNamedImportParsingError_0"; -import , { a } from "es6ImportNamedImportParsingError_0"; -import { a }, from "es6ImportNamedImportParsingError_0"; +import { * } from "./es6ImportNamedImportParsingError_0"; +import defaultBinding, from "./es6ImportNamedImportParsingError_0"; +import , { a } from "./es6ImportNamedImportParsingError_0"; +import { a }, from "./es6ImportNamedImportParsingError_0"; //// [es6ImportNamedImportParsingError_0.js] export var a = 10; @@ -17,11 +17,11 @@ export var x = a; export var m = a; //// [es6ImportNamedImportParsingError_1.js] from; -"es6ImportNamedImportParsingError_0"; +"./es6ImportNamedImportParsingError_0"; { a; } from; -"es6ImportNamedImportParsingError_0"; +"./es6ImportNamedImportParsingError_0"; import { a } from , from; -"es6ImportNamedImportParsingError_0"; +"./es6ImportNamedImportParsingError_0"; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.symbols b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.symbols index 107241ff45..e721430df5 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.symbols +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.symbols @@ -13,13 +13,13 @@ export var m = a; >a : Symbol(a, Decl(es6ImportNamedImportParsingError_0.ts, 0, 10)) === es6ImportNamedImportParsingError_1.ts === -import { * } from "es6ImportNamedImportParsingError_0"; -import defaultBinding, from "es6ImportNamedImportParsingError_0"; +import { * } from "./es6ImportNamedImportParsingError_0"; +import defaultBinding, from "./es6ImportNamedImportParsingError_0"; >defaultBinding : Symbol(defaultBinding, Decl(es6ImportNamedImportParsingError_1.ts, 1, 6)) -import , { a } from "es6ImportNamedImportParsingError_0"; +import , { a } from "./es6ImportNamedImportParsingError_0"; >a : Symbol(a, Decl(es6ImportNamedImportParsingError_1.ts, 3, 8)) -import { a }, from "es6ImportNamedImportParsingError_0"; +import { a }, from "./es6ImportNamedImportParsingError_0"; >a : Symbol(a, Decl(es6ImportNamedImportParsingError_1.ts, 3, 8)) diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.types b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.types index 1e563177a3..5621b32b70 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.types +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportParsingError.types @@ -14,25 +14,25 @@ export var m = a; >a : number === es6ImportNamedImportParsingError_1.ts === -import { * } from "es6ImportNamedImportParsingError_0"; +import { * } from "./es6ImportNamedImportParsingError_0"; >* : number > : any > : any >from : any ->"es6ImportNamedImportParsingError_0" : "es6ImportNamedImportParsingError_0" +>"./es6ImportNamedImportParsingError_0" : "./es6ImportNamedImportParsingError_0" -import defaultBinding, from "es6ImportNamedImportParsingError_0"; +import defaultBinding, from "./es6ImportNamedImportParsingError_0"; >defaultBinding : any -import , { a } from "es6ImportNamedImportParsingError_0"; +import , { a } from "./es6ImportNamedImportParsingError_0"; >a : any >from : any ->"es6ImportNamedImportParsingError_0" : "es6ImportNamedImportParsingError_0" +>"./es6ImportNamedImportParsingError_0" : "./es6ImportNamedImportParsingError_0" -import { a }, from "es6ImportNamedImportParsingError_0"; +import { a }, from "./es6ImportNamedImportParsingError_0"; >a : any >, from : any > : any >from : any ->"es6ImportNamedImportParsingError_0" : "es6ImportNamedImportParsingError_0" +>"./es6ImportNamedImportParsingError_0" : "./es6ImportNamedImportParsingError_0" diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithExport.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithExport.js.diff deleted file mode 100644 index 3e0f2c5373..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithExport.js.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.es6ImportNamedImportWithExport.js -+++ new.es6ImportNamedImportWithExport.js -@@= skipped -54, +54 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.z2 = exports.z111 = exports.xxxx = void 0; --var server_1 = require("./server"); -+const server_1 = require("./server"); - exports.xxxx = server_1.a; --var server_2 = require("./server"); -+const server_2 = require("./server"); - exports.xxxx = server_2.a; --var server_3 = require("./server"); -+const server_3 = require("./server"); - exports.xxxx = server_3.x; - exports.xxxx = server_3.a; --var server_4 = require("./server"); -+const server_4 = require("./server"); - exports.xxxx = server_4.x; --var server_5 = require("./server"); -+const server_5 = require("./server"); - exports.xxxx = server_5.m; --var server_6 = require("./server"); -+const server_6 = require("./server"); - exports.xxxx = server_6.a1; - exports.xxxx = server_6.x1; --var server_7 = require("./server"); -+const server_7 = require("./server"); - exports.xxxx = server_7.a1; - exports.xxxx = server_7.x1; --var server_8 = require("./server"); -+const server_8 = require("./server"); - exports.z111 = server_8.z1; --var server_9 = require("./server"); -+const server_9 = require("./server"); - exports.z2 = server_9.z2; // z2 shouldn't give redeclare error - diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithTypesAndValues.js.diff b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithTypesAndValues.js.diff index 5cb9073eb2..b3348520b5 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithTypesAndValues.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ImportNamedImportWithTypesAndValues.js.diff @@ -17,11 +17,4 @@ + prop2 = "world"; } exports.C2 = C2; - //// [client.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.cVal = void 0; --var server_1 = require("./server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file -+const server_1 = require("./server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file - exports.cVal = new server_1.C(); - + //// [client.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInterop.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInterop.js.diff deleted file mode 100644 index 2984280048..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInterop.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.esModuleInterop.js -+++ new.esModuleInterop.js -@@= skipped -56, +56 lines =@@ - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var hybrid_1 = require("./hybrid"); --var path_1 = __importDefault(require("./path")); --var fs = __importStar(require("./fs")); -+const hybrid_1 = require("./hybrid"); -+const path_1 = __importDefault(require("./path")); -+const fs = __importStar(require("./fs")); - path_1.default; - (0, hybrid_1.sayHello)(); - fs; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultImports.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultImports.js.diff index 4d24abf74d..3df8093184 100644 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultImports.js.diff +++ b/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultImports.js.diff @@ -1,27 +1,10 @@ --- old.esModuleInteropDefaultImports.js +++ new.esModuleInteropDefaultImports.js -@@= skipped -41, +41 lines =@@ - exports.default = fun; - //// [a.js] - "use strict"; --var mod = require("./mod"); -+const mod = require("./mod"); - module.exports = mod; - //// [b.js] - "use strict"; -@@= skipped -42, +42 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.def = exports.default = void 0; --var a_1 = __importDefault(require("./a")); --var a_2 = __importDefault(require("./a")); --var a_3 = __importDefault(require("./a")); --var self = __importStar(require("./b")); +@@= skipped -87, +87 lines =@@ + const a_2 = __importDefault(require("./a")); + const a_3 = __importDefault(require("./a")); + const self = __importStar(require("./b")); -var a_4 = require("./a"); -+const a_1 = __importDefault(require("./a")); -+const a_2 = __importDefault(require("./a")); -+const a_3 = __importDefault(require("./a")); -+const self = __importStar(require("./b")); +const a_4 = require("./a"); Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(a_4).default; } }); -var a_5 = require("./a"); diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultMemberMustBeSyntacticallyDefaultExport.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultMemberMustBeSyntacticallyDefaultExport.js.diff deleted file mode 100644 index 265e37fbe9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropDefaultMemberMustBeSyntacticallyDefaultExport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.esModuleInteropDefaultMemberMustBeSyntacticallyDefaultExport.js -+++ new.esModuleInteropDefaultMemberMustBeSyntacticallyDefaultExport.js -@@= skipped -23, +23 lines =@@ - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var point_1 = __importDefault(require("./point")); -+const point_1 = __importDefault(require("./point")); - const C = point_1.default; - const p = new C(1, 2); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropImportCall.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropImportCall.js.diff deleted file mode 100644 index 558a6649b8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropImportCall.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.esModuleInteropImportCall.js -+++ new.esModuleInteropImportCall.js -@@= skipped -43, +43 lines =@@ - return result; - }; - })(); --Promise.resolve().then(function () { return __importStar(require("./foo")); }).then(f => { -+Promise.resolve().then(() => __importStar(require("./foo"))).then(f => { - f.default; - }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.js.diff deleted file mode 100644 index f19e80f484..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.js -+++ new.esModuleInteropImportDefaultWhenAllNamedAreDefaultAlias.js -@@= skipped -10, +10 lines =@@ - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var m_1 = __importDefault(require("m")); -+const m_1 = __importDefault(require("m")); - void m_1.default; - void m_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropImportNamespace.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropImportNamespace.js.diff deleted file mode 100644 index 4d528e5341..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropImportNamespace.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.esModuleInteropImportNamespace.js -+++ new.esModuleInteropImportNamespace.js -@@= skipped -45, +45 lines =@@ - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); --var foo = __importStar(require("./foo")); -+const foo = __importStar(require("./foo")); - foo.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropNamedDefaultImports.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropNamedDefaultImports.js.diff deleted file mode 100644 index 93eefcf4dc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropNamedDefaultImports.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.esModuleInteropNamedDefaultImports.js -+++ new.esModuleInteropNamedDefaultImports.js -@@= skipped -60, +60 lines =@@ - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var mod_1 = __importDefault(require("./mod")); --var mod_2 = __importDefault(require("./mod")); --var mod_3 = __importStar(require("./mod")); -+const mod_1 = __importDefault(require("./mod")); -+const mod_2 = __importDefault(require("./mod")); -+const mod_3 = __importStar(require("./mod")); - new mod_1.default(); - new mod_2.default(); - new mod_3.Bar(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropPrettyErrorRelatedInformation.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropPrettyErrorRelatedInformation.js.diff deleted file mode 100644 index 8d6125ffe9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropPrettyErrorRelatedInformation.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.esModuleInteropPrettyErrorRelatedInformation.js -+++ new.esModuleInteropPrettyErrorRelatedInformation.js -@@= skipped -45, +45 lines =@@ - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); --var foo = __importStar(require("./foo")); -+const foo = __importStar(require("./foo")); - function invoke(f) { f(); } - invoke(foo); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropTslibHelpers.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropTslibHelpers.js.diff deleted file mode 100644 index 29b8bcd865..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropTslibHelpers.js.diff +++ /dev/null @@ -1,45 +0,0 @@ ---- old.esModuleInteropTslibHelpers.js -+++ new.esModuleInteropTslibHelpers.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo = void 0; --var tslib_1 = require("tslib"); --var path_1 = tslib_1.__importDefault(require("path")); -+const tslib_1 = require("tslib"); -+const path_1 = tslib_1.__importDefault(require("path")); - path_1.default.resolve("", "../"); - class Foo { - } -@@= skipped -10, +10 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo2 = void 0; --var tslib_1 = require("tslib"); --var path = tslib_1.__importStar(require("path")); -+const tslib_1 = require("tslib"); -+const path = tslib_1.__importStar(require("path")); - path.resolve("", "../"); - class Foo2 { - } -@@= skipped -10, +10 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo3 = void 0; --var tslib_1 = require("tslib"); --var path_1 = tslib_1.__importDefault(require("path")); -+const tslib_1 = require("tslib"); -+const path_1 = tslib_1.__importDefault(require("path")); - (0, path_1.default)("", "../"); - class Foo3 { - } -@@= skipped -10, +10 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Bar = void 0; --var tslib_1 = require("tslib"); --var path_1 = tslib_1.__importStar(require("path")); -+const tslib_1 = require("tslib"); -+const path_1 = tslib_1.__importStar(require("path")); - Object.defineProperty(exports, "Bar", { enumerable: true, get: function () { return path_1.Bar; } }); - (0, path_1.default)("", "../"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropUsesExportStarWhenDefaultPlusNames.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropUsesExportStarWhenDefaultPlusNames.js.diff deleted file mode 100644 index 55b7e6e2e9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropUsesExportStarWhenDefaultPlusNames.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.esModuleInteropUsesExportStarWhenDefaultPlusNames.js -+++ new.esModuleInteropUsesExportStarWhenDefaultPlusNames.js -@@= skipped -40, +40 lines =@@ - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); --var dep_1 = __importStar(require("./dep")); -+const dep_1 = __importStar(require("./dep")); - void dep_1.default; - void dep_1.var2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/esModuleInteropWithExportStar.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleInteropWithExportStar.js.diff index 9b7e71879a..aa30c76447 100644 --- a/testdata/baselines/reference/submodule/compiler/esModuleInteropWithExportStar.js.diff +++ b/testdata/baselines/reference/submodule/compiler/esModuleInteropWithExportStar.js.diff @@ -1,11 +1,7 @@ --- old.esModuleInteropWithExportStar.js +++ new.esModuleInteropWithExportStar.js -@@= skipped -51, +51 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.y = exports.x = void 0; --var fs = __importStar(require("./fs")); -+const fs = __importStar(require("./fs")); +@@= skipped -54, +54 lines =@@ + const fs = __importStar(require("./fs")); fs; __exportStar(require("./fs"), exports); -var fs_1 = require("./fs"); diff --git a/testdata/baselines/reference/submodule/compiler/esModuleIntersectionCrash.js.diff b/testdata/baselines/reference/submodule/compiler/esModuleIntersectionCrash.js.diff deleted file mode 100644 index 65eac7792f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/esModuleIntersectionCrash.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.esModuleIntersectionCrash.js -+++ new.esModuleIntersectionCrash.js -@@= skipped -47, +47 lines =@@ - }; - })(); - Object.defineProperty(exports, "__esModule", { value: true }); --var mod = __importStar(require("./mod")); -+const mod = __importStar(require("./mod")); - mod.a; - mod.b; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt b/testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt new file mode 100644 index 0000000000..fd747ba80e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt @@ -0,0 +1,10 @@ +evalAfter0.ts(4,2): error TS2695: Left side of comma operator is unused and has no side effects. + + +==== evalAfter0.ts (1 errors) ==== + (0,eval)("10"); // fine: special case for eval + + declare var eva; + (0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something) + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt.diff deleted file mode 100644 index 720d6a66af..0000000000 --- a/testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.evalAfter0.errors.txt -+++ new.evalAfter0.errors.txt -@@= skipped -0, +0 lines =@@ --evalAfter0.ts(4,2): error TS2695: Left side of comma operator is unused and has no side effects. -- -- --==== evalAfter0.ts (1 errors) ==== -- (0,eval)("10"); // fine: special case for eval -- -- declare var eva; -- (0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something) -- ~ --!!! error TS2695: Left side of comma operator is unused and has no side effects. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js b/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js index 567f6b58da..5421b15e0b 100644 --- a/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js +++ b/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js @@ -14,3 +14,4 @@ interface B extends A { } //// [eventEmitterPatternWithRecordOfFunction.js] +"use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js.diff b/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js.diff deleted file mode 100644 index 59094d6184..0000000000 --- a/testdata/baselines/reference/submodule/compiler/eventEmitterPatternWithRecordOfFunction.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.eventEmitterPatternWithRecordOfFunction.js -+++ new.eventEmitterPatternWithRecordOfFunction.js -@@= skipped -13, +13 lines =@@ - } - - //// [eventEmitterPatternWithRecordOfFunction.js] --"use strict"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js b/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js index 88422a6c52..76efc28dd9 100644 --- a/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js +++ b/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js @@ -9,6 +9,7 @@ for (var a in C) { //// [evolvingArrayResolvedAssert.js] +"use strict"; var C = []; for (var a in C) { if (C.hasOwnProperty(a)) { diff --git a/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js.diff b/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js.diff deleted file mode 100644 index 67d1d02463..0000000000 --- a/testdata/baselines/reference/submodule/compiler/evolvingArrayResolvedAssert.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.evolvingArrayResolvedAssert.js -+++ new.evolvingArrayResolvedAssert.js -@@= skipped -8, +8 lines =@@ - - - //// [evolvingArrayResolvedAssert.js] --"use strict"; - var C = []; - for (var a in C) { - if (C.hasOwnProperty(a)) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js b/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js index 42b62d11f4..90927062e3 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js @@ -7,4 +7,5 @@ fn({ z: 3, a: 3 }); //// [excessPropertiesInOverloads.js] +"use strict"; fn({ z: 3, a: 3 }); diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js.diff deleted file mode 100644 index b8b027978e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertiesInOverloads.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.excessPropertiesInOverloads.js -+++ new.excessPropertiesInOverloads.js -@@= skipped -6, +6 lines =@@ - - - //// [excessPropertiesInOverloads.js] --"use strict"; - fn({ z: 3, a: 3 }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js index 349edda7b7..74b91666fe 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js @@ -18,6 +18,7 @@ const yy: Record & Record = { //// [excessPropertyCheckIntersectionWithIndexSignature.js] +"use strict"; // Repro from #51875 let x; x = { y: { a: 0 } }; // Error diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js.diff deleted file mode 100644 index 5156612962..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckIntersectionWithIndexSignature.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessPropertyCheckIntersectionWithIndexSignature.js -+++ new.excessPropertyCheckIntersectionWithIndexSignature.js -@@= skipped -17, +17 lines =@@ - - - //// [excessPropertyCheckIntersectionWithIndexSignature.js] --"use strict"; - // Repro from #51875 - let x; - x = { y: { a: 0 } }; // Error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js index a81be3a2ca..7c0a7f2eda 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js @@ -144,6 +144,7 @@ const attributes2: Attribute2 = { //// [excessPropertyCheckWithMultipleDiscriminants.js] "use strict"; +// Repro from #32657 Object.defineProperty(exports, "__esModule", { value: true }); const foo = { type: "number", diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js.diff deleted file mode 100644 index 9f32319ccc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessPropertyCheckWithMultipleDiscriminants.js -+++ new.excessPropertyCheckWithMultipleDiscriminants.js -@@= skipped -143, +143 lines =@@ - - //// [excessPropertyCheckWithMultipleDiscriminants.js] - "use strict"; --// Repro from #32657 - Object.defineProperty(exports, "__esModule", { value: true }); - const foo = { - type: "number", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithSpread.js b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithSpread.js index a05d342391..a5de2298a1 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithSpread.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithSpread.js @@ -20,16 +20,5 @@ f({ a: 1, ...l, ...r }); //// [excessPropertyCheckWithSpread.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -f(__assign({ a: 1 }, i)); -f(__assign(__assign({ a: 1 }, l), r)); +f(Object.assign({ a: 1 }, i)); +f(Object.assign(Object.assign({ a: 1 }, l), r)); diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js index 269fade2d4..599c84f4b8 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js @@ -155,17 +155,7 @@ F2({ //// [excessPropertyCheckWithUnions.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; +"use strict"; let wrong = { tag: "T", a1: "extra" }; wrong = { tag: "A", d20: 12 }; wrong = { tag: "D" }; @@ -184,7 +174,7 @@ let over; // these two are still errors despite their doubled up discriminants over = { a: 1, b: 1, first: "ok", second: "error" }; over = { a: 1, b: 1, first: "ok", third: "error" }; -let t2 = __assign({}, t1); +let t2 = Object.assign({}, t1); t0 = t2; const abab = { kind: "A", diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js.diff deleted file mode 100644 index 05b1283df7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithUnions.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessPropertyCheckWithUnions.js -+++ new.excessPropertyCheckWithUnions.js -@@= skipped -154, +154 lines =@@ - - - //// [excessPropertyCheckWithUnions.js] --"use strict"; - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js b/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js index 2da41c0e26..1d1a6bde39 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js @@ -75,6 +75,7 @@ test = { foo: true, bar: { foo: true, bar: true, boo: true } } //// [excessPropertyChecksWithNestedIntersections.js] "use strict"; +// https://github.com/Microsoft/TypeScript/issues/13813 Object.defineProperty(exports, "__esModule", { value: true }); exports.myInstance = exports.photo = exports.obj = void 0; let a = { a: { x: 'hello' } }; // ok diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js.diff deleted file mode 100644 index f87d79cdcf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessPropertyChecksWithNestedIntersections.js -+++ new.excessPropertyChecksWithNestedIntersections.js -@@= skipped -74, +74 lines =@@ - - //// [excessPropertyChecksWithNestedIntersections.js] - "use strict"; --// https://github.com/Microsoft/TypeScript/issues/13813 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.myInstance = exports.photo = exports.obj = void 0; - let a = { a: { x: 'hello' } }; // ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js b/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js index b6e2180083..13fd6616f4 100644 --- a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js +++ b/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js @@ -48,6 +48,8 @@ configureStore({ }); const Component = () => { const categories = ['Fruit', 'Vegetables']; - return (React.createElement("ul", null, React.createElement("li", null, "All"), categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only - )))); + return (React.createElement("ul", null, + React.createElement("li", null, "All"), + categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only + )))); }; diff --git a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js.diff b/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js.diff deleted file mode 100644 index 0fd96a87b2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.excessiveStackDepthFlatArray.js -+++ new.excessiveStackDepthFlatArray.js -@@= skipped -47, +47 lines =@@ - }); - const Component = () => { - const categories = ['Fruit', 'Vegetables']; -- return (React.createElement("ul", null, -- React.createElement("li", null, "All"), -- categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only -- )))); -+ return (React.createElement("ul", null, React.createElement("li", null, "All"), categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only -+ )))); - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js b/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js index 5f3c2cb38a..eb963d74e4 100644 --- a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js +++ b/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js @@ -42,6 +42,7 @@ const a14 = [...a13, ...a13] as const; // 2^14 > 10,000 //// [excessivelyLargeTupleSpread.js] +// #41771 const a0 = [0]; const a1 = [...a0, ...a0]; const a2 = [...a1, ...a1]; diff --git a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js.diff b/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js.diff deleted file mode 100644 index 92979b3175..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessivelyLargeTupleSpread.js -+++ new.excessivelyLargeTupleSpread.js -@@= skipped -41, +41 lines =@@ - - - //// [excessivelyLargeTupleSpread.js] --// #41771 - const a0 = [0]; - const a1 = [...a0, ...a0]; - const a2 = [...a1, ...a1]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js index e92726d1c4..8357fd67e0 100644 --- a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js +++ b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js @@ -40,6 +40,8 @@ function functionC(): void { //// [exhaustiveSwitchCheckCircularity.js] +"use strict"; +// Repro from #47539 function f() { let foo = "aaa"; while (true) { diff --git a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff deleted file mode 100644 index 993390a5ce..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.exhaustiveSwitchCheckCircularity.js -+++ new.exhaustiveSwitchCheckCircularity.js -@@= skipped -39, +39 lines =@@ - - - //// [exhaustiveSwitchCheckCircularity.js] --"use strict"; --// Repro from #47539 - function f() { - let foo = "aaa"; - while (true) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js index 1b37891205..dfa5893abe 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js @@ -22,10 +22,10 @@ if (Math.random()) { //// [expandoFunctionBlockShadowing.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/56538 Object.defineProperty(exports, "__esModule", { value: true }); exports.X = X; exports.Y = Y; -// https://github.com/microsoft/TypeScript/issues/56538 function X() { } if (Math.random()) { const X = {}; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js.diff deleted file mode 100644 index ad675825bb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.expandoFunctionBlockShadowing.js -+++ new.expandoFunctionBlockShadowing.js -@@= skipped -21, +21 lines =@@ - - //// [expandoFunctionBlockShadowing.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/56538 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.X = X; - exports.Y = Y; -+// https://github.com/microsoft/TypeScript/issues/56538 - function X() { } - if (Math.random()) { - const X = {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt deleted file mode 100644 index 267621261d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ /dev/null @@ -1,61 +0,0 @@ -input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== input.js (1 errors) ==== - /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ - - /** - * @template P - * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ - - /** - * @type {StatelessComponent} - */ - const MyComponent = () => /* @type {any} */(null); - - MyComponent.defaultProps = { - color: "red" - }; - - const MyComponent2 = () => null; - - /** - * @type {MyComponentProps} - */ - MyComponent2.defaultProps = { - color: "red" - } - - /** - * @type {StatelessComponent} - */ - const check = MyComponent2; - - /** - * - * @param {{ props: MyComponentProps }} p - */ - function expectLiteral(p) {} - - function foo() { - /** - * @type {MyComponentProps} - */ - this.props = { color: "red" }; - - expectLiteral(this); - } - - /** - * @type {MyComponentProps} - */ - module.exports = { - ~~~~~~~~~~~~~~~~~~ - color: "red" - ~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - expectLiteral({ props: module.exports }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols index 814586c8ea..e61e42ed24 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols @@ -71,7 +71,7 @@ function foo() { */ module.exports = { >module.exports : Symbol(export=, Decl(input.js, 42, 1)) ->module : Symbol(module.exports) +>module : Symbol("input", Decl(input.js, 0, 0)) >exports : Symbol(export=, Decl(input.js, 42, 1)) color: "red" @@ -82,6 +82,6 @@ expectLiteral({ props: module.exports }); >expectLiteral : Symbol(expectLiteral, Decl(input.js, 27, 27)) >props : Symbol(props, Decl(input.js, 51, 15)) >module.exports : Symbol(export=, Decl(input.js, 42, 1)) ->module : Symbol(module.exports) +>module : Symbol("input", Decl(input.js, 0, 0)) >exports : Symbol(export=, Decl(input.js, 42, 1)) diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff index b80e0680f8..7e898bf0fd 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff @@ -61,7 +61,7 @@ ->module.exports : Symbol(module.exports, Decl(input.js, 0, 0)) ->module : Symbol(export=, Decl(input.js, 42, 1)) +>module.exports : Symbol(export=, Decl(input.js, 42, 1)) -+>module : Symbol(module.exports) ++>module : Symbol("input", Decl(input.js, 0, 0)) >exports : Symbol(export=, Decl(input.js, 42, 1)) color: "red" @@ -73,5 +73,5 @@ ->module : Symbol(module, Decl(input.js, 42, 1), Decl(input.js, 51, 22)) ->exports : Symbol(module.exports, Decl(input.js, 0, 0)) +>module.exports : Symbol(export=, Decl(input.js, 42, 1)) -+>module : Symbol(module.exports) ++>module : Symbol("input", Decl(input.js, 0, 0)) +>exports : Symbol(export=, Decl(input.js, 42, 1)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff rename to testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js index a1f8110ceb..3b4d5eb362 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js @@ -11,9 +11,12 @@ Foo.bar = () => { }; //// [expandoFunctionContextualTypesNoValue.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.Foo = Foo; // GH #38532 -const blah_1 = require("blah"); +const blah_1 = __importDefault(require("blah")); function Foo() { } blah_1.default.bar = () => { }; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js.diff deleted file mode 100644 index 4720f816ff..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesNoValue.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.expandoFunctionContextualTypesNoValue.js -+++ new.expandoFunctionContextualTypesNoValue.js -@@= skipped -13, +13 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo = Foo; - // GH #38532 --var blah_1 = require("blah"); -+const blah_1 = require("blah"); - function Foo() { } - blah_1.default.bar = () => { }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js index 054a90b860..da77799946 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js @@ -14,9 +14,9 @@ expr2[s] = 0 //// [expandoFunctionExpressionsWithDynamicNames.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/54809 Object.defineProperty(exports, "__esModule", { value: true }); exports.expr2 = exports.expr = void 0; -// https://github.com/microsoft/TypeScript/issues/54809 const s = "X"; const expr = () => { }; exports.expr = expr; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff index df20fd2068..bc387e9ed0 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff @@ -1,17 +1,6 @@ --- old.expandoFunctionExpressionsWithDynamicNames.js +++ new.expandoFunctionExpressionsWithDynamicNames.js -@@= skipped -13, +13 lines =@@ - - //// [expandoFunctionExpressionsWithDynamicNames.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/54809 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.expr2 = exports.expr = void 0; -+// https://github.com/microsoft/TypeScript/issues/54809 - const s = "X"; - const expr = () => { }; - exports.expr = expr; -@@= skipped -13, +13 lines =@@ +@@= skipped -26, +26 lines =@@ //// [expandoFunctionExpressionsWithDynamicNames.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js index eaa83e486c..cd98400344 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js @@ -38,6 +38,7 @@ export function testUndefined(): TestUndefined { //// [expandoFunctionNullishProperty.js] +// mentioned in https://github.com/microsoft/TypeScript/issues/54220 export function testNull() { function inner() { } inner.prop = null; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js.diff deleted file mode 100644 index f5d6dc439b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.expandoFunctionNullishProperty.js -+++ new.expandoFunctionNullishProperty.js -@@= skipped -37, +37 lines =@@ - - - //// [expandoFunctionNullishProperty.js] --// mentioned in https://github.com/microsoft/TypeScript/issues/54220 - export function testNull() { - function inner() { } - inner.prop = null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.js.diff index 3c63bfc7f6..8c79a52141 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.js.diff +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.js.diff @@ -1,15 +1,6 @@ --- old.expandoFunctionSymbolPropertyJs.js +++ new.expandoFunctionSymbolPropertyJs.js -@@= skipped -28, +28 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.test = test; --var types_1 = require("./types"); -+const types_1 = require("./types"); - /** - * @returns {import("./types").TestSymb} - */ -@@= skipped -21, +21 lines =@@ +@@= skipped -49, +49 lines =@@ /** * @returns {import("./types").TestSymb} */ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.types.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.types.diff rename to testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js.diff b/testdata/baselines/reference/submodule/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js.diff index 131d8587e6..131321b18c 100644 --- a/testdata/baselines/reference/submodule/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js.diff +++ b/testdata/baselines/reference/submodule/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js.diff @@ -16,19 +16,13 @@ -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; --let Foo = (() => { -- var _a, _b, _c, _d; -- class Foo { -- f(user) { } -- } -- __decorate([ -- __param(0, decorate), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [typeof (_d = typeof A !== "undefined" && (_a = A.B) !== void 0 && (_b = _a.C) !== void 0 && (_c = _b.D) !== void 0 && _c.E) === "function" ? _d : Object]), -- __metadata("design:returntype", void 0) -- ], Foo.prototype, "f", null); -- return Foo; --})(); -+class Foo { -+ f(user) { } -+} \ No newline at end of file +-var _a, _b, _c, _d; + class Foo { + f(user) { } + } +-__decorate([ +- __param(0, decorate), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [typeof (_d = typeof A !== "undefined" && (_a = A.B) !== void 0 && (_b = _a.C) !== void 0 && (_c = _b.D) !== void 0 && _c.E) === "function" ? _d : Object]), +- __metadata("design:returntype", void 0) +-], Foo.prototype, "f", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/explicitAnyAfterSpreadNoImplicitAnyError.js b/testdata/baselines/reference/submodule/compiler/explicitAnyAfterSpreadNoImplicitAnyError.js index 5cd098b2d1..23bc21278c 100644 --- a/testdata/baselines/reference/submodule/compiler/explicitAnyAfterSpreadNoImplicitAnyError.js +++ b/testdata/baselines/reference/submodule/compiler/explicitAnyAfterSpreadNoImplicitAnyError.js @@ -6,16 +6,5 @@ let x: any; //// [explicitAnyAfterSpreadNoImplicitAnyError.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -(__assign({ a: [] }, null)); +(Object.assign({ a: [] }, null)); let x; diff --git a/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt index 4b08c73606..0008df30a8 100644 --- a/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt @@ -1,9 +1,12 @@ +/a.d.ts(2,1): error TS2303: Circular definition of import alias 'N'. /a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'. -==== /a.d.ts (1 errors) ==== +==== /a.d.ts (2 errors) ==== declare global { namespace N {} } export = N; + ~~~~~~~~~~~ +!!! error TS2303: Circular definition of import alias 'N'. export as namespace N; ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'N'. diff --git a/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff new file mode 100644 index 0000000000..78e304bf69 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.exportAsNamespaceConflict.errors.txt ++++ new.exportAsNamespaceConflict.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.d.ts(2,1): error TS2303: Circular definition of import alias 'N'. + /a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'. + + +-==== /a.d.ts (1 errors) ==== ++==== /a.d.ts (2 errors) ==== + declare global { namespace N {} } + export = N; ++ ~~~~~~~~~~~ ++!!! error TS2303: Circular definition of import alias 'N'. + export as namespace N; + ~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2303: Circular definition of import alias 'N'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js b/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js index f9e2e39be2..4115dbc13d 100644 --- a/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js +++ b/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js @@ -26,7 +26,40 @@ a2.x + a2.y + a2.z + a2.conflict; //// [b.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const a2 = require("./a"); +const a2 = __importStar(require("./a")); a.x + a.y + a.z + a.conflict; a2.x + a2.y + a2.z + a2.conflict; diff --git a/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js.diff b/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js.diff deleted file mode 100644 index c5c1ca6d36..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAsNamespace_augment.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.exportAsNamespace_augment.js -+++ new.exportAsNamespace_augment.js -@@= skipped -26, +26 lines =@@ - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a2 = require("./a"); -+const a2 = require("./a"); - a.x + a.y + a.z + a.conflict; - a2.x + a2.y + a2.z + a2.conflict; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.js.diff deleted file mode 100644 index 9df2ffa85b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.exportAssignedNamespaceIsVisibleInDeclarationEmit.js -+++ new.exportAssignedNamespaceIsVisibleInDeclarationEmit.js -@@= skipped -13, +13 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.thing = void 0; --var thing_1 = require("./thing"); -+const thing_1 = require("./thing"); - exports.thing = (0, thing_1.f)(); - diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentEnum.js.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentEnum.js.diff deleted file mode 100644 index 202b5b9f9b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentEnum.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.exportAssignmentEnum.js -+++ new.exportAssignmentEnum.js -@@= skipped -27, +27 lines =@@ - //// [exportAssignmentEnum_B.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var EnumE = require("./exportAssignmentEnum_A"); -+const EnumE = require("./exportAssignmentEnum_A"); - var a = EnumE.A; - var b = EnumE.B; - var c = EnumE.C; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt b/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt index 4d54d16ef5..7a53980c7f 100644 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt @@ -1,6 +1,6 @@ -/index.ts(7,7): error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. +/index.ts(7,7): error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. Types of property 'configs' are incompatible. - Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. + Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. Property ''stage-0'' is incompatible with index signature. Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. Types of property 'parser' are incompatible. @@ -43,9 +43,9 @@ const p: Plugin = pluginImportX; ~ -!!! error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. +!!! error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. !!! error TS2322: Types of property 'configs' are incompatible. -!!! error TS2322: Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. +!!! error TS2322: Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. !!! error TS2322: Property ''stage-0'' is incompatible with index signature. !!! error TS2322: Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. !!! error TS2322: Types of property 'parser' are incompatible. diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt.diff deleted file mode 100644 index aa4d5bb0b8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.exportAssignmentExpressionIsExpressionNode.errors.txt -+++ new.exportAssignmentExpressionIsExpressionNode.errors.txt -@@= skipped -0, +0 lines =@@ --/index.ts(7,7): error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. -+/index.ts(7,7): error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. - Types of property 'configs' are incompatible. -- Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. -+ Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. - Property ''stage-0'' is incompatible with index signature. - Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. - Types of property 'parser' are incompatible. -@@= skipped -42, +42 lines =@@ - - const p: Plugin = pluginImportX; - ~ --!!! error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. -+!!! error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. - !!! error TS2322: Types of property 'configs' are incompatible. --!!! error TS2322: Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. -+!!! error TS2322: Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. - !!! error TS2322: Property ''stage-0'' is incompatible with index signature. - !!! error TS2322: Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. - !!! error TS2322: Types of property 'parser' are incompatible. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js b/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js index 5c1f547dc2..476b9d75d0 100644 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js +++ b/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js @@ -19,7 +19,10 @@ exports.default = { }; //// [user.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.Obj = void 0; -const assignment_1 = require("./assignment"); +const assignment_1 = __importDefault(require("./assignment")); exports.Obj = void exports.Obj; diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js.diff deleted file mode 100644 index ac3193c841..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentImportMergeNoCrash.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportAssignmentImportMergeNoCrash.js -+++ new.exportAssignmentImportMergeNoCrash.js -@@= skipped -20, +20 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Obj = void 0; --var assignment_1 = require("./assignment"); -+const assignment_1 = require("./assignment"); - exports.Obj = void exports.Obj; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentVariable.js.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentVariable.js.diff deleted file mode 100644 index 4f2c34796c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentVariable.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportAssignmentVariable.js -+++ new.exportAssignmentVariable.js -@@= skipped -16, +16 lines =@@ - //// [exportAssignmentVariable_B.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var y = require("./exportAssignmentVariable_A"); -+const y = require("./exportAssignmentVariable_A"); - var n = y; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.errors.txt.diff deleted file mode 100644 index 313279aa28..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.exportAssignmentWithoutAllowSyntheticDefaultImportsError.errors.txt -+++ new.exportAssignmentWithoutAllowSyntheticDefaultImportsError.errors.txt -@@= skipped -0, +0 lines =@@ - /bar.ts(1,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. --/foo.ts(1,8): error TS1259: Module '"/bar"' can only be default-imported using the 'allowSyntheticDefaultImports' flag - - - ==== /bar.ts (1 errors) ==== -@@= skipped -7, +6 lines =@@ - !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - function bar() {} - --==== /foo.ts (1 errors) ==== -+==== /foo.ts (0 errors) ==== - import bar from './bar'; -- ~~~ --!!! error TS1259: Module '"/bar"' can only be default-imported using the 'allowSyntheticDefaultImports' flag --!!! related TS2594 /bar.ts:1:1: This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.types.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.types.diff deleted file mode 100644 index 1fc793e38e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentWithoutAllowSyntheticDefaultImportsError.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.exportAssignmentWithoutAllowSyntheticDefaultImportsError.types -+++ new.exportAssignmentWithoutAllowSyntheticDefaultImportsError.types -@@= skipped -8, +8 lines =@@ - - === /foo.ts === - import bar from './bar'; -->bar : any -+>bar : () => void diff --git a/testdata/baselines/reference/submodule/compiler/exportClassExtendingIntersection.js.diff b/testdata/baselines/reference/submodule/compiler/exportClassExtendingIntersection.js.diff index 3ae7308b38..4b34c32ba5 100644 --- a/testdata/baselines/reference/submodule/compiler/exportClassExtendingIntersection.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportClassExtendingIntersection.js.diff @@ -16,23 +16,11 @@ }; } //// [FinalClass.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.MyExtendedClass = void 0; --var BaseClass_1 = require("./BaseClass"); --var MixinClass_1 = require("./MixinClass"); -+const BaseClass_1 = require("./BaseClass"); -+const MixinClass_1 = require("./MixinClass"); +@@= skipped -9, +10 lines =@@ + const BaseClass_1 = require("./BaseClass"); + const MixinClass_1 = require("./MixinClass"); class MyExtendedClass extends (0, MixinClass_1.MyMixin)(BaseClass_1.MyBaseClass) { + extendedClassProperty; } exports.MyExtendedClass = MyExtendedClass; - //// [Main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var FinalClass_1 = require("./FinalClass"); --var MixinClass_1 = require("./MixinClass"); -+const FinalClass_1 = require("./FinalClass"); -+const MixinClass_1 = require("./MixinClass"); - const myExtendedClass = new FinalClass_1.MyExtendedClass('string'); - const AnotherMixedClass = (0, MixinClass_1.MyMixin)(FinalClass_1.MyExtendedClass); + //// [Main.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js b/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js index 56044df4b6..e8fe3f601b 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js +++ b/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js @@ -18,9 +18,9 @@ export { B } //// [exportDeclarationForModuleOrEnumWithMemberOfSameName.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/55038 Object.defineProperty(exports, "__esModule", { value: true }); exports.B = exports.A = void 0; -// https://github.com/microsoft/TypeScript/issues/55038 var A; (function (A_1) { A_1.A = 0; diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js.diff b/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js.diff deleted file mode 100644 index 9675ac592a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js -+++ new.exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js -@@= skipped -17, +17 lines =@@ - - //// [exportDeclarationForModuleOrEnumWithMemberOfSameName.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/55038 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.B = exports.A = void 0; -+// https://github.com/microsoft/TypeScript/issues/55038 - var A; - (function (A_1) { - A_1.A = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.errors.txt b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.errors.txt new file mode 100644 index 0000000000..d175c12c00 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.errors.txt @@ -0,0 +1,18 @@ +exportDeclareClass1.ts(2,21): error TS1183: An implementation cannot be declared in ambient contexts. +exportDeclareClass1.ts(3,31): error TS1183: An implementation cannot be declared in ambient contexts. + + +==== exportDeclareClass1.ts (2 errors) ==== + export declare class eaC { + static tF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static tsF(param:any) { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + }; + + export declare class eaC2 { + static tF(); + static tsF(param:any); + }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.js b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.js new file mode 100644 index 0000000000..c0aadda389 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/exportDeclareClass1.ts] //// + +//// [exportDeclareClass1.ts] + export declare class eaC { + static tF() { }; + static tsF(param:any) { }; + }; + + export declare class eaC2 { + static tF(); + static tsF(param:any); + }; + +//// [exportDeclareClass1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +; +; diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.symbols b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.symbols new file mode 100644 index 0000000000..ad4f0a5aea --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/exportDeclareClass1.ts] //// + +=== exportDeclareClass1.ts === + export declare class eaC { +>eaC : Symbol(eaC, Decl(exportDeclareClass1.ts, 0, 0)) + + static tF() { }; +>tF : Symbol(eaC.tF, Decl(exportDeclareClass1.ts, 0, 30)) + + static tsF(param:any) { }; +>tsF : Symbol(eaC.tsF, Decl(exportDeclareClass1.ts, 1, 24)) +>param : Symbol(param, Decl(exportDeclareClass1.ts, 2, 19)) + + }; + + export declare class eaC2 { +>eaC2 : Symbol(eaC2, Decl(exportDeclareClass1.ts, 3, 6)) + + static tF(); +>tF : Symbol(eaC2.tF, Decl(exportDeclareClass1.ts, 5, 28)) + + static tsF(param:any); +>tsF : Symbol(eaC2.tsF, Decl(exportDeclareClass1.ts, 6, 20)) +>param : Symbol(param, Decl(exportDeclareClass1.ts, 7, 19)) + + }; diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.types b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.types new file mode 100644 index 0000000000..bb0796ae62 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportDeclareClass1.types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/exportDeclareClass1.ts] //// + +=== exportDeclareClass1.ts === + export declare class eaC { +>eaC : eaC + + static tF() { }; +>tF : () => void + + static tsF(param:any) { }; +>tsF : (param: any) => void +>param : any + + }; + + export declare class eaC2 { +>eaC2 : eaC2 + + static tF(); +>tF : () => any + + static tsF(param:any); +>tsF : (param: any) => any +>param : any + + }; diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js b/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js index f8a6e5aeda..1760cbfbe9 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js @@ -24,8 +24,11 @@ class B extends A { new B().a.toExponential(); //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); class C extends a_1.default { } new C().a.toExponential(); diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js.diff index b297e0f6f6..03dc85abcc 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAbstractClass.js.diff @@ -7,13 +7,4 @@ + a; } exports.default = A; - class B extends A { -@@= skipped -8, +9 lines =@@ - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - class C extends a_1.default { - } - new C().a.toExponential(); \ No newline at end of file + class B extends A { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt index 0a8853c29e..90e5a3e617 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt @@ -1,12 +1,8 @@ a.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -a.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. asyncawait.ts(2,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. c.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -c.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. d.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -d.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. e.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -e.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. ==== asyncawait.ts (1 errors) ==== @@ -15,40 +11,32 @@ e.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding t ~~~~~ !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -==== a.ts (2 errors) ==== - import { async, await } from 'asyncawait'; +==== a.ts (1 errors) ==== + import { async, await } from './asyncawait'; ~~~~~ !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. - ~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. export default async(() => await(Promise.resolve(1))); ==== b.ts (0 errors) ==== export default async () => { return 0; }; -==== c.ts (2 errors) ==== - import { async, await } from 'asyncawait'; +==== c.ts (1 errors) ==== + import { async, await } from './asyncawait'; ~~~~~ !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. - ~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. export default async(); -==== d.ts (2 errors) ==== - import { async, await } from 'asyncawait'; +==== d.ts (1 errors) ==== + import { async, await } from './asyncawait'; ~~~~~ !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. - ~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. export default async; -==== e.ts (2 errors) ==== - import { async, await } from 'asyncawait'; +==== e.ts (1 errors) ==== + import { async, await } from './asyncawait'; ~~~~~ !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. - ~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. export default async diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt.diff deleted file mode 100644 index 76f8aab771..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.errors.txt.diff +++ /dev/null @@ -1,60 +0,0 @@ ---- old.exportDefaultAsyncFunction2.errors.txt -+++ new.exportDefaultAsyncFunction2.errors.txt -@@= skipped -0, +0 lines =@@ - a.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+a.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - asyncawait.ts(2,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. - c.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+c.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - d.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+d.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - e.ts(1,17): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+e.ts(1,30): error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - - - ==== asyncawait.ts (1 errors) ==== -@@= skipped -10, +14 lines =@@ - ~~~~~ - !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. - --==== a.ts (1 errors) ==== -+==== a.ts (2 errors) ==== - import { async, await } from 'asyncawait'; - ~~~~~ - !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+ ~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - export default async(() => await(Promise.resolve(1))); - - ==== b.ts (0 errors) ==== - export default async () => { return 0; }; - --==== c.ts (1 errors) ==== -+==== c.ts (2 errors) ==== - import { async, await } from 'asyncawait'; - ~~~~~ - !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+ ~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - export default async(); - --==== d.ts (1 errors) ==== -+==== d.ts (2 errors) ==== - import { async, await } from 'asyncawait'; - ~~~~~ - !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+ ~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - - export default async; - --==== e.ts (1 errors) ==== -+==== e.ts (2 errors) ==== - import { async, await } from 'asyncawait'; - ~~~~~ - !!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module. -+ ~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'asyncawait' or its corresponding type declarations. - - export default async - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js index 11973c9b17..7eb390e8ad 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js @@ -5,23 +5,23 @@ export function async(...args: any[]): any { } export function await(...args: any[]): any { } //// [a.ts] -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; export default async(() => await(Promise.resolve(1))); //// [b.ts] export default async () => { return 0; }; //// [c.ts] -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; export default async(); //// [d.ts] -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; export default async; //// [e.ts] -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; export default async @@ -31,17 +31,17 @@ export function foo() { } export function async(...args) { } export function await(...args) { } //// [a.js] -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; export default async(() => await(Promise.resolve(1))); //// [b.js] export default async () => { return 0; }; //// [c.js] -import { async } from 'asyncawait'; +import { async } from './asyncawait'; export default async(); //// [d.js] -import { async } from 'asyncawait'; +import { async } from './asyncawait'; export default async; //// [e.js] -import { async } from 'asyncawait'; +import { async } from './asyncawait'; export default async; export function foo() { } diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js.diff index f0f7d71fad..cf54430fba 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.js.diff @@ -1,7 +1,7 @@ --- old.exportDefaultAsyncFunction2.js +++ new.exportDefaultAsyncFunction2.js @@= skipped -33, +33 lines =@@ - import { async, await } from 'asyncawait'; + import { async, await } from './asyncawait'; export default async(() => await(Promise.resolve(1))); //// [b.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -16,5 +16,5 @@ -export default () => __awaiter(void 0, void 0, void 0, function* () { return 0; }); +export default async () => { return 0; }; //// [c.js] - import { async } from 'asyncawait'; + import { async } from './asyncawait'; export default async(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.symbols b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.symbols index 04733e02f0..449e44d6e4 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.symbols +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.symbols @@ -11,7 +11,7 @@ export function await(...args: any[]): any { } >args : Symbol(args, Decl(asyncawait.ts, 1, 22)) === a.ts === -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; >async : Symbol(async, Decl(a.ts, 0, 8)) >await : Symbol(await, Decl(a.ts, 0, 15)) @@ -27,7 +27,7 @@ export default async(() => await(Promise.resolve(1))); export default async () => { return 0; }; === c.ts === -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; >async : Symbol(async, Decl(c.ts, 0, 8)) >await : Symbol(await, Decl(c.ts, 0, 15)) @@ -35,7 +35,7 @@ export default async(); >async : Symbol(async, Decl(c.ts, 0, 8)) === d.ts === -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; >async : Symbol(async, Decl(d.ts, 0, 8)) >await : Symbol(await, Decl(d.ts, 0, 15)) @@ -43,7 +43,7 @@ export default async; >async : Symbol(async, Decl(d.ts, 0, 8)) === e.ts === -import { async, await } from 'asyncawait'; +import { async, await } from './asyncawait'; >async : Symbol(async, Decl(e.ts, 0, 8)) >await : Symbol(await, Decl(e.ts, 0, 15)) diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types index f8eeafbfbd..a714c4d9f8 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types @@ -10,16 +10,16 @@ export function await(...args: any[]): any { } >args : any[] === a.ts === -import { async, await } from 'asyncawait'; ->async : any ->await : any +import { async, await } from './asyncawait'; +>async : (...args: any[]) => any +>await : (...args: any[]) => any export default async(() => await(Promise.resolve(1))); >async(() => await(Promise.resolve(1))) : any ->async : any +>async : (...args: any[]) => any >() => await(Promise.resolve(1)) : () => any >await(Promise.resolve(1)) : any ->await : any +>await : (...args: any[]) => any >Promise.resolve(1) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor @@ -32,29 +32,29 @@ export default async () => { return 0; }; >0 : 0 === c.ts === -import { async, await } from 'asyncawait'; ->async : any ->await : any +import { async, await } from './asyncawait'; +>async : (...args: any[]) => any +>await : (...args: any[]) => any export default async(); >async() : any ->async : any +>async : (...args: any[]) => any === d.ts === -import { async, await } from 'asyncawait'; ->async : any ->await : any +import { async, await } from './asyncawait'; +>async : (...args: any[]) => any +>await : (...args: any[]) => any export default async; ->async : any +>async : (...args: any[]) => any === e.ts === -import { async, await } from 'asyncawait'; ->async : any ->await : any +import { async, await } from './asyncawait'; +>async : (...args: any[]) => any +>await : (...args: any[]) => any export default async ->async : any +>async : (...args: any[]) => any export function foo() { } >foo : () => void diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types.diff deleted file mode 100644 index a53c409e2e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultAsyncFunction2.types.diff +++ /dev/null @@ -1,60 +0,0 @@ ---- old.exportDefaultAsyncFunction2.types -+++ new.exportDefaultAsyncFunction2.types -@@= skipped -10, +10 lines =@@ - - === a.ts === - import { async, await } from 'asyncawait'; -->async : (...args: any[]) => any -->await : (...args: any[]) => any -+>async : any -+>await : any - - export default async(() => await(Promise.resolve(1))); - >async(() => await(Promise.resolve(1))) : any -->async : (...args: any[]) => any -+>async : any - >() => await(Promise.resolve(1)) : () => any - >await(Promise.resolve(1)) : any -->await : (...args: any[]) => any -+>await : any - >Promise.resolve(1) : Promise - >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } - >Promise : PromiseConstructor -@@= skipped -22, +22 lines =@@ - - === c.ts === - import { async, await } from 'asyncawait'; -->async : (...args: any[]) => any -->await : (...args: any[]) => any -+>async : any -+>await : any - - export default async(); - >async() : any -->async : (...args: any[]) => any -+>async : any - - === d.ts === - import { async, await } from 'asyncawait'; -->async : (...args: any[]) => any -->await : (...args: any[]) => any -+>async : any -+>await : any - - export default async; -->async : (...args: any[]) => any -+>async : any - - === e.ts === - import { async, await } from 'asyncawait'; -->async : (...args: any[]) => any -->await : (...args: any[]) => any -+>async : any -+>await : any - - export default async -->async : (...args: any[]) => any -+>async : any - - export function foo() { } - >foo : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js index 30f165ebe4..6d4537de90 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js @@ -10,12 +10,15 @@ export { aa as default } from './hi' //// [exportDefaultDuplicateCrash.js] "use strict"; +// #38214 +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; exports.default = default_1; -// #38214 function default_1() { } const hi_1 = require("./hi"); -Object.defineProperty(exports, "default", { enumerable: true, get: function () { return hi_1.default; } }); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(hi_1).default; } }); const hi_2 = require("./hi"); Object.defineProperty(exports, "default", { enumerable: true, get: function () { return hi_2.aa; } }); diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff index 9fc17e9cc4..b758f1f6eb 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff @@ -1,18 +1,12 @@ --- old.exportDefaultDuplicateCrash.js +++ new.exportDefaultDuplicateCrash.js -@@= skipped -9, +9 lines =@@ - - //// [exportDefaultDuplicateCrash.js] - "use strict"; --// #38214 - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -17, +17 lines =@@ exports.default = void 0; exports.default = default_1; -+// #38214 function default_1() { } -var hi_1 = require("./hi"); +const hi_1 = require("./hi"); - Object.defineProperty(exports, "default", { enumerable: true, get: function () { return hi_1.default; } }); + Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(hi_1).default; } }); -var hi_2 = require("./hi"); +const hi_2 = require("./hi"); Object.defineProperty(exports, "default", { enumerable: true, get: function () { return hi_2.aa; } }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultMarksIdentifierAsUsed.js b/testdata/baselines/reference/submodule/compiler/exportDefaultMarksIdentifierAsUsed.js index 5772dcfa15..6062f3a06e 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultMarksIdentifierAsUsed.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultMarksIdentifierAsUsed.js @@ -15,6 +15,9 @@ const Obj = {}; exports.default = Obj; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); a_1.default.fn = function () { }; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultMarksIdentifierAsUsed.types.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultMarksIdentifierAsUsed.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultMarksIdentifierAsUsed.types.diff rename to testdata/baselines/reference/submodule/compiler/exportDefaultMarksIdentifierAsUsed.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js index 17fc65677f..ed36cac0c8 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js @@ -59,13 +59,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "foo".length; //// [index.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); /// -const foobar_1 = require("foobar"); -const foobarx_1 = require("foobarx"); +const foobar_1 = __importDefault(require("foobar")); +const foobarx_1 = __importDefault(require("foobarx")); const x = X; const x2 = foobarx_1.default; -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); const b = new a_1.default(a_1.default.b); -const b_1 = require("./b"); +const b_1 = __importDefault(require("./b")); b_1.default + 1; diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js.diff index 94bf307b34..980e865d8a 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty.js.diff @@ -1,19 +1,10 @@ --- old.exportDefaultProperty.js +++ new.exportDefaultProperty.js -@@= skipped -60, +60 lines =@@ - "use strict"; +@@= skipped -64, +64 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); /// --var foobar_1 = require("foobar"); + const foobar_1 = __importDefault(require("foobar")); -var X = foobar_1.default.X; --var foobarx_1 = require("foobarx"); -+const foobar_1 = require("foobar"); -+const foobarx_1 = require("foobarx"); + const foobarx_1 = __importDefault(require("foobarx")); const x = X; - const x2 = foobarx_1.default; --var a_1 = require("./a"); -+const a_1 = require("./a"); - const b = new a_1.default(a_1.default.b); --var b_1 = require("./b"); -+const b_1 = require("./b"); - b_1.default + 1; \ No newline at end of file + const x2 = foobarx_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js index 2ce5168afb..ae60a12e62 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js @@ -24,6 +24,9 @@ class C { exports.default = C.B; //// [b.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); const x = { c: a_1.default }; diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js.diff index 5fa7c36278..8deefbe0c6 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultProperty2.js.diff @@ -7,9 +7,4 @@ + static B; } exports.default = C.B; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a_1 = require("./a"); -+const a_1 = require("./a"); - const x = { c: a_1.default }; \ No newline at end of file + //// [b.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js b/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js index 872a5ea6c1..4bdb830f31 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js @@ -17,6 +17,9 @@ class C { exports.default = C.x; //// [usage.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const code_1 = require("./code"); +const code_1 = __importDefault(require("./code")); void code_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js.diff index f804de7c97..6219aea4c6 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultQualifiedNameNoError.js.diff @@ -1,23 +1,12 @@ --- old.exportDefaultQualifiedNameNoError.js +++ new.exportDefaultQualifiedNameNoError.js -@@= skipped -9, +9 lines =@@ - //// [code.js] +@@= skipped -10, +10 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); --let C = (() => { -- class C { -- } -- C.x = 0; -- return C; --})(); -+class C { + class C { + static x = 0; -+} + } +-C.x = 0; ; exports.default = C.x; - //// [usage.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var code_1 = require("./code"); -+const code_1 = require("./code"); - void code_1.default; \ No newline at end of file + //// [usage.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js b/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js index 2551e73853..bca09b3e5d 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js @@ -35,8 +35,41 @@ exports.q = { }; //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const items_1 = require("./items"); +const items_1 = __importStar(require("./items")); function nFoo(x) { } nFoo(items_1.q); // for comparison nFoo(items_1.default); diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js.diff deleted file mode 100644 index 71b68e2ef9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultStripsFreshness.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.exportDefaultStripsFreshness.js -+++ new.exportDefaultStripsFreshness.js -@@= skipped -35, +35 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var items_1 = require("./items"); -+const items_1 = require("./items"); - function nFoo(x) { } - nFoo(items_1.q); // for comparison - nFoo(items_1.default); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js b/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js index a75a467ba1..ed42c5818e 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js @@ -11,3 +11,4 @@ declare module 'module' { //// [exportDefaultVariable.js] +// Regression test for #3018 diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js.diff deleted file mode 100644 index fb2dddfa33..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.exportDefaultVariable.js -+++ new.exportDefaultVariable.js -@@= skipped -10, +10 lines =@@ - - - //// [exportDefaultVariable.js] --// Regression test for #3018 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff rename to testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.errors.txt b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.errors.txt new file mode 100644 index 0000000000..0678fe7039 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.errors.txt @@ -0,0 +1,25 @@ +exportEqualErrorType_1.ts(3,23): error TS2339: Property 'static' does not exist on type '{ (): connectExport; foo: Date; }'. + + +==== exportEqualErrorType_1.ts (1 errors) ==== + /// + import connect = require('./exportEqualErrorType_0'); + connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. + ~~~~~~ +!!! error TS2339: Property 'static' does not exist on type '{ (): connectExport; foo: Date; }'. + +==== exportEqualErrorType_0.ts (0 errors) ==== + module server { + export interface connectModule { + (res, req, next): void; + } + export interface connectExport { + use: (mod: connectModule) => connectExport; + } + } + var server: { + (): server.connectExport; + foo: Date; + }; + export = server; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.js b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.js new file mode 100644 index 0000000000..448996e01f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/exportEqualErrorType.ts] //// + +//// [exportEqualErrorType_0.ts] +module server { + export interface connectModule { + (res, req, next): void; + } + export interface connectExport { + use: (mod: connectModule) => connectExport; + } +} +var server: { + (): server.connectExport; + foo: Date; +}; +export = server; + +//// [exportEqualErrorType_1.ts] +/// +import connect = require('./exportEqualErrorType_0'); +connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. + + +//// [exportEqualErrorType_0.js] +"use strict"; +var server; +module.exports = server; +//// [exportEqualErrorType_1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +const connect = require("./exportEqualErrorType_0"); +connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.symbols b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.symbols new file mode 100644 index 0000000000..d31bd04ec8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/exportEqualErrorType.ts] //// + +=== exportEqualErrorType_1.ts === +/// +import connect = require('./exportEqualErrorType_0'); +>connect : Symbol(connect, Decl(exportEqualErrorType_1.ts, 0, 0)) + +connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. +>connect().use : Symbol(connect.connectExport.use, Decl(exportEqualErrorType_0.ts, 4, 36)) +>connect : Symbol(connect, Decl(exportEqualErrorType_1.ts, 0, 0)) +>use : Symbol(connect.connectExport.use, Decl(exportEqualErrorType_0.ts, 4, 36)) +>connect : Symbol(connect, Decl(exportEqualErrorType_1.ts, 0, 0)) + +=== exportEqualErrorType_0.ts === +module server { +>server : Symbol(server, Decl(exportEqualErrorType_0.ts, 0, 0), Decl(exportEqualErrorType_0.ts, 8, 3)) + + export interface connectModule { +>connectModule : Symbol(connectModule, Decl(exportEqualErrorType_0.ts, 0, 15)) + + (res, req, next): void; +>res : Symbol(res, Decl(exportEqualErrorType_0.ts, 2, 9)) +>req : Symbol(req, Decl(exportEqualErrorType_0.ts, 2, 13)) +>next : Symbol(next, Decl(exportEqualErrorType_0.ts, 2, 18)) + } + export interface connectExport { +>connectExport : Symbol(connectExport, Decl(exportEqualErrorType_0.ts, 3, 5)) + + use: (mod: connectModule) => connectExport; +>use : Symbol(connectExport.use, Decl(exportEqualErrorType_0.ts, 4, 36)) +>mod : Symbol(mod, Decl(exportEqualErrorType_0.ts, 5, 14)) +>connectModule : Symbol(connectModule, Decl(exportEqualErrorType_0.ts, 0, 15)) +>connectExport : Symbol(connectExport, Decl(exportEqualErrorType_0.ts, 3, 5)) + } +} +var server: { +>server : Symbol(server, Decl(exportEqualErrorType_0.ts, 0, 0), Decl(exportEqualErrorType_0.ts, 8, 3)) + + (): server.connectExport; +>server : Symbol(server, Decl(exportEqualErrorType_0.ts, 0, 0), Decl(exportEqualErrorType_0.ts, 8, 3)) +>connectExport : Symbol(server.connectExport, Decl(exportEqualErrorType_0.ts, 3, 5)) + + foo: Date; +>foo : Symbol(foo, Decl(exportEqualErrorType_0.ts, 9, 29)) +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) + +}; +export = server; +>server : Symbol(server, Decl(exportEqualErrorType_0.ts, 0, 0), Decl(exportEqualErrorType_0.ts, 8, 3)) + diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.types b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.types new file mode 100644 index 0000000000..cc29313770 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.types @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/exportEqualErrorType.ts] //// + +=== exportEqualErrorType_1.ts === +/// +import connect = require('./exportEqualErrorType_0'); +>connect : { (): connect.connectExport; foo: Date; } + +connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. +>connect().use(connect.static('foo')) : connect.connectExport +>connect().use : (mod: connect.connectModule) => connect.connectExport +>connect() : connect.connectExport +>connect : { (): connect.connectExport; foo: Date; } +>use : (mod: connect.connectModule) => connect.connectExport +>connect.static('foo') : any +>connect.static : any +>connect : { (): connect.connectExport; foo: Date; } +>static : any +>'foo' : "foo" + +=== exportEqualErrorType_0.ts === +module server { + export interface connectModule { + (res, req, next): void; +>res : any +>req : any +>next : any + } + export interface connectExport { + use: (mod: connectModule) => connectExport; +>use : (mod: connectModule) => connectExport +>mod : connectModule + } +} +var server: { +>server : { (): import("exportEqualErrorType_0").connectExport; foo: Date; } + + (): server.connectExport; +>server : any + + foo: Date; +>foo : Date + +}; +export = server; +>server : { (): import("exportEqualErrorType_0").connectExport; foo: Date; } + diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.types.diff b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.types.diff new file mode 100644 index 0000000000..1b92508784 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportEqualErrorType.types.diff @@ -0,0 +1,18 @@ +--- old.exportEqualErrorType.types ++++ new.exportEqualErrorType.types +@@= skipped -31, +31 lines =@@ + } + } + var server: { +->server : { (): server.connectExport; foo: Date; } ++>server : { (): import("exportEqualErrorType_0").connectExport; foo: Date; } + + (): server.connectExport; + >server : any +@@= skipped -10, +10 lines =@@ + + }; + export = server; +->server : { (): server.connectExport; foo: Date; } ++>server : { (): import("exportEqualErrorType_0").connectExport; foo: Date; } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualMemberMissing.js.diff b/testdata/baselines/reference/submodule/compiler/exportEqualMemberMissing.js.diff deleted file mode 100644 index ce0c70e5d5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualMemberMissing.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportEqualMemberMissing.js -+++ new.exportEqualMemberMissing.js -@@= skipped -28, +28 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var connect = require("./exportEqualMemberMissing_0"); -+const connect = require("./exportEqualMemberMissing_0"); - connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.errors.txt.diff deleted file mode 100644 index 3c2bc80adf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.exportEqualsDefaultProperty.errors.txt -+++ new.exportEqualsDefaultProperty.errors.txt -@@= skipped -0, +0 lines =@@ -- -+imp.ts(2,5): error TS2339: Property 'toExponential' does not exist on type '{ greeting: string; default: number; }'. -+ -+ -+==== exp.ts (0 errors) ==== -+ var x = { -+ "greeting": "hello, world", -+ "default": 42 -+ }; -+ -+ export = x -+ -+==== imp.ts (1 errors) ==== -+ import foo from "./exp"; -+ foo.toExponential(2); -+ ~~~~~~~~~~~~~ -+!!! error TS2339: Property 'toExponential' does not exist on type '{ greeting: string; default: number; }'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js index ef59eb4d24..f2c3a6bb85 100644 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js +++ b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js @@ -22,6 +22,9 @@ var x = { module.exports = x; //// [imp.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const exp_1 = require("./exp"); +const exp_1 = __importDefault(require("./exp")); exp_1.default.toExponential(2); diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js.diff deleted file mode 100644 index 2c9c620c5f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportEqualsDefaultProperty.js -+++ new.exportEqualsDefaultProperty.js -@@= skipped -22, +22 lines =@@ - //// [imp.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var exp_1 = require("./exp"); -+const exp_1 = require("./exp"); - exp_1.default.toExponential(2); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.symbols.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.symbols.diff deleted file mode 100644 index 35de9ce474..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.symbols.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportEqualsDefaultProperty.symbols -+++ new.exportEqualsDefaultProperty.symbols -@@= skipped -19, +19 lines =@@ - >foo : Symbol(foo, Decl(imp.ts, 0, 6)) - - foo.toExponential(2); -->foo.toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --)) - >foo : Symbol(foo, Decl(imp.ts, 0, 6)) -->toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.types.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.types.diff deleted file mode 100644 index 6b7846da27..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.types.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.exportEqualsDefaultProperty.types -+++ new.exportEqualsDefaultProperty.types -@@= skipped -19, +19 lines =@@ - - === imp.ts === - import foo from "./exp"; -->foo : number -+>foo : { greeting: string; default: number; } - - foo.toExponential(2); -->foo.toExponential(2) : string -->foo.toExponential : (fractionDigits?: number) => string -->foo : number -->toExponential : (fractionDigits?: number) => string -+>foo.toExponential(2) : any -+>foo.toExponential : any -+>foo : { greeting: string; default: number; } -+>toExponential : any - >2 : 2 diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsProperty.js.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsProperty.js.diff deleted file mode 100644 index 8e802fff75..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsProperty.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.exportEqualsProperty.js -+++ new.exportEqualsProperty.js -@@= skipped -57, +57 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var foobar_1 = require("foobar"); --var X2 = require("foobarx"); -+const foobar_1 = require("foobar"); -+const X2 = require("foobarx"); - const x = foobar_1.X; - const x2 = X2; --var B = require("./a"); -+const B = require("./a"); - const b = new B(B.b); --var fooLength = require("./b"); -+const fooLength = require("./b"); - fooLength + 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsProperty2.js.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsProperty2.js.diff index 8c18c82539..32562c1313 100644 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsProperty2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportEqualsProperty2.js.diff @@ -7,9 +7,4 @@ + static B; } module.exports = C.B; - //// [b.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var B = require("./a"); -+const B = require("./a"); - const x = { c: B }; \ No newline at end of file + //// [b.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.errors.txt b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.errors.txt new file mode 100644 index 0000000000..d81f9c5566 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.errors.txt @@ -0,0 +1,12 @@ +exportSameNameFuncVar.ts(1,12): error TS2300: Duplicate identifier 'a'. +exportSameNameFuncVar.ts(2,17): error TS2300: Duplicate identifier 'a'. + + +==== exportSameNameFuncVar.ts (2 errors) ==== + export var a = 10; + ~ +!!! error TS2300: Duplicate identifier 'a'. + export function a() { + ~ +!!! error TS2300: Duplicate identifier 'a'. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.js b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.js new file mode 100644 index 0000000000..88272ae169 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/exportSameNameFuncVar.ts] //// + +//// [exportSameNameFuncVar.ts] +export var a = 10; +export function a() { +} + +//// [exportSameNameFuncVar.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = a; +exports.a = 10; +function a() { +} diff --git a/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.symbols b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.symbols new file mode 100644 index 0000000000..de081aa7ac --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.symbols @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/exportSameNameFuncVar.ts] //// + +=== exportSameNameFuncVar.ts === +export var a = 10; +>a : Symbol(a, Decl(exportSameNameFuncVar.ts, 0, 10)) + +export function a() { +>a : Symbol(a, Decl(exportSameNameFuncVar.ts, 0, 18)) +} diff --git a/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.types b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.types new file mode 100644 index 0000000000..5181ca6b76 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportSameNameFuncVar.types @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/exportSameNameFuncVar.ts] //// + +=== exportSameNameFuncVar.ts === +export var a = 10; +>a : number +>10 : 10 + +export function a() { +>a : () => void +} diff --git a/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js b/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js index f86e7b7e9a..1be8a70041 100644 --- a/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js +++ b/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js @@ -58,8 +58,41 @@ class A { exports.A = A; //// [exportStarFromEmptyModule_module4.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const X = require("./exportStarFromEmptyModule_module3"); +const X = __importStar(require("./exportStarFromEmptyModule_module3")); var s; X.A.q; X.A.r; // Error diff --git a/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js.diff b/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js.diff index 7c33e43513..379a412124 100644 --- a/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportStarFromEmptyModule.js.diff @@ -15,11 +15,4 @@ + static q; } exports.A = A; - //// [exportStarFromEmptyModule_module4.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var X = require("./exportStarFromEmptyModule_module3"); -+const X = require("./exportStarFromEmptyModule_module3"); - var s; - X.A.q; - X.A.r; // Error \ No newline at end of file + //// [exportStarFromEmptyModule_module4.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js b/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js index ba721257eb..dabe577d9d 100644 --- a/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js +++ b/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js @@ -34,14 +34,36 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi if (k2 === undefined) k2 = k; o[k2] = m[k]; })); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.aliased = void 0; __exportStar(require("./register"), exports); __exportStar(require("./data1"), exports); -exports.aliased = require("./data1"); +exports.aliased = __importStar(require("./data1")); //// [data1.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js.diff b/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js.diff deleted file mode 100644 index 713223991b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportStarNotElided.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportStarNotElided.js -+++ new.exportStarNotElided.js -@@= skipped -44, +44 lines =@@ - //// [data1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var _1 = require("./"); -+const _1 = require("./"); - (0, _1.register)("ok"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.errors.txt b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.errors.txt new file mode 100644 index 0000000000..d6069e99b6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.errors.txt @@ -0,0 +1,52 @@ +exportedBlockScopedDeclarations.ts(1,13): error TS2448: Block-scoped variable 'foo' used before its declaration. +exportedBlockScopedDeclarations.ts(2,20): error TS2448: Block-scoped variable 'bar' used before its declaration. +exportedBlockScopedDeclarations.ts(4,15): error TS2448: Block-scoped variable 'bar' used before its declaration. +exportedBlockScopedDeclarations.ts(7,22): error TS2448: Block-scoped variable 'bar' used before its declaration. +exportedBlockScopedDeclarations.ts(10,12): error TS2448: Block-scoped variable 'foo1' used before its declaration. +exportedBlockScopedDeclarations.ts(11,19): error TS2448: Block-scoped variable 'bar1' used before its declaration. +exportedBlockScopedDeclarations.ts(13,14): error TS2448: Block-scoped variable 'bar1' used before its declaration. +exportedBlockScopedDeclarations.ts(16,21): error TS2448: Block-scoped variable 'bar1' used before its declaration. + + +==== exportedBlockScopedDeclarations.ts (8 errors) ==== + const foo = foo; // compile error + ~~~ +!!! error TS2448: Block-scoped variable 'foo' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:1:7: 'foo' is declared here. + export const bar = bar; // should be compile error + ~~~ +!!! error TS2448: Block-scoped variable 'bar' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:2:14: 'bar' is declared here. + function f() { + const bar = bar; // compile error + ~~~ +!!! error TS2448: Block-scoped variable 'bar' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:4:9: 'bar' is declared here. + } + namespace NS { + export const bar = bar; // should be compile error + ~~~ +!!! error TS2448: Block-scoped variable 'bar' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:7:16: 'bar' is declared here. + } + + let foo1 = foo1; // compile error + ~~~~ +!!! error TS2448: Block-scoped variable 'foo1' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:10:5: 'foo1' is declared here. + export let bar1 = bar1; // should be compile error + ~~~~ +!!! error TS2448: Block-scoped variable 'bar1' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:11:12: 'bar1' is declared here. + function f1() { + let bar1 = bar1; // compile error + ~~~~ +!!! error TS2448: Block-scoped variable 'bar1' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:13:7: 'bar1' is declared here. + } + namespace NS1 { + export let bar1 = bar1; // should be compile error + ~~~~ +!!! error TS2448: Block-scoped variable 'bar1' used before its declaration. +!!! related TS2728 exportedBlockScopedDeclarations.ts:16:14: 'bar1' is declared here. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.js b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.js new file mode 100644 index 0000000000..93aa3f0d54 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/exportedBlockScopedDeclarations.ts] //// + +//// [exportedBlockScopedDeclarations.ts] +const foo = foo; // compile error +export const bar = bar; // should be compile error +function f() { + const bar = bar; // compile error +} +namespace NS { + export const bar = bar; // should be compile error +} + +let foo1 = foo1; // compile error +export let bar1 = bar1; // should be compile error +function f1() { + let bar1 = bar1; // compile error +} +namespace NS1 { + export let bar1 = bar1; // should be compile error +} + +//// [exportedBlockScopedDeclarations.js] +const foo = foo; // compile error +export const bar = bar; // should be compile error +function f() { + const bar = bar; // compile error +} +var NS; +(function (NS) { + NS.bar = NS.bar; // should be compile error +})(NS || (NS = {})); +let foo1 = foo1; // compile error +export let bar1 = bar1; // should be compile error +function f1() { + let bar1 = bar1; // compile error +} +var NS1; +(function (NS1) { + NS1.bar1 = NS1.bar1; // should be compile error +})(NS1 || (NS1 = {})); diff --git a/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.symbols b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.symbols new file mode 100644 index 0000000000..dab45564d4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.symbols @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/exportedBlockScopedDeclarations.ts] //// + +=== exportedBlockScopedDeclarations.ts === +const foo = foo; // compile error +>foo : Symbol(foo, Decl(exportedBlockScopedDeclarations.ts, 0, 5)) +>foo : Symbol(foo, Decl(exportedBlockScopedDeclarations.ts, 0, 5)) + +export const bar = bar; // should be compile error +>bar : Symbol(bar, Decl(exportedBlockScopedDeclarations.ts, 1, 12)) +>bar : Symbol(bar, Decl(exportedBlockScopedDeclarations.ts, 1, 12)) + +function f() { +>f : Symbol(f, Decl(exportedBlockScopedDeclarations.ts, 1, 23)) + + const bar = bar; // compile error +>bar : Symbol(bar, Decl(exportedBlockScopedDeclarations.ts, 3, 7)) +>bar : Symbol(bar, Decl(exportedBlockScopedDeclarations.ts, 3, 7)) +} +namespace NS { +>NS : Symbol(NS, Decl(exportedBlockScopedDeclarations.ts, 4, 1)) + + export const bar = bar; // should be compile error +>bar : Symbol(bar, Decl(exportedBlockScopedDeclarations.ts, 6, 14)) +>bar : Symbol(bar, Decl(exportedBlockScopedDeclarations.ts, 6, 14)) +} + +let foo1 = foo1; // compile error +>foo1 : Symbol(foo1, Decl(exportedBlockScopedDeclarations.ts, 9, 3)) +>foo1 : Symbol(foo1, Decl(exportedBlockScopedDeclarations.ts, 9, 3)) + +export let bar1 = bar1; // should be compile error +>bar1 : Symbol(bar1, Decl(exportedBlockScopedDeclarations.ts, 10, 10)) +>bar1 : Symbol(bar1, Decl(exportedBlockScopedDeclarations.ts, 10, 10)) + +function f1() { +>f1 : Symbol(f1, Decl(exportedBlockScopedDeclarations.ts, 10, 23)) + + let bar1 = bar1; // compile error +>bar1 : Symbol(bar1, Decl(exportedBlockScopedDeclarations.ts, 12, 5)) +>bar1 : Symbol(bar1, Decl(exportedBlockScopedDeclarations.ts, 12, 5)) +} +namespace NS1 { +>NS1 : Symbol(NS1, Decl(exportedBlockScopedDeclarations.ts, 13, 1)) + + export let bar1 = bar1; // should be compile error +>bar1 : Symbol(bar1, Decl(exportedBlockScopedDeclarations.ts, 15, 12)) +>bar1 : Symbol(bar1, Decl(exportedBlockScopedDeclarations.ts, 15, 12)) +} diff --git a/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.types b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.types new file mode 100644 index 0000000000..74e9636f30 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportedBlockScopedDeclarations.types @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/exportedBlockScopedDeclarations.ts] //// + +=== exportedBlockScopedDeclarations.ts === +const foo = foo; // compile error +>foo : any +>foo : any + +export const bar = bar; // should be compile error +>bar : any +>bar : any + +function f() { +>f : () => void + + const bar = bar; // compile error +>bar : any +>bar : any +} +namespace NS { +>NS : typeof NS + + export const bar = bar; // should be compile error +>bar : any +>bar : any +} + +let foo1 = foo1; // compile error +>foo1 : any +>foo1 : any + +export let bar1 = bar1; // should be compile error +>bar1 : any +>bar1 : any + +function f1() { +>f1 : () => void + + let bar1 = bar1; // compile error +>bar1 : any +>bar1 : any +} +namespace NS1 { +>NS1 : typeof NS1 + + export let bar1 = bar1; // should be compile error +>bar1 : any +>bar1 : any +} diff --git a/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js b/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js index 880fe1e0e1..ab8848e2a3 100644 --- a/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js +++ b/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js @@ -31,6 +31,7 @@ type TComeOnBar = typeof Bar; //// [expressionWithJSDocTypeArguments.js] +"use strict"; // Repro from #51802 function foo(x) { return x; } class Bar { diff --git a/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js.diff b/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js.diff index 269ca2f526..f8be8ad9b7 100644 --- a/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/expressionWithJSDocTypeArguments.js.diff @@ -1,10 +1,6 @@ --- old.expressionWithJSDocTypeArguments.js +++ new.expressionWithJSDocTypeArguments.js -@@= skipped -30, +30 lines =@@ - - - //// [expressionWithJSDocTypeArguments.js] --"use strict"; +@@= skipped -34, +34 lines =@@ // Repro from #51802 function foo(x) { return x; } class Bar { diff --git a/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js b/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js index 213472d465..f82c496d42 100644 --- a/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js +++ b/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js @@ -10,10 +10,43 @@ export function* foo2({ foo = yield "a" }) { //// [bar.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.foo = foo; exports.foo2 = foo2; -async function foo({ foo = await Promise.resolve().then(() => require("./bar")) }) { +async function foo({ foo = await Promise.resolve().then(() => __importStar(require("./bar"))) }) { } function* foo2({ foo = yield "a" }) { } diff --git a/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js.diff b/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js.diff index 2367d8dab0..23547c2967 100644 --- a/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/expressionsForbiddenInParameterInitializers.js.diff @@ -1,9 +1,9 @@ --- old.expressionsForbiddenInParameterInitializers.js +++ new.expressionsForbiddenInParameterInitializers.js -@@= skipped -9, +9 lines =@@ - - //// [bar.js] - "use strict"; +@@= skipped -42, +42 lines =@@ + return result; + }; + })(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { @@ -17,9 +17,9 @@ exports.foo = foo; exports.foo2 = foo2; -function foo(_a) { -- return __awaiter(this, arguments, void 0, function* ({ foo = yield Promise.resolve().then(function () { return require("./bar"); }) }) { +- return __awaiter(this, arguments, void 0, function* ({ foo = yield Promise.resolve().then(() => __importStar(require("./bar"))) }) { - }); -+async function foo({ foo = await Promise.resolve().then(() => require("./bar")) }) { ++async function foo({ foo = await Promise.resolve().then(() => __importStar(require("./bar"))) }) { } function* foo2({ foo = yield "a" }) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/extendFromAny.js.diff b/testdata/baselines/reference/submodule/compiler/extendFromAny.js.diff index 7668d6323a..4fa0a2cad4 100644 --- a/testdata/baselines/reference/submodule/compiler/extendFromAny.js.diff +++ b/testdata/baselines/reference/submodule/compiler/extendFromAny.js.diff @@ -1,23 +1,17 @@ --- old.extendFromAny.js +++ new.extendFromAny.js -@@= skipped -14, +14 lines =@@ - +@@= skipped -15, +15 lines =@@ //// [extendFromAny.js] --let C = (() => { -- class C extends Base { -- constructor() { -- super(...arguments); -- this.known = 1; -- } + class C extends Base { +- constructor() { +- super(...arguments); +- this.known = 1; - } -- C.sknown = 2; -- return C; --})(); -+class C extends Base { + known = 1; + static sknown = 2; -+} + } +-C.sknown = 2; let c = new C(); c.known.length; // error, 'known' has no 'length' property C.sknown.length; // error, 'sknown' has no 'length' property \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/extendingClassFromAliasAndUsageInIndexer.js.diff b/testdata/baselines/reference/submodule/compiler/extendingClassFromAliasAndUsageInIndexer.js.diff index a59c81ff2f..a699617e7c 100644 --- a/testdata/baselines/reference/submodule/compiler/extendingClassFromAliasAndUsageInIndexer.js.diff +++ b/testdata/baselines/reference/submodule/compiler/extendingClassFromAliasAndUsageInIndexer.js.diff @@ -7,31 +7,4 @@ + someData; } exports.Model = Model; - //// [extendingClassFromAliasAndUsageInIndexer_moduleA.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); -+const Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; -@@= skipped -14, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.VisualizationModel = void 0; --var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); -+const Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); - class VisualizationModel extends Backbone.Model { - } - exports.VisualizationModel = VisualizationModel; - //// [extendingClassFromAliasAndUsageInIndexer_main.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); --var moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); -+const moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); -+const moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); - var moduleATyped = moduleA; - var moduleMap = { - "moduleA": moduleA, \ No newline at end of file + //// [extendingClassFromAliasAndUsageInIndexer_moduleA.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js b/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js index 1ceeffe70d..c639862917 100644 --- a/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js +++ b/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js @@ -14,9 +14,12 @@ export class A extends Foo { } //// [a.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; -const foo_1 = require("foo"); +const foo_1 = __importDefault(require("foo")); class A extends foo_1.default { } exports.A = A; diff --git a/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js.diff b/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js.diff deleted file mode 100644 index d056bffce9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/extendsUntypedModule.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.extendsUntypedModule.js -+++ new.extendsUntypedModule.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.A = void 0; --var foo_1 = require("foo"); -+const foo_1 = require("foo"); - class A extends foo_1.default { - } - exports.A = A; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/externalModuleExportingGenericClass.js.diff b/testdata/baselines/reference/submodule/compiler/externalModuleExportingGenericClass.js.diff index 33c84a2710..30b4e28f74 100644 --- a/testdata/baselines/reference/submodule/compiler/externalModuleExportingGenericClass.js.diff +++ b/testdata/baselines/reference/submodule/compiler/externalModuleExportingGenericClass.js.diff @@ -7,11 +7,4 @@ + foo; } module.exports = C; - //// [externalModuleExportingGenericClass_file1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var a = require("./externalModuleExportingGenericClass_file0"); -+const a = require("./externalModuleExportingGenericClass_file0"); - var v; // this should report error - var v2 = (new a()).foo; - var v3 = (new a()).foo; \ No newline at end of file + //// [externalModuleExportingGenericClass_file1.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js b/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js index 9271281edd..c74588f758 100644 --- a/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js +++ b/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js @@ -57,9 +57,42 @@ exports.x = void 0; exports.x = 1; //// [f2.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); // all mutations below are illegal and should be fixed -const stuff = require("./f1"); +const stuff = __importStar(require("./f1")); var n = 'baz'; stuff.x = 0; stuff['x'] = 1; diff --git a/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js.diff b/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js.diff deleted file mode 100644 index e2cc255977..0000000000 --- a/testdata/baselines/reference/submodule/compiler/externalModuleImmutableBindings.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.externalModuleImmutableBindings.js -+++ new.externalModuleImmutableBindings.js -@@= skipped -58, +58 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - // all mutations below are illegal and should be fixed --var stuff = require("./f1"); -+const stuff = require("./f1"); - var n = 'baz'; - stuff.x = 0; - stuff['x'] = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.js.diff b/testdata/baselines/reference/submodule/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.js.diff deleted file mode 100644 index 2657cbcbfa..0000000000 --- a/testdata/baselines/reference/submodule/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.externalModuleRefernceResolutionOrderInImportDeclaration.js -+++ new.externalModuleRefernceResolutionOrderInImportDeclaration.js -@@= skipped -27, +27 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var file1 = require("./externalModuleRefernceResolutionOrderInImportDeclaration_file1"); -+const file1 = require("./externalModuleRefernceResolutionOrderInImportDeclaration_file1"); - file1.foo(); - file1.bar(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/externalModuleResolution.js.diff b/testdata/baselines/reference/submodule/compiler/externalModuleResolution.js.diff deleted file mode 100644 index ce095e4ffb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/externalModuleResolution.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.externalModuleResolution.js -+++ new.externalModuleResolution.js -@@= skipped -25, +25 lines =@@ - //// [consumer.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var x = require("./foo"); -+const x = require("./foo"); - x.Y; // .ts should be picked \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/externalModuleResolution2.js.diff b/testdata/baselines/reference/submodule/compiler/externalModuleResolution2.js.diff deleted file mode 100644 index 6710c9036a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/externalModuleResolution2.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.externalModuleResolution2.js -+++ new.externalModuleResolution2.js -@@= skipped -26, +26 lines =@@ - //// [consumer.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var x = require("./foo"); -+const x = require("./foo"); - x.X; // .ts should be picked \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.errors.txt b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.errors.txt new file mode 100644 index 0000000000..048144f971 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.errors.txt @@ -0,0 +1,13 @@ +fieldAndGetterWithSameName.ts(2,5): error TS2300: Duplicate identifier 'x'. +fieldAndGetterWithSameName.ts(3,7): error TS2300: Duplicate identifier 'x'. + + +==== fieldAndGetterWithSameName.ts (2 errors) ==== + export class C { + x: number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + get x(): number { return 1; } + ~ +!!! error TS2300: Duplicate identifier 'x'. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.js b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.js new file mode 100644 index 0000000000..c4b9234c84 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/fieldAndGetterWithSameName.ts] //// + +//// [fieldAndGetterWithSameName.ts] +export class C { + x: number; + get x(): number { return 1; } +} + +//// [fieldAndGetterWithSameName.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +class C { + x; + get x() { return 1; } +} +exports.C = C; diff --git a/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.js.diff b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.js.diff new file mode 100644 index 0000000000..8130ff3d15 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.js.diff @@ -0,0 +1,10 @@ +--- old.fieldAndGetterWithSameName.js ++++ new.fieldAndGetterWithSameName.js +@@= skipped -10, +10 lines =@@ + Object.defineProperty(exports, "__esModule", { value: true }); + exports.C = void 0; + class C { ++ x; + get x() { return 1; } + } + exports.C = C; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.symbols b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.symbols new file mode 100644 index 0000000000..71e5070074 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/fieldAndGetterWithSameName.ts] //// + +=== fieldAndGetterWithSameName.ts === +export class C { +>C : Symbol(C, Decl(fieldAndGetterWithSameName.ts, 0, 0)) + + x: number; +>x : Symbol(C.x, Decl(fieldAndGetterWithSameName.ts, 0, 16)) + + get x(): number { return 1; } +>x : Symbol(C.x, Decl(fieldAndGetterWithSameName.ts, 1, 14)) +} diff --git a/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.types b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.types new file mode 100644 index 0000000000..6232c8682f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/fieldAndGetterWithSameName.types @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/fieldAndGetterWithSameName.ts] //// + +=== fieldAndGetterWithSameName.ts === +export class C { +>C : C + + x: number; +>x : number + + get x(): number { return 1; } +>x : number +>1 : 1 +} diff --git a/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js b/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js index f6a41d4142..72e0512425 100644 --- a/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js +++ b/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js @@ -10,6 +10,7 @@ if (match !== null) { //// [firstMatchRegExpMatchArray.js] +"use strict"; const match = ''.match(/ /); if (match !== null) { const foo = match[0]; diff --git a/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js.diff b/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js.diff deleted file mode 100644 index 7263dbe607..0000000000 --- a/testdata/baselines/reference/submodule/compiler/firstMatchRegExpMatchArray.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.firstMatchRegExpMatchArray.js -+++ new.firstMatchRegExpMatchArray.js -@@= skipped -9, +9 lines =@@ - - - //// [firstMatchRegExpMatchArray.js] --"use strict"; - const match = ''.match(/ /); - if (match !== null) { - const foo = match[0]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js index 34286aaf03..217c8bfb4d 100644 --- a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js +++ b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js @@ -25,6 +25,8 @@ function f(x: FlatArray, y: FlatArray) //// [flatArrayNoExcessiveStackDepth.js] +"use strict"; +// Repro from #43493 const bar = foo.flatMap(bar => bar); // Repros from comments in #43249 const repro_43249 = (value) => { diff --git a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff deleted file mode 100644 index de12ee2d61..0000000000 --- a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.flatArrayNoExcessiveStackDepth.js -+++ new.flatArrayNoExcessiveStackDepth.js -@@= skipped -24, +24 lines =@@ - - - //// [flatArrayNoExcessiveStackDepth.js] --"use strict"; --// Repro from #43493 - const bar = foo.flatMap(bar => bar); - // Repros from comments in #43249 - const repro_43249 = (value) => { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/forwardRefInClassProperties.js.diff b/testdata/baselines/reference/submodule/compiler/forwardRefInClassProperties.js.diff index 512ed20ca3..3cbfa36d12 100644 --- a/testdata/baselines/reference/submodule/compiler/forwardRefInClassProperties.js.diff +++ b/testdata/baselines/reference/submodule/compiler/forwardRefInClassProperties.js.diff @@ -1,30 +1,21 @@ --- old.forwardRefInClassProperties.js +++ new.forwardRefInClassProperties.js -@@= skipped -17, +17 lines =@@ - +@@= skipped -18, +18 lines =@@ //// [forwardRefInClassProperties.js] --let Test = (() => { -- class Test { -- constructor() { -- this._b = this._a; // undefined, no error/warning -- this._a = 3; -- } -- method() { -- let a = b; // Property 'b' is used before its initialization. -- let b = 3; -- } -+class Test { + class Test { +- constructor() { +- this._b = this._a; // undefined, no error/warning +- this._a = 3; +- } + _b = this._a; // undefined, no error/warning + _a = 3; + static _B = Test._A; // undefined, no error/warning + static _A = 3; -+ method() { -+ let a = b; // Property 'b' is used before its initialization. -+ let b = 3; + method() { + let a = b; // Property 'b' is used before its initialization. + let b = 3; } -- Test._B = Test._A; // undefined, no error/warning -- Test._A = 3; -- return Test; --})(); -+} \ No newline at end of file + } +-Test._B = Test._A; // undefined, no error/warning +-Test._A = 3; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=false).js.diff b/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=false).js.diff index e8ff4b3490..0ee80793ed 100644 --- a/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=false).js.diff +++ b/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=false).js.diff @@ -1,16 +1,10 @@ --- old.forwardRefInTypeDeclaration(strict=false).js +++ new.forwardRefInTypeDeclaration(strict=false).js -@@= skipped -34, +34 lines =@@ - const s3 = "x"; +@@= skipped -35, +35 lines =@@ const s4 = "x"; const s5 = "x"; --let Cls2 = (() => { -- class Cls2 { -- } -- Cls2.b = "b"; -- return Cls2; --})(); -+class Cls2 { + class Cls2 { + static b = "b"; -+} + } +-Cls2.b = "b"; const obj2 = { d: 'd' }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js b/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js index d85f6d178f..2e3a279019 100644 --- a/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js +++ b/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js @@ -30,6 +30,7 @@ const obj2 = { d: 'd' } as const //// [forwardRefInTypeDeclaration.js] +"use strict"; const s1 = "x"; const s2 = "x"; const s3 = "x"; diff --git a/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js.diff b/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js.diff index 76eeeaccd4..0437897b4f 100644 --- a/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js.diff +++ b/testdata/baselines/reference/submodule/compiler/forwardRefInTypeDeclaration(strict=true).js.diff @@ -1,22 +1,10 @@ --- old.forwardRefInTypeDeclaration(strict=true).js +++ new.forwardRefInTypeDeclaration(strict=true).js -@@= skipped -29, +29 lines =@@ - - - //// [forwardRefInTypeDeclaration.js] --"use strict"; - const s1 = "x"; - const s2 = "x"; - const s3 = "x"; +@@= skipped -36, +36 lines =@@ const s4 = "x"; const s5 = "x"; --let Cls2 = (() => { -- class Cls2 { -- } -- Cls2.b = "b"; -- return Cls2; --})(); -+class Cls2 { + class Cls2 { + static b = "b"; -+} + } +-Cls2.b = "b"; const obj2 = { d: 'd' }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js index 18ffbc6d0c..8ed0fdbe37 100644 --- a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js +++ b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js @@ -9,5 +9,7 @@ q("x"); //// [freshLiteralTypesInIntersections.js] +"use strict"; +// Repro from #19657 const q = func("x", ["x"]); q("x"); diff --git a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff deleted file mode 100644 index 1a4ac6adf4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.freshLiteralTypesInIntersections.js -+++ new.freshLiteralTypesInIntersections.js -@@= skipped -8, +8 lines =@@ - - - //// [freshLiteralTypesInIntersections.js] --"use strict"; --// Repro from #19657 - const q = func("x", ["x"]); - q("x"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js b/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js index 4cad442684..3be1c66499 100644 --- a/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js +++ b/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js @@ -5,5 +5,6 @@ function func() {} const array: ArrayLike = func; //// [functionAssignabilityWithArrayLike01.js] +"use strict"; function func() { } const array = func; diff --git a/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js.diff b/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js.diff deleted file mode 100644 index 54d593f8ce..0000000000 --- a/testdata/baselines/reference/submodule/compiler/functionAssignabilityWithArrayLike01(strict=true).js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.functionAssignabilityWithArrayLike01(strict=true).js -+++ new.functionAssignabilityWithArrayLike01(strict=true).js -@@= skipped -4, +4 lines =@@ - const array: ArrayLike = func; - - //// [functionAssignabilityWithArrayLike01.js] --"use strict"; - function func() { } - const array = func; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js index e26a0c62a4..889d3c13a8 100644 --- a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js +++ b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js @@ -23,6 +23,8 @@ function callN(p: T) { } //// [functionCallOnConstrainedTypeVariable.js] +"use strict"; +// Repro from #20196 function call0(p) { p.a("s"); // Error } diff --git a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff deleted file mode 100644 index 6b5920b987..0000000000 --- a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.functionCallOnConstrainedTypeVariable.js -+++ new.functionCallOnConstrainedTypeVariable.js -@@= skipped -22, +22 lines =@@ - } - - //// [functionCallOnConstrainedTypeVariable.js] --"use strict"; --// Repro from #20196 - function call0(p) { - p.a("s"); // Error - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/functionExpressionNames.types.diff b/testdata/baselines/reference/submodule/compiler/functionExpressionNames.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/functionExpressionNames.types.diff rename to testdata/baselines/reference/submodule/compiler/functionExpressionNames.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.errors.txt b/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.errors.txt new file mode 100644 index 0000000000..a51f29297d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.errors.txt @@ -0,0 +1,34 @@ +functionLikeInParameterInitializer.ts(2,34): error TS2304: Cannot find name 'foo'. +functionLikeInParameterInitializer.ts(6,44): error TS2304: Cannot find name 'foo'. +functionLikeInParameterInitializer.ts(11,50): error TS2304: Cannot find name 'foo'. +functionLikeInParameterInitializer.ts(16,41): error TS2304: Cannot find name 'foo'. + + +==== functionLikeInParameterInitializer.ts (4 errors) ==== + // error + export function bar(func = () => foo) { + ~~~ +!!! error TS2304: Cannot find name 'foo'. + let foo = "in"; + } + // error + export function baz1(func = { f() { return foo } }) { + ~~~ +!!! error TS2304: Cannot find name 'foo'. + let foo = "in"; + } + + // error + export function baz2(func = function () { return foo }) { + ~~~ +!!! error TS2304: Cannot find name 'foo'. + let foo = "in"; + } + + // error + export function baz3(func = class { x = foo }) { + ~~~ +!!! error TS2304: Cannot find name 'foo'. + let foo = "in"; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.symbols b/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.symbols index c2ccb25545..c67e44f4e6 100644 --- a/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.symbols +++ b/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.symbols @@ -5,7 +5,6 @@ export function bar(func = () => foo) { >bar : Symbol(bar, Decl(functionLikeInParameterInitializer.ts, 0, 0)) >func : Symbol(func, Decl(functionLikeInParameterInitializer.ts, 1, 20)) ->foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 2, 7)) let foo = "in"; >foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 2, 7)) @@ -15,7 +14,6 @@ export function baz1(func = { f() { return foo } }) { >baz1 : Symbol(baz1, Decl(functionLikeInParameterInitializer.ts, 3, 1)) >func : Symbol(func, Decl(functionLikeInParameterInitializer.ts, 5, 21)) >f : Symbol(f, Decl(functionLikeInParameterInitializer.ts, 5, 29)) ->foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 6, 7)) let foo = "in"; >foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 6, 7)) @@ -25,7 +23,6 @@ export function baz1(func = { f() { return foo } }) { export function baz2(func = function () { return foo }) { >baz2 : Symbol(baz2, Decl(functionLikeInParameterInitializer.ts, 7, 1)) >func : Symbol(func, Decl(functionLikeInParameterInitializer.ts, 10, 21)) ->foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 11, 7)) let foo = "in"; >foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 11, 7)) @@ -36,7 +33,6 @@ export function baz3(func = class { x = foo }) { >baz3 : Symbol(baz3, Decl(functionLikeInParameterInitializer.ts, 12, 1)) >func : Symbol(func, Decl(functionLikeInParameterInitializer.ts, 15, 21)) >x : Symbol((Anonymous class).x, Decl(functionLikeInParameterInitializer.ts, 15, 35)) ->foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 16, 7)) let foo = "in"; >foo : Symbol(foo, Decl(functionLikeInParameterInitializer.ts, 16, 7)) diff --git a/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.types b/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.types index cf27ae4b1b..cf9011b879 100644 --- a/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.types +++ b/testdata/baselines/reference/submodule/compiler/functionLikeInParameterInitializer.types @@ -3,10 +3,10 @@ === functionLikeInParameterInitializer.ts === // error export function bar(func = () => foo) { ->bar : (func?: () => string) => void ->func : () => string ->() => foo : () => string ->foo : string +>bar : (func?: () => any) => void +>func : () => any +>() => foo : () => any +>foo : any let foo = "in"; >foo : string @@ -14,11 +14,11 @@ export function bar(func = () => foo) { } // error export function baz1(func = { f() { return foo } }) { ->baz1 : (func?: { f(): string; }) => void ->func : { f(): string; } ->{ f() { return foo } } : { f(): string; } ->f : () => string ->foo : string +>baz1 : (func?: { f(): any; }) => void +>func : { f(): any; } +>{ f() { return foo } } : { f(): any; } +>f : () => any +>foo : any let foo = "in"; >foo : string @@ -27,10 +27,10 @@ export function baz1(func = { f() { return foo } }) { // error export function baz2(func = function () { return foo }) { ->baz2 : (func?: () => string) => void ->func : () => string ->function () { return foo } : () => string ->foo : string +>baz2 : (func?: () => any) => void +>func : () => any +>function () { return foo } : () => any +>foo : any let foo = "in"; >foo : string @@ -42,8 +42,8 @@ export function baz3(func = class { x = foo }) { >baz3 : (func?: typeof (Anonymous class)) => void >func : typeof (Anonymous class) >class { x = foo } : typeof (Anonymous class) ->x : string ->foo : string +>x : any +>foo : any let foo = "in"; >foo : string diff --git a/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js b/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js index 238fdea900..954c531cfa 100644 --- a/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js +++ b/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js @@ -29,6 +29,7 @@ const toThenableInferred = (fn: (input: Input) => Result | Thenab //// [genericCallWithinOwnBodyCastTypeParameterIdentity.js] +"use strict"; const toThenable = (fn) => (input) => { const result = fn(input); return { diff --git a/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js.diff b/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js.diff deleted file mode 100644 index fce0cfae13..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericCallWithinOwnBodyCastTypeParameterIdentity.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericCallWithinOwnBodyCastTypeParameterIdentity.js -+++ new.genericCallWithinOwnBodyCastTypeParameterIdentity.js -@@= skipped -28, +28 lines =@@ - - - //// [genericCallWithinOwnBodyCastTypeParameterIdentity.js] --"use strict"; - const toThenable = (fn) => (input) => { - const result = fn(input); - return { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericClassWithStaticsUsingTypeArguments.js.diff b/testdata/baselines/reference/submodule/compiler/genericClassWithStaticsUsingTypeArguments.js.diff index 0a9021b60f..248c48accc 100644 --- a/testdata/baselines/reference/submodule/compiler/genericClassWithStaticsUsingTypeArguments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/genericClassWithStaticsUsingTypeArguments.js.diff @@ -1,27 +1,19 @@ --- old.genericClassWithStaticsUsingTypeArguments.js +++ new.genericClassWithStaticsUsingTypeArguments.js -@@= skipped -20, +20 lines =@@ - +@@= skipped -21, +21 lines =@@ //// [genericClassWithStaticsUsingTypeArguments.js] // Should be error to use 'T' in all declarations within Foo. --let Foo = (() => { -- class Foo { -- static f(xs) { -- return xs.reverse(); -- } -+class Foo { + class Foo { + static a = (n) => { }; + static b; + static c = []; + static d = false || ((x) => x || undefined)(null); + static e = function (x) { return null; }; -+ static f(xs) { -+ return xs.reverse(); + static f(xs) { + return xs.reverse(); } -- Foo.a = (n) => { }; -- Foo.c = []; -- Foo.d = false || ((x) => x || undefined)(null); -- Foo.e = function (x) { return null; }; -- return Foo; --})(); -+} \ No newline at end of file + } +-Foo.a = (n) => { }; +-Foo.c = []; +-Foo.d = false || ((x) => x || undefined)(null); +-Foo.e = function (x) { return null; }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.types.diff b/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.types.diff rename to testdata/baselines/reference/submodule/compiler/genericDefaultsJs.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js b/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js index eac4f5f8e0..cbb72e8ab1 100644 --- a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js +++ b/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js @@ -34,6 +34,7 @@ enhancer4.onChange(null); //// [genericFunctionInference2.js] +// Repro from #30685 const myReducer1 = combineReducers({ combined: combineReducers({ foo }), }); diff --git a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js.diff b/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js.diff deleted file mode 100644 index 57fccd601a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericFunctionInference2.js -+++ new.genericFunctionInference2.js -@@= skipped -33, +33 lines =@@ - - - //// [genericFunctionInference2.js] --// Repro from #30685 - const myReducer1 = combineReducers({ - combined: combineReducers({ foo }), - }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js b/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js index 66dd327563..f7ea78b01d 100644 --- a/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js +++ b/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js @@ -9,6 +9,7 @@ const a = f((_: K) => _ => ({})); // (_: K) //// [genericFunctionsNotContextSensitive.js] +"use strict"; // Repro from #37110 const f = (_) => _; const a = f((_) => _ => ({})); // (_: K) => (_: G) => {} diff --git a/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js.diff b/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js.diff deleted file mode 100644 index e734247968..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericFunctionsNotContextSensitive.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericFunctionsNotContextSensitive.js -+++ new.genericFunctionsNotContextSensitive.js -@@= skipped -8, +8 lines =@@ - - - //// [genericFunctionsNotContextSensitive.js] --"use strict"; - // Repro from #37110 - const f = (_) => _; - const a = f((_) => _ => ({})); // (_: K) => (_: G) => {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js index b630ace2fd..0dc883cc89 100644 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js +++ b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js @@ -16,6 +16,8 @@ f1<"b">(event => { }); //// [genericInferenceDefaultTypeParameter.js] +"use strict"; +// Repro from #50858 f1(event => { }); f1(event => { }); f1(event => { }); diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff deleted file mode 100644 index 58907b3091..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.genericInferenceDefaultTypeParameter.js -+++ new.genericInferenceDefaultTypeParameter.js -@@= skipped -15, +15 lines =@@ - - - //// [genericInferenceDefaultTypeParameter.js] --"use strict"; --// Repro from #50858 - f1(event => { }); - f1(event => { }); - f1(event => { }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js index 5dc0a47dea..7c9d1c4b98 100644 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js +++ b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js @@ -18,11 +18,11 @@ const v1 = e.preventDefault()} />; //// [genericInferenceDefaultTypeParameterJsxReact.js] "use strict"; +/// var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -/// // Repro from #50858 const react_1 = __importDefault(require("react")); function Component(props) { diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff deleted file mode 100644 index fb30d959fd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.genericInferenceDefaultTypeParameterJsxReact.js -+++ new.genericInferenceDefaultTypeParameterJsxReact.js -@@= skipped -17, +17 lines =@@ - - //// [genericInferenceDefaultTypeParameterJsxReact.js] - "use strict"; --/// - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); -+/// - // Repro from #50858 --var react_1 = __importDefault(require("react")); -+const react_1 = __importDefault(require("react")); - function Component(props) { - return react_1.default.createElement(react_1.default.Fragment, null); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js index 64a67ccc66..4f6c2901ae 100644 --- a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js +++ b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js @@ -13,17 +13,8 @@ let o2: { b: string, x: number } = test(o1); //// [genericIsNeverEmptyObject.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; +"use strict"; +// Repro from #29067 var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) @@ -35,10 +26,9 @@ var __rest = (this && this.__rest) || function (s, e) { } return t; }; -// Repro from #29067 function test(obj) { let { a } = obj, rest = __rest(obj, ["a"]); - return __assign(__assign({}, rest), { b: a }); + return Object.assign(Object.assign({}, rest), { b: a }); } let o1 = { a: 'hello', x: 42 }; let o2 = test(o1); diff --git a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff deleted file mode 100644 index f4c36261ad..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.genericIsNeverEmptyObject.js -+++ new.genericIsNeverEmptyObject.js -@@= skipped -12, +12 lines =@@ - - - //// [genericIsNeverEmptyObject.js] --"use strict"; --// Repro from #29067 - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -24, +22 lines =@@ - } - return t; - }; -+// Repro from #29067 - function test(obj) { - let { a } = obj, rest = __rest(obj, ["a"]); - return __assign(__assign({}, rest), { b: a }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js b/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js index bf184227d9..425c23a32c 100644 --- a/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js +++ b/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js @@ -29,6 +29,7 @@ interface RecordInterface2 extends RemapRecord {} //// [genericMappedTypeAsClause.js] +"use strict"; const foo1 = { aFoo: 'test', bFoo: 42 }; const foo2 = { bFoo: 'bar' }; // Error function f1() { diff --git a/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js.diff b/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js.diff deleted file mode 100644 index f850b4d1de..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericMappedTypeAsClause.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericMappedTypeAsClause.js -+++ new.genericMappedTypeAsClause.js -@@= skipped -28, +28 lines =@@ - - - //// [genericMappedTypeAsClause.js] --"use strict"; - const foo1 = { aFoo: 'test', bFoo: 42 }; - const foo2 = { bFoo: 'bar' }; // Error - function f1() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericMemberFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.errors.txt new file mode 100644 index 0000000000..16af297523 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.errors.txt @@ -0,0 +1,34 @@ +genericMemberFunction.ts(16,5): error TS2304: Cannot find name 'a'. +genericMemberFunction.ts(17,5): error TS2304: Cannot find name 'removedFiles'. +genericMemberFunction.ts(18,12): error TS2339: Property 'removeFile' does not exist on type 'BuildResult'. + + +==== genericMemberFunction.ts (3 errors) ==== + export class BuildError{ + public parent(): FileWithErrors { + return undefined; + } + } + export class FileWithErrors{ + public errors(): BuildError[] { + return undefined; + } + public parent(): BuildResult { + return undefined; + } + } + export class BuildResult{ + public merge(other: BuildResult): void { + a.b.c.d.e.f.g = 0; + ~ +!!! error TS2304: Cannot find name 'a'. + removedFiles.forEach((each: FileWithErrors) => { + ~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'removedFiles'. + this.removeFile(each); + ~~~~~~~~~~ +!!! error TS2339: Property 'removeFile' does not exist on type 'BuildResult'. + }); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericMemberFunction.js b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.js new file mode 100644 index 0000000000..121c82c788 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.js @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/genericMemberFunction.ts] //// + +//// [genericMemberFunction.ts] +export class BuildError{ + public parent(): FileWithErrors { + return undefined; + } +} +export class FileWithErrors{ + public errors(): BuildError[] { + return undefined; + } + public parent(): BuildResult { + return undefined; + } +} +export class BuildResult{ + public merge(other: BuildResult): void { + a.b.c.d.e.f.g = 0; + removedFiles.forEach((each: FileWithErrors) => { + this.removeFile(each); + }); + } +} + + +//// [genericMemberFunction.js] +export class BuildError { + parent() { + return undefined; + } +} +export class FileWithErrors { + errors() { + return undefined; + } + parent() { + return undefined; + } +} +export class BuildResult { + merge(other) { + a.b.c.d.e.f.g = 0; + removedFiles.forEach((each) => { + this.removeFile(each); + }); + } +} diff --git a/testdata/baselines/reference/submodule/compiler/genericMemberFunction.symbols b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.symbols new file mode 100644 index 0000000000..8488c82bc8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.symbols @@ -0,0 +1,97 @@ +//// [tests/cases/compiler/genericMemberFunction.ts] //// + +=== genericMemberFunction.ts === +export class BuildError{ +>BuildError : Symbol(BuildError, Decl(genericMemberFunction.ts, 0, 0)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 0, 24)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 0, 26)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 0, 29)) + + public parent(): FileWithErrors { +>parent : Symbol(BuildError.parent, Decl(genericMemberFunction.ts, 0, 33)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 1, 16)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 1, 18)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 1, 16)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 1, 31)) +>FileWithErrors : Symbol(FileWithErrors, Decl(genericMemberFunction.ts, 4, 1)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 1, 16)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 1, 18)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 1, 31)) + + return undefined; +>undefined : Symbol(undefined) + } +} +export class FileWithErrors{ +>FileWithErrors : Symbol(FileWithErrors, Decl(genericMemberFunction.ts, 4, 1)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 5, 28)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 5, 30)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 5, 33)) + + public errors(): BuildError[] { +>errors : Symbol(FileWithErrors.errors, Decl(genericMemberFunction.ts, 5, 37)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 6, 16)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 6, 18)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 6, 16)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 6, 31)) +>BuildError : Symbol(BuildError, Decl(genericMemberFunction.ts, 0, 0)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 6, 16)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 6, 18)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 6, 31)) + + return undefined; +>undefined : Symbol(undefined) + } + public parent(): BuildResult { +>parent : Symbol(FileWithErrors.parent, Decl(genericMemberFunction.ts, 8, 3)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 9, 16)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 9, 18)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 9, 16)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 9, 31)) +>BuildResult : Symbol(BuildResult, Decl(genericMemberFunction.ts, 12, 1)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 9, 16)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 9, 18)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 9, 31)) + + return undefined; +>undefined : Symbol(undefined) + } +} +export class BuildResult{ +>BuildResult : Symbol(BuildResult, Decl(genericMemberFunction.ts, 12, 1)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 13, 25)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 13, 27)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 13, 30)) + + public merge(other: BuildResult): void { +>merge : Symbol(BuildResult.merge, Decl(genericMemberFunction.ts, 13, 34)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 14, 15)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 14, 17)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 14, 15)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 14, 30)) +>other : Symbol(other, Decl(genericMemberFunction.ts, 14, 34)) +>BuildResult : Symbol(BuildResult, Decl(genericMemberFunction.ts, 12, 1)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 14, 15)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 14, 17)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 14, 30)) + + a.b.c.d.e.f.g = 0; + removedFiles.forEach((each: FileWithErrors) => { +>A : Symbol(A, Decl(genericMemberFunction.ts, 16, 26)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 16, 28)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 16, 26)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 16, 41)) +>each : Symbol(each, Decl(genericMemberFunction.ts, 16, 45)) +>FileWithErrors : Symbol(FileWithErrors, Decl(genericMemberFunction.ts, 4, 1)) +>A : Symbol(A, Decl(genericMemberFunction.ts, 16, 26)) +>B : Symbol(B, Decl(genericMemberFunction.ts, 16, 28)) +>C : Symbol(C, Decl(genericMemberFunction.ts, 16, 41)) + + this.removeFile(each); +>this : Symbol(BuildResult, Decl(genericMemberFunction.ts, 12, 1)) +>each : Symbol(each, Decl(genericMemberFunction.ts, 16, 45)) + + }); + } +} + diff --git a/testdata/baselines/reference/submodule/compiler/genericMemberFunction.types b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.types new file mode 100644 index 0000000000..a203f8ffea --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.types @@ -0,0 +1,72 @@ +//// [tests/cases/compiler/genericMemberFunction.ts] //// + +=== genericMemberFunction.ts === +export class BuildError{ +>BuildError : BuildError + + public parent(): FileWithErrors { +>parent : () => FileWithErrors + + return undefined; +>undefined : undefined + } +} +export class FileWithErrors{ +>FileWithErrors : FileWithErrors + + public errors(): BuildError[] { +>errors : () => BuildError[] + + return undefined; +>undefined : undefined + } + public parent(): BuildResult { +>parent : () => BuildResult + + return undefined; +>undefined : undefined + } +} +export class BuildResult{ +>BuildResult : BuildResult + + public merge(other: BuildResult): void { +>merge : (other: BuildResult) => void +>other : BuildResult + + a.b.c.d.e.f.g = 0; +>a.b.c.d.e.f.g = 0 : 0 +>a.b.c.d.e.f.g : any +>a.b.c.d.e.f : any +>a.b.c.d.e : any +>a.b.c.d : any +>a.b.c : any +>a.b : any +>a : any +>b : any +>c : any +>d : any +>e : any +>f : any +>g : any +>0 : 0 + + removedFiles.forEach((each: FileWithErrors) => { +>removedFiles.forEach((each: FileWithErrors) => { this.removeFile(each); }) : any +>removedFiles.forEach : any +>removedFiles : any +>forEach : any +>(each: FileWithErrors) => { this.removeFile(each); } : (each: FileWithErrors) => void +>each : FileWithErrors + + this.removeFile(each); +>this.removeFile(each) : any +>this.removeFile : any +>this : this +>removeFile : any +>each : FileWithErrors + + }); + } +} + diff --git a/testdata/baselines/reference/submodule/compiler/genericMemberFunction.types.diff b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.types.diff new file mode 100644 index 0000000000..b2abff18a4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericMemberFunction.types.diff @@ -0,0 +1,11 @@ +--- old.genericMemberFunction.types ++++ new.genericMemberFunction.types +@@= skipped -30, +30 lines =@@ + >BuildResult : BuildResult + + public merge(other: BuildResult): void { +->merge : (other: BuildResult) => void ++>merge : (other: BuildResult) => void + >other : BuildResult + + a.b.c.d.e.f.g = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js index 3440eff575..32cc291aab 100644 --- a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js +++ b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js @@ -30,6 +30,8 @@ function assignmentWithComplexRest3() { } //// [genericRestTypes.js] +"use strict"; +// Repro from #25793 function assignmentWithComplexRest() { const fn1 = (x, ..._) => x; const fn2 = fn1; diff --git a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff deleted file mode 100644 index 327b439fef..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.genericRestTypes.js -+++ new.genericRestTypes.js -@@= skipped -29, +29 lines =@@ - } - - //// [genericRestTypes.js] --"use strict"; --// Repro from #25793 - function assignmentWithComplexRest() { - const fn1 = (x, ..._) => x; - const fn2 = fn1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.errors.txt b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.errors.txt new file mode 100644 index 0000000000..80cb5a9db8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.errors.txt @@ -0,0 +1,14 @@ +genericReturnTypeFromGetter1.ts(5,18): error TS2314: Generic type 'A' requires 1 type argument(s). + + +==== genericReturnTypeFromGetter1.ts (1 errors) ==== + export interface A { + new (dbSet: DbSet): T; + } + export class DbSet { + _entityType: A; + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + get entityType() { return this._entityType; } // used to ICE without return type annotation + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.js b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.js new file mode 100644 index 0000000000..3be833d75c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/genericReturnTypeFromGetter1.ts] //// + +//// [genericReturnTypeFromGetter1.ts] +export interface A { + new (dbSet: DbSet): T; +} +export class DbSet { + _entityType: A; + get entityType() { return this._entityType; } // used to ICE without return type annotation +} + + +//// [genericReturnTypeFromGetter1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DbSet = void 0; +class DbSet { + _entityType; + get entityType() { return this._entityType; } // used to ICE without return type annotation +} +exports.DbSet = DbSet; diff --git a/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.js.diff b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.js.diff new file mode 100644 index 0000000000..fed7900e73 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.js.diff @@ -0,0 +1,10 @@ +--- old.genericReturnTypeFromGetter1.js ++++ new.genericReturnTypeFromGetter1.js +@@= skipped -14, +14 lines =@@ + Object.defineProperty(exports, "__esModule", { value: true }); + exports.DbSet = void 0; + class DbSet { ++ _entityType; + get entityType() { return this._entityType; } // used to ICE without return type annotation + } + exports.DbSet = DbSet; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.symbols b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.symbols new file mode 100644 index 0000000000..3722433471 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.symbols @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/genericReturnTypeFromGetter1.ts] //// + +=== genericReturnTypeFromGetter1.ts === +export interface A { +>A : Symbol(A, Decl(genericReturnTypeFromGetter1.ts, 0, 0)) +>T : Symbol(T, Decl(genericReturnTypeFromGetter1.ts, 0, 19)) + + new (dbSet: DbSet): T; +>dbSet : Symbol(dbSet, Decl(genericReturnTypeFromGetter1.ts, 1, 8)) +>DbSet : Symbol(DbSet, Decl(genericReturnTypeFromGetter1.ts, 2, 1)) +>T : Symbol(T, Decl(genericReturnTypeFromGetter1.ts, 0, 19)) +>T : Symbol(T, Decl(genericReturnTypeFromGetter1.ts, 0, 19)) +} +export class DbSet { +>DbSet : Symbol(DbSet, Decl(genericReturnTypeFromGetter1.ts, 2, 1)) +>T : Symbol(T, Decl(genericReturnTypeFromGetter1.ts, 3, 19)) + + _entityType: A; +>_entityType : Symbol(DbSet._entityType, Decl(genericReturnTypeFromGetter1.ts, 3, 23)) +>A : Symbol(A, Decl(genericReturnTypeFromGetter1.ts, 0, 0)) + + get entityType() { return this._entityType; } // used to ICE without return type annotation +>entityType : Symbol(DbSet.entityType, Decl(genericReturnTypeFromGetter1.ts, 4, 19)) +>this._entityType : Symbol(DbSet._entityType, Decl(genericReturnTypeFromGetter1.ts, 3, 23)) +>this : Symbol(DbSet, Decl(genericReturnTypeFromGetter1.ts, 2, 1)) +>_entityType : Symbol(DbSet._entityType, Decl(genericReturnTypeFromGetter1.ts, 3, 23)) +} + diff --git a/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.types b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.types new file mode 100644 index 0000000000..c6d8904b05 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericReturnTypeFromGetter1.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/genericReturnTypeFromGetter1.ts] //// + +=== genericReturnTypeFromGetter1.ts === +export interface A { + new (dbSet: DbSet): T; +>dbSet : DbSet +} +export class DbSet { +>DbSet : DbSet + + _entityType: A; +>_entityType : any + + get entityType() { return this._entityType; } // used to ICE without return type annotation +>entityType : any +>this._entityType : any +>this : this +>_entityType : any +} + diff --git a/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js b/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js index 1a0cf014d5..61aaac7554 100644 --- a/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js +++ b/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js @@ -22,6 +22,7 @@ function user(t: T) { //// [genericUnboundedTypeParamAssignability.js] +"use strict"; function f1(o) { o.toString(); // error } diff --git a/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js.diff b/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js.diff deleted file mode 100644 index 090c302909..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericUnboundedTypeParamAssignability.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericUnboundedTypeParamAssignability.js -+++ new.genericUnboundedTypeParamAssignability.js -@@= skipped -21, +21 lines =@@ - - - //// [genericUnboundedTypeParamAssignability.js] --"use strict"; - function f1(o) { - o.toString(); // error - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js b/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js index a77dd8e31a..27e781af5c 100644 --- a/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js +++ b/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js @@ -32,6 +32,7 @@ function yes() { } //// [genericWithNoConstraintComparableWithCurlyCurly.js] +"use strict"; function foo() { let x = {}; x; diff --git a/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js.diff b/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js.diff deleted file mode 100644 index b70eed9488..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericWithNoConstraintComparableWithCurlyCurly.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericWithNoConstraintComparableWithCurlyCurly.js -+++ new.genericWithNoConstraintComparableWithCurlyCurly.js -@@= skipped -31, +31 lines =@@ - } - - //// [genericWithNoConstraintComparableWithCurlyCurly.js] --"use strict"; - function foo() { - let x = {}; - x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js index 81379d9a8e..6431ba8cb8 100644 --- a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js +++ b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js @@ -13,4 +13,6 @@ cases(fn(opts => { })); //// [getParameterNameAtPosition.js] +"use strict"; +// Repro from #30171 cases(fn(opts => { })); diff --git a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff deleted file mode 100644 index 6faee97c2a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.getParameterNameAtPosition.js -+++ new.getParameterNameAtPosition.js -@@= skipped -12, +12 lines =@@ - - - //// [getParameterNameAtPosition.js] --"use strict"; --// Repro from #30171 - cases(fn(opts => { })); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/giant.errors.txt b/testdata/baselines/reference/submodule/compiler/giant.errors.txt new file mode 100644 index 0000000000..47c79a67ce --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/giant.errors.txt @@ -0,0 +1,1377 @@ +giant.ts(23,12): error TS2300: Duplicate identifier 'pgF'. +giant.ts(24,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(24,20): error TS1005: '{' expected. +giant.ts(25,12): error TS2300: Duplicate identifier 'psF'. +giant.ts(26,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(26,29): error TS1005: '{' expected. +giant.ts(27,13): error TS2300: Duplicate identifier 'rgF'. +giant.ts(28,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(28,21): error TS1005: '{' expected. +giant.ts(29,13): error TS2300: Duplicate identifier 'rsF'. +giant.ts(30,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(30,30): error TS1005: '{' expected. +giant.ts(33,12): error TS2300: Duplicate identifier 'tsF'. +giant.ts(34,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(34,29): error TS1005: '{' expected. +giant.ts(35,12): error TS2300: Duplicate identifier 'tgF'. +giant.ts(36,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(36,20): error TS1005: '{' expected. +giant.ts(62,5): error TS1021: An index signature must have a type annotation. +giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. +giant.ts(76,5): error TS2386: Overload signatures must all be optional or required. +giant.ts(87,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(88,20): error TS2300: Duplicate identifier 'pgF'. +giant.ts(88,24): error TS1005: '{' expected. +giant.ts(89,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(90,20): error TS2300: Duplicate identifier 'psF'. +giant.ts(90,33): error TS1005: '{' expected. +giant.ts(91,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(92,21): error TS2300: Duplicate identifier 'rgF'. +giant.ts(92,25): error TS1005: '{' expected. +giant.ts(93,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(94,21): error TS2300: Duplicate identifier 'rsF'. +giant.ts(94,34): error TS1005: '{' expected. +giant.ts(97,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(98,20): error TS2300: Duplicate identifier 'tsF'. +giant.ts(98,33): error TS1005: '{' expected. +giant.ts(99,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(100,20): error TS2300: Duplicate identifier 'tgF'. +giant.ts(100,24): error TS1005: '{' expected. +giant.ts(126,9): error TS1021: An index signature must have a type annotation. +giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. +giant.ts(140,9): error TS2386: Overload signatures must all be optional or required. +giant.ts(154,39): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(166,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(167,20): error TS2300: Duplicate identifier 'pgF'. +giant.ts(167,24): error TS1005: '{' expected. +giant.ts(168,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(169,20): error TS2300: Duplicate identifier 'psF'. +giant.ts(169,33): error TS1005: '{' expected. +giant.ts(170,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(171,21): error TS2300: Duplicate identifier 'rgF'. +giant.ts(171,25): error TS1005: '{' expected. +giant.ts(172,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(173,21): error TS2300: Duplicate identifier 'rsF'. +giant.ts(173,34): error TS1005: '{' expected. +giant.ts(176,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(177,20): error TS2300: Duplicate identifier 'tsF'. +giant.ts(177,33): error TS1005: '{' expected. +giant.ts(178,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(179,20): error TS2300: Duplicate identifier 'tgF'. +giant.ts(179,24): error TS1005: '{' expected. +giant.ts(205,9): error TS1021: An index signature must have a type annotation. +giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. +giant.ts(219,9): error TS2386: Overload signatures must all be optional or required. +giant.ts(233,39): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(238,35): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(240,24): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(243,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(244,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(245,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(246,20): error TS2300: Duplicate identifier 'pgF'. +giant.ts(247,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(247,31): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(248,20): error TS2300: Duplicate identifier 'psF'. +giant.ts(249,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(249,23): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(250,21): error TS2300: Duplicate identifier 'rgF'. +giant.ts(251,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(251,32): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(252,21): error TS2300: Duplicate identifier 'rsF'. +giant.ts(254,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(255,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(255,31): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(256,20): error TS2300: Duplicate identifier 'tsF'. +giant.ts(257,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(257,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(258,20): error TS2300: Duplicate identifier 'tgF'. +giant.ts(262,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(262,25): error TS1036: Statements are not allowed in ambient contexts. +giant.ts(267,30): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(281,12): error TS2300: Duplicate identifier 'pgF'. +giant.ts(282,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(282,20): error TS1005: '{' expected. +giant.ts(283,12): error TS2300: Duplicate identifier 'psF'. +giant.ts(284,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(284,29): error TS1005: '{' expected. +giant.ts(285,13): error TS2300: Duplicate identifier 'rgF'. +giant.ts(286,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(286,21): error TS1005: '{' expected. +giant.ts(287,13): error TS2300: Duplicate identifier 'rsF'. +giant.ts(288,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(288,30): error TS1005: '{' expected. +giant.ts(291,12): error TS2300: Duplicate identifier 'tsF'. +giant.ts(292,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(292,29): error TS1005: '{' expected. +giant.ts(293,12): error TS2300: Duplicate identifier 'tgF'. +giant.ts(294,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(294,20): error TS1005: '{' expected. +giant.ts(320,5): error TS1021: An index signature must have a type annotation. +giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. +giant.ts(334,5): error TS2386: Overload signatures must all be optional or required. +giant.ts(345,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(346,20): error TS2300: Duplicate identifier 'pgF'. +giant.ts(346,24): error TS1005: '{' expected. +giant.ts(347,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(348,20): error TS2300: Duplicate identifier 'psF'. +giant.ts(348,33): error TS1005: '{' expected. +giant.ts(349,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(350,21): error TS2300: Duplicate identifier 'rgF'. +giant.ts(350,25): error TS1005: '{' expected. +giant.ts(351,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(352,21): error TS2300: Duplicate identifier 'rsF'. +giant.ts(352,34): error TS1005: '{' expected. +giant.ts(355,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(356,20): error TS2300: Duplicate identifier 'tsF'. +giant.ts(356,33): error TS1005: '{' expected. +giant.ts(357,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(358,20): error TS2300: Duplicate identifier 'tgF'. +giant.ts(358,24): error TS1005: '{' expected. +giant.ts(384,9): error TS1021: An index signature must have a type annotation. +giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. +giant.ts(398,9): error TS2386: Overload signatures must all be optional or required. +giant.ts(412,39): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(424,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(425,20): error TS2300: Duplicate identifier 'pgF'. +giant.ts(425,24): error TS1005: '{' expected. +giant.ts(426,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(427,20): error TS2300: Duplicate identifier 'psF'. +giant.ts(427,33): error TS1005: '{' expected. +giant.ts(428,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(429,21): error TS2300: Duplicate identifier 'rgF'. +giant.ts(429,25): error TS1005: '{' expected. +giant.ts(430,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(431,21): error TS2300: Duplicate identifier 'rsF'. +giant.ts(431,34): error TS1005: '{' expected. +giant.ts(434,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(435,20): error TS2300: Duplicate identifier 'tsF'. +giant.ts(435,33): error TS1005: '{' expected. +giant.ts(436,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(437,20): error TS2300: Duplicate identifier 'tgF'. +giant.ts(437,24): error TS1005: '{' expected. +giant.ts(463,9): error TS1021: An index signature must have a type annotation. +giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. +giant.ts(477,9): error TS2386: Overload signatures must all be optional or required. +giant.ts(491,39): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(496,35): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(498,24): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(501,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(502,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(503,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(504,20): error TS2300: Duplicate identifier 'pgF'. +giant.ts(505,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(505,31): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(506,20): error TS2300: Duplicate identifier 'psF'. +giant.ts(507,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(507,23): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(508,21): error TS2300: Duplicate identifier 'rgF'. +giant.ts(509,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(509,32): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(510,21): error TS2300: Duplicate identifier 'rsF'. +giant.ts(512,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(513,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(513,31): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(514,20): error TS2300: Duplicate identifier 'tsF'. +giant.ts(515,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(515,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(516,20): error TS2300: Duplicate identifier 'tgF'. +giant.ts(520,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(520,25): error TS1036: Statements are not allowed in ambient contexts. +giant.ts(525,30): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(532,31): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(534,20): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(537,17): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(538,18): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(539,12): error TS2300: Duplicate identifier 'pgF'. +giant.ts(539,18): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(540,16): error TS2300: Duplicate identifier 'pgF'. +giant.ts(541,12): error TS2300: Duplicate identifier 'psF'. +giant.ts(541,27): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(542,16): error TS2300: Duplicate identifier 'psF'. +giant.ts(543,13): error TS2300: Duplicate identifier 'rgF'. +giant.ts(543,19): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(544,17): error TS2300: Duplicate identifier 'rgF'. +giant.ts(545,13): error TS2300: Duplicate identifier 'rsF'. +giant.ts(545,28): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(546,17): error TS2300: Duplicate identifier 'rsF'. +giant.ts(548,17): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(549,12): error TS2300: Duplicate identifier 'tsF'. +giant.ts(549,27): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(550,16): error TS2300: Duplicate identifier 'tsF'. +giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'. +giant.ts(551,18): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'. +giant.ts(556,18): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(556,21): error TS1036: Statements are not allowed in ambient contexts. +giant.ts(558,24): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(561,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(563,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(588,9): error TS1021: An index signature must have a type annotation. +giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. +giant.ts(602,9): error TS2386: Overload signatures must all be optional or required. +giant.ts(606,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(606,25): error TS1036: Statements are not allowed in ambient contexts. +giant.ts(611,30): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(615,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. +giant.ts(616,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. +giant.ts(616,39): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(617,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. +giant.ts(618,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. +giant.ts(621,26): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(623,24): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(626,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(628,21): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(654,9): error TS1021: An index signature must have a type annotation. +giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. +giant.ts(668,9): error TS2386: Overload signatures must all be optional or required. +giant.ts(672,22): error TS1183: An implementation cannot be declared in ambient contexts. +giant.ts(672,25): error TS1036: Statements are not allowed in ambient contexts. +giant.ts(676,30): error TS1183: An implementation cannot be declared in ambient contexts. + + +==== giant.ts (231 errors) ==== + /* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS + */ + const p = "propName"; + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1005: '{' expected. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1005: '{' expected. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1005: '{' expected. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1005: '{' expected. + static tV; + static tF() { } + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1005: '{' expected. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1005: '{' expected. + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + module M { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1005: '{' expected. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1005: '{' expected. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1005: '{' expected. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1005: '{' expected. + static tV; + static tF() { } + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1005: '{' expected. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1005: '{' expected. + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + module M { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { }; + export declare module eaM { }; + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1005: '{' expected. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1005: '{' expected. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1005: '{' expected. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1005: '{' expected. + static tV; + static tF() { } + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1005: '{' expected. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1005: '{' expected. + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + export module eM { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { }; + export declare module eaM { }; + } + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { + constructor () { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pV; + private rV; + public pF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private rF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + static tV; + static tF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + } + export declare module eaM { + var V; + function F() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export class eC { } + export interface eI { } + export module eM { } + } + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1005: '{' expected. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1005: '{' expected. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1005: '{' expected. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1005: '{' expected. + static tV; + static tF() { } + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1005: '{' expected. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1005: '{' expected. + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + export module eM { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1005: '{' expected. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1005: '{' expected. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1005: '{' expected. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1005: '{' expected. + static tV; + static tF() { } + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1005: '{' expected. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1005: '{' expected. + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + module M { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { }; + export declare module eaM { }; + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1005: '{' expected. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1005: '{' expected. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1005: '{' expected. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1005: '{' expected. + static tV; + static tF() { } + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1005: '{' expected. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1005: '{' expected. + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + export module eM { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { }; + export declare module eaM { }; + } + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { + constructor () { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pV; + private rV; + public pF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private rF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + static tV; + static tF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + } + export declare module eaM { + var V; + function F() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export class eC { } + export interface eI { } + export module eM { } + } + } + export declare var eaV; + export declare function eaF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { + constructor () { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pV; + private rV; + public pF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private rF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public get pgF() + ~~~ +!!! error TS2300: Duplicate identifier 'pgF'. + public psF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public set psF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'psF'. + private rgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private get rgF() + ~~~ +!!! error TS2300: Duplicate identifier 'rgF'. + private rsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + private set rsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'rsF'. + static tV; + static tF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static tsF(param:any) { } + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static set tsF(param:any) + ~~~ +!!! error TS2300: Duplicate identifier 'tsF'. + static tgF() { } + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static get tgF() + ~~~ +!!! error TS2300: Duplicate identifier 'tgF'. + } + export declare module eaM { + var V; + function F() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + class C { + constructor () { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pV; + private rV; + public pF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static tV; + static tF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + } + interface I { + //Call Signature + (); + (): number; + (p: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + module M { + var V; + function F() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export class eC { } + export interface eI { } + export module eM { } + export declare var eaV + ~~~~~~~ +!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. + export declare function eaF() { }; + ~~~~~~~ +!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export declare class eaC { } + ~~~~~~~ +!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. + export declare module eaM { } + ~~~~~~~ +!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. + } + export var eV; + export function eF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export class eC { + constructor () { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + public pV; + private rV; + public pF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + static tV + static tF() { } + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + ~~~~~~~~~~~~~ +!!! error TS1021: An index signature must have a type annotation. + [p2: string, p3: number]; + ~~ +!!! error TS1096: An index signature must have exactly one parameter. + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + ~~ +!!! error TS2386: Overload signatures must all be optional or required. + } + export module eM { + var V; + function F() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + class C { } + module M { } + export var eV; + export function eF() { }; + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. + export class eC { } + export interface eI { } + export module eM { } + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/giant.js b/testdata/baselines/reference/submodule/compiler/giant.js new file mode 100644 index 0000000000..2965b76c07 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/giant.js @@ -0,0 +1,1216 @@ +//// [tests/cases/compiler/giant.ts] //// + +//// [giant.ts] +/* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS +*/ +const p = "propName"; +var V; +function F() { }; +class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() +} +interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; +} +module M { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + module M { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + export module eM { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export declare module eaM { + var V; + function F() { }; + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + } +} +export var eV; +export function eF() { }; +export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() +} +export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; +} +export module eM { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + module M { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + export module eM { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export declare module eaM { + var V; + function F() { }; + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + } +} +export declare var eaV; +export declare function eaF() { }; +export declare class eaC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() +} +export declare module eaM { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + static tV; + static tF() { } + } + interface I { + //Call Signature + (); + (): number; + (p: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + module M { + var V; + function F() { }; + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + export declare var eaV + export declare function eaF() { }; + export declare class eaC { } + export declare module eaM { } + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + static tV + static tF() { } + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + export module eM { + var V; + function F() { }; + class C { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + } +} + +//// [giant.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.eM = exports.eC = exports.eV = void 0; +exports.eF = eF; +/* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS +*/ +const p = "propName"; +var V; +function F() { } +; +class C { + constructor() { } + pV; + rV; + pF() { } + rF() { } + pgF() { } + psF(param) { } + rgF() { } + rsF(param) { } + static tV; + static tF() { } + static tsF(param) { } + static tgF() { } +} +var M; +(function (M_1) { + var V; + function F() { } + ; + class C { + constructor() { } + pV; + rV; + pF() { } + rF() { } + pgF() { } + psF(param) { } + rgF() { } + rsF(param) { } + static tV; + static tF() { } + static tsF(param) { } + static tgF() { } + } + let M; + (function (M) { + var V; + function F() { } + ; + class C { + } + ; + ; + ; + function eF() { } + M.eF = eF; + ; + class eC { + } + M.eC = eC; + ; + ; + ; + ; + ; + ; + })(M || (M = {})); + function eF() { } + M_1.eF = eF; + ; + class eC { + constructor() { } + pV; + rV; + pF() { } + rF() { } + pgF() { } + psF(param) { } + rgF() { } + rsF(param) { } + static tV; + static tF() { } + static tsF(param) { } + static tgF() { } + } + M_1.eC = eC; + let eM; + (function (eM) { + var V; + function F() { } + ; + class C { + } + ; + ; + ; + function eF() { } + eM.eF = eF; + ; + class eC { + } + eM.eC = eC; + ; + ; + ; + ; + ; + ; + })(eM = M_1.eM || (M_1.eM = {})); + ; +})(M || (M = {})); +function eF() { } +; +class eC { + constructor() { } + pV; + rV; + pF() { } + rF() { } + pgF() { } + psF(param) { } + rgF() { } + rsF(param) { } + static tV; + static tF() { } + static tsF(param) { } + static tgF() { } +} +exports.eC = eC; +var eM; +(function (eM_1) { + var V; + function F() { } + ; + class C { + constructor() { } + pV; + rV; + pF() { } + rF() { } + pgF() { } + psF(param) { } + rgF() { } + rsF(param) { } + static tV; + static tF() { } + static tsF(param) { } + static tgF() { } + } + let M; + (function (M) { + var V; + function F() { } + ; + class C { + } + ; + ; + ; + function eF() { } + M.eF = eF; + ; + class eC { + } + M.eC = eC; + ; + ; + ; + ; + ; + ; + })(M || (M = {})); + function eF() { } + eM_1.eF = eF; + ; + class eC { + constructor() { } + pV; + rV; + pF() { } + rF() { } + pgF() { } + psF(param) { } + rgF() { } + rsF(param) { } + static tV; + static tF() { } + static tsF(param) { } + static tgF() { } + } + eM_1.eC = eC; + let eM; + (function (eM) { + var V; + function F() { } + ; + class C { + } + ; + ; + ; + function eF() { } + eM.eF = eF; + ; + class eC { + } + eM.eC = eC; + ; + ; + ; + ; + ; + ; + })(eM = eM_1.eM || (eM_1.eM = {})); + ; +})(eM || (exports.eM = eM = {})); +; + + +//// [giant.d.ts] +declare const p = "propName"; +export declare var eV: any; +export declare function eF(): void; +export declare class eC { + constructor(); + pV: any; + private rV; + pF(): void; + private rF; + pgF(): void; + get pgF(): any; + psF(param: any): void; + set psF(param: any); + private rgF; + private get rgF(); + private rsF; + private set rsF(value); + static tV: any; + static tF(): void; + static tsF(param: any): void; + static set tsF(param: any); + static tgF(): void; + static get tgF(): any; +} +export interface eI { + (): any; + (): number; + (p: any): any; + (p1: string): any; + (p2?: string): any; + (...p3: any[]): any; + (p4: string, p5?: string): any; + (p6: string, ...p7: any[]): any; + new (): any; + new (): number; + new (p: string): any; + new (p2?: string): any; + new (...p3: any[]): any; + new (p4: string, p5?: string): any; + new (p6: string, ...p7: any[]): any; + [p]: any; + [p1: string]: any; + [p2: string, p3: number]: any; + p: any; + p1?: any; + p2?: string; + p3(): any; + p4?(): any; + p5?(): void; + p6(pa1: any): void; + p7(pa1: any, pa2: any): void; + p7?(pa1: any, pa2: any): void; +} +export declare namespace eM { + var eV: any; + function eF(): void; + class eC { + constructor(); + pV: any; + private rV; + pF(): void; + private rF; + pgF(): void; + get pgF(): any; + psF(param: any): void; + set psF(param: any); + private rgF; + private get rgF(); + private rsF; + private set rsF(value); + static tV: any; + static tF(): void; + static tsF(param: any): void; + static set tsF(param: any); + static tgF(): void; + static get tgF(): any; + } + interface eI { + (): any; + (): number; + (p: any): any; + (p1: string): any; + (p2?: string): any; + (...p3: any[]): any; + (p4: string, p5?: string): any; + (p6: string, ...p7: any[]): any; + new (): any; + new (): number; + new (p: string): any; + new (p2?: string): any; + new (...p3: any[]): any; + new (p4: string, p5?: string): any; + new (p6: string, ...p7: any[]): any; + [p]: any; + [p1: string]: any; + [p2: string, p3: number]: any; + p: any; + p1?: any; + p2?: string; + p3(): any; + p4?(): any; + p5?(): void; + p6(pa1: any): void; + p7(pa1: any, pa2: any): void; + p7?(pa1: any, pa2: any): void; + } + namespace eM { + var eV: any; + function eF(): void; + class eC { + } + interface eI { + } + namespace eM { } + var eaV: any; + function eaF(): void; + class eaC { + } + namespace eaM { } + } + var eaV: any; + function eaF(): void; + class eaC { + constructor(); + pV: any; + private rV; + pF(): void; + private rF; + pgF(): void; + get pgF(): any; + psF(param: any): void; + set psF(param: any); + private rgF; + private get rgF(); + private rsF; + private set rsF(value); + static tV: any; + static tF(): void; + static tsF(param: any): void; + static set tsF(param: any); + static tgF(): void; + static get tgF(): any; + } + namespace eaM { + var V: any; + function F(): void; + class C { + } + interface I { + } + namespace M { } + var eV: any; + function eF(): void; + class eC { + } + interface eI { + } + namespace eM { } + } +} +export declare var eaV: any; +export declare function eaF(): void; +export declare class eaC { + constructor(); + pV: any; + private rV; + pF(): void; + private rF; + pgF(): void; + get pgF(): any; + psF(param: any): void; + set psF(param: any); + private rgF; + private get rgF(); + private rsF; + private set rsF(value); + static tV: any; + static tF(): void; + static tsF(param: any): void; + static set tsF(param: any); + static tgF(): void; + static get tgF(): any; +} +export declare namespace eaM { + var V: any; + function F(): void; + class C { + constructor(); + pV: any; + private rV; + pF(): void; + static tV: any; + static tF(): void; + } + interface I { + (): any; + (): number; + (p: string): any; + (p2?: string): any; + (...p3: any[]): any; + (p4: string, p5?: string): any; + (p6: string, ...p7: any[]): any; + new (): any; + new (): number; + new (p: string): any; + new (p2?: string): any; + new (...p3: any[]): any; + new (p4: string, p5?: string): any; + new (p6: string, ...p7: any[]): any; + [p]: any; + [p1: string]: any; + [p2: string, p3: number]: any; + p: any; + p1?: any; + p2?: string; + p3(): any; + p4?(): any; + p5?(): void; + p6(pa1: any): void; + p7(pa1: any, pa2: any): void; + p7?(pa1: any, pa2: any): void; + } + namespace M { + var V: any; + function F(): void; + class C { + } + interface I { + } + namespace M { } + var eV: any; + function eF(): void; + class eC { + } + interface eI { + } + namespace eM { } + var eaV: any; + function eaF(): void; + class eaC { + } + namespace eaM { } + } + var eV: any; + function eF(): void; + class eC { + constructor(); + pV: any; + private rV; + pF(): void; + static tV: any; + static tF(): void; + } + interface eI { + (): any; + (): number; + (p: any): any; + (p1: string): any; + (p2?: string): any; + (...p3: any[]): any; + (p4: string, p5?: string): any; + (p6: string, ...p7: any[]): any; + new (): any; + new (): number; + new (p: string): any; + new (p2?: string): any; + new (...p3: any[]): any; + new (p4: string, p5?: string): any; + new (p6: string, ...p7: any[]): any; + [p]: any; + [p1: string]: any; + [p2: string, p3: number]: any; + p: any; + p1?: any; + p2?: string; + p3(): any; + p4?(): any; + p5?(): void; + p6(pa1: any): void; + p7(pa1: any, pa2: any): void; + p7?(pa1: any, pa2: any): void; + } + namespace eM { + var V: any; + function F(): void; + class C { + } + namespace M { } + var eV: any; + function eF(): void; + class eC { + } + interface eI { + } + namespace eM { } + } +} +export {}; diff --git a/testdata/baselines/reference/submodule/compiler/giant.js.diff b/testdata/baselines/reference/submodule/compiler/giant.js.diff new file mode 100644 index 0000000000..60f469762b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/giant.js.diff @@ -0,0 +1,152 @@ +--- old.giant.js ++++ new.giant.js +@@= skipped -706, +706 lines =@@ + ; + class C { + constructor() { } ++ pV; ++ rV; + pF() { } + rF() { } + pgF() { } +- get pgF() { } + psF(param) { } +- set psF(param) { } + rgF() { } +- get rgF() { } + rsF(param) { } +- set rsF(param) { } ++ static tV; + static tF() { } + static tsF(param) { } +- static set tsF(param) { } + static tgF() { } +- static get tgF() { } + } + var M; + (function (M_1) { +@@= skipped -23, +20 lines =@@ + ; + class C { + constructor() { } ++ pV; ++ rV; + pF() { } + rF() { } + pgF() { } +- get pgF() { } + psF(param) { } +- set psF(param) { } + rgF() { } +- get rgF() { } + rsF(param) { } +- set rsF(param) { } ++ static tV; + static tF() { } + static tsF(param) { } +- static set tsF(param) { } + static tgF() { } +- static get tgF() { } + } + let M; + (function (M) { +@@= skipped -44, +41 lines =@@ + ; + class eC { + constructor() { } ++ pV; ++ rV; + pF() { } + rF() { } + pgF() { } +- get pgF() { } + psF(param) { } +- set psF(param) { } + rgF() { } +- get rgF() { } + rsF(param) { } +- set rsF(param) { } ++ static tV; + static tF() { } + static tsF(param) { } +- static set tsF(param) { } + static tgF() { } +- static get tgF() { } + } + M_1.eC = eC; + let eM; +@@= skipped -46, +43 lines =@@ + ; + class eC { + constructor() { } ++ pV; ++ rV; + pF() { } + rF() { } + pgF() { } +- get pgF() { } + psF(param) { } +- set psF(param) { } + rgF() { } +- get rgF() { } + rsF(param) { } +- set rsF(param) { } ++ static tV; + static tF() { } + static tsF(param) { } +- static set tsF(param) { } + static tgF() { } +- static get tgF() { } + } + exports.eC = eC; + var eM; +@@= skipped -24, +21 lines =@@ + ; + class C { + constructor() { } ++ pV; ++ rV; + pF() { } + rF() { } + pgF() { } +- get pgF() { } + psF(param) { } +- set psF(param) { } + rgF() { } +- get rgF() { } + rsF(param) { } +- set rsF(param) { } ++ static tV; + static tF() { } + static tsF(param) { } +- static set tsF(param) { } + static tgF() { } +- static get tgF() { } + } + let M; + (function (M) { +@@= skipped -44, +41 lines =@@ + ; + class eC { + constructor() { } ++ pV; ++ rV; + pF() { } + rF() { } + pgF() { } +- get pgF() { } + psF(param) { } +- set psF(param) { } + rgF() { } +- get rgF() { } + rsF(param) { } +- set rsF(param) { } ++ static tV; + static tF() { } + static tsF(param) { } +- static set tsF(param) { } + static tgF() { } +- static get tgF() { } + } + eM_1.eC = eC; + let eM; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/giant.symbols b/testdata/baselines/reference/submodule/compiler/giant.symbols new file mode 100644 index 0000000000..0c7d9c2b21 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/giant.symbols @@ -0,0 +1,1789 @@ +//// [tests/cases/compiler/giant.ts] //// + +=== giant.ts === +/* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS +*/ +const p = "propName"; +>p : Symbol(p, Decl(giant.ts, 13, 5)) + +var V; +>V : Symbol(V, Decl(giant.ts, 14, 3)) + +function F() { }; +>F : Symbol(F, Decl(giant.ts, 14, 6)) + +class C { +>C : Symbol(C, Decl(giant.ts, 15, 17)) + + constructor () { } + public pV; +>pV : Symbol(C.pV, Decl(giant.ts, 17, 22)) + + private rV; +>rV : Symbol(C.rV, Decl(giant.ts, 18, 14)) + + public pF() { } +>pF : Symbol(C.pF, Decl(giant.ts, 19, 15)) + + private rF() { } +>rF : Symbol(C.rF, Decl(giant.ts, 20, 19)) + + public pgF() { } +>pgF : Symbol(C.pgF, Decl(giant.ts, 21, 20)) + + public get pgF() +>pgF : Symbol(C.pgF, Decl(giant.ts, 22, 20)) + + public psF(param:any) { } +>psF : Symbol(C.psF, Decl(giant.ts, 23, 20)) +>param : Symbol(param, Decl(giant.ts, 24, 15)) + + public set psF(param:any) +>psF : Symbol(C.psF, Decl(giant.ts, 24, 29)) +>param : Symbol(param, Decl(giant.ts, 25, 19)) + + private rgF() { } +>rgF : Symbol(C.rgF, Decl(giant.ts, 25, 29)) + + private get rgF() +>rgF : Symbol(C.rgF, Decl(giant.ts, 26, 21)) + + private rsF(param:any) { } +>rsF : Symbol(C.rsF, Decl(giant.ts, 27, 21)) +>param : Symbol(param, Decl(giant.ts, 28, 16)) + + private set rsF(param:any) +>rsF : Symbol(C.rsF, Decl(giant.ts, 28, 30)) +>param : Symbol(param, Decl(giant.ts, 29, 20)) + + static tV; +>tV : Symbol(C.tV, Decl(giant.ts, 29, 30)) + + static tF() { } +>tF : Symbol(C.tF, Decl(giant.ts, 30, 14)) + + static tsF(param:any) { } +>tsF : Symbol(C.tsF, Decl(giant.ts, 31, 19)) +>param : Symbol(param, Decl(giant.ts, 32, 15)) + + static set tsF(param:any) +>tsF : Symbol(C.tsF, Decl(giant.ts, 32, 29)) +>param : Symbol(param, Decl(giant.ts, 33, 19)) + + static tgF() { } +>tgF : Symbol(C.tgF, Decl(giant.ts, 33, 29)) + + static get tgF() +>tgF : Symbol(C.tgF, Decl(giant.ts, 34, 20)) +} +interface I { +>I : Symbol(I, Decl(giant.ts, 36, 1)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 41, 5)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 42, 5)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 43, 5)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 44, 5)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 45, 5)) +>p5 : Symbol(p5, Decl(giant.ts, 45, 16)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 46, 5)) +>p7 : Symbol(p7, Decl(giant.ts, 46, 16)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 53, 9)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 54, 9)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 55, 9)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 56, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 56, 20)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 57, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 57, 20)) + + //Index Signature + [p]; +>[p] : Symbol(I[p], Decl(giant.ts, 57, 35)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 61, 5)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 62, 5)) +>p3 : Symbol(p3, Decl(giant.ts, 62, 16)) + + //Property Signature + p; +>p : Symbol(I.p, Decl(giant.ts, 62, 29)) + + p1?; +>p1 : Symbol(I.p1, Decl(giant.ts, 65, 6)) + + p2?: string; +>p2 : Symbol(I.p2, Decl(giant.ts, 66, 8)) + + //Function Signature + p3(); +>p3 : Symbol(I.p3, Decl(giant.ts, 67, 16)) + + p4? (); +>p4 : Symbol(I.p4, Decl(giant.ts, 70, 9)) + + p5? (): void; +>p5 : Symbol(I.p5, Decl(giant.ts, 71, 11)) + + p6(pa1): void; +>p6 : Symbol(I.p6, Decl(giant.ts, 72, 17)) +>pa1 : Symbol(pa1, Decl(giant.ts, 73, 7)) + + p7(pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 73, 18), Decl(giant.ts, 74, 23)) +>pa1 : Symbol(pa1, Decl(giant.ts, 74, 7)) +>pa2 : Symbol(pa2, Decl(giant.ts, 74, 11)) + + p7? (pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 73, 18), Decl(giant.ts, 74, 23)) +>pa1 : Symbol(pa1, Decl(giant.ts, 75, 9)) +>pa2 : Symbol(pa2, Decl(giant.ts, 75, 13)) +} +module M { +>M : Symbol(M, Decl(giant.ts, 76, 1)) + + var V; +>V : Symbol(V, Decl(giant.ts, 78, 7)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 78, 10)) + + class C { +>C : Symbol(C, Decl(giant.ts, 79, 21)) + + constructor () { } + public pV; +>pV : Symbol(C.pV, Decl(giant.ts, 81, 26)) + + private rV; +>rV : Symbol(C.rV, Decl(giant.ts, 82, 18)) + + public pF() { } +>pF : Symbol(C.pF, Decl(giant.ts, 83, 19)) + + private rF() { } +>rF : Symbol(C.rF, Decl(giant.ts, 84, 23)) + + public pgF() { } +>pgF : Symbol(C.pgF, Decl(giant.ts, 85, 24)) + + public get pgF() +>pgF : Symbol(C.pgF, Decl(giant.ts, 86, 24)) + + public psF(param:any) { } +>psF : Symbol(C.psF, Decl(giant.ts, 87, 24)) +>param : Symbol(param, Decl(giant.ts, 88, 19)) + + public set psF(param:any) +>psF : Symbol(C.psF, Decl(giant.ts, 88, 33)) +>param : Symbol(param, Decl(giant.ts, 89, 23)) + + private rgF() { } +>rgF : Symbol(C.rgF, Decl(giant.ts, 89, 33)) + + private get rgF() +>rgF : Symbol(C.rgF, Decl(giant.ts, 90, 25)) + + private rsF(param:any) { } +>rsF : Symbol(C.rsF, Decl(giant.ts, 91, 25)) +>param : Symbol(param, Decl(giant.ts, 92, 20)) + + private set rsF(param:any) +>rsF : Symbol(C.rsF, Decl(giant.ts, 92, 34)) +>param : Symbol(param, Decl(giant.ts, 93, 24)) + + static tV; +>tV : Symbol(C.tV, Decl(giant.ts, 93, 34)) + + static tF() { } +>tF : Symbol(C.tF, Decl(giant.ts, 94, 18)) + + static tsF(param:any) { } +>tsF : Symbol(C.tsF, Decl(giant.ts, 95, 23)) +>param : Symbol(param, Decl(giant.ts, 96, 19)) + + static set tsF(param:any) +>tsF : Symbol(C.tsF, Decl(giant.ts, 96, 33)) +>param : Symbol(param, Decl(giant.ts, 97, 23)) + + static tgF() { } +>tgF : Symbol(C.tgF, Decl(giant.ts, 97, 33)) + + static get tgF() +>tgF : Symbol(C.tgF, Decl(giant.ts, 98, 24)) + } + interface I { +>I : Symbol(I, Decl(giant.ts, 100, 5)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 105, 9)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 106, 9)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 107, 9)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 108, 9)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 109, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 109, 20)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 110, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 110, 20)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 117, 13)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 118, 13)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 119, 13)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 120, 13)) +>p5 : Symbol(p5, Decl(giant.ts, 120, 24)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 121, 13)) +>p7 : Symbol(p7, Decl(giant.ts, 121, 24)) + + //Index Signature + [p]; +>[p] : Symbol(I[p], Decl(giant.ts, 121, 39)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 125, 9)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 126, 9)) +>p3 : Symbol(p3, Decl(giant.ts, 126, 20)) + + //Property Signature + p; +>p : Symbol(I.p, Decl(giant.ts, 126, 33)) + + p1?; +>p1 : Symbol(I.p1, Decl(giant.ts, 129, 10)) + + p2?: string; +>p2 : Symbol(I.p2, Decl(giant.ts, 130, 12)) + + //Function Signature + p3(); +>p3 : Symbol(I.p3, Decl(giant.ts, 131, 20)) + + p4? (); +>p4 : Symbol(I.p4, Decl(giant.ts, 134, 13)) + + p5? (): void; +>p5 : Symbol(I.p5, Decl(giant.ts, 135, 15)) + + p6(pa1): void; +>p6 : Symbol(I.p6, Decl(giant.ts, 136, 21)) +>pa1 : Symbol(pa1, Decl(giant.ts, 137, 11)) + + p7(pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 137, 22), Decl(giant.ts, 138, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 138, 11)) +>pa2 : Symbol(pa2, Decl(giant.ts, 138, 15)) + + p7? (pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 137, 22), Decl(giant.ts, 138, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 139, 13)) +>pa2 : Symbol(pa2, Decl(giant.ts, 139, 17)) + } + module M { +>M : Symbol(M, Decl(giant.ts, 140, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 142, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 142, 14)) + + class C { }; +>C : Symbol(C, Decl(giant.ts, 143, 25)) + + interface I { }; +>I : Symbol(I, Decl(giant.ts, 144, 20)) + + module M { }; +>M : Symbol(M, Decl(giant.ts, 145, 24)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 147, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 147, 22)) + + export class eC { }; +>eC : Symbol(eC, Decl(giant.ts, 148, 33)) + + export interface eI { }; +>eI : Symbol(eI, Decl(giant.ts, 149, 28)) + + export module eM { }; +>eM : Symbol(eM, Decl(giant.ts, 150, 32)) + + export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 152, 26)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 152, 31)) + + export declare class eaC { }; +>eaC : Symbol(eaC, Decl(giant.ts, 153, 42)) + + export declare module eaM { }; +>eaM : Symbol(eaM, Decl(giant.ts, 154, 37)) + } + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 157, 14)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 157, 18)) + + export class eC { +>eC : Symbol(eC, Decl(giant.ts, 158, 29)) + + constructor () { } + public pV; +>pV : Symbol(eC.pV, Decl(giant.ts, 160, 26)) + + private rV; +>rV : Symbol(eC.rV, Decl(giant.ts, 161, 18)) + + public pF() { } +>pF : Symbol(eC.pF, Decl(giant.ts, 162, 19)) + + private rF() { } +>rF : Symbol(eC.rF, Decl(giant.ts, 163, 23)) + + public pgF() { } +>pgF : Symbol(eC.pgF, Decl(giant.ts, 164, 24)) + + public get pgF() +>pgF : Symbol(eC.pgF, Decl(giant.ts, 165, 24)) + + public psF(param:any) { } +>psF : Symbol(eC.psF, Decl(giant.ts, 166, 24)) +>param : Symbol(param, Decl(giant.ts, 167, 19)) + + public set psF(param:any) +>psF : Symbol(eC.psF, Decl(giant.ts, 167, 33)) +>param : Symbol(param, Decl(giant.ts, 168, 23)) + + private rgF() { } +>rgF : Symbol(eC.rgF, Decl(giant.ts, 168, 33)) + + private get rgF() +>rgF : Symbol(eC.rgF, Decl(giant.ts, 169, 25)) + + private rsF(param:any) { } +>rsF : Symbol(eC.rsF, Decl(giant.ts, 170, 25)) +>param : Symbol(param, Decl(giant.ts, 171, 20)) + + private set rsF(param:any) +>rsF : Symbol(eC.rsF, Decl(giant.ts, 171, 34)) +>param : Symbol(param, Decl(giant.ts, 172, 24)) + + static tV; +>tV : Symbol(eC.tV, Decl(giant.ts, 172, 34)) + + static tF() { } +>tF : Symbol(eC.tF, Decl(giant.ts, 173, 18)) + + static tsF(param:any) { } +>tsF : Symbol(eC.tsF, Decl(giant.ts, 174, 23)) +>param : Symbol(param, Decl(giant.ts, 175, 19)) + + static set tsF(param:any) +>tsF : Symbol(eC.tsF, Decl(giant.ts, 175, 33)) +>param : Symbol(param, Decl(giant.ts, 176, 23)) + + static tgF() { } +>tgF : Symbol(eC.tgF, Decl(giant.ts, 176, 33)) + + static get tgF() +>tgF : Symbol(eC.tgF, Decl(giant.ts, 177, 24)) + } + export interface eI { +>eI : Symbol(eI, Decl(giant.ts, 179, 5)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 184, 9)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 185, 9)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 186, 9)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 187, 9)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 188, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 188, 20)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 189, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 189, 20)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 196, 13)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 197, 13)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 198, 13)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 199, 13)) +>p5 : Symbol(p5, Decl(giant.ts, 199, 24)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 200, 13)) +>p7 : Symbol(p7, Decl(giant.ts, 200, 24)) + + //Index Signature + [p]; +>[p] : Symbol(eI[p], Decl(giant.ts, 200, 39)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 204, 9)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 205, 9)) +>p3 : Symbol(p3, Decl(giant.ts, 205, 20)) + + //Property Signature + p; +>p : Symbol(eI.p, Decl(giant.ts, 205, 33)) + + p1?; +>p1 : Symbol(eI.p1, Decl(giant.ts, 208, 10)) + + p2?: string; +>p2 : Symbol(eI.p2, Decl(giant.ts, 209, 12)) + + //Function Signature + p3(); +>p3 : Symbol(eI.p3, Decl(giant.ts, 210, 20)) + + p4? (); +>p4 : Symbol(eI.p4, Decl(giant.ts, 213, 13)) + + p5? (): void; +>p5 : Symbol(eI.p5, Decl(giant.ts, 214, 15)) + + p6(pa1): void; +>p6 : Symbol(eI.p6, Decl(giant.ts, 215, 21)) +>pa1 : Symbol(pa1, Decl(giant.ts, 216, 11)) + + p7(pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 216, 22), Decl(giant.ts, 217, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 217, 11)) +>pa2 : Symbol(pa2, Decl(giant.ts, 217, 15)) + + p7? (pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 216, 22), Decl(giant.ts, 217, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 218, 13)) +>pa2 : Symbol(pa2, Decl(giant.ts, 218, 17)) + } + export module eM { +>eM : Symbol(eM, Decl(giant.ts, 219, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 221, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 221, 14)) + + class C { }; +>C : Symbol(C, Decl(giant.ts, 222, 25)) + + interface I { }; +>I : Symbol(I, Decl(giant.ts, 223, 20)) + + module M { }; +>M : Symbol(M, Decl(giant.ts, 224, 24)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 226, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 226, 22)) + + export class eC { }; +>eC : Symbol(eC, Decl(giant.ts, 227, 33)) + + export interface eI { }; +>eI : Symbol(eI, Decl(giant.ts, 228, 28)) + + export module eM { }; +>eM : Symbol(eM, Decl(giant.ts, 229, 32)) + + export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 231, 26)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 231, 31)) + + export declare class eaC { }; +>eaC : Symbol(eaC, Decl(giant.ts, 232, 42)) + + export declare module eaM { }; +>eaM : Symbol(eaM, Decl(giant.ts, 233, 37)) + } + export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 236, 22)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 236, 27)) + + export declare class eaC { +>eaC : Symbol(eaC, Decl(giant.ts, 237, 38)) + + constructor () { } + public pV; +>pV : Symbol(eaC.pV, Decl(giant.ts, 239, 26)) + + private rV; +>rV : Symbol(eaC.rV, Decl(giant.ts, 240, 18)) + + public pF() { } +>pF : Symbol(eaC.pF, Decl(giant.ts, 241, 19)) + + private rF() { } +>rF : Symbol(eaC.rF, Decl(giant.ts, 242, 23)) + + public pgF() { } +>pgF : Symbol(eaC.pgF, Decl(giant.ts, 243, 24)) + + public get pgF() +>pgF : Symbol(eaC.pgF, Decl(giant.ts, 244, 24)) + + public psF(param:any) { } +>psF : Symbol(eaC.psF, Decl(giant.ts, 245, 24)) +>param : Symbol(param, Decl(giant.ts, 246, 19)) + + public set psF(param:any) +>psF : Symbol(eaC.psF, Decl(giant.ts, 246, 33)) +>param : Symbol(param, Decl(giant.ts, 247, 23)) + + private rgF() { } +>rgF : Symbol(eaC.rgF, Decl(giant.ts, 247, 33)) + + private get rgF() +>rgF : Symbol(eaC.rgF, Decl(giant.ts, 248, 25)) + + private rsF(param:any) { } +>rsF : Symbol(eaC.rsF, Decl(giant.ts, 249, 25)) +>param : Symbol(param, Decl(giant.ts, 250, 20)) + + private set rsF(param:any) +>rsF : Symbol(eaC.rsF, Decl(giant.ts, 250, 34)) +>param : Symbol(param, Decl(giant.ts, 251, 24)) + + static tV; +>tV : Symbol(eaC.tV, Decl(giant.ts, 251, 34)) + + static tF() { } +>tF : Symbol(eaC.tF, Decl(giant.ts, 252, 18)) + + static tsF(param:any) { } +>tsF : Symbol(eaC.tsF, Decl(giant.ts, 253, 23)) +>param : Symbol(param, Decl(giant.ts, 254, 19)) + + static set tsF(param:any) +>tsF : Symbol(eaC.tsF, Decl(giant.ts, 254, 33)) +>param : Symbol(param, Decl(giant.ts, 255, 23)) + + static tgF() { } +>tgF : Symbol(eaC.tgF, Decl(giant.ts, 255, 33)) + + static get tgF() +>tgF : Symbol(eaC.tgF, Decl(giant.ts, 256, 24)) + } + export declare module eaM { +>eaM : Symbol(eaM, Decl(giant.ts, 258, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 260, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 260, 14)) + + class C { } +>C : Symbol(C, Decl(giant.ts, 261, 25)) + + interface I { } +>I : Symbol(I, Decl(giant.ts, 262, 19)) + + module M { } +>M : Symbol(M, Decl(giant.ts, 263, 23)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 265, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 265, 22)) + + export class eC { } +>eC : Symbol(eC, Decl(giant.ts, 266, 33)) + + export interface eI { } +>eI : Symbol(eI, Decl(giant.ts, 267, 27)) + + export module eM { } +>eM : Symbol(eM, Decl(giant.ts, 268, 31)) + } +} +export var eV; +>eV : Symbol(eV, Decl(giant.ts, 272, 10)) + +export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 272, 14)) + +export class eC { +>eC : Symbol(eC, Decl(giant.ts, 273, 25)) + + constructor () { } + public pV; +>pV : Symbol(eC.pV, Decl(giant.ts, 275, 22)) + + private rV; +>rV : Symbol(eC.rV, Decl(giant.ts, 276, 14)) + + public pF() { } +>pF : Symbol(eC.pF, Decl(giant.ts, 277, 15)) + + private rF() { } +>rF : Symbol(eC.rF, Decl(giant.ts, 278, 19)) + + public pgF() { } +>pgF : Symbol(eC.pgF, Decl(giant.ts, 279, 20)) + + public get pgF() +>pgF : Symbol(eC.pgF, Decl(giant.ts, 280, 20)) + + public psF(param:any) { } +>psF : Symbol(eC.psF, Decl(giant.ts, 281, 20)) +>param : Symbol(param, Decl(giant.ts, 282, 15)) + + public set psF(param:any) +>psF : Symbol(eC.psF, Decl(giant.ts, 282, 29)) +>param : Symbol(param, Decl(giant.ts, 283, 19)) + + private rgF() { } +>rgF : Symbol(eC.rgF, Decl(giant.ts, 283, 29)) + + private get rgF() +>rgF : Symbol(eC.rgF, Decl(giant.ts, 284, 21)) + + private rsF(param:any) { } +>rsF : Symbol(eC.rsF, Decl(giant.ts, 285, 21)) +>param : Symbol(param, Decl(giant.ts, 286, 16)) + + private set rsF(param:any) +>rsF : Symbol(eC.rsF, Decl(giant.ts, 286, 30)) +>param : Symbol(param, Decl(giant.ts, 287, 20)) + + static tV; +>tV : Symbol(eC.tV, Decl(giant.ts, 287, 30)) + + static tF() { } +>tF : Symbol(eC.tF, Decl(giant.ts, 288, 14)) + + static tsF(param:any) { } +>tsF : Symbol(eC.tsF, Decl(giant.ts, 289, 19)) +>param : Symbol(param, Decl(giant.ts, 290, 15)) + + static set tsF(param:any) +>tsF : Symbol(eC.tsF, Decl(giant.ts, 290, 29)) +>param : Symbol(param, Decl(giant.ts, 291, 19)) + + static tgF() { } +>tgF : Symbol(eC.tgF, Decl(giant.ts, 291, 29)) + + static get tgF() +>tgF : Symbol(eC.tgF, Decl(giant.ts, 292, 20)) +} +export interface eI { +>eI : Symbol(eI, Decl(giant.ts, 294, 1)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 299, 5)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 300, 5)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 301, 5)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 302, 5)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 303, 5)) +>p5 : Symbol(p5, Decl(giant.ts, 303, 16)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 304, 5)) +>p7 : Symbol(p7, Decl(giant.ts, 304, 16)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 311, 9)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 312, 9)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 313, 9)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 314, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 314, 20)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 315, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 315, 20)) + + //Index Signature + [p]; +>[p] : Symbol(eI[p], Decl(giant.ts, 315, 35)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 319, 5)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 320, 5)) +>p3 : Symbol(p3, Decl(giant.ts, 320, 16)) + + //Property Signature + p; +>p : Symbol(eI.p, Decl(giant.ts, 320, 29)) + + p1?; +>p1 : Symbol(eI.p1, Decl(giant.ts, 323, 6)) + + p2?: string; +>p2 : Symbol(eI.p2, Decl(giant.ts, 324, 8)) + + //Function Signature + p3(); +>p3 : Symbol(eI.p3, Decl(giant.ts, 325, 16)) + + p4? (); +>p4 : Symbol(eI.p4, Decl(giant.ts, 328, 9)) + + p5? (): void; +>p5 : Symbol(eI.p5, Decl(giant.ts, 329, 11)) + + p6(pa1): void; +>p6 : Symbol(eI.p6, Decl(giant.ts, 330, 17)) +>pa1 : Symbol(pa1, Decl(giant.ts, 331, 7)) + + p7(pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 331, 18), Decl(giant.ts, 332, 23)) +>pa1 : Symbol(pa1, Decl(giant.ts, 332, 7)) +>pa2 : Symbol(pa2, Decl(giant.ts, 332, 11)) + + p7? (pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 331, 18), Decl(giant.ts, 332, 23)) +>pa1 : Symbol(pa1, Decl(giant.ts, 333, 9)) +>pa2 : Symbol(pa2, Decl(giant.ts, 333, 13)) +} +export module eM { +>eM : Symbol(eM, Decl(giant.ts, 334, 1)) + + var V; +>V : Symbol(V, Decl(giant.ts, 336, 7)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 336, 10)) + + class C { +>C : Symbol(C, Decl(giant.ts, 337, 21)) + + constructor () { } + public pV; +>pV : Symbol(C.pV, Decl(giant.ts, 339, 26)) + + private rV; +>rV : Symbol(C.rV, Decl(giant.ts, 340, 18)) + + public pF() { } +>pF : Symbol(C.pF, Decl(giant.ts, 341, 19)) + + private rF() { } +>rF : Symbol(C.rF, Decl(giant.ts, 342, 23)) + + public pgF() { } +>pgF : Symbol(C.pgF, Decl(giant.ts, 343, 24)) + + public get pgF() +>pgF : Symbol(C.pgF, Decl(giant.ts, 344, 24)) + + public psF(param:any) { } +>psF : Symbol(C.psF, Decl(giant.ts, 345, 24)) +>param : Symbol(param, Decl(giant.ts, 346, 19)) + + public set psF(param:any) +>psF : Symbol(C.psF, Decl(giant.ts, 346, 33)) +>param : Symbol(param, Decl(giant.ts, 347, 23)) + + private rgF() { } +>rgF : Symbol(C.rgF, Decl(giant.ts, 347, 33)) + + private get rgF() +>rgF : Symbol(C.rgF, Decl(giant.ts, 348, 25)) + + private rsF(param:any) { } +>rsF : Symbol(C.rsF, Decl(giant.ts, 349, 25)) +>param : Symbol(param, Decl(giant.ts, 350, 20)) + + private set rsF(param:any) +>rsF : Symbol(C.rsF, Decl(giant.ts, 350, 34)) +>param : Symbol(param, Decl(giant.ts, 351, 24)) + + static tV; +>tV : Symbol(C.tV, Decl(giant.ts, 351, 34)) + + static tF() { } +>tF : Symbol(C.tF, Decl(giant.ts, 352, 18)) + + static tsF(param:any) { } +>tsF : Symbol(C.tsF, Decl(giant.ts, 353, 23)) +>param : Symbol(param, Decl(giant.ts, 354, 19)) + + static set tsF(param:any) +>tsF : Symbol(C.tsF, Decl(giant.ts, 354, 33)) +>param : Symbol(param, Decl(giant.ts, 355, 23)) + + static tgF() { } +>tgF : Symbol(C.tgF, Decl(giant.ts, 355, 33)) + + static get tgF() +>tgF : Symbol(C.tgF, Decl(giant.ts, 356, 24)) + } + interface I { +>I : Symbol(I, Decl(giant.ts, 358, 5)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 363, 9)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 364, 9)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 365, 9)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 366, 9)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 367, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 367, 20)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 368, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 368, 20)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 375, 13)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 376, 13)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 377, 13)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 378, 13)) +>p5 : Symbol(p5, Decl(giant.ts, 378, 24)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 379, 13)) +>p7 : Symbol(p7, Decl(giant.ts, 379, 24)) + + //Index Signature + [p]; +>[p] : Symbol(I[p], Decl(giant.ts, 379, 39)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 383, 9)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 384, 9)) +>p3 : Symbol(p3, Decl(giant.ts, 384, 20)) + + //Property Signature + p; +>p : Symbol(I.p, Decl(giant.ts, 384, 33)) + + p1?; +>p1 : Symbol(I.p1, Decl(giant.ts, 387, 10)) + + p2?: string; +>p2 : Symbol(I.p2, Decl(giant.ts, 388, 12)) + + //Function Signature + p3(); +>p3 : Symbol(I.p3, Decl(giant.ts, 389, 20)) + + p4? (); +>p4 : Symbol(I.p4, Decl(giant.ts, 392, 13)) + + p5? (): void; +>p5 : Symbol(I.p5, Decl(giant.ts, 393, 15)) + + p6(pa1): void; +>p6 : Symbol(I.p6, Decl(giant.ts, 394, 21)) +>pa1 : Symbol(pa1, Decl(giant.ts, 395, 11)) + + p7(pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 395, 22), Decl(giant.ts, 396, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 396, 11)) +>pa2 : Symbol(pa2, Decl(giant.ts, 396, 15)) + + p7? (pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 395, 22), Decl(giant.ts, 396, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 397, 13)) +>pa2 : Symbol(pa2, Decl(giant.ts, 397, 17)) + } + module M { +>M : Symbol(M, Decl(giant.ts, 398, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 400, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 400, 14)) + + class C { }; +>C : Symbol(C, Decl(giant.ts, 401, 25)) + + interface I { }; +>I : Symbol(I, Decl(giant.ts, 402, 20)) + + module M { }; +>M : Symbol(M, Decl(giant.ts, 403, 24)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 405, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 405, 22)) + + export class eC { }; +>eC : Symbol(eC, Decl(giant.ts, 406, 33)) + + export interface eI { }; +>eI : Symbol(eI, Decl(giant.ts, 407, 28)) + + export module eM { }; +>eM : Symbol(eM, Decl(giant.ts, 408, 32)) + + export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 410, 26)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 410, 31)) + + export declare class eaC { }; +>eaC : Symbol(eaC, Decl(giant.ts, 411, 42)) + + export declare module eaM { }; +>eaM : Symbol(eaM, Decl(giant.ts, 412, 37)) + } + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 415, 14)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 415, 18)) + + export class eC { +>eC : Symbol(eC, Decl(giant.ts, 416, 29)) + + constructor () { } + public pV; +>pV : Symbol(eC.pV, Decl(giant.ts, 418, 26)) + + private rV; +>rV : Symbol(eC.rV, Decl(giant.ts, 419, 18)) + + public pF() { } +>pF : Symbol(eC.pF, Decl(giant.ts, 420, 19)) + + private rF() { } +>rF : Symbol(eC.rF, Decl(giant.ts, 421, 23)) + + public pgF() { } +>pgF : Symbol(eC.pgF, Decl(giant.ts, 422, 24)) + + public get pgF() +>pgF : Symbol(eC.pgF, Decl(giant.ts, 423, 24)) + + public psF(param:any) { } +>psF : Symbol(eC.psF, Decl(giant.ts, 424, 24)) +>param : Symbol(param, Decl(giant.ts, 425, 19)) + + public set psF(param:any) +>psF : Symbol(eC.psF, Decl(giant.ts, 425, 33)) +>param : Symbol(param, Decl(giant.ts, 426, 23)) + + private rgF() { } +>rgF : Symbol(eC.rgF, Decl(giant.ts, 426, 33)) + + private get rgF() +>rgF : Symbol(eC.rgF, Decl(giant.ts, 427, 25)) + + private rsF(param:any) { } +>rsF : Symbol(eC.rsF, Decl(giant.ts, 428, 25)) +>param : Symbol(param, Decl(giant.ts, 429, 20)) + + private set rsF(param:any) +>rsF : Symbol(eC.rsF, Decl(giant.ts, 429, 34)) +>param : Symbol(param, Decl(giant.ts, 430, 24)) + + static tV; +>tV : Symbol(eC.tV, Decl(giant.ts, 430, 34)) + + static tF() { } +>tF : Symbol(eC.tF, Decl(giant.ts, 431, 18)) + + static tsF(param:any) { } +>tsF : Symbol(eC.tsF, Decl(giant.ts, 432, 23)) +>param : Symbol(param, Decl(giant.ts, 433, 19)) + + static set tsF(param:any) +>tsF : Symbol(eC.tsF, Decl(giant.ts, 433, 33)) +>param : Symbol(param, Decl(giant.ts, 434, 23)) + + static tgF() { } +>tgF : Symbol(eC.tgF, Decl(giant.ts, 434, 33)) + + static get tgF() +>tgF : Symbol(eC.tgF, Decl(giant.ts, 435, 24)) + } + export interface eI { +>eI : Symbol(eI, Decl(giant.ts, 437, 5)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 442, 9)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 443, 9)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 444, 9)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 445, 9)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 446, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 446, 20)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 447, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 447, 20)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 454, 13)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 455, 13)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 456, 13)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 457, 13)) +>p5 : Symbol(p5, Decl(giant.ts, 457, 24)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 458, 13)) +>p7 : Symbol(p7, Decl(giant.ts, 458, 24)) + + //Index Signature + [p]; +>[p] : Symbol(eI[p], Decl(giant.ts, 458, 39)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 462, 9)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 463, 9)) +>p3 : Symbol(p3, Decl(giant.ts, 463, 20)) + + //Property Signature + p; +>p : Symbol(eI.p, Decl(giant.ts, 463, 33)) + + p1?; +>p1 : Symbol(eI.p1, Decl(giant.ts, 466, 10)) + + p2?: string; +>p2 : Symbol(eI.p2, Decl(giant.ts, 467, 12)) + + //Function Signature + p3(); +>p3 : Symbol(eI.p3, Decl(giant.ts, 468, 20)) + + p4? (); +>p4 : Symbol(eI.p4, Decl(giant.ts, 471, 13)) + + p5? (): void; +>p5 : Symbol(eI.p5, Decl(giant.ts, 472, 15)) + + p6(pa1): void; +>p6 : Symbol(eI.p6, Decl(giant.ts, 473, 21)) +>pa1 : Symbol(pa1, Decl(giant.ts, 474, 11)) + + p7(pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 474, 22), Decl(giant.ts, 475, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 475, 11)) +>pa2 : Symbol(pa2, Decl(giant.ts, 475, 15)) + + p7? (pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 474, 22), Decl(giant.ts, 475, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 476, 13)) +>pa2 : Symbol(pa2, Decl(giant.ts, 476, 17)) + } + export module eM { +>eM : Symbol(eM, Decl(giant.ts, 477, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 479, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 479, 14)) + + class C { }; +>C : Symbol(C, Decl(giant.ts, 480, 25)) + + interface I { }; +>I : Symbol(I, Decl(giant.ts, 481, 20)) + + module M { }; +>M : Symbol(M, Decl(giant.ts, 482, 24)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 484, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 484, 22)) + + export class eC { }; +>eC : Symbol(eC, Decl(giant.ts, 485, 33)) + + export interface eI { }; +>eI : Symbol(eI, Decl(giant.ts, 486, 28)) + + export module eM { }; +>eM : Symbol(eM, Decl(giant.ts, 487, 32)) + + export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 489, 26)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 489, 31)) + + export declare class eaC { }; +>eaC : Symbol(eaC, Decl(giant.ts, 490, 42)) + + export declare module eaM { }; +>eaM : Symbol(eaM, Decl(giant.ts, 491, 37)) + } + export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 494, 22)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 494, 27)) + + export declare class eaC { +>eaC : Symbol(eaC, Decl(giant.ts, 495, 38)) + + constructor () { } + public pV; +>pV : Symbol(eaC.pV, Decl(giant.ts, 497, 26)) + + private rV; +>rV : Symbol(eaC.rV, Decl(giant.ts, 498, 18)) + + public pF() { } +>pF : Symbol(eaC.pF, Decl(giant.ts, 499, 19)) + + private rF() { } +>rF : Symbol(eaC.rF, Decl(giant.ts, 500, 23)) + + public pgF() { } +>pgF : Symbol(eaC.pgF, Decl(giant.ts, 501, 24)) + + public get pgF() +>pgF : Symbol(eaC.pgF, Decl(giant.ts, 502, 24)) + + public psF(param:any) { } +>psF : Symbol(eaC.psF, Decl(giant.ts, 503, 24)) +>param : Symbol(param, Decl(giant.ts, 504, 19)) + + public set psF(param:any) +>psF : Symbol(eaC.psF, Decl(giant.ts, 504, 33)) +>param : Symbol(param, Decl(giant.ts, 505, 23)) + + private rgF() { } +>rgF : Symbol(eaC.rgF, Decl(giant.ts, 505, 33)) + + private get rgF() +>rgF : Symbol(eaC.rgF, Decl(giant.ts, 506, 25)) + + private rsF(param:any) { } +>rsF : Symbol(eaC.rsF, Decl(giant.ts, 507, 25)) +>param : Symbol(param, Decl(giant.ts, 508, 20)) + + private set rsF(param:any) +>rsF : Symbol(eaC.rsF, Decl(giant.ts, 508, 34)) +>param : Symbol(param, Decl(giant.ts, 509, 24)) + + static tV; +>tV : Symbol(eaC.tV, Decl(giant.ts, 509, 34)) + + static tF() { } +>tF : Symbol(eaC.tF, Decl(giant.ts, 510, 18)) + + static tsF(param:any) { } +>tsF : Symbol(eaC.tsF, Decl(giant.ts, 511, 23)) +>param : Symbol(param, Decl(giant.ts, 512, 19)) + + static set tsF(param:any) +>tsF : Symbol(eaC.tsF, Decl(giant.ts, 512, 33)) +>param : Symbol(param, Decl(giant.ts, 513, 23)) + + static tgF() { } +>tgF : Symbol(eaC.tgF, Decl(giant.ts, 513, 33)) + + static get tgF() +>tgF : Symbol(eaC.tgF, Decl(giant.ts, 514, 24)) + } + export declare module eaM { +>eaM : Symbol(eaM, Decl(giant.ts, 516, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 518, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 518, 14)) + + class C { } +>C : Symbol(C, Decl(giant.ts, 519, 25)) + + interface I { } +>I : Symbol(I, Decl(giant.ts, 520, 19)) + + module M { } +>M : Symbol(M, Decl(giant.ts, 521, 23)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 523, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 523, 22)) + + export class eC { } +>eC : Symbol(eC, Decl(giant.ts, 524, 33)) + + export interface eI { } +>eI : Symbol(eI, Decl(giant.ts, 525, 27)) + + export module eM { } +>eM : Symbol(eM, Decl(giant.ts, 526, 31)) + } +} +export declare var eaV; +>eaV : Symbol(eaV, Decl(giant.ts, 530, 18)) + +export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 530, 23)) + +export declare class eaC { +>eaC : Symbol(eaC, Decl(giant.ts, 531, 34)) + + constructor () { } + public pV; +>pV : Symbol(eaC.pV, Decl(giant.ts, 533, 22)) + + private rV; +>rV : Symbol(eaC.rV, Decl(giant.ts, 534, 14)) + + public pF() { } +>pF : Symbol(eaC.pF, Decl(giant.ts, 535, 15)) + + private rF() { } +>rF : Symbol(eaC.rF, Decl(giant.ts, 536, 19)) + + public pgF() { } +>pgF : Symbol(eaC.pgF, Decl(giant.ts, 537, 20)) + + public get pgF() +>pgF : Symbol(eaC.pgF, Decl(giant.ts, 538, 20)) + + public psF(param:any) { } +>psF : Symbol(eaC.psF, Decl(giant.ts, 539, 20)) +>param : Symbol(param, Decl(giant.ts, 540, 15)) + + public set psF(param:any) +>psF : Symbol(eaC.psF, Decl(giant.ts, 540, 29)) +>param : Symbol(param, Decl(giant.ts, 541, 19)) + + private rgF() { } +>rgF : Symbol(eaC.rgF, Decl(giant.ts, 541, 29)) + + private get rgF() +>rgF : Symbol(eaC.rgF, Decl(giant.ts, 542, 21)) + + private rsF(param:any) { } +>rsF : Symbol(eaC.rsF, Decl(giant.ts, 543, 21)) +>param : Symbol(param, Decl(giant.ts, 544, 16)) + + private set rsF(param:any) +>rsF : Symbol(eaC.rsF, Decl(giant.ts, 544, 30)) +>param : Symbol(param, Decl(giant.ts, 545, 20)) + + static tV; +>tV : Symbol(eaC.tV, Decl(giant.ts, 545, 30)) + + static tF() { } +>tF : Symbol(eaC.tF, Decl(giant.ts, 546, 14)) + + static tsF(param:any) { } +>tsF : Symbol(eaC.tsF, Decl(giant.ts, 547, 19)) +>param : Symbol(param, Decl(giant.ts, 548, 15)) + + static set tsF(param:any) +>tsF : Symbol(eaC.tsF, Decl(giant.ts, 548, 29)) +>param : Symbol(param, Decl(giant.ts, 549, 19)) + + static tgF() { } +>tgF : Symbol(eaC.tgF, Decl(giant.ts, 549, 29)) + + static get tgF() +>tgF : Symbol(eaC.tgF, Decl(giant.ts, 550, 20)) +} +export declare module eaM { +>eaM : Symbol(eaM, Decl(giant.ts, 552, 1)) + + var V; +>V : Symbol(V, Decl(giant.ts, 554, 7)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 554, 10)) + + class C { +>C : Symbol(C, Decl(giant.ts, 555, 21)) + + constructor () { } + public pV; +>pV : Symbol(C.pV, Decl(giant.ts, 557, 26)) + + private rV; +>rV : Symbol(C.rV, Decl(giant.ts, 558, 18)) + + public pF() { } +>pF : Symbol(C.pF, Decl(giant.ts, 559, 19)) + + static tV; +>tV : Symbol(C.tV, Decl(giant.ts, 560, 23)) + + static tF() { } +>tF : Symbol(C.tF, Decl(giant.ts, 561, 18)) + } + interface I { +>I : Symbol(I, Decl(giant.ts, 563, 5)) + + //Call Signature + (); + (): number; + (p: string); +>p : Symbol(p, Decl(giant.ts, 568, 9)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 569, 9)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 570, 9)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 571, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 571, 20)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 572, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 572, 20)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 579, 13)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 580, 13)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 581, 13)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 582, 13)) +>p5 : Symbol(p5, Decl(giant.ts, 582, 24)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 583, 13)) +>p7 : Symbol(p7, Decl(giant.ts, 583, 24)) + + //Index Signature + [p]; +>[p] : Symbol(I[p], Decl(giant.ts, 583, 39)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 587, 9)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 588, 9)) +>p3 : Symbol(p3, Decl(giant.ts, 588, 20)) + + //Property Signature + p; +>p : Symbol(I.p, Decl(giant.ts, 588, 33)) + + p1?; +>p1 : Symbol(I.p1, Decl(giant.ts, 591, 10)) + + p2?: string; +>p2 : Symbol(I.p2, Decl(giant.ts, 592, 12)) + + //Function Signature + p3(); +>p3 : Symbol(I.p3, Decl(giant.ts, 593, 20)) + + p4? (); +>p4 : Symbol(I.p4, Decl(giant.ts, 596, 13)) + + p5? (): void; +>p5 : Symbol(I.p5, Decl(giant.ts, 597, 15)) + + p6(pa1): void; +>p6 : Symbol(I.p6, Decl(giant.ts, 598, 21)) +>pa1 : Symbol(pa1, Decl(giant.ts, 599, 11)) + + p7(pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 599, 22), Decl(giant.ts, 600, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 600, 11)) +>pa2 : Symbol(pa2, Decl(giant.ts, 600, 15)) + + p7? (pa1, pa2): void; +>p7 : Symbol(I.p7, Decl(giant.ts, 599, 22), Decl(giant.ts, 600, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 601, 13)) +>pa2 : Symbol(pa2, Decl(giant.ts, 601, 17)) + } + module M { +>M : Symbol(M, Decl(giant.ts, 602, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 604, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 604, 14)) + + class C { } +>C : Symbol(C, Decl(giant.ts, 605, 25)) + + interface I { } +>I : Symbol(I, Decl(giant.ts, 606, 19)) + + module M { } +>M : Symbol(M, Decl(giant.ts, 607, 23)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 609, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 609, 22)) + + export class eC { } +>eC : Symbol(eC, Decl(giant.ts, 610, 33)) + + export interface eI { } +>eI : Symbol(eI, Decl(giant.ts, 611, 27)) + + export module eM { } +>eM : Symbol(eM, Decl(giant.ts, 612, 31)) + + export declare var eaV +>eaV : Symbol(eaV, Decl(giant.ts, 614, 26)) + + export declare function eaF() { }; +>eaF : Symbol(eaF, Decl(giant.ts, 614, 30)) + + export declare class eaC { } +>eaC : Symbol(eaC, Decl(giant.ts, 615, 42)) + + export declare module eaM { } +>eaM : Symbol(eaM, Decl(giant.ts, 616, 36)) + } + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 619, 14)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 619, 18)) + + export class eC { +>eC : Symbol(eC, Decl(giant.ts, 620, 29)) + + constructor () { } + public pV; +>pV : Symbol(eC.pV, Decl(giant.ts, 622, 26)) + + private rV; +>rV : Symbol(eC.rV, Decl(giant.ts, 623, 18)) + + public pF() { } +>pF : Symbol(eC.pF, Decl(giant.ts, 624, 19)) + + static tV +>tV : Symbol(eC.tV, Decl(giant.ts, 625, 23)) + + static tF() { } +>tF : Symbol(eC.tF, Decl(giant.ts, 626, 17)) + } + export interface eI { +>eI : Symbol(eI, Decl(giant.ts, 628, 5)) + + //Call Signature + (); + (): number; + (p); +>p : Symbol(p, Decl(giant.ts, 633, 9)) + + (p1: string); +>p1 : Symbol(p1, Decl(giant.ts, 634, 9)) + + (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 635, 9)) + + (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 636, 9)) + + (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 637, 9)) +>p5 : Symbol(p5, Decl(giant.ts, 637, 20)) + + (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 638, 9)) +>p7 : Symbol(p7, Decl(giant.ts, 638, 20)) + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : Symbol(p, Decl(giant.ts, 645, 13)) + + new (p2?: string); +>p2 : Symbol(p2, Decl(giant.ts, 646, 13)) + + new (...p3: any[]); +>p3 : Symbol(p3, Decl(giant.ts, 647, 13)) + + new (p4: string, p5?: string); +>p4 : Symbol(p4, Decl(giant.ts, 648, 13)) +>p5 : Symbol(p5, Decl(giant.ts, 648, 24)) + + new (p6: string, ...p7: any[]); +>p6 : Symbol(p6, Decl(giant.ts, 649, 13)) +>p7 : Symbol(p7, Decl(giant.ts, 649, 24)) + + //Index Signature + [p]; +>[p] : Symbol(eI[p], Decl(giant.ts, 649, 39)) +>p : Symbol(p, Decl(giant.ts, 13, 5)) + + [p1: string]; +>p1 : Symbol(p1, Decl(giant.ts, 653, 9)) + + [p2: string, p3: number]; +>p2 : Symbol(p2, Decl(giant.ts, 654, 9)) +>p3 : Symbol(p3, Decl(giant.ts, 654, 20)) + + //Property Signature + p; +>p : Symbol(eI.p, Decl(giant.ts, 654, 33)) + + p1?; +>p1 : Symbol(eI.p1, Decl(giant.ts, 657, 10)) + + p2?: string; +>p2 : Symbol(eI.p2, Decl(giant.ts, 658, 12)) + + //Function Signature + p3(); +>p3 : Symbol(eI.p3, Decl(giant.ts, 659, 20)) + + p4? (); +>p4 : Symbol(eI.p4, Decl(giant.ts, 662, 13)) + + p5? (): void; +>p5 : Symbol(eI.p5, Decl(giant.ts, 663, 15)) + + p6(pa1): void; +>p6 : Symbol(eI.p6, Decl(giant.ts, 664, 21)) +>pa1 : Symbol(pa1, Decl(giant.ts, 665, 11)) + + p7(pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 665, 22), Decl(giant.ts, 666, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 666, 11)) +>pa2 : Symbol(pa2, Decl(giant.ts, 666, 15)) + + p7? (pa1, pa2): void; +>p7 : Symbol(eI.p7, Decl(giant.ts, 665, 22), Decl(giant.ts, 666, 27)) +>pa1 : Symbol(pa1, Decl(giant.ts, 667, 13)) +>pa2 : Symbol(pa2, Decl(giant.ts, 667, 17)) + } + export module eM { +>eM : Symbol(eM, Decl(giant.ts, 668, 5)) + + var V; +>V : Symbol(V, Decl(giant.ts, 670, 11)) + + function F() { }; +>F : Symbol(F, Decl(giant.ts, 670, 14)) + + class C { } +>C : Symbol(C, Decl(giant.ts, 671, 25)) + + module M { } +>M : Symbol(M, Decl(giant.ts, 672, 19)) + + export var eV; +>eV : Symbol(eV, Decl(giant.ts, 674, 18)) + + export function eF() { }; +>eF : Symbol(eF, Decl(giant.ts, 674, 22)) + + export class eC { } +>eC : Symbol(eC, Decl(giant.ts, 675, 33)) + + export interface eI { } +>eI : Symbol(eI, Decl(giant.ts, 676, 27)) + + export module eM { } +>eM : Symbol(eM, Decl(giant.ts, 677, 31)) + } +} diff --git a/testdata/baselines/reference/submodule/compiler/giant.types b/testdata/baselines/reference/submodule/compiler/giant.types new file mode 100644 index 0000000000..61d2019461 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/giant.types @@ -0,0 +1,1710 @@ +//// [tests/cases/compiler/giant.ts] //// + +=== giant.ts === +/* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS +*/ +const p = "propName"; +>p : "propName" +>"propName" : "propName" + +var V; +>V : any + +function F() { }; +>F : () => void + +class C { +>C : C + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any +} +interface I { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any +} +module M { +>M : typeof M + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { +>C : C + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any + } + interface I { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + } + module M { +>M : typeof M + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { }; +>C : C + + interface I { }; + module M { }; + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { }; +>eC : eC + + export interface eI { }; + export module eM { }; + export declare var eaV; +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { }; +>eaC : eaC + + export declare module eaM { }; + } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { +>eC : eC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any + } + export interface eI { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + } + export module eM { +>eM : typeof eM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { }; +>C : C + + interface I { }; + module M { }; + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { }; +>eC : eC + + export interface eI { }; + export module eM { }; + export declare var eaV; +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { }; +>eaC : eaC + + export declare module eaM { }; + } + export declare var eaV; +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { +>eaC : eaC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any + } + export declare module eaM { +>eaM : typeof eaM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { } +>C : C + + interface I { } + module M { } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { } +>eC : eC + + export interface eI { } + export module eM { } + } +} +export var eV; +>eV : any + +export function eF() { }; +>eF : () => void + +export class eC { +>eC : eC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any +} +export interface eI { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any +} +export module eM { +>eM : typeof import("giant").eM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { +>C : C + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any + } + interface I { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + } + module M { +>M : typeof M + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { }; +>C : C + + interface I { }; + module M { }; + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { }; +>eC : eC + + export interface eI { }; + export module eM { }; + export declare var eaV; +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { }; +>eaC : eaC + + export declare module eaM { }; + } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { +>eC : eC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any + } + export interface eI { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + } + export module eM { +>eM : typeof eM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { }; +>C : C + + interface I { }; + module M { }; + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { }; +>eC : eC + + export interface eI { }; + export module eM { }; + export declare var eaV; +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { }; +>eaC : eaC + + export declare module eaM { }; + } + export declare var eaV; +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { +>eaC : eaC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any + } + export declare module eaM { +>eaM : typeof eaM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { } +>C : C + + interface I { } + module M { } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { } +>eC : eC + + export interface eI { } + export module eM { } + } +} +export declare var eaV; +>eaV : any + +export declare function eaF() { }; +>eaF : () => void + +export declare class eaC { +>eaC : eaC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + private rF() { } +>rF : () => void + + public pgF() { } +>pgF : () => void + + public get pgF() +>pgF : any + + public psF(param:any) { } +>psF : (param: any) => void +>param : any + + public set psF(param:any) +>psF : any +>param : any + + private rgF() { } +>rgF : () => void + + private get rgF() +>rgF : any + + private rsF(param:any) { } +>rsF : (param: any) => void +>param : any + + private set rsF(param:any) +>rsF : any +>param : any + + static tV; +>tV : any + + static tF() { } +>tF : () => void + + static tsF(param:any) { } +>tsF : (param: any) => void +>param : any + + static set tsF(param:any) +>tsF : any +>param : any + + static tgF() { } +>tgF : () => void + + static get tgF() +>tgF : any +} +export declare module eaM { +>eaM : typeof eaM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { +>C : C + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + static tV; +>tV : any + + static tF() { } +>tF : () => void + } + interface I { + //Call Signature + (); + (): number; + (p: string); +>p : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + } + module M { +>M : typeof M + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { } +>C : C + + interface I { } + module M { } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { } +>eC : eC + + export interface eI { } + export module eM { } + export declare var eaV +>eaV : any + + export declare function eaF() { }; +>eaF : () => void + + export declare class eaC { } +>eaC : eaC + + export declare module eaM { } + } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { +>eC : eC + + constructor () { } + public pV; +>pV : any + + private rV; +>rV : any + + public pF() { } +>pF : () => void + + static tV +>tV : any + + static tF() { } +>tF : () => void + } + export interface eI { + //Call Signature + (); + (): number; + (p); +>p : any + + (p1: string); +>p1 : string + + (p2?: string); +>p2 : string + + (...p3: any[]); +>p3 : any[] + + (p4: string, p5?: string); +>p4 : string +>p5 : string + + (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); +>p : string + + new (p2?: string); +>p2 : string + + new (...p3: any[]); +>p3 : any[] + + new (p4: string, p5?: string); +>p4 : string +>p5 : string + + new (p6: string, ...p7: any[]); +>p6 : string +>p7 : any[] + + //Index Signature + [p]; +>[p] : any +>p : "propName" + + [p1: string]; +>p1 : string + + [p2: string, p3: number]; +>p2 : string +>p3 : number + + //Property Signature + p; +>p : any + + p1?; +>p1 : any + + p2?: string; +>p2 : string + + //Function Signature + p3(); +>p3 : () => any + + p4? (); +>p4 : () => any + + p5? (): void; +>p5 : () => void + + p6(pa1): void; +>p6 : (pa1: any) => void +>pa1 : any + + p7(pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + + p7? (pa1, pa2): void; +>p7 : { (pa1: any, pa2: any): void; (pa1: any, pa2: any): void; } +>pa1 : any +>pa2 : any + } + export module eM { +>eM : typeof eM + + var V; +>V : any + + function F() { }; +>F : () => void + + class C { } +>C : C + + module M { } + export var eV; +>eV : any + + export function eF() { }; +>eF : () => void + + export class eC { } +>eC : eC + + export interface eI { } + export module eM { } + } +} diff --git a/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit.js.diff index 4c75f38b3a..d5ef1c6171 100644 --- a/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit.js.diff +++ b/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit.js.diff @@ -1,13 +1,6 @@ --- old.globalThisDeclarationEmit.js +++ new.globalThisDeclarationEmit.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.globalThis = void 0; --var variable_1 = require("./variable"); -+const variable_1 = require("./variable"); - exports.globalThis = variable_1.variable; - +@@= skipped -21, +21 lines =@@ //// [variable.d.ts] export declare const variable: typeof globalThis; diff --git a/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit2.js.diff b/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit2.js.diff deleted file mode 100644 index 037089f8d7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.globalThisDeclarationEmit2.js -+++ new.globalThisDeclarationEmit2.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.globalThis = void 0; --var variable_1 = require("./variable"); -+const variable_1 = require("./variable"); - Object.defineProperty(exports, "globalThis", { enumerable: true, get: function () { return variable_1.variable; } }); - diff --git a/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit3.js.diff b/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit3.js.diff index 7a0d64d79f..5c8a78e223 100644 --- a/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/globalThisDeclarationEmit3.js.diff @@ -8,9 +8,4 @@ -exports.variable = mod; //// [index.js] "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.globalThis = void 0; --var variable_1 = require("./variable"); -+const variable_1 = require("./variable"); - Object.defineProperty(exports, "globalThis", { enumerable: true, get: function () { return variable_1.variable; } }); - + Object.defineProperty(exports, "__esModule", { value: true }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js b/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js index b9a0520567..b6c3bb1ef9 100644 --- a/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js +++ b/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js @@ -11,6 +11,7 @@ function f( //// [homomorphicMappedTypeIntersectionAssignability.js] +"use strict"; function f(a, b, c) { c = a; // Works b = a; // Should also work diff --git a/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js.diff b/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js.diff deleted file mode 100644 index aedf81ef3c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/homomorphicMappedTypeIntersectionAssignability.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.homomorphicMappedTypeIntersectionAssignability.js -+++ new.homomorphicMappedTypeIntersectionAssignability.js -@@= skipped -10, +10 lines =@@ - - - //// [homomorphicMappedTypeIntersectionAssignability.js] --"use strict"; - function f(a, b, c) { - c = a; // Works - b = a; // Should also work \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js index 3a97a865d2..3beca81775 100644 --- a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js +++ b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js @@ -21,6 +21,8 @@ function f1(state: State<{ foo: number }>) { //// [identityRelationNeverTypes.js] +"use strict"; +// Repro from #47996 function f1(state) { if (state.matches('a') && state.matches('a.b')) { state; // never diff --git a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff deleted file mode 100644 index a3fc586d45..0000000000 --- a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.identityRelationNeverTypes.js -+++ new.identityRelationNeverTypes.js -@@= skipped -20, +20 lines =@@ - - - //// [identityRelationNeverTypes.js] --"use strict"; --// Repro from #47996 - function f1(state) { - if (state.matches('a') && state.matches('a.b')) { - state; // never \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js index e4eea244b9..c2662909f9 100644 --- a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js +++ b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js @@ -25,10 +25,43 @@ let x2 = ; // Error //// [ignoredJsxAttributes.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); // Repro from #44797 -const React = require("react"); +const React = __importStar(require("react")); let props = { foo: "", "data-yadda": 42, // Error diff --git a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff deleted file mode 100644 index 39292a7044..0000000000 --- a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.ignoredJsxAttributes.js -+++ new.ignoredJsxAttributes.js -@@= skipped -24, +24 lines =@@ - - //// [ignoredJsxAttributes.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// - // Repro from #44797 --var React = require("react"); -+const React = require("react"); - let props = { - foo: "", - "data-yadda": 42, // Error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js b/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js index a336436e99..c0a40a48ca 100644 --- a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js +++ b/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js @@ -23,6 +23,8 @@ class C2 implements IFoo2 { // error } //// [implementGenericWithMismatchedTypes.js] +// no errors because in the derived types the best common type for T's value is Object +// and that matches the original signature for assignability since we treat its T's as Object class C { foo(x) { return null; diff --git a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js.diff b/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js.diff deleted file mode 100644 index 62094db9bf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.implementGenericWithMismatchedTypes.js -+++ new.implementGenericWithMismatchedTypes.js -@@= skipped -22, +22 lines =@@ - } - - //// [implementGenericWithMismatchedTypes.js] --// no errors because in the derived types the best common type for T's value is Object --// and that matches the original signature for assignability since we treat its T's as Object - class C { - foo(x) { - return null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importAliasAnExternalModuleInsideAnInternalModule.js.diff b/testdata/baselines/reference/submodule/compiler/importAliasAnExternalModuleInsideAnInternalModule.js.diff index b8f0a9480d..7fdcb8aec7 100644 --- a/testdata/baselines/reference/submodule/compiler/importAliasAnExternalModuleInsideAnInternalModule.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importAliasAnExternalModuleInsideAnInternalModule.js.diff @@ -1,11 +1,7 @@ --- old.importAliasAnExternalModuleInsideAnInternalModule.js +++ new.importAliasAnExternalModuleInsideAnInternalModule.js -@@= skipped -25, +25 lines =@@ - //// [importAliasAnExternalModuleInsideAnInternalModule_file1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var r = require("./importAliasAnExternalModuleInsideAnInternalModule_file0"); -+const r = require("./importAliasAnExternalModuleInsideAnInternalModule_file0"); +@@= skipped -28, +28 lines =@@ + const r = require("./importAliasAnExternalModuleInsideAnInternalModule_file0"); var m_private; (function (m_private) { - //import r2 = require('m'); // would be error diff --git a/testdata/baselines/reference/submodule/compiler/importAsBaseClass.js.diff b/testdata/baselines/reference/submodule/compiler/importAsBaseClass.js.diff deleted file mode 100644 index b6981328a5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importAsBaseClass.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.importAsBaseClass.js -+++ new.importAsBaseClass.js -@@= skipped -20, +20 lines =@@ - //// [importAsBaseClass_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var Greeter = require("./importAsBaseClass_0"); -+const Greeter = require("./importAsBaseClass_0"); - class Hello extends Greeter { - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importDecl.js.diff b/testdata/baselines/reference/submodule/compiler/importDecl.js.diff index 91fad09376..d99f46071e 100644 --- a/testdata/baselines/reference/submodule/compiler/importDecl.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importDecl.js.diff @@ -31,44 +31,4 @@ + bing; } exports.d = d; - function foo() { return null; } -@@= skipped -17, +18 lines =@@ - /// - /// - /// --var m4 = require("./importDecl_require"); // Emit used -+const m4 = require("./importDecl_require"); // Emit used - exports.x4 = m4.x; - exports.d4 = m4.d; - exports.f4 = m4.foo(); -@@= skipped -14, +14 lines =@@ - var f3 = m4.foo(); - })(m1 || (exports.m1 = m1 = {})); - //Emit global only usage --var glo_m4 = require("./importDecl_require1"); -+const glo_m4 = require("./importDecl_require1"); - exports.useGlo_m4_d4 = glo_m4.d; - exports.useGlo_m4_f4 = glo_m4.foo(); - //Emit even when used just in function type --var fncOnly_m4 = require("./importDecl_require2"); -+const fncOnly_m4 = require("./importDecl_require2"); - exports.useFncOnly_m4_f4 = fncOnly_m4.foo(); - // only used privately no need to emit --var private_m4 = require("./importDecl_require3"); -+const private_m4 = require("./importDecl_require3"); - var usePrivate_m4_m1; - (function (usePrivate_m4_m1) { - var x3 = private_m4.x; -@@= skipped -15, +15 lines =@@ - var f3 = private_m4.foo(); - })(usePrivate_m4_m1 || (exports.usePrivate_m4_m1 = usePrivate_m4_m1 = {})); - // Do not emit unused import --var m5 = require("./importDecl_require4"); -+const m5 = require("./importDecl_require4"); - exports.d = m5.foo2(); - // Do not emit multiple used import statements --var multiImport_m4 = require("./importDecl_require"); // Emit used -+const multiImport_m4 = require("./importDecl_require"); // Emit used - exports.useMultiImport_m4_x4 = multiImport_m4.x; - exports.useMultiImport_m4_d4 = multiImport_m4.d; - exports.useMultiImport_m4_f4 = multiImport_m4.foo(); \ No newline at end of file + function foo() { return null; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.errors.txt b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.errors.txt new file mode 100644 index 0000000000..12e30795ff --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.errors.txt @@ -0,0 +1,39 @@ +importDeclWithClassModifiers.ts(5,8): error TS1044: 'public' modifier cannot appear on a module or namespace element. +importDeclWithClassModifiers.ts(5,26): error TS2708: Cannot use namespace 'x' as a value. +importDeclWithClassModifiers.ts(5,28): error TS2694: Namespace 'x' has no exported member 'c'. +importDeclWithClassModifiers.ts(6,8): error TS1044: 'private' modifier cannot appear on a module or namespace element. +importDeclWithClassModifiers.ts(6,27): error TS2708: Cannot use namespace 'x' as a value. +importDeclWithClassModifiers.ts(6,29): error TS2694: Namespace 'x' has no exported member 'c'. +importDeclWithClassModifiers.ts(7,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. +importDeclWithClassModifiers.ts(7,26): error TS2708: Cannot use namespace 'x' as a value. +importDeclWithClassModifiers.ts(7,28): error TS2694: Namespace 'x' has no exported member 'c'. + + +==== importDeclWithClassModifiers.ts (9 errors) ==== + namespace x { + interface c { + } + } + export public import a = x.c; + ~~~~~~ +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. + ~ +!!! error TS2708: Cannot use namespace 'x' as a value. + ~ +!!! error TS2694: Namespace 'x' has no exported member 'c'. + export private import b = x.c; + ~~~~~~~ +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. + ~ +!!! error TS2708: Cannot use namespace 'x' as a value. + ~ +!!! error TS2694: Namespace 'x' has no exported member 'c'. + export static import c = x.c; + ~~~~~~ +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. + ~ +!!! error TS2708: Cannot use namespace 'x' as a value. + ~ +!!! error TS2694: Namespace 'x' has no exported member 'c'. + var b: a; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.js b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.js new file mode 100644 index 0000000000..daf66572ad --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/importDeclWithClassModifiers.ts] //// + +//// [importDeclWithClassModifiers.ts] +namespace x { + interface c { + } +} +export public import a = x.c; +export private import b = x.c; +export static import c = x.c; +var b: a; + + +//// [importDeclWithClassModifiers.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var b; diff --git a/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.js.diff b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.js.diff new file mode 100644 index 0000000000..9f03b5ceda --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.js.diff @@ -0,0 +1,11 @@ +--- old.importDeclWithClassModifiers.js ++++ new.importDeclWithClassModifiers.js +@@= skipped -13, +13 lines =@@ + //// [importDeclWithClassModifiers.js] + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +-exports.c = exports.b = exports.a = void 0; +-exports.a = x.c; +-exports.b = x.c; +-exports.c = x.c; + var b; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.symbols b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.symbols new file mode 100644 index 0000000000..4defa696fb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/importDeclWithClassModifiers.ts] //// + +=== importDeclWithClassModifiers.ts === +namespace x { +>x : Symbol(x, Decl(importDeclWithClassModifiers.ts, 0, 0)) + + interface c { +>c : Symbol(c, Decl(importDeclWithClassModifiers.ts, 0, 13)) + } +} +export public import a = x.c; +>a : Symbol(a, Decl(importDeclWithClassModifiers.ts, 3, 1)) +>x : Symbol(x, Decl(importDeclWithClassModifiers.ts, 0, 0)) + +export private import b = x.c; +>b : Symbol(b, Decl(importDeclWithClassModifiers.ts, 4, 29)) +>x : Symbol(x, Decl(importDeclWithClassModifiers.ts, 0, 0)) + +export static import c = x.c; +>c : Symbol(c, Decl(importDeclWithClassModifiers.ts, 5, 30)) +>x : Symbol(x, Decl(importDeclWithClassModifiers.ts, 0, 0)) + +var b: a; +>b : Symbol(b, Decl(importDeclWithClassModifiers.ts, 7, 3)) +>a : Symbol(a, Decl(importDeclWithClassModifiers.ts, 3, 1)) + diff --git a/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.types b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.types new file mode 100644 index 0000000000..a915e8be3e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importDeclWithClassModifiers.types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/importDeclWithClassModifiers.ts] //// + +=== importDeclWithClassModifiers.ts === +namespace x { + interface c { + } +} +export public import a = x.c; +>a : any +>x : any +>c : any + +export private import b = x.c; +>b : any +>x : any +>c : any + +export static import c = x.c; +>c : any +>x : any +>c : any + +var b: a; +>b : a + diff --git a/testdata/baselines/reference/submodule/compiler/importHelpers.js b/testdata/baselines/reference/submodule/compiler/importHelpers.js index b6f49b26d4..3f818f167e 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpers.js +++ b/testdata/baselines/reference/submodule/compiler/importHelpers.js @@ -36,7 +36,7 @@ function id(x: T) { const result = id`hello world`; -//// [tslib.d.ts] +//// [index.d.ts] export declare function __extends(d: Function, b: Function): void; export declare function __assign(t: any, ...sources: any[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpers.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpers.js.diff index 832953b793..91026ef138 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importHelpers.js.diff @@ -4,33 +4,28 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.result = exports.B = exports.A = void 0; --var tslib_1 = require("tslib"); +-const tslib_1 = require("tslib"); class A { } exports.A = A; class B extends A { } exports.B = B; --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- tslib_1.__decorate([ -- tslib_1.__param(0, dec), -- tslib_1.__metadata("design:type", Function), -- tslib_1.__metadata("design:paramtypes", [Number]), -- tslib_1.__metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = tslib_1.__decorate([ -- dec -- ], C); -- return C; --})(); +-let C = class C { +@dec +class C { -+ method(x) { -+ } + method(x) { + } +-}; +-tslib_1.__decorate([ +- tslib_1.__param(0, dec), +- tslib_1.__metadata("design:type", Function), +- tslib_1.__metadata("design:paramtypes", [Number]), +- tslib_1.__metadata("design:returntype", void 0) +-], C.prototype, "method", null); +-C = tslib_1.__decorate([ +- dec +-], C); +} function id(x) { return x; @@ -53,26 +48,21 @@ } class B extends A { } --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- __decorate([ -- __param(0, dec), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Number]), -- __metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = __decorate([ -- dec -- ], C); -- return C; --})(); +-let C = class C { +@dec +class C { -+ method(x) { -+ } + method(x) { + } +-}; +-__decorate([ +- __param(0, dec), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Number]), +- __metadata("design:returntype", void 0) +-], C.prototype, "method", null); +-C = __decorate([ +- dec +-], C); +} function id(x) { return x; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpers.symbols b/testdata/baselines/reference/submodule/compiler/importHelpers.symbols index 89b7a935c4..b5129fc716 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpers.symbols +++ b/testdata/baselines/reference/submodule/compiler/importHelpers.symbols @@ -76,52 +76,52 @@ const result = id`hello world`; >result : Symbol(result, Decl(script.ts, 15, 5)) >id : Symbol(id, Decl(script.ts, 9, 1)) -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; ->__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) ->d : Symbol(d, Decl(tslib.d.ts, 0, 34)) +>__extends : Symbol(__extends, Decl(index.d.ts, 0, 0)) +>d : Symbol(d, Decl(index.d.ts, 0, 34)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->b : Symbol(b, Decl(tslib.d.ts, 0, 46)) +>b : Symbol(b, Decl(index.d.ts, 0, 46)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __assign(t: any, ...sources: any[]): any; ->__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) ->t : Symbol(t, Decl(tslib.d.ts, 1, 33)) ->sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) +>__assign : Symbol(__assign, Decl(index.d.ts, 0, 66)) +>t : Symbol(t, Decl(index.d.ts, 1, 33)) +>sources : Symbol(sources, Decl(index.d.ts, 1, 40)) export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; ->__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) ->decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) +>__decorate : Symbol(__decorate, Decl(index.d.ts, 1, 65)) +>decorators : Symbol(decorators, Decl(index.d.ts, 2, 35)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->target : Symbol(target, Decl(tslib.d.ts, 2, 58)) ->key : Symbol(key, Decl(tslib.d.ts, 2, 71)) ->desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) +>target : Symbol(target, Decl(index.d.ts, 2, 58)) +>key : Symbol(key, Decl(index.d.ts, 2, 71)) +>desc : Symbol(desc, Decl(index.d.ts, 2, 94)) export declare function __param(paramIndex: number, decorator: Function): Function; ->__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) ->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) ->decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) +>__param : Symbol(__param, Decl(index.d.ts, 2, 112)) +>paramIndex : Symbol(paramIndex, Decl(index.d.ts, 3, 32)) +>decorator : Symbol(decorator, Decl(index.d.ts, 3, 51)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __metadata(metadataKey: any, metadataValue: any): Function; ->__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) ->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) ->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) +>__metadata : Symbol(__metadata, Decl(index.d.ts, 3, 83)) +>metadataKey : Symbol(metadataKey, Decl(index.d.ts, 4, 35)) +>metadataValue : Symbol(metadataValue, Decl(index.d.ts, 4, 52)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; ->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) ->thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) ->_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) ->P : Symbol(P, Decl(tslib.d.ts, 5, 64)) +>__awaiter : Symbol(__awaiter, Decl(index.d.ts, 4, 83)) +>thisArg : Symbol(thisArg, Decl(index.d.ts, 5, 34)) +>_arguments : Symbol(_arguments, Decl(index.d.ts, 5, 47)) +>P : Symbol(P, Decl(index.d.ts, 5, 64)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) +>generator : Symbol(generator, Decl(index.d.ts, 5, 77)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray; ->__makeTemplateObject : Symbol(__makeTemplateObject, Decl(tslib.d.ts, 5, 104)) ->cooked : Symbol(cooked, Decl(tslib.d.ts, 6, 45)) ->raw : Symbol(raw, Decl(tslib.d.ts, 6, 62)) +>__makeTemplateObject : Symbol(__makeTemplateObject, Decl(index.d.ts, 5, 104)) +>cooked : Symbol(cooked, Decl(index.d.ts, 6, 45)) +>raw : Symbol(raw, Decl(index.d.ts, 6, 62)) >TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpers.symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpers.symbols.diff deleted file mode 100644 index de9c2fe80d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpers.symbols.diff +++ /dev/null @@ -1,77 +0,0 @@ ---- old.importHelpers.symbols -+++ new.importHelpers.symbols -@@= skipped -77, +77 lines =@@ - - === tslib.d.ts === - export declare function __extends(d: Function, b: Function): void; -->__extends : Symbol(__extends, Decl(tslib.d.ts, --, --)) -->d : Symbol(d, Decl(tslib.d.ts, --, --)) -+>__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) -+>d : Symbol(d, Decl(tslib.d.ts, 0, 34)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->b : Symbol(b, Decl(tslib.d.ts, --, --)) -+>b : Symbol(b, Decl(tslib.d.ts, 0, 46)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __assign(t: any, ...sources: any[]): any; -->__assign : Symbol(__assign, Decl(tslib.d.ts, --, --)) -->t : Symbol(t, Decl(tslib.d.ts, --, --)) -->sources : Symbol(sources, Decl(tslib.d.ts, --, --)) -+>__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) -+>t : Symbol(t, Decl(tslib.d.ts, 1, 33)) -+>sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) - - export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; -->__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --)) -->decorators : Symbol(decorators, Decl(tslib.d.ts, --, --)) -+>__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) -+>decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->target : Symbol(target, Decl(tslib.d.ts, --, --)) -->key : Symbol(key, Decl(tslib.d.ts, --, --)) -->desc : Symbol(desc, Decl(tslib.d.ts, --, --)) -+>target : Symbol(target, Decl(tslib.d.ts, 2, 58)) -+>key : Symbol(key, Decl(tslib.d.ts, 2, 71)) -+>desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) - - export declare function __param(paramIndex: number, decorator: Function): Function; -->__param : Symbol(__param, Decl(tslib.d.ts, --, --)) -->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, --, --)) -->decorator : Symbol(decorator, Decl(tslib.d.ts, --, --)) -+>__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) -+>paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) -+>decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __metadata(metadataKey: any, metadataValue: any): Function; -->__metadata : Symbol(__metadata, Decl(tslib.d.ts, --, --)) -->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, --, --)) -->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, --, --)) -+>__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) -+>metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) -+>metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; -->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, --, --)) -->thisArg : Symbol(thisArg, Decl(tslib.d.ts, --, --)) -->_arguments : Symbol(_arguments, Decl(tslib.d.ts, --, --)) -->P : Symbol(P, Decl(tslib.d.ts, --, --)) -+>__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) -+>thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) -+>_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) -+>P : Symbol(P, Decl(tslib.d.ts, 5, 64)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->generator : Symbol(generator, Decl(tslib.d.ts, --, --)) -+>generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray; -->__makeTemplateObject : Symbol(__makeTemplateObject, Decl(tslib.d.ts, --, --)) -->cooked : Symbol(cooked, Decl(tslib.d.ts, --, --)) -->raw : Symbol(raw, Decl(tslib.d.ts, --, --)) -+>__makeTemplateObject : Symbol(__makeTemplateObject, Decl(tslib.d.ts, 5, 104)) -+>cooked : Symbol(cooked, Decl(tslib.d.ts, 6, 45)) -+>raw : Symbol(raw, Decl(tslib.d.ts, 6, 62)) - >TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpers.types b/testdata/baselines/reference/submodule/compiler/importHelpers.types index 2027d3c598..55bc2641cf 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpers.types +++ b/testdata/baselines/reference/submodule/compiler/importHelpers.types @@ -76,7 +76,7 @@ const result = id`hello world`; >id : (x: T) => T >`hello world` : "hello world" -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; >__extends : (d: Function, b: Function) => void >d : Function diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js index 946418741b..88b9861628 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js @@ -49,5 +49,4 @@ class Foo { } class Bar extends Foo { } -export = Bar; module.exports = Bar; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js.diff deleted file mode 100644 index d22dc7aef7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js -+++ new.importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).js -@@= skipped -48, +48 lines =@@ - } - class Bar extends Foo { - } -+export = Bar; - module.exports = Bar; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols index 285cda7771..bb4cf4e782 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols @@ -18,7 +18,7 @@ class Bar extends Foo {} module.exports = Bar; >module.exports : Symbol(Bar, Decl(index.js, 0, 12)) ->module : Symbol(module.exports) +>module : Symbol("/index", Decl(index.js, 0, 0)) >exports : Symbol(Bar, Decl(index.js, 0, 12)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols.diff index 570acccb4c..28919c3444 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).symbols.diff @@ -17,6 +17,6 @@ ->module : Symbol(export=, Decl(index.js, 2, 24)) ->exports : Symbol(export=, Decl(index.js, 2, 24)) +>module.exports : Symbol(Bar, Decl(index.js, 0, 12)) -+>module : Symbol(module.exports) ++>module : Symbol("/index", Decl(index.js, 0, 0)) +>exports : Symbol(Bar, Decl(index.js, 0, 12)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).types.diff b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).types.diff rename to testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).types.diff diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js index 946418741b..88b9861628 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js @@ -49,5 +49,4 @@ class Foo { } class Bar extends Foo { } -export = Bar; module.exports = Bar; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js.diff deleted file mode 100644 index ee2afeda7a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js -+++ new.importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).js -@@= skipped -48, +48 lines =@@ - } - class Bar extends Foo { - } -+export = Bar; - module.exports = Bar; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols index 285cda7771..bb4cf4e782 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols @@ -18,7 +18,7 @@ class Bar extends Foo {} module.exports = Bar; >module.exports : Symbol(Bar, Decl(index.js, 0, 12)) ->module : Symbol(module.exports) +>module : Symbol("/index", Decl(index.js, 0, 0)) >exports : Symbol(Bar, Decl(index.js, 0, 12)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols.diff index a473a8cb48..ecbde6fafc 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).symbols.diff @@ -17,6 +17,6 @@ ->module : Symbol(export=, Decl(index.js, 2, 24)) ->exports : Symbol(export=, Decl(index.js, 2, 24)) +>module.exports : Symbol(Bar, Decl(index.js, 0, 12)) -+>module : Symbol(module.exports) ++>module : Symbol("/index", Decl(index.js, 0, 0)) +>exports : Symbol(Bar, Decl(index.js, 0, 12)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).types.diff b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).types.diff rename to testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).types.diff diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff new file mode 100644 index 0000000000..60f9121f02 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.importHelpersES6.errors.txt ++++ new.importHelpersES6.errors.txt +@@= skipped -0, +0 lines =@@ +-a.ts(2,1): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. +- +- +-==== a.ts (1 errors) ==== +- declare var dec: any; +- @dec export class A { +- ~~~~ +-!!! error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. +- #x: number = 1; +- async f() { this.#x = await this.#x; } +- g(u) { return #x in u; } +- } +- +- const o = { a: 1 }; +- const y = { ...o }; +- +-==== tslib.d.ts (0 errors) ==== +- export declare function __extends(d: Function, b: Function): void; +- export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +- export declare function __param(paramIndex: number, decorator: Function): Function; +- export declare function __metadata(metadataKey: any, metadataValue: any): Function; +- export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; +- export declare function __classPrivateFieldGet(a: any, b: any, c: any, d: any): any; +- export declare function __classPrivateFieldSet(a: any, b: any, c: any, d: any, e: any): any; +- export declare function __classPrivateFieldIn(a: any, b: any): boolean; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js index e455c9c63b..c38d01d11f 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js @@ -24,7 +24,7 @@ class C { } } -//// [tslib.d.ts] +//// [index.d.ts] export declare function __extends(d: Function, b: Function): void; export declare function __assign(t: any, ...sources: any[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js.diff index 0953e78b12..db0ab0c55e 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.js.diff @@ -4,33 +4,28 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.B = exports.A = void 0; --var tslib_1 = require("tslib"); +-const tslib_1 = require("tslib"); class A { } exports.A = A; class B extends A { } exports.B = B; --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- tslib_1.__decorate([ -- tslib_1.__param(0, dec), -- tslib_1.__metadata("design:type", Function), -- tslib_1.__metadata("design:paramtypes", [Number]), -- tslib_1.__metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = tslib_1.__decorate([ -- dec -- ], C); -- return C; --})(); +-let C = class C { +@dec +class C { -+ method(x) { -+ } + method(x) { + } +-}; +-tslib_1.__decorate([ +- tslib_1.__param(0, dec), +- tslib_1.__metadata("design:type", Function), +- tslib_1.__metadata("design:paramtypes", [Number]), +- tslib_1.__metadata("design:returntype", void 0) +-], C.prototype, "method", null); +-C = tslib_1.__decorate([ +- dec +-], C); +} //// [script.js] -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { @@ -49,24 +44,19 @@ } class B extends A { } --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- __decorate([ -- __param(0, dec), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Number]), -- __metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = __decorate([ -- dec -- ], C); -- return C; --})(); +-let C = class C { +@dec +class C { -+ method(x) { -+ } + method(x) { + } +-}; +-__decorate([ +- __param(0, dec), +- __metadata("design:type", Function), +- __metadata("design:paramtypes", [Number]), +- __metadata("design:returntype", void 0) +-], C.prototype, "method", null); +-C = __decorate([ +- dec +-], C); +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols index 99e81761f9..dd10b49a53 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols @@ -48,46 +48,46 @@ class C { } } -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; ->__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) ->d : Symbol(d, Decl(tslib.d.ts, 0, 34)) +>__extends : Symbol(__extends, Decl(index.d.ts, 0, 0)) +>d : Symbol(d, Decl(index.d.ts, 0, 34)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->b : Symbol(b, Decl(tslib.d.ts, 0, 46)) +>b : Symbol(b, Decl(index.d.ts, 0, 46)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __assign(t: any, ...sources: any[]): any; ->__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) ->t : Symbol(t, Decl(tslib.d.ts, 1, 33)) ->sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) +>__assign : Symbol(__assign, Decl(index.d.ts, 0, 66)) +>t : Symbol(t, Decl(index.d.ts, 1, 33)) +>sources : Symbol(sources, Decl(index.d.ts, 1, 40)) export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; ->__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) ->decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) +>__decorate : Symbol(__decorate, Decl(index.d.ts, 1, 65)) +>decorators : Symbol(decorators, Decl(index.d.ts, 2, 35)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->target : Symbol(target, Decl(tslib.d.ts, 2, 58)) ->key : Symbol(key, Decl(tslib.d.ts, 2, 71)) ->desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) +>target : Symbol(target, Decl(index.d.ts, 2, 58)) +>key : Symbol(key, Decl(index.d.ts, 2, 71)) +>desc : Symbol(desc, Decl(index.d.ts, 2, 94)) export declare function __param(paramIndex: number, decorator: Function): Function; ->__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) ->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) ->decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) +>__param : Symbol(__param, Decl(index.d.ts, 2, 112)) +>paramIndex : Symbol(paramIndex, Decl(index.d.ts, 3, 32)) +>decorator : Symbol(decorator, Decl(index.d.ts, 3, 51)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __metadata(metadataKey: any, metadataValue: any): Function; ->__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) ->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) ->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) +>__metadata : Symbol(__metadata, Decl(index.d.ts, 3, 83)) +>metadataKey : Symbol(metadataKey, Decl(index.d.ts, 4, 35)) +>metadataValue : Symbol(metadataValue, Decl(index.d.ts, 4, 52)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; ->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) ->thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) ->_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) ->P : Symbol(P, Decl(tslib.d.ts, 5, 64)) +>__awaiter : Symbol(__awaiter, Decl(index.d.ts, 4, 83)) +>thisArg : Symbol(thisArg, Decl(index.d.ts, 5, 34)) +>_arguments : Symbol(_arguments, Decl(index.d.ts, 5, 47)) +>P : Symbol(P, Decl(index.d.ts, 5, 64)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) +>generator : Symbol(generator, Decl(index.d.ts, 5, 77)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols.diff deleted file mode 100644 index c41fc7d7fc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.symbols.diff +++ /dev/null @@ -1,68 +0,0 @@ ---- old.importHelpersInIsolatedModules.symbols -+++ new.importHelpersInIsolatedModules.symbols -@@= skipped -49, +49 lines =@@ - - === tslib.d.ts === - export declare function __extends(d: Function, b: Function): void; -->__extends : Symbol(__extends, Decl(tslib.d.ts, --, --)) -->d : Symbol(d, Decl(tslib.d.ts, --, --)) -+>__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) -+>d : Symbol(d, Decl(tslib.d.ts, 0, 34)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->b : Symbol(b, Decl(tslib.d.ts, --, --)) -+>b : Symbol(b, Decl(tslib.d.ts, 0, 46)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __assign(t: any, ...sources: any[]): any; -->__assign : Symbol(__assign, Decl(tslib.d.ts, --, --)) -->t : Symbol(t, Decl(tslib.d.ts, --, --)) -->sources : Symbol(sources, Decl(tslib.d.ts, --, --)) -+>__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) -+>t : Symbol(t, Decl(tslib.d.ts, 1, 33)) -+>sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) - - export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; -->__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --)) -->decorators : Symbol(decorators, Decl(tslib.d.ts, --, --)) -+>__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) -+>decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->target : Symbol(target, Decl(tslib.d.ts, --, --)) -->key : Symbol(key, Decl(tslib.d.ts, --, --)) -->desc : Symbol(desc, Decl(tslib.d.ts, --, --)) -+>target : Symbol(target, Decl(tslib.d.ts, 2, 58)) -+>key : Symbol(key, Decl(tslib.d.ts, 2, 71)) -+>desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) - - export declare function __param(paramIndex: number, decorator: Function): Function; -->__param : Symbol(__param, Decl(tslib.d.ts, --, --)) -->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, --, --)) -->decorator : Symbol(decorator, Decl(tslib.d.ts, --, --)) -+>__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) -+>paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) -+>decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __metadata(metadataKey: any, metadataValue: any): Function; -->__metadata : Symbol(__metadata, Decl(tslib.d.ts, --, --)) -->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, --, --)) -->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, --, --)) -+>__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) -+>metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) -+>metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; -->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, --, --)) -->thisArg : Symbol(thisArg, Decl(tslib.d.ts, --, --)) -->_arguments : Symbol(_arguments, Decl(tslib.d.ts, --, --)) -->P : Symbol(P, Decl(tslib.d.ts, --, --)) -+>__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) -+>thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) -+>_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) -+>P : Symbol(P, Decl(tslib.d.ts, 5, 64)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->generator : Symbol(generator, Decl(tslib.d.ts, --, --)) -+>generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.types b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.types index c90d5e1872..3620f8a01c 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.types +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInIsolatedModules.types @@ -48,7 +48,7 @@ class C { } } -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; >__extends : (d: Function, b: Function) => void >d : Function diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js index bb85abcce9..054c0daeea 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js @@ -10,7 +10,7 @@ declare var React: any; declare var o: any; const x = -//// [tslib.d.ts] +//// [index.d.ts] export declare function __extends(d: Function, b: Function): void; export declare function __assign(t: any, ...sources: any[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; @@ -23,18 +23,6 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; -const tslib_1 = require("tslib"); -exports.x = React.createElement("span", tslib_1.__assign({}, o)); +exports.x = React.createElement("span", Object.assign({}, o)); //// [script.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -const x = React.createElement("span", __assign({}, o)); +const x = React.createElement("span", Object.assign({}, o)); diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js.diff deleted file mode 100644 index 0727e4623f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importHelpersInTsx.js -+++ new.importHelpersInTsx.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.x = void 0; --var tslib_1 = require("tslib"); -+const tslib_1 = require("tslib"); - exports.x = React.createElement("span", tslib_1.__assign({}, o)); - //// [script.js] - var __assign = (this && this.__assign) || function () { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols index 5196660bdb..e6c5d0a6f3 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols @@ -22,46 +22,46 @@ const x = >x : Symbol(x, Decl(script.tsx, 2, 5)) >o : Symbol(o, Decl(script.tsx, 1, 11)) -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; ->__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) ->d : Symbol(d, Decl(tslib.d.ts, 0, 34)) +>__extends : Symbol(__extends, Decl(index.d.ts, 0, 0)) +>d : Symbol(d, Decl(index.d.ts, 0, 34)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->b : Symbol(b, Decl(tslib.d.ts, 0, 46)) +>b : Symbol(b, Decl(index.d.ts, 0, 46)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __assign(t: any, ...sources: any[]): any; ->__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) ->t : Symbol(t, Decl(tslib.d.ts, 1, 33)) ->sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) +>__assign : Symbol(__assign, Decl(index.d.ts, 0, 66)) +>t : Symbol(t, Decl(index.d.ts, 1, 33)) +>sources : Symbol(sources, Decl(index.d.ts, 1, 40)) export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; ->__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) ->decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) +>__decorate : Symbol(__decorate, Decl(index.d.ts, 1, 65)) +>decorators : Symbol(decorators, Decl(index.d.ts, 2, 35)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->target : Symbol(target, Decl(tslib.d.ts, 2, 58)) ->key : Symbol(key, Decl(tslib.d.ts, 2, 71)) ->desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) +>target : Symbol(target, Decl(index.d.ts, 2, 58)) +>key : Symbol(key, Decl(index.d.ts, 2, 71)) +>desc : Symbol(desc, Decl(index.d.ts, 2, 94)) export declare function __param(paramIndex: number, decorator: Function): Function; ->__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) ->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) ->decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) +>__param : Symbol(__param, Decl(index.d.ts, 2, 112)) +>paramIndex : Symbol(paramIndex, Decl(index.d.ts, 3, 32)) +>decorator : Symbol(decorator, Decl(index.d.ts, 3, 51)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __metadata(metadataKey: any, metadataValue: any): Function; ->__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) ->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) ->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) +>__metadata : Symbol(__metadata, Decl(index.d.ts, 3, 83)) +>metadataKey : Symbol(metadataKey, Decl(index.d.ts, 4, 35)) +>metadataValue : Symbol(metadataValue, Decl(index.d.ts, 4, 52)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; ->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) ->thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) ->_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) ->P : Symbol(P, Decl(tslib.d.ts, 5, 64)) +>__awaiter : Symbol(__awaiter, Decl(index.d.ts, 4, 83)) +>thisArg : Symbol(thisArg, Decl(index.d.ts, 5, 34)) +>_arguments : Symbol(_arguments, Decl(index.d.ts, 5, 47)) +>P : Symbol(P, Decl(index.d.ts, 5, 64)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) +>generator : Symbol(generator, Decl(index.d.ts, 5, 77)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols.diff deleted file mode 100644 index 941b519187..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.symbols.diff +++ /dev/null @@ -1,68 +0,0 @@ ---- old.importHelpersInTsx.symbols -+++ new.importHelpersInTsx.symbols -@@= skipped -23, +23 lines =@@ - - === tslib.d.ts === - export declare function __extends(d: Function, b: Function): void; -->__extends : Symbol(__extends, Decl(tslib.d.ts, --, --)) -->d : Symbol(d, Decl(tslib.d.ts, --, --)) -+>__extends : Symbol(__extends, Decl(tslib.d.ts, 0, 0)) -+>d : Symbol(d, Decl(tslib.d.ts, 0, 34)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->b : Symbol(b, Decl(tslib.d.ts, --, --)) -+>b : Symbol(b, Decl(tslib.d.ts, 0, 46)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __assign(t: any, ...sources: any[]): any; -->__assign : Symbol(__assign, Decl(tslib.d.ts, --, --)) -->t : Symbol(t, Decl(tslib.d.ts, --, --)) -->sources : Symbol(sources, Decl(tslib.d.ts, --, --)) -+>__assign : Symbol(__assign, Decl(tslib.d.ts, 0, 66)) -+>t : Symbol(t, Decl(tslib.d.ts, 1, 33)) -+>sources : Symbol(sources, Decl(tslib.d.ts, 1, 40)) - - export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; -->__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --)) -->decorators : Symbol(decorators, Decl(tslib.d.ts, --, --)) -+>__decorate : Symbol(__decorate, Decl(tslib.d.ts, 1, 65)) -+>decorators : Symbol(decorators, Decl(tslib.d.ts, 2, 35)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->target : Symbol(target, Decl(tslib.d.ts, --, --)) -->key : Symbol(key, Decl(tslib.d.ts, --, --)) -->desc : Symbol(desc, Decl(tslib.d.ts, --, --)) -+>target : Symbol(target, Decl(tslib.d.ts, 2, 58)) -+>key : Symbol(key, Decl(tslib.d.ts, 2, 71)) -+>desc : Symbol(desc, Decl(tslib.d.ts, 2, 94)) - - export declare function __param(paramIndex: number, decorator: Function): Function; -->__param : Symbol(__param, Decl(tslib.d.ts, --, --)) -->paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, --, --)) -->decorator : Symbol(decorator, Decl(tslib.d.ts, --, --)) -+>__param : Symbol(__param, Decl(tslib.d.ts, 2, 112)) -+>paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, 3, 32)) -+>decorator : Symbol(decorator, Decl(tslib.d.ts, 3, 51)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __metadata(metadataKey: any, metadataValue: any): Function; -->__metadata : Symbol(__metadata, Decl(tslib.d.ts, --, --)) -->metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, --, --)) -->metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, --, --)) -+>__metadata : Symbol(__metadata, Decl(tslib.d.ts, 3, 83)) -+>metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, 4, 35)) -+>metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, 4, 52)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; -->__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, --, --)) -->thisArg : Symbol(thisArg, Decl(tslib.d.ts, --, --)) -->_arguments : Symbol(_arguments, Decl(tslib.d.ts, --, --)) -->P : Symbol(P, Decl(tslib.d.ts, --, --)) -+>__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, 4, 83)) -+>thisArg : Symbol(thisArg, Decl(tslib.d.ts, 5, 34)) -+>_arguments : Symbol(_arguments, Decl(tslib.d.ts, 5, 47)) -+>P : Symbol(P, Decl(tslib.d.ts, 5, 64)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) -->generator : Symbol(generator, Decl(tslib.d.ts, --, --)) -+>generator : Symbol(generator, Decl(tslib.d.ts, 5, 77)) - >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.types b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.types index e05eea951f..6ad008e20a 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.types +++ b/testdata/baselines/reference/submodule/compiler/importHelpersInTsx.types @@ -26,7 +26,7 @@ const x = >span : any >o : any -=== tslib.d.ts === +=== node_modules/tslib/index.d.ts === export declare function __extends(d: Function, b: Function): void; >__extends : (d: Function, b: Function) => void >d : Function diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoEmitHelpersExportDefault.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoEmitHelpersExportDefault.js.diff index 2eb8da4d08..7935cee152 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoEmitHelpersExportDefault.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importHelpersNoEmitHelpersExportDefault.js.diff @@ -1,11 +1,8 @@ --- old.importHelpersNoEmitHelpersExportDefault.js +++ new.importHelpersNoEmitHelpersExportDefault.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -24, +24 lines =@@ exports.A = void 0; --var tslib_1 = require("tslib"); -+const tslib_1 = require("tslib"); + const tslib_1 = require("tslib"); // https://github.com/microsoft/TypeScript/issues/40328 -var other_1 = require("./other"); +const other_1 = require("./other"); @@ -14,8 +11,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; --var tslib_1 = require("tslib"); + const tslib_1 = require("tslib"); -var other_1 = require("./other"); -+const tslib_1 = require("tslib"); +const other_1 = require("./other"); Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(other_1).default; } }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.errors.txt.diff deleted file mode 100644 index d8198de297..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.errors.txt.diff +++ /dev/null @@ -1,62 +0,0 @@ ---- old.importHelpersNoHelpers.errors.txt -+++ new.importHelpersNoHelpers.errors.txt -@@= skipped -0, +0 lines =@@ --external.ts(1,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --external.ts(3,16): error TS2343: This syntax requires an imported helper named '__extends' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --external.ts(7,1): error TS2343: This syntax requires an imported helper named '__decorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --external.ts(7,1): error TS2343: This syntax requires an imported helper named '__metadata' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --external.ts(9,12): error TS2343: This syntax requires an imported helper named '__param' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --external.ts(14,13): error TS2343: This syntax requires an imported helper named '__assign' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --external.ts(15,12): error TS2343: This syntax requires an imported helper named '__rest' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- -- --==== external.ts (7 errors) ==== -- export * from "./other"; -- ~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- export class A { } -- export class B extends A { } -- ~~~~~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__extends' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- -- declare var dec: any; -- -- @dec -- ~~~~ --!!! error TS2343: This syntax requires an imported helper named '__decorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- ~~~~ --!!! error TS2343: This syntax requires an imported helper named '__metadata' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- class C { -- method(@dec x: number) { -- ~~~~ --!!! error TS2343: This syntax requires an imported helper named '__param' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- } -- } -- -- const o = { a: 1 }; -- const y = { ...o }; -- ~~~~ --!!! error TS2343: This syntax requires an imported helper named '__assign' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- const { ...x } = y; -- ~ --!!! error TS2343: This syntax requires an imported helper named '__rest' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- --==== other.ts (0 errors) ==== -- export const x = 1; -- --==== script.ts (0 errors) ==== -- class A { } -- class B extends A { } -- -- declare var dec: any; -- -- @dec -- class C { -- method(@dec x: number) { -- } -- } -- --==== tslib.d.ts (0 errors) ==== -- export {} -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.js b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.js deleted file mode 100644 index 67899671f1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.js +++ /dev/null @@ -1,73 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpers.ts] //// - -//// [external.ts] -export * from "./other"; -export class A { } -export class B extends A { } - -declare var dec: any; - -@dec -class C { - method(@dec x: number) { - } -} - -const o = { a: 1 }; -const y = { ...o }; -const { ...x } = y; - -//// [other.ts] -export const x = 1; - -//// [script.ts] -class A { } -class B extends A { } - -declare var dec: any; - -@dec -class C { - method(@dec x: number) { - } -} - -//// [tslib.d.ts] -export {} - - -//// [other.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.x = void 0; -exports.x = 1; -//// [external.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.B = exports.A = void 0; -const tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./other"), exports); -class A { -} -exports.A = A; -class B extends A { -} -exports.B = B; -@dec -class C { - method(x) { - } -} -const o = { a: 1 }; -const y = tslib_1.__assign({}, o); -const x = tslib_1.__rest(y, []); -//// [script.js] -class A { -} -class B extends A { -} -@dec -class C { - method(x) { - } -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.js.diff deleted file mode 100644 index 0ac6654328..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.js.diff +++ /dev/null @@ -1,77 +0,0 @@ ---- old.importHelpersNoHelpers.js -+++ new.importHelpersNoHelpers.js -@@= skipped -44, +44 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.B = exports.A = void 0; --var tslib_1 = require("tslib"); -+const tslib_1 = require("tslib"); - tslib_1.__exportStar(require("./other"), exports); - class A { - } -@@= skipped -8, +8 lines =@@ - class B extends A { - } - exports.B = B; --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- tslib_1.__decorate([ -- tslib_1.__param(0, dec), -- tslib_1.__metadata("design:type", Function), -- tslib_1.__metadata("design:paramtypes", [Number]), -- tslib_1.__metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = tslib_1.__decorate([ -- dec -- ], C); -- return C; --})(); -+@dec -+class C { -+ method(x) { -+ } -+} - const o = { a: 1 }; - const y = tslib_1.__assign({}, o); - const x = tslib_1.__rest(y, []); - //// [script.js] --var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { -- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; -- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); -- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; -- return c > 3 && r && Object.defineProperty(target, key, r), r; --}; --var __metadata = (this && this.__metadata) || function (k, v) { -- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); --}; --var __param = (this && this.__param) || function (paramIndex, decorator) { -- return function (target, key) { decorator(target, key, paramIndex); } --}; - class A { - } - class B extends A { - } --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- __decorate([ -- __param(0, dec), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Number]), -- __metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = __decorate([ -- dec -- ], C); -- return C; --})(); -+@dec -+class C { -+ method(x) { -+ } -+} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.symbols b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.symbols deleted file mode 100644 index 787d61d0f6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.symbols +++ /dev/null @@ -1,71 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpers.ts] //// - -=== external.ts === -export * from "./other"; -export class A { } ->A : Symbol(A, Decl(external.ts, 0, 24)) - -export class B extends A { } ->B : Symbol(B, Decl(external.ts, 1, 18)) ->A : Symbol(A, Decl(external.ts, 0, 24)) - -declare var dec: any; ->dec : Symbol(dec, Decl(external.ts, 4, 11)) - -@dec ->dec : Symbol(dec, Decl(external.ts, 4, 11)) - -class C { ->C : Symbol(C, Decl(external.ts, 4, 21)) - - method(@dec x: number) { ->method : Symbol(C.method, Decl(external.ts, 7, 9)) ->dec : Symbol(dec, Decl(external.ts, 4, 11)) ->x : Symbol(x, Decl(external.ts, 8, 11)) - } -} - -const o = { a: 1 }; ->o : Symbol(o, Decl(external.ts, 12, 5)) ->a : Symbol(a, Decl(external.ts, 12, 11)) - -const y = { ...o }; ->y : Symbol(y, Decl(external.ts, 13, 5)) ->o : Symbol(o, Decl(external.ts, 12, 5)) - -const { ...x } = y; ->x : Symbol(x, Decl(external.ts, 14, 7)) ->y : Symbol(y, Decl(external.ts, 13, 5)) - -=== other.ts === -export const x = 1; ->x : Symbol(x, Decl(other.ts, 0, 12)) - -=== script.ts === -class A { } ->A : Symbol(A, Decl(script.ts, 0, 0)) - -class B extends A { } ->B : Symbol(B, Decl(script.ts, 0, 11)) ->A : Symbol(A, Decl(script.ts, 0, 0)) - -declare var dec: any; ->dec : Symbol(dec, Decl(script.ts, 3, 11)) - -@dec ->dec : Symbol(dec, Decl(script.ts, 3, 11)) - -class C { ->C : Symbol(C, Decl(script.ts, 3, 21)) - - method(@dec x: number) { ->method : Symbol(C.method, Decl(script.ts, 6, 9)) ->dec : Symbol(dec, Decl(script.ts, 3, 11)) ->x : Symbol(x, Decl(script.ts, 7, 11)) - } -} - -=== tslib.d.ts === - -export {} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.types b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.types deleted file mode 100644 index a1fa560625..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpers.types +++ /dev/null @@ -1,75 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpers.ts] //// - -=== external.ts === -export * from "./other"; -export class A { } ->A : A - -export class B extends A { } ->B : B ->A : A - -declare var dec: any; ->dec : any - -@dec ->dec : any - -class C { ->C : C - - method(@dec x: number) { ->method : (x: number) => void ->dec : any ->x : number - } -} - -const o = { a: 1 }; ->o : { a: number; } ->{ a: 1 } : { a: number; } ->a : number ->1 : 1 - -const y = { ...o }; ->y : { a: number; } ->{ ...o } : { a: number; } ->o : { a: number; } - -const { ...x } = y; ->x : { a: number; } ->y : { a: number; } - -=== other.ts === -export const x = 1; ->x : 1 ->1 : 1 - -=== script.ts === -class A { } ->A : A - -class B extends A { } ->B : B ->A : A - -declare var dec: any; ->dec : any - -@dec ->dec : any - -class C { ->C : C - - method(@dec x: number) { ->method : (x: number) => void ->dec : any ->x : number - } -} - -=== tslib.d.ts === - -export {} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.errors.txt.diff deleted file mode 100644 index 251577a030..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.importHelpersNoHelpersForAsyncGenerators.errors.txt -+++ new.importHelpersNoHelpersForAsyncGenerators.errors.txt -@@= skipped -0, +0 lines =@@ --main.ts(1,25): error TS2343: This syntax requires an imported helper named '__asyncGenerator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --main.ts(1,25): error TS2343: This syntax requires an imported helper named '__await' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --main.ts(1,25): error TS2343: This syntax requires an imported helper named '__generator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --main.ts(4,5): error TS2343: This syntax requires an imported helper named '__asyncDelegator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --main.ts(4,5): error TS2343: This syntax requires an imported helper named '__asyncValues' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- -- --==== main.ts (5 errors) ==== -- export async function * f() { -- ~ --!!! error TS2343: This syntax requires an imported helper named '__asyncGenerator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- ~ --!!! error TS2343: This syntax requires an imported helper named '__await' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- ~ --!!! error TS2343: This syntax requires an imported helper named '__generator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- await 1; -- yield 2; -- yield* [3]; -- ~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__asyncDelegator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- ~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__asyncValues' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- } -- --==== tslib.d.ts (0 errors) ==== -- export {} -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.js b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.js deleted file mode 100644 index 7d563b778a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.js +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpersForAsyncGenerators.ts] //// - -//// [main.ts] -export async function * f() { - await 1; - yield 2; - yield* [3]; -} - -//// [tslib.d.ts] -export {} - - -//// [main.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.f = f; -async function* f() { - await 1; - yield 2; - yield* [3]; -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.js.diff deleted file mode 100644 index 623b1326fc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.importHelpersNoHelpersForAsyncGenerators.js -+++ new.importHelpersNoHelpersForAsyncGenerators.js -@@= skipped -14, +14 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.f = f; --var tslib_1 = require("tslib"); --function f() { -- return tslib_1.__asyncGenerator(this, arguments, function* f_1() { -- yield tslib_1.__await(1); -- yield yield tslib_1.__await(2); -- yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues([3]))); -- }); -+async function* f() { -+ await 1; -+ yield 2; -+ yield* [3]; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.symbols b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.symbols deleted file mode 100644 index 30c0590218..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.symbols +++ /dev/null @@ -1,15 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpersForAsyncGenerators.ts] //// - -=== main.ts === -export async function * f() { ->f : Symbol(f, Decl(main.ts, 0, 0)) - - await 1; - yield 2; - yield* [3]; -} - -=== tslib.d.ts === - -export {} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.types b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.types deleted file mode 100644 index 3d7e2647df..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForAsyncGenerators.types +++ /dev/null @@ -1,24 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpersForAsyncGenerators.ts] //// - -=== main.ts === -export async function * f() { ->f : () => AsyncGenerator - - await 1; ->await 1 : 1 ->1 : 1 - - yield 2; ->yield 2 : any ->2 : 2 - - yield* [3]; ->yield* [3] : any ->[3] : number[] ->3 : 3 -} - -=== tslib.d.ts === - -export {} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.errors.txt.diff deleted file mode 100644 index 631943e825..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.importHelpersNoHelpersForPrivateFields.errors.txt -+++ new.importHelpersNoHelpersForPrivateFields.errors.txt -@@= skipped -0, +0 lines =@@ --main.ts(4,9): error TS2343: This syntax requires an imported helper named '__classPrivateFieldSet' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --main.ts(4,23): error TS2343: This syntax requires an imported helper named '__classPrivateFieldGet' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. --main.ts(5,9): error TS2343: This syntax requires an imported helper named '__classPrivateFieldIn' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- -- --==== main.ts (3 errors) ==== -- export class Foo { -- #field = true; -- f() { -- this.#field = this.#field; -- ~~~~~~~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__classPrivateFieldSet' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- ~~~~~~~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__classPrivateFieldGet' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- #field in this; -- ~~~~~~ --!!! error TS2343: This syntax requires an imported helper named '__classPrivateFieldIn' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -- } -- } -- --==== tslib.d.ts (0 errors) ==== -- export {} -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.js b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.js deleted file mode 100644 index 47dadd336e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.js +++ /dev/null @@ -1,27 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpersForPrivateFields.ts] //// - -//// [main.ts] -export class Foo { - #field = true; - f() { - this.#field = this.#field; - #field in this; - } -} - -//// [tslib.d.ts] -export {} - - -//// [main.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Foo = void 0; -class Foo { - #field = true; - f() { - this.#field = this.#field; - #field in this; - } -} -exports.Foo = Foo; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.js.diff deleted file mode 100644 index 21b9d7c63b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.js.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.importHelpersNoHelpersForPrivateFields.js -+++ new.importHelpersNoHelpersForPrivateFields.js -@@= skipped -14, +14 lines =@@ - - //// [main.js] - "use strict"; --var _Foo_field; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Foo = void 0; --const tslib_1 = require("tslib"); - class Foo { -- constructor() { -- _Foo_field.set(this, true); -- } -+ #field = true; - f() { -- tslib_1.__classPrivateFieldSet(this, _Foo_field, tslib_1.__classPrivateFieldGet(this, _Foo_field, "f"), "f"); -- tslib_1.__classPrivateFieldIn(_Foo_field, this); -+ this.#field = this.#field; -+ #field in this; - } - } - exports.Foo = Foo; --_Foo_field = new WeakMap(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.symbols b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.symbols deleted file mode 100644 index 6e306866c6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.symbols +++ /dev/null @@ -1,28 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpersForPrivateFields.ts] //// - -=== main.ts === -export class Foo { ->Foo : Symbol(Foo, Decl(main.ts, 0, 0)) - - #field = true; ->#field : Symbol(Foo.#field, Decl(main.ts, 0, 18)) - - f() { ->f : Symbol(Foo.f, Decl(main.ts, 1, 18)) - - this.#field = this.#field; ->this.#field : Symbol(Foo.#field, Decl(main.ts, 0, 18)) ->this : Symbol(Foo, Decl(main.ts, 0, 0)) ->this.#field : Symbol(Foo.#field, Decl(main.ts, 0, 18)) ->this : Symbol(Foo, Decl(main.ts, 0, 0)) - - #field in this; ->#field : Symbol(Foo.#field, Decl(main.ts, 0, 18)) ->this : Symbol(Foo, Decl(main.ts, 0, 0)) - } -} - -=== tslib.d.ts === - -export {} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.types b/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.types deleted file mode 100644 index 56db496360..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoHelpersForPrivateFields.types +++ /dev/null @@ -1,31 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoHelpersForPrivateFields.ts] //// - -=== main.ts === -export class Foo { ->Foo : Foo - - #field = true; ->#field : boolean ->true : true - - f() { ->f : () => void - - this.#field = this.#field; ->this.#field = this.#field : boolean ->this.#field : boolean ->this : this ->this.#field : boolean ->this : this - - #field in this; ->#field in this : boolean ->#field : any ->this : this - } -} - -=== tslib.d.ts === - -export {} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.errors.txt.diff deleted file mode 100644 index 7d4467114f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.importHelpersNoModule.errors.txt -+++ new.importHelpersNoModule.errors.txt -@@= skipped -0, +0 lines =@@ --external.ts(2,16): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. -- -- --==== external.ts (1 errors) ==== -- export class A { } -- export class B extends A { } -- ~~~~~~~~~ --!!! error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. -- -- declare var dec: any; -- -- @dec -- class C { -- method(@dec x: number) { -- } -- } -- --==== script.ts (0 errors) ==== -- class A { } -- class B extends A { } -- -- declare var dec: any; -- -- @dec -- class C { -- method(@dec x: number) { -- } -- } -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.js b/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.js deleted file mode 100644 index 70c25909d3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.js +++ /dev/null @@ -1,52 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoModule.ts] //// - -//// [external.ts] -export class A { } -export class B extends A { } - -declare var dec: any; - -@dec -class C { - method(@dec x: number) { - } -} - -//// [script.ts] -class A { } -class B extends A { } - -declare var dec: any; - -@dec -class C { - method(@dec x: number) { - } -} - - -//// [external.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.B = exports.A = void 0; -class A { -} -exports.A = A; -class B extends A { -} -exports.B = B; -@dec -class C { - method(x) { - } -} -//// [script.js] -class A { -} -class B extends A { -} -@dec -class C { - method(x) { - } -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.js.diff deleted file mode 100644 index aa0453ed96..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.js.diff +++ /dev/null @@ -1,72 +0,0 @@ ---- old.importHelpersNoModule.js -+++ new.importHelpersNoModule.js -@@= skipped -28, +28 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.B = exports.A = void 0; --var tslib_1 = require("tslib"); - class A { - } - exports.A = A; - class B extends A { - } - exports.B = B; --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- tslib_1.__decorate([ -- tslib_1.__param(0, dec), -- tslib_1.__metadata("design:type", Function), -- tslib_1.__metadata("design:paramtypes", [Number]), -- tslib_1.__metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = tslib_1.__decorate([ -- dec -- ], C); -- return C; --})(); -+@dec -+class C { -+ method(x) { -+ } -+} - //// [script.js] --var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { -- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; -- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); -- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; -- return c > 3 && r && Object.defineProperty(target, key, r), r; --}; --var __metadata = (this && this.__metadata) || function (k, v) { -- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); --}; --var __param = (this && this.__param) || function (paramIndex, decorator) { -- return function (target, key) { decorator(target, key, paramIndex); } --}; - class A { - } - class B extends A { - } --let C = (() => { -- let C = class C { -- method(x) { -- } -- }; -- __decorate([ -- __param(0, dec), -- __metadata("design:type", Function), -- __metadata("design:paramtypes", [Number]), -- __metadata("design:returntype", void 0) -- ], C.prototype, "method", null); -- C = __decorate([ -- dec -- ], C); -- return C; --})(); -+@dec -+class C { -+ method(x) { -+ } -+} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.symbols b/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.symbols deleted file mode 100644 index 684f87cd57..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.symbols +++ /dev/null @@ -1,50 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoModule.ts] //// - -=== external.ts === -export class A { } ->A : Symbol(A, Decl(external.ts, 0, 0)) - -export class B extends A { } ->B : Symbol(B, Decl(external.ts, 0, 18)) ->A : Symbol(A, Decl(external.ts, 0, 0)) - -declare var dec: any; ->dec : Symbol(dec, Decl(external.ts, 3, 11)) - -@dec ->dec : Symbol(dec, Decl(external.ts, 3, 11)) - -class C { ->C : Symbol(C, Decl(external.ts, 3, 21)) - - method(@dec x: number) { ->method : Symbol(C.method, Decl(external.ts, 6, 9)) ->dec : Symbol(dec, Decl(external.ts, 3, 11)) ->x : Symbol(x, Decl(external.ts, 7, 11)) - } -} - -=== script.ts === -class A { } ->A : Symbol(A, Decl(script.ts, 0, 0)) - -class B extends A { } ->B : Symbol(B, Decl(script.ts, 0, 11)) ->A : Symbol(A, Decl(script.ts, 0, 0)) - -declare var dec: any; ->dec : Symbol(dec, Decl(script.ts, 3, 11)) - -@dec ->dec : Symbol(dec, Decl(script.ts, 3, 11)) - -class C { ->C : Symbol(C, Decl(script.ts, 3, 21)) - - method(@dec x: number) { ->method : Symbol(C.method, Decl(script.ts, 6, 9)) ->dec : Symbol(dec, Decl(script.ts, 3, 11)) ->x : Symbol(x, Decl(script.ts, 7, 11)) - } -} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.types b/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.types deleted file mode 100644 index fd4e40576b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersNoModule.types +++ /dev/null @@ -1,50 +0,0 @@ -//// [tests/cases/compiler/importHelpersNoModule.ts] //// - -=== external.ts === -export class A { } ->A : A - -export class B extends A { } ->B : B ->A : A - -declare var dec: any; ->dec : any - -@dec ->dec : any - -class C { ->C : C - - method(@dec x: number) { ->method : (x: number) => void ->dec : any ->x : number - } -} - -=== script.ts === -class A { } ->A : A - -class B extends A { } ->B : B ->A : A - -declare var dec: any; ->dec : any - -@dec ->dec : any - -class C { ->C : C - - method(@dec x: number) { ->method : (x: number) => void ->dec : any ->x : number - } -} - diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).js deleted file mode 100644 index 31beae743c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).js +++ /dev/null @@ -1,25 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -export * as a from "./a"; - -//// [tslib.d.ts] -declare module "tslib" { - function __importStar(m: any): void; -} - -//// [a.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.A = void 0; -class A { -} -exports.A = A; -//// [b.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = require("./a"); diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols deleted file mode 100644 index 97555e2107..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== b.ts === -export * as a from "./a"; ->a : Symbol(a, Decl(b.ts, 0, 6)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; ->__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 26)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols.diff deleted file mode 100644 index d85648207f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols -+++ new.importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).symbols -@@= skipped -9, +9 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; -->__importStar : Symbol(__importStar, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 26)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).types deleted file mode 100644 index f5df44496d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=commonjs).types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : A - -=== b.ts === -export * as a from "./a"; ->a : typeof import("a") - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importStar(m: any): void; ->__importStar : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).js deleted file mode 100644 index 68116bf951..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).js +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -export * as a from "./a"; - -//// [tslib.d.ts] -declare module "tslib" { - function __importStar(m: any): void; -} - -//// [a.js] -export class A { -} -//// [b.js] -import * as a_1 from "./a"; -export { a_1 as a }; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols deleted file mode 100644 index 97555e2107..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== b.ts === -export * as a from "./a"; ->a : Symbol(a, Decl(b.ts, 0, 6)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; ->__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 26)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols.diff deleted file mode 100644 index b9bb3ff358..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols -+++ new.importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).symbols -@@= skipped -9, +9 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; -->__importStar : Symbol(__importStar, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 26)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).types deleted file mode 100644 index f5df44496d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2015).types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : A - -=== b.ts === -export * as a from "./a"; ->a : typeof import("a") - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importStar(m: any): void; ->__importStar : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).js deleted file mode 100644 index 28e70a903d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).js +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -export * as a from "./a"; - -//// [tslib.d.ts] -declare module "tslib" { - function __importStar(m: any): void; -} - -//// [a.js] -export class A { -} -//// [b.js] -export * as a from "./a"; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols deleted file mode 100644 index 97555e2107..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== b.ts === -export * as a from "./a"; ->a : Symbol(a, Decl(b.ts, 0, 6)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; ->__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 26)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols.diff deleted file mode 100644 index e3bdde4826..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols -+++ new.importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).symbols -@@= skipped -9, +9 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; -->__importStar : Symbol(__importStar, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 26)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).types deleted file mode 100644 index f5df44496d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithExportStarAs(esmoduleinterop=false,module=es2020).types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithExportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : A - -=== b.ts === -export * as a from "./a"; ->a : typeof import("a") - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importStar(m: any): void; ->__importStar : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js deleted file mode 100644 index ea14d2e7de..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js +++ /dev/null @@ -1,32 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -//// [a.ts] -export default class { } - -//// [b.ts] -export { default } from "./a"; -export { default as a } from "./a"; -import { default as b } from "./a"; -void b; - -//// [tslib.d.ts] -declare module "tslib" { - function __importDefault(m: any): void; -} - -//// [a.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class default_1 { -} -exports.default = default_1; -//// [b.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = exports.default = void 0; -const a_1 = require("./a"); -Object.defineProperty(exports, "default", { enumerable: true, get: function () { return a_1.default; } }); -const a_2 = require("./a"); -Object.defineProperty(exports, "a", { enumerable: true, get: function () { return a_2.default; } }); -const a_3 = require("./a"); -void a_3.default; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js.diff deleted file mode 100644 index eb54926434..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js -+++ new.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).js -@@= skipped -23, +23 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = exports.default = void 0; --var a_1 = require("./a"); -+const a_1 = require("./a"); - Object.defineProperty(exports, "default", { enumerable: true, get: function () { return a_1.default; } }); --var a_2 = require("./a"); -+const a_2 = require("./a"); - Object.defineProperty(exports, "a", { enumerable: true, get: function () { return a_2.default; } }); - const a_3 = require("./a"); - void a_3.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols deleted file mode 100644 index 59499f9085..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols +++ /dev/null @@ -1,29 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -=== a.ts === - -export default class { } - -=== b.ts === -export { default } from "./a"; ->default : Symbol(default, Decl(b.ts, 0, 8)) - -export { default as a } from "./a"; ->default : Symbol(b, Decl(a.ts, 0, 0)) ->a : Symbol(a, Decl(b.ts, 1, 8)) - -import { default as b } from "./a"; ->default : Symbol(b, Decl(a.ts, 0, 0)) ->b : Symbol(b, Decl(b.ts, 2, 8)) - -void b; ->b : Symbol(b, Decl(b.ts, 2, 8)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importDefault(m: any): void; ->__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 29)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols.diff deleted file mode 100644 index 50f126b9d6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols -+++ new.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).symbols -@@= skipped -20, +20 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importDefault(m: any): void; -->__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 29)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).types deleted file mode 100644 index 8bd28a2027..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=commonjs).types +++ /dev/null @@ -1,30 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -=== a.ts === - -export default class { } - -=== b.ts === -export { default } from "./a"; ->default : typeof b - -export { default as a } from "./a"; ->default : typeof b ->a : typeof b - -import { default as b } from "./a"; ->default : typeof b ->b : typeof b - -void b; ->void b : undefined ->b : typeof b - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importDefault(m: any): void; ->__importDefault : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).js deleted file mode 100644 index cb24120cb6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).js +++ /dev/null @@ -1,24 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -//// [a.ts] -export default class { } - -//// [b.ts] -export { default } from "./a"; -export { default as a } from "./a"; -import { default as b } from "./a"; -void b; - -//// [tslib.d.ts] -declare module "tslib" { - function __importDefault(m: any): void; -} - -//// [a.js] -export default class { -} -//// [b.js] -export { default } from "./a"; -export { default as a } from "./a"; -import { default as b } from "./a"; -void b; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols deleted file mode 100644 index 59499f9085..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols +++ /dev/null @@ -1,29 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -=== a.ts === - -export default class { } - -=== b.ts === -export { default } from "./a"; ->default : Symbol(default, Decl(b.ts, 0, 8)) - -export { default as a } from "./a"; ->default : Symbol(b, Decl(a.ts, 0, 0)) ->a : Symbol(a, Decl(b.ts, 1, 8)) - -import { default as b } from "./a"; ->default : Symbol(b, Decl(a.ts, 0, 0)) ->b : Symbol(b, Decl(b.ts, 2, 8)) - -void b; ->b : Symbol(b, Decl(b.ts, 2, 8)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importDefault(m: any): void; ->__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 29)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols.diff deleted file mode 100644 index 3a06a2d40e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols -+++ new.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).symbols -@@= skipped -20, +20 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importDefault(m: any): void; -->__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 29)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).types deleted file mode 100644 index 8bd28a2027..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2015).types +++ /dev/null @@ -1,30 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -=== a.ts === - -export default class { } - -=== b.ts === -export { default } from "./a"; ->default : typeof b - -export { default as a } from "./a"; ->default : typeof b ->a : typeof b - -import { default as b } from "./a"; ->default : typeof b ->b : typeof b - -void b; ->void b : undefined ->b : typeof b - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importDefault(m: any): void; ->__importDefault : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).js deleted file mode 100644 index cb24120cb6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).js +++ /dev/null @@ -1,24 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -//// [a.ts] -export default class { } - -//// [b.ts] -export { default } from "./a"; -export { default as a } from "./a"; -import { default as b } from "./a"; -void b; - -//// [tslib.d.ts] -declare module "tslib" { - function __importDefault(m: any): void; -} - -//// [a.js] -export default class { -} -//// [b.js] -export { default } from "./a"; -export { default as a } from "./a"; -import { default as b } from "./a"; -void b; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols deleted file mode 100644 index 59499f9085..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols +++ /dev/null @@ -1,29 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -=== a.ts === - -export default class { } - -=== b.ts === -export { default } from "./a"; ->default : Symbol(default, Decl(b.ts, 0, 8)) - -export { default as a } from "./a"; ->default : Symbol(b, Decl(a.ts, 0, 0)) ->a : Symbol(a, Decl(b.ts, 1, 8)) - -import { default as b } from "./a"; ->default : Symbol(b, Decl(a.ts, 0, 0)) ->b : Symbol(b, Decl(b.ts, 2, 8)) - -void b; ->b : Symbol(b, Decl(b.ts, 2, 8)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importDefault(m: any): void; ->__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 29)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols.diff deleted file mode 100644 index afbb243031..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols -+++ new.importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).symbols -@@= skipped -20, +20 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importDefault(m: any): void; -->__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importDefault : Symbol(__importDefault, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 29)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).types deleted file mode 100644 index 8bd28a2027..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportOrExportDefault(esmoduleinterop=false,module=es2020).types +++ /dev/null @@ -1,30 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportOrExportDefault.ts] //// - -=== a.ts === - -export default class { } - -=== b.ts === -export { default } from "./a"; ->default : typeof b - -export { default as a } from "./a"; ->default : typeof b ->a : typeof b - -import { default as b } from "./a"; ->default : typeof b ->b : typeof b - -void b; ->void b : undefined ->b : typeof b - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importDefault(m: any): void; ->__importDefault : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).js deleted file mode 100644 index 8ecadfeab3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).js +++ /dev/null @@ -1,27 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -import * as a from "./a"; -export { a }; - -//// [tslib.d.ts] -declare module "tslib" { - function __importStar(m: any): void; -} - -//// [a.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.A = void 0; -class A { -} -exports.A = A; -//// [b.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -const a = require("./a"); -exports.a = a; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols deleted file mode 100644 index 06d0f645fd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== b.ts === -import * as a from "./a"; ->a : Symbol(a, Decl(b.ts, 0, 6)) - -export { a }; ->a : Symbol(a, Decl(b.ts, 1, 8)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; ->__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 26)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols.diff deleted file mode 100644 index 76a8ac6ca0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols -+++ new.importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).symbols -@@= skipped -12, +12 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; -->__importStar : Symbol(__importStar, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 26)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).types deleted file mode 100644 index 40e598a9cc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=commonjs).types +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : A - -=== b.ts === -import * as a from "./a"; ->a : typeof a - -export { a }; ->a : typeof a - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importStar(m: any): void; ->__importStar : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).js deleted file mode 100644 index c08ff68957..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).js +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -import * as a from "./a"; -export { a }; - -//// [tslib.d.ts] -declare module "tslib" { - function __importStar(m: any): void; -} - -//// [a.js] -export class A { -} -//// [b.js] -import * as a from "./a"; -export { a }; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols deleted file mode 100644 index 06d0f645fd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== b.ts === -import * as a from "./a"; ->a : Symbol(a, Decl(b.ts, 0, 6)) - -export { a }; ->a : Symbol(a, Decl(b.ts, 1, 8)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; ->__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 26)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols.diff deleted file mode 100644 index 29b6b9d4b1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols -+++ new.importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).symbols -@@= skipped -12, +12 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; -->__importStar : Symbol(__importStar, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 26)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).types deleted file mode 100644 index 40e598a9cc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2015).types +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : A - -=== b.ts === -import * as a from "./a"; ->a : typeof a - -export { a }; ->a : typeof a - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importStar(m: any): void; ->__importStar : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).js deleted file mode 100644 index c08ff68957..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).js +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -//// [a.ts] -export class A { } - -//// [b.ts] -import * as a from "./a"; -export { a }; - -//// [tslib.d.ts] -declare module "tslib" { - function __importStar(m: any): void; -} - -//// [a.js] -export class A { -} -//// [b.js] -import * as a from "./a"; -export { a }; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols deleted file mode 100644 index 06d0f645fd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : Symbol(A, Decl(a.ts, 0, 0)) - -=== b.ts === -import * as a from "./a"; ->a : Symbol(a, Decl(b.ts, 0, 6)) - -export { a }; ->a : Symbol(a, Decl(b.ts, 1, 8)) - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; ->__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) ->m : Symbol(m, Decl(tslib.d.ts, 1, 26)) -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols.diff b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols.diff deleted file mode 100644 index d59be423e4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols -+++ new.importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).symbols -@@= skipped -12, +12 lines =@@ - - === tslib.d.ts === - declare module "tslib" { -->"tslib" : Symbol("tslib", Decl(tslib.d.ts, --, --)) -+>"tslib" : Symbol("tslib", Decl(tslib.d.ts, 0, 0)) - - function __importStar(m: any): void; -->__importStar : Symbol(__importStar, Decl(tslib.d.ts, --, --)) -->m : Symbol(m, Decl(tslib.d.ts, --, --)) -+>__importStar : Symbol(__importStar, Decl(tslib.d.ts, 0, 24)) -+>m : Symbol(m, Decl(tslib.d.ts, 1, 26)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).types b/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).types deleted file mode 100644 index 40e598a9cc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithImportStarAs(esmoduleinterop=false,module=es2020).types +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/importHelpersWithImportStarAs.ts] //// - -=== a.ts === -export class A { } ->A : A - -=== b.ts === -import * as a from "./a"; ->a : typeof a - -export { a }; ->a : typeof a - -=== tslib.d.ts === -declare module "tslib" { ->"tslib" : typeof import("tslib") - - function __importStar(m: any): void; ->__importStar : (m: any) => void ->m : any -} diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=commonjs).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=commonjs).js index 5499da070a..cc1242f528 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=commonjs).js +++ b/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=commonjs).js @@ -9,7 +9,7 @@ declare var dec: any, __decorate: any; const o = { a: 1 }; const y = { ...o }; -//// [tslib.d.ts] +//// [index.d.ts] export declare function __extends(d: Function, b: Function): void; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; export declare function __param(paramIndex: number, decorator: Function): Function; diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=es2015).js b/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=es2015).js index 36fb70701c..8f7015dcd2 100644 --- a/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=es2015).js +++ b/testdata/baselines/reference/submodule/compiler/importHelpersWithLocalCollisions(module=es2015).js @@ -9,7 +9,7 @@ declare var dec: any, __decorate: any; const o = { a: 1 }; const y = { ...o }; -//// [tslib.d.ts] +//// [index.d.ts] export declare function __extends(d: Function, b: Function): void; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; export declare function __param(paramIndex: number, decorator: Function): Function; diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.errors.txt b/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.errors.txt deleted file mode 100644 index 66f586f133..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -b.js(1,10): error TS2596: 'Foo' can only be imported by turning on the 'esModuleInterop' flag and using a default import. -b.js(1,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export. - - -==== a.ts (1 errors) ==== - class Foo {} - export = Foo; - ~~~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - -==== b.js (2 errors) ==== - import { Foo } from './a'; - ~~~ -!!! error TS2596: 'Foo' can only be imported by turning on the 'esModuleInterop' flag and using a default import. - ~~~~~ -!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.symbols b/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.symbols deleted file mode 100644 index 7c5af0d0ca..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.symbols +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember10.ts] //// - -=== a.ts === -class Foo {} ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -export = Foo; ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -=== b.js === -import { Foo } from './a'; ->Foo : Symbol(Foo, Decl(b.js, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.types b/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.types deleted file mode 100644 index c1b3848239..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember10.types +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember10.ts] //// - -=== a.ts === -class Foo {} ->Foo : Foo - -export = Foo; ->Foo : Foo - -=== b.js === -import { Foo } from './a'; ->Foo : any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importNonExportedMember12.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/importNonExportedMember12.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/importNonExportedMember12.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols b/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols index 657f6d3f03..9aca857846 100644 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols +++ b/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols @@ -3,7 +3,7 @@ === /node_modules/foo/src/index.js === module.exports = 1; >module.exports : Symbol(export=, Decl(index.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("/node_modules/foo/src/index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 0)) === /a.js === diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols.diff b/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols.diff index 9417643c99..64fff670ef 100644 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.symbols.diff @@ -7,7 +7,7 @@ ->module.exports : Symbol(module.exports, Decl(index.js, 0, 0)) ->module : Symbol(export=, Decl(index.js, 0, 0)) +>module.exports : Symbol(export=, Decl(index.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("/node_modules/foo/src/index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 0)) === /a.js === diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importNonExportedMember12.types.diff b/testdata/baselines/reference/submodule/compiler/importNonExportedMember12.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/importNonExportedMember12.types.diff rename to testdata/baselines/reference/submodule/compiler/importNonExportedMember12.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.errors.txt b/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.errors.txt deleted file mode 100644 index d4294bc523..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -b.ts(1,10): error TS2617: 'Foo' can only be imported by using 'import Foo = require("./a")' or by turning on the 'esModuleInterop' flag and using a default import. -b.ts(1,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - - -==== a.ts (0 errors) ==== - class Foo {} - export = Foo; - -==== b.ts (2 errors) ==== - import { Foo } from './a'; - ~~~ -!!! error TS2617: 'Foo' can only be imported by using 'import Foo = require("./a")' or by turning on the 'esModuleInterop' flag and using a default import. - ~~~~~ -!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.js b/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.js deleted file mode 100644 index 89c572f288..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember4.ts] //// - -//// [a.ts] -class Foo {} -export = Foo; - -//// [b.ts] -import { Foo } from './a'; - -//// [a.js] -"use strict"; -class Foo { -} -module.exports = Foo; -//// [b.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.symbols b/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.symbols deleted file mode 100644 index 7f94a2da7b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.symbols +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember4.ts] //// - -=== a.ts === -class Foo {} ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -export = Foo; ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -=== b.ts === -import { Foo } from './a'; ->Foo : Symbol(Foo, Decl(b.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.types b/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.types deleted file mode 100644 index cedd4d61f8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember4.types +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember4.ts] //// - -=== a.ts === -class Foo {} ->Foo : Foo - -export = Foo; ->Foo : Foo - -=== b.ts === -import { Foo } from './a'; ->Foo : any - diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.errors.txt b/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.errors.txt deleted file mode 100644 index 07938b7690..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -b.ts(1,10): error TS2596: 'Foo' can only be imported by turning on the 'esModuleInterop' flag and using a default import. -b.ts(1,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export. - - -==== a.ts (1 errors) ==== - class Foo {} - export = Foo; - ~~~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - -==== b.ts (2 errors) ==== - import { Foo } from './a'; - ~~~ -!!! error TS2596: 'Foo' can only be imported by turning on the 'esModuleInterop' flag and using a default import. - ~~~~~ -!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.js b/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.js deleted file mode 100644 index 8eed26d3c4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember6.ts] //// - -//// [a.ts] -class Foo {} -export = Foo; - -//// [b.ts] -import { Foo } from './a'; - -//// [a.js] -class Foo { -} -export {}; -//// [b.js] -export {}; diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.symbols b/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.symbols deleted file mode 100644 index fe60c83021..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.symbols +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember6.ts] //// - -=== a.ts === -class Foo {} ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -export = Foo; ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -=== b.ts === -import { Foo } from './a'; ->Foo : Symbol(Foo, Decl(b.ts, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.types b/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.types deleted file mode 100644 index b03c41a7c7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember6.types +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember6.ts] //// - -=== a.ts === -class Foo {} ->Foo : Foo - -export = Foo; ->Foo : Foo - -=== b.ts === -import { Foo } from './a'; ->Foo : any - diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.errors.txt b/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.errors.txt deleted file mode 100644 index 5b9b99ac88..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -b.js(1,10): error TS2617: 'Foo' can only be imported by using 'import Foo = require("./a")' or by turning on the 'esModuleInterop' flag and using a default import. -b.js(1,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - - -==== a.ts (0 errors) ==== - class Foo {} - export = Foo; - -==== b.js (2 errors) ==== - import { Foo } from './a'; - ~~~ -!!! error TS2617: 'Foo' can only be imported by using 'import Foo = require("./a")' or by turning on the 'esModuleInterop' flag and using a default import. - ~~~~~ -!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.symbols b/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.symbols deleted file mode 100644 index 3e39a58b8c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.symbols +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember8.ts] //// - -=== a.ts === -class Foo {} ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -export = Foo; ->Foo : Symbol(Foo, Decl(a.ts, 0, 0)) - -=== b.js === -import { Foo } from './a'; ->Foo : Symbol(Foo, Decl(b.js, 0, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.types b/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.types deleted file mode 100644 index 7a3b7891fc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNonExportedMember8.types +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/importNonExportedMember8.ts] //// - -=== a.ts === -class Foo {} ->Foo : Foo - -export = Foo; ->Foo : Foo - -=== b.js === -import { Foo } from './a'; ->Foo : any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importNonExportedMember9.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importNonExportedMember9.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/importNonExportedMember9.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/importNonExportedMember9.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js b/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js index d0c75d19d0..c2d68df4e3 100644 --- a/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js +++ b/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js @@ -21,16 +21,19 @@ class Q extends Z { //// [importNotElidedWhenNotFound.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const file_1 = require("file"); -const other_file_1 = require("other_file"); +const file_1 = __importDefault(require("file")); +const other_file_1 = __importDefault(require("other_file")); class Y extends other_file_1.default { constructor() { super(file_1.default); } } -const file2_1 = require("file2"); -const file3_1 = require("file3"); +const file2_1 = __importDefault(require("file2")); +const file3_1 = __importDefault(require("file3")); class Q extends other_file_1.default { constructor() { super(file2_1.default, file3_1.default); diff --git a/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js.diff b/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js.diff deleted file mode 100644 index 0e3fd5bab2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importNotElidedWhenNotFound.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.importNotElidedWhenNotFound.js -+++ new.importNotElidedWhenNotFound.js -@@= skipped -21, +21 lines =@@ - //// [importNotElidedWhenNotFound.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var file_1 = require("file"); --var other_file_1 = require("other_file"); -+const file_1 = require("file"); -+const other_file_1 = require("other_file"); - class Y extends other_file_1.default { - constructor() { - super(file_1.default); - } - } --var file2_1 = require("file2"); --var file3_1 = require("file3"); -+const file2_1 = require("file2"); -+const file3_1 = require("file3"); - class Q extends other_file_1.default { - constructor() { - super(file2_1.default, file3_1.default); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importShouldNotBeElidedInDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/importShouldNotBeElidedInDeclarationEmit.js.diff deleted file mode 100644 index 2bdd49bfaa..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importShouldNotBeElidedInDeclarationEmit.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.importShouldNotBeElidedInDeclarationEmit.js -+++ new.importShouldNotBeElidedInDeclarationEmit.js -@@= skipped -16, +16 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.thing = void 0; --var umd_1 = require("umd"); -+const umd_1 = require("umd"); - exports.thing = (0, umd_1.makeThing)(); - diff --git a/testdata/baselines/reference/submodule/compiler/importTypeGenericArrowTypeParenthesized.js.diff b/testdata/baselines/reference/submodule/compiler/importTypeGenericArrowTypeParenthesized.js.diff index e12f973bdb..7dfb52db99 100644 --- a/testdata/baselines/reference/submodule/compiler/importTypeGenericArrowTypeParenthesized.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importTypeGenericArrowTypeParenthesized.js.diff @@ -1,15 +1,6 @@ --- old.importTypeGenericArrowTypeParenthesized.js +++ new.importTypeGenericArrowTypeParenthesized.js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.works2 = exports.works1 = exports.fail2 = exports.fail1 = void 0; --var module_1 = require("module"); -+const module_1 = require("module"); - exports.fail1 = (0, module_1.fn)((x) => x); - exports.fail2 = (0, module_1.fn)(function (x) { - return x; -@@= skipped -10, +10 lines =@@ +@@= skipped -32, +32 lines =@@ //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/importUsedInExtendsList1.js.diff b/testdata/baselines/reference/submodule/compiler/importUsedInExtendsList1.js.diff index dbd7527ee1..2dece451dc 100644 --- a/testdata/baselines/reference/submodule/compiler/importUsedInExtendsList1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/importUsedInExtendsList1.js.diff @@ -7,12 +7,4 @@ + foo; } exports.Super = Super; - //// [importUsedInExtendsList1_1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var foo = require("./importUsedInExtendsList1_require"); -+const foo = require("./importUsedInExtendsList1_require"); - class Sub extends foo.Super { - } - var s; \ No newline at end of file + //// [importUsedInExtendsList1_1.js] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js b/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js index 334836a3a3..4626869c56 100644 --- a/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js +++ b/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js @@ -29,15 +29,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { aIndex: 0 }; //// [test.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const _1 = require("."); -const _2 = require("./"); +const _1 = __importDefault(require(".")); +const _2 = __importDefault(require("./")); _1.default.a; _2.default.aIndex; //// [test.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -const __1 = require(".."); -const __2 = require("../"); +const __1 = __importDefault(require("..")); +const __2 = __importDefault(require("../")); __1.default.a; __2.default.aIndex; diff --git a/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js.diff b/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js.diff deleted file mode 100644 index ae54250a75..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importWithTrailingSlash.js.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.importWithTrailingSlash.js -+++ new.importWithTrailingSlash.js -@@= skipped -29, +29 lines =@@ - //// [test.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var _1 = require("."); --var _2 = require("./"); -+const _1 = require("."); -+const _2 = require("./"); - _1.default.a; - _2.default.aIndex; - //// [test.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var __1 = require(".."); --var __2 = require("../"); -+const __1 = require(".."); -+const __2 = require("../"); - __1.default.a; - __2.default.aIndex; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js b/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js index 5a94601829..59709a4b60 100644 --- a/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js +++ b/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js @@ -33,6 +33,7 @@ if (instance instanceof ClassOne) { //// [inKeywordAndIntersection.js] +"use strict"; class A { a = 0; } diff --git a/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js.diff b/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js.diff index bc115a2d7f..09af9e577d 100644 --- a/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inKeywordAndIntersection.js.diff @@ -1,10 +1,8 @@ --- old.inKeywordAndIntersection.js +++ new.inKeywordAndIntersection.js -@@= skipped -32, +32 lines =@@ - - +@@= skipped -34, +34 lines =@@ //// [inKeywordAndIntersection.js] --"use strict"; + "use strict"; class A { - constructor() { - this.a = 0; diff --git a/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js b/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js index c4500d57d5..9357ea4b7a 100644 --- a/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js +++ b/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js @@ -54,6 +54,7 @@ function f7(x: T & {}) { //// [inKeywordAndUnknown.js] +"use strict"; // Repro from #50531 function f(x, y) { if (!("a" in x)) { diff --git a/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js.diff b/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js.diff deleted file mode 100644 index 67512f2575..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inKeywordAndUnknown.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inKeywordAndUnknown.js -+++ new.inKeywordAndUnknown.js -@@= skipped -53, +53 lines =@@ - - - //// [inKeywordAndUnknown.js] --"use strict"; - // Repro from #50531 - function f(x, y) { - if (!("a" in x)) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js b/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js index c65b5afbc3..06e52eb617 100644 --- a/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js +++ b/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js @@ -387,6 +387,7 @@ function test3>(obj: T) { //// [inKeywordTypeguard.js] +"use strict"; class A { a; } diff --git a/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js.diff b/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js.diff index a611918991..3be5bf99d0 100644 --- a/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js.diff +++ b/testdata/baselines/reference/submodule/compiler/inKeywordTypeguard(strict=true).js.diff @@ -1,10 +1,8 @@ --- old.inKeywordTypeguard(strict=true).js +++ new.inKeywordTypeguard(strict=true).js -@@= skipped -386, +386 lines =@@ - - +@@= skipped -388, +388 lines =@@ //// [inKeywordTypeguard.js] --"use strict"; + "use strict"; class A { + a; } @@ -13,7 +11,7 @@ } function negativeClassesTest(x) { if ("a" in x) { -@@= skipped -22, +23 lines =@@ +@@= skipped -20, +22 lines =@@ } } class AWithOptionalProp { diff --git a/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js b/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js index 86e879bbd1..35fab02487 100644 --- a/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js +++ b/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js @@ -17,6 +17,7 @@ else { //// [incrementOnNullAssertion.js] +"use strict"; const x = 'bar'; let foo = {}; if (foo[x] === undefined) { diff --git a/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js.diff b/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js.diff deleted file mode 100644 index 8966d0349f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/incrementOnNullAssertion.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.incrementOnNullAssertion.js -+++ new.incrementOnNullAssertion.js -@@= skipped -16, +16 lines =@@ - - - //// [incrementOnNullAssertion.js] --"use strict"; - const x = 'bar'; - let foo = {}; - if (foo[x] === undefined) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/incrementalOut.errors.txt b/testdata/baselines/reference/submodule/compiler/incrementalOut.errors.txt deleted file mode 100644 index 387178c402..0000000000 --- a/testdata/baselines/reference/submodule/compiler/incrementalOut.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== incrementalOut.ts (0 errors) ==== - const x = 10; - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/incrementalOut.symbols b/testdata/baselines/reference/submodule/compiler/incrementalOut.symbols deleted file mode 100644 index 6a32ed5bdd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/incrementalOut.symbols +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/incrementalOut.ts] //// - -=== incrementalOut.ts === -const x = 10; ->x : Symbol(x, Decl(incrementalOut.ts, 0, 5)) - - diff --git a/testdata/baselines/reference/submodule/compiler/incrementalOut.types b/testdata/baselines/reference/submodule/compiler/incrementalOut.types deleted file mode 100644 index f1bfa2c6ad..0000000000 --- a/testdata/baselines/reference/submodule/compiler/incrementalOut.types +++ /dev/null @@ -1,8 +0,0 @@ -//// [tests/cases/compiler/incrementalOut.ts] //// - -=== incrementalOut.ts === -const x = 10; ->x : 10 ->10 : 10 - - diff --git a/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js b/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js index aa6873ef82..f09800ae2f 100644 --- a/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js +++ b/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js @@ -36,6 +36,7 @@ interface IEntity extends IBaseEntity { //// [indexSignatureAndMappedType.js] +"use strict"; // A mapped type { [P in K]: X }, where K is a generic type, is related to // { [key: string]: Y } if X is related to Y. function f1(x, y) { diff --git a/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js.diff b/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js.diff deleted file mode 100644 index f7a4e38889..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexSignatureAndMappedType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.indexSignatureAndMappedType.js -+++ new.indexSignatureAndMappedType.js -@@= skipped -35, +35 lines =@@ - - - //// [indexSignatureAndMappedType.js] --"use strict"; - // A mapped type { [P in K]: X }, where K is a generic type, is related to - // { [key: string]: Y } if X is related to Y. - function f1(x, y) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js b/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js index 4edee77031..73409f466e 100644 --- a/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js +++ b/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js @@ -9,5 +9,6 @@ type Test = keyof typeof Foo; //// [indexTypeNoSubstitutionTemplateLiteral.js] +"use strict"; function Foo() { } Foo[`b`] = function () { }; diff --git a/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js.diff b/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js.diff deleted file mode 100644 index d2902f02fc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexTypeNoSubstitutionTemplateLiteral.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.indexTypeNoSubstitutionTemplateLiteral.js -+++ new.indexTypeNoSubstitutionTemplateLiteral.js -@@= skipped -8, +8 lines =@@ - - - //// [indexTypeNoSubstitutionTemplateLiteral.js] --"use strict"; - function Foo() { } - Foo[`b`] = function () { }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js index 51b4c2f889..d4df89963f 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js @@ -24,6 +24,8 @@ function f2(mymap: MyMap, k: keyof M, z: { x: number }) { //// [indexedAccessNormalization.js] +"use strict"; +// Repro from from #43152 function f1(mymap, k) { const elemofM = mymap[k]; g(elemofM); diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff deleted file mode 100644 index 5595f810a2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.indexedAccessNormalization.js -+++ new.indexedAccessNormalization.js -@@= skipped -23, +23 lines =@@ - - - //// [indexedAccessNormalization.js] --"use strict"; --// Repro from from #43152 - function f1(mymap, k) { - const elemofM = mymap[k]; - g(elemofM); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js b/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js index ccdebbb66a..0a52abf84e 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js @@ -23,8 +23,8 @@ class Comp extends Component> //// [indexedAccessRelation.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // Repro from #14723 +Object.defineProperty(exports, "__esModule", { value: true }); class Component { setState(state) { } } diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js.diff deleted file mode 100644 index 2f676bbe24..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.indexedAccessRelation.js -+++ new.indexedAccessRelation.js -@@= skipped -22, +22 lines =@@ - - //// [indexedAccessRelation.js] - "use strict"; --// Repro from #14723 - Object.defineProperty(exports, "__esModule", { value: true }); -+// Repro from #14723 - class Component { - setState(state) { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js index aa3ef89972..85888552d7 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js @@ -39,6 +39,7 @@ function foo(x: C, y: T['content']) { //// [indexedAccessTypeConstraints.js] "use strict"; +// Repro from #14557 Object.defineProperty(exports, "__esModule", { value: true }); exports.Bar = exports.Foo = void 0; class Parent { diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff index 1fcf56ce47..7812071eaa 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff @@ -1,10 +1,6 @@ --- old.indexedAccessTypeConstraints.js +++ new.indexedAccessTypeConstraints.js -@@= skipped -38, +38 lines =@@ - - //// [indexedAccessTypeConstraints.js] - "use strict"; --// Repro from #14557 +@@= skipped -42, +42 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Bar = exports.Foo = void 0; class Parent { diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js b/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js index fd81039137..446859b746 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js @@ -57,6 +57,7 @@ function grault(id: string) { //// [indexedAccessWithFreshObjectLiteral.js] +"use strict"; function foo(id) { return { a: 1, diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js.diff deleted file mode 100644 index 436ef54919..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessWithFreshObjectLiteral.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.indexedAccessWithFreshObjectLiteral.js -+++ new.indexedAccessWithFreshObjectLiteral.js -@@= skipped -56, +56 lines =@@ - - - //// [indexedAccessWithFreshObjectLiteral.js] --"use strict"; - function foo(id) { - return { - a: 1, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js b/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js index 7b68e7aef0..bcdf099afb 100644 --- a/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js +++ b/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js @@ -121,6 +121,7 @@ type Res3 = Example; // never //// [indexingTypesWithNever.js] +"use strict"; // Should be never const result3 = genericFn1({ c: "ctest", d: "dtest" }); // Should be never diff --git a/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js.diff b/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js.diff deleted file mode 100644 index 0f15a0403c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexingTypesWithNever.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.indexingTypesWithNever.js -+++ new.indexingTypesWithNever.js -@@= skipped -120, +120 lines =@@ - - - //// [indexingTypesWithNever.js] --"use strict"; - // Should be never - const result3 = genericFn1({ c: "ctest", d: "dtest" }); - // Should be never \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js b/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js index 2049f4d25b..4e66f0faa5 100644 --- a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js +++ b/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js @@ -33,6 +33,7 @@ let n: number = f(2).a; //// [indirectTypeParameterReferences.js] +// Repro from #19043 const flowtypes = (b) => { const combined = (fn) => null; const literal = (fn) => null; diff --git a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js.diff b/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js.diff deleted file mode 100644 index aaa080d08a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.indirectTypeParameterReferences.js -+++ new.indirectTypeParameterReferences.js -@@= skipped -32, +32 lines =@@ - - - //// [indirectTypeParameterReferences.js] --// Repro from #19043 - const flowtypes = (b) => { - const combined = (fn) => null; - const literal = (fn) => null; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/inexistentPropertyInsideToStringType.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/inexistentPropertyInsideToStringType.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/inexistentPropertyInsideToStringType.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/inexistentPropertyInsideToStringType.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/inexistentPropertyInsideToStringType.types.diff b/testdata/baselines/reference/submodule/compiler/inexistentPropertyInsideToStringType.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/inexistentPropertyInsideToStringType.types.diff rename to testdata/baselines/reference/submodule/compiler/inexistentPropertyInsideToStringType.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js b/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js index f03eabd0de..0f98e917d4 100644 --- a/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js +++ b/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js @@ -27,5 +27,6 @@ const myPrimitiveTupleNew: [string, number] = extractPrimitivesNew({ primitive: //// [inferRestArgumentsMappedTuple.js] +"use strict"; const myPrimitiveTupleOld = extractPrimitivesOld({ primitive: "" }, { primitive: 0 }); const myPrimitiveTupleNew = extractPrimitivesNew({ primitive: "" }, { primitive: 0 }); diff --git a/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js.diff b/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js.diff deleted file mode 100644 index 4cd9ba6912..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferRestArgumentsMappedTuple.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.inferRestArgumentsMappedTuple.js -+++ new.inferRestArgumentsMappedTuple.js -@@= skipped -26, +26 lines =@@ - - - //// [inferRestArgumentsMappedTuple.js] --"use strict"; - const myPrimitiveTupleOld = extractPrimitivesOld({ primitive: "" }, { primitive: 0 }); - const myPrimitiveTupleNew = extractPrimitivesNew({ primitive: "" }, { primitive: 0 }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js b/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js index 3584a8132a..fd0f6080ea 100644 --- a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js +++ b/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js @@ -12,6 +12,7 @@ b.m("test", function (bug) { }); //// [inferSecondaryParameter.js] +// type inference on 'bug' should give 'any' var b = { m: function (test, fn) { } }; b.m("test", function (bug) { var a = bug; diff --git a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js.diff b/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js.diff deleted file mode 100644 index 01cb15dbb6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferSecondaryParameter.js -+++ new.inferSecondaryParameter.js -@@= skipped -11, +11 lines =@@ - }); - - //// [inferSecondaryParameter.js] --// type inference on 'bug' should give 'any' - var b = { m: function (test, fn) { } }; - b.m("test", function (bug) { - var a = bug; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js index f038359b08..4f0fd4f8f0 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js @@ -41,6 +41,8 @@ m.child; // ok //// [inferTypeParameterConstraints.js] +"use strict"; +// Repro from #42636 // https://github.com/microsoft/TypeScript/issues/57286#issuecomment-1927920336 class BaseClass { fake() { diff --git a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff index 4d4403e0ed..9971f7bc0a 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff @@ -1,15 +1,6 @@ --- old.inferTypeParameterConstraints.js +++ new.inferTypeParameterConstraints.js -@@= skipped -40, +40 lines =@@ - - - //// [inferTypeParameterConstraints.js] --"use strict"; --// Repro from #42636 - // https://github.com/microsoft/TypeScript/issues/57286#issuecomment-1927920336 - class BaseClass { - fake() { -@@= skipped -9, +7 lines =@@ +@@= skipped -49, +49 lines =@@ } } class Klass extends BaseClass { diff --git a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js b/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js index 3ba422ef3f..c630f363f7 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js @@ -33,6 +33,7 @@ const res3 = test({ //// [inferenceAndSelfReferentialConstraint.js] +// @strict function test(arg) { return arg; } diff --git a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js.diff deleted file mode 100644 index 97cadbab15..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceAndSelfReferentialConstraint.js -+++ new.inferenceAndSelfReferentialConstraint.js -@@= skipped -32, +32 lines =@@ - - - //// [inferenceAndSelfReferentialConstraint.js] --// @strict - function test(arg) { - return arg; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js b/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js index 74b31690e6..11fd9c2e13 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js @@ -34,6 +34,7 @@ function flatMapChildren2(node: Node, cb: (child: Node) => readonly T[] | T | //// [inferenceDoesNotAddUndefinedOrNull.js] +"use strict"; function flatMapChildren(node, cb) { const result = []; node.forEachChild(child => { diff --git a/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js.diff deleted file mode 100644 index e1171aedfc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceDoesNotAddUndefinedOrNull.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceDoesNotAddUndefinedOrNull.js -+++ new.inferenceDoesNotAddUndefinedOrNull.js -@@= skipped -33, +33 lines =@@ - - - //// [inferenceDoesNotAddUndefinedOrNull.js] --"use strict"; - function flatMapChildren(node, cb) { - const result = []; - node.forEachChild(child => { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js index 7349cb195d..2ee9e3421c 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js @@ -56,6 +56,8 @@ type T2 = GetT1; // number //// [inferenceErasedSignatures.js] +"use strict"; +// Repro from #37163 class SomeAbstractClass extends SomeBaseClass { foo; bar; diff --git a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff index fad7f0a963..71ac68b6fa 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff @@ -1,11 +1,9 @@ --- old.inferenceErasedSignatures.js +++ new.inferenceErasedSignatures.js -@@= skipped -55, +55 lines =@@ - - +@@= skipped -57, +57 lines =@@ //// [inferenceErasedSignatures.js] --"use strict"; --// Repro from #37163 + "use strict"; + // Repro from #37163 -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { diff --git a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js index a5fd40279b..5991fdec6d 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js @@ -15,4 +15,6 @@ Component({items: [{name:' string'}], itemKey: 'name' }); //// [inferenceFromIncompleteSource.js] +"use strict"; +// Repro from #42030 Component({ items: [{ name: ' string' }], itemKey: 'name' }); diff --git a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff deleted file mode 100644 index 165491bb7d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.inferenceFromIncompleteSource.js -+++ new.inferenceFromIncompleteSource.js -@@= skipped -14, +14 lines =@@ - - - //// [inferenceFromIncompleteSource.js] --"use strict"; --// Repro from #42030 - Component({ items: [{ name: ' string' }], itemKey: 'name' }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js b/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js index c9e45620a4..98babac9f5 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js @@ -36,6 +36,7 @@ equal(v as string & { tag: 'foo' } | undefined, v as string); //// [inferenceOfNullableObjectTypesWithCommonBase.js] +"use strict"; function equal(a, b) { } let v = null; equal(v, v); diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js.diff deleted file mode 100644 index 3cc48e4afe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceOfNullableObjectTypesWithCommonBase.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceOfNullableObjectTypesWithCommonBase.js -+++ new.inferenceOfNullableObjectTypesWithCommonBase.js -@@= skipped -35, +35 lines =@@ - - - //// [inferenceOfNullableObjectTypesWithCommonBase.js] --"use strict"; - function equal(a, b) { } - let v = null; - equal(v, v); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js b/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js index f890e3de6a..3f283402a0 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js @@ -29,6 +29,7 @@ var v6: { a: string, b: string | undefined }; //// [inferenceOptionalProperties.js] +"use strict"; const y1 = test(x1); const y2 = test(x2); var v1; diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js.diff deleted file mode 100644 index f6f5b4c989..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceOptionalProperties.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceOptionalProperties.js -+++ new.inferenceOptionalProperties.js -@@= skipped -28, +28 lines =@@ - - - //// [inferenceOptionalProperties.js] --"use strict"; - const y1 = test(x1); - const y2 = test(x2); - var v1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js b/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js index 9415bed6b4..8932a279a8 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js @@ -29,6 +29,7 @@ var v6: { a: string, b: string | undefined }; //// [inferenceOptionalPropertiesStrict.js] +"use strict"; const y1 = test(x1); const y2 = test(x2); var v1; diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js.diff deleted file mode 100644 index fb8998eacf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesStrict.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceOptionalPropertiesStrict.js -+++ new.inferenceOptionalPropertiesStrict.js -@@= skipped -28, +28 lines =@@ - - - //// [inferenceOptionalPropertiesStrict.js] --"use strict"; - const y1 = test(x1); - const y2 = test(x2); - var v1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js b/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js index b202273a6a..0ee331c144 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js @@ -28,6 +28,7 @@ const query = Object.entries(obj).map( //// [inferenceOptionalPropertiesToIndexSignatures.js] +"use strict"; let a1 = foo(x1); // string | number let a2 = foo(x2); // string | number | undefined let a3 = foo(x3); // string | number diff --git a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js.diff deleted file mode 100644 index 9403921579..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceOptionalPropertiesToIndexSignatures.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceOptionalPropertiesToIndexSignatures.js -+++ new.inferenceOptionalPropertiesToIndexSignatures.js -@@= skipped -27, +27 lines =@@ - - - //// [inferenceOptionalPropertiesToIndexSignatures.js] --"use strict"; - let a1 = foo(x1); // string | number - let a2 = foo(x2); // string | number | undefined - let a3 = foo(x3); // string | number \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js b/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js index 24b83f9ba4..309c9c3049 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js @@ -21,6 +21,7 @@ zz.push(logLength(42)); // no error; T is inferred as `any` zz = logFirstLength([42]); // no error; T is inferred as `any[]` //// [inferenceShouldFailOnEvolvingArrays.js] +"use strict"; // repro from https://github.com/Microsoft/TypeScript/issues/25675 // The type of `arg` blocks inference but simplifies to T. function logLength(arg) { diff --git a/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js.diff deleted file mode 100644 index f5f285ddd1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceShouldFailOnEvolvingArrays.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceShouldFailOnEvolvingArrays.js -+++ new.inferenceShouldFailOnEvolvingArrays.js -@@= skipped -20, +20 lines =@@ - zz = logFirstLength([42]); // no error; T is inferred as `any[]` - - //// [inferenceShouldFailOnEvolvingArrays.js] --"use strict"; - // repro from https://github.com/Microsoft/TypeScript/issues/25675 - // The type of `arg` blocks inference but simplifies to T. - function logLength(arg) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js b/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js index a9ddfdee55..f3dc967cd1 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js @@ -19,6 +19,7 @@ const test: RowRenderer = { //// [inferenceUnionOfObjectsMappedContextualType.js] +"use strict"; const test = { key: 'someDate', caption: 'My Date', diff --git a/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js.diff deleted file mode 100644 index 5e6da2c637..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceUnionOfObjectsMappedContextualType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceUnionOfObjectsMappedContextualType.js -+++ new.inferenceUnionOfObjectsMappedContextualType.js -@@= skipped -18, +18 lines =@@ - - - //// [inferenceUnionOfObjectsMappedContextualType.js] --"use strict"; - const test = { - key: 'someDate', - caption: 'My Date', \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js b/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js index 91d9830d45..8e99cd0ce8 100644 --- a/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js +++ b/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js @@ -21,8 +21,41 @@ exports.x = 3; exports.y = 5; //// [bar.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const foo = require("./foo"); +const foo = __importStar(require("./foo")); function f(map) { // ... } diff --git a/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js.diff b/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js.diff deleted file mode 100644 index 9e0dd6d45f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferredIndexerOnNamespaceImport.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.inferredIndexerOnNamespaceImport.js -+++ new.inferredIndexerOnNamespaceImport.js -@@= skipped -21, +21 lines =@@ - //// [bar.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var foo = require("./foo"); -+const foo = require("./foo"); - function f(map) { - // ... - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js b/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js index 791ffb843a..e3dff9c7a2 100644 --- a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js @@ -53,6 +53,7 @@ type Conv = //// [infiniteConstraints.js] "use strict"; +// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint Object.defineProperty(exports, "__esModule", { value: true }); const out = myBug({ obj1: { a: "test" } }); const noError = ensureNoDuplicates({ main: value("test"), alternate: value("test2") }); diff --git a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js.diff deleted file mode 100644 index bccf326f67..0000000000 --- a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.infiniteConstraints.js -+++ new.infiniteConstraints.js -@@= skipped -52, +52 lines =@@ - - //// [infiniteConstraints.js] - "use strict"; --// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint - Object.defineProperty(exports, "__esModule", { value: true }); - const out = myBug({ obj1: { a: "test" } }); - const noError = ensureNoDuplicates({ main: value("test"), alternate: value("test2") }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js b/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js index d1ffb0cc77..1d9c86ac69 100644 --- a/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js +++ b/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js @@ -36,6 +36,7 @@ class Bar { //// [initializerWithThisPropertyAccess.js] +"use strict"; class A { a; b = this.a; // Error diff --git a/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js.diff b/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js.diff index 8148ce045f..a3cb0f2fdb 100644 --- a/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js.diff +++ b/testdata/baselines/reference/submodule/compiler/initializerWithThisPropertyAccess.js.diff @@ -1,10 +1,8 @@ --- old.initializerWithThisPropertyAccess.js +++ new.initializerWithThisPropertyAccess.js -@@= skipped -35, +35 lines =@@ - - +@@= skipped -37, +37 lines =@@ //// [initializerWithThisPropertyAccess.js] --"use strict"; + "use strict"; class A { + a; + b = this.a; // Error @@ -48,7 +46,7 @@ } -@@= skipped -51, +46 lines =@@ +@@= skipped -49, +45 lines =@@ } declare class Foo { private bar; diff --git a/testdata/baselines/reference/submodule/compiler/inlineMappedTypeModifierDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/inlineMappedTypeModifierDeclarationEmit.js.diff deleted file mode 100644 index 8a81efd1b8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineMappedTypeModifierDeclarationEmit.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.inlineMappedTypeModifierDeclarationEmit.js -+++ new.inlineMappedTypeModifierDeclarationEmit.js -@@= skipped -50, +50 lines =@@ - exports.processedInternally2 = exports.processedInternally1 = void 0; - exports.wrappedTest1 = wrappedTest1; - exports.wrappedTest2 = wrappedTest2; --var other_1 = require("./other"); -+const other_1 = require("./other"); - function wrappedTest1(obj, k) { - return (0, other_1.test1)(obj, k); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.errors.txt b/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.errors.txt deleted file mode 100644 index 6578302a29..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. -error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. -!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== inlineSourceMap2.ts (0 errors) ==== - // configuration errors - - var x = 0; - console.log(x); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.symbols b/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.symbols deleted file mode 100644 index 8cd650b50c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.symbols +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/inlineSourceMap2.ts] //// - -=== inlineSourceMap2.ts === -// configuration errors - -var x = 0; ->x : Symbol(x, Decl(inlineSourceMap2.ts, 2, 3)) - -console.log(x); ->console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->console : Symbol(console, Decl(lib.dom.d.ts, --, --)) ->log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->x : Symbol(x, Decl(inlineSourceMap2.ts, 2, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.types b/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.types deleted file mode 100644 index 7dee271a14..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSourceMap2.types +++ /dev/null @@ -1,16 +0,0 @@ -//// [tests/cases/compiler/inlineSourceMap2.ts] //// - -=== inlineSourceMap2.ts === -// configuration errors - -var x = 0; ->x : number ->0 : 0 - -console.log(x); ->console.log(x) : void ->console.log : (...data: any[]) => void ->console : Console ->log : (...data: any[]) => void ->x : number - diff --git a/testdata/baselines/reference/submodule/compiler/inlineSources.errors.txt b/testdata/baselines/reference/submodule/compiler/inlineSources.errors.txt deleted file mode 100644 index aa0cba9278..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSources.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - var a = 0; - console.log(a); - -==== b.ts (0 errors) ==== - var b = 0; - console.log(b); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inlineSources.symbols b/testdata/baselines/reference/submodule/compiler/inlineSources.symbols deleted file mode 100644 index 5a31c811cc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSources.symbols +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/inlineSources.ts] //// - -=== a.ts === -var a = 0; ->a : Symbol(a, Decl(a.ts, 0, 3)) - -console.log(a); ->console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->console : Symbol(console, Decl(lib.dom.d.ts, --, --)) ->log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->a : Symbol(a, Decl(a.ts, 0, 3)) - -=== b.ts === -var b = 0; ->b : Symbol(b, Decl(b.ts, 0, 3)) - -console.log(b); ->console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->console : Symbol(console, Decl(lib.dom.d.ts, --, --)) ->log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->b : Symbol(b, Decl(b.ts, 0, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/inlineSources.types b/testdata/baselines/reference/submodule/compiler/inlineSources.types deleted file mode 100644 index d6ff6f2c02..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSources.types +++ /dev/null @@ -1,26 +0,0 @@ -//// [tests/cases/compiler/inlineSources.ts] //// - -=== a.ts === -var a = 0; ->a : number ->0 : 0 - -console.log(a); ->console.log(a) : void ->console.log : (...data: any[]) => void ->console : Console ->log : (...data: any[]) => void ->a : number - -=== b.ts === -var b = 0; ->b : number ->0 : 0 - -console.log(b); ->console.log(b) : void ->console.log : (...data: any[]) => void ->console : Console ->log : (...data: any[]) => void ->b : number - diff --git a/testdata/baselines/reference/submodule/compiler/inlineSources2.errors.txt b/testdata/baselines/reference/submodule/compiler/inlineSources2.errors.txt deleted file mode 100644 index aa0cba9278..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSources2.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - var a = 0; - console.log(a); - -==== b.ts (0 errors) ==== - var b = 0; - console.log(b); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inlineSources2.symbols b/testdata/baselines/reference/submodule/compiler/inlineSources2.symbols deleted file mode 100644 index 9519a2aa4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSources2.symbols +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/inlineSources2.ts] //// - -=== a.ts === -var a = 0; ->a : Symbol(a, Decl(a.ts, 0, 3)) - -console.log(a); ->console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->console : Symbol(console, Decl(lib.dom.d.ts, --, --)) ->log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->a : Symbol(a, Decl(a.ts, 0, 3)) - -=== b.ts === -var b = 0; ->b : Symbol(b, Decl(b.ts, 0, 3)) - -console.log(b); ->console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->console : Symbol(console, Decl(lib.dom.d.ts, --, --)) ->log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->b : Symbol(b, Decl(b.ts, 0, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/inlineSources2.types b/testdata/baselines/reference/submodule/compiler/inlineSources2.types deleted file mode 100644 index 19444ec813..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inlineSources2.types +++ /dev/null @@ -1,26 +0,0 @@ -//// [tests/cases/compiler/inlineSources2.ts] //// - -=== a.ts === -var a = 0; ->a : number ->0 : 0 - -console.log(a); ->console.log(a) : void ->console.log : (...data: any[]) => void ->console : Console ->log : (...data: any[]) => void ->a : number - -=== b.ts === -var b = 0; ->b : number ->0 : 0 - -console.log(b); ->console.log(b) : void ->console.log : (...data: any[]) => void ->console : Console ->log : (...data: any[]) => void ->b : number - diff --git a/testdata/baselines/reference/submodule/compiler/instanceAndStaticDeclarations1.js.diff b/testdata/baselines/reference/submodule/compiler/instanceAndStaticDeclarations1.js.diff index 4419386572..8dbbbb87a9 100644 --- a/testdata/baselines/reference/submodule/compiler/instanceAndStaticDeclarations1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/instanceAndStaticDeclarations1.js.diff @@ -1,37 +1,19 @@ --- old.instanceAndStaticDeclarations1.js +++ new.instanceAndStaticDeclarations1.js -@@= skipped -15, +15 lines =@@ - +@@= skipped -16, +16 lines =@@ //// [instanceAndStaticDeclarations1.js] // from spec --let Point = (() => { -- class Point { -- constructor(x, y) { -- this.x = x; -- this.y = y; -- } -- distance(p) { -- var dx = this.x - p.x; -- var dy = this.y - p.y; -- return Math.sqrt(dx * dx + dy * dy); -- } -- static distance(p1, p2) { return p1.distance(p2); } -- } -- Point.origin = new Point(0, 0); -- return Point; --})(); -+class Point { + class Point { + x; + y; -+ constructor(x, y) { -+ this.x = x; -+ this.y = y; -+ } -+ distance(p) { -+ var dx = this.x - p.x; -+ var dy = this.y - p.y; -+ return Math.sqrt(dx * dx + dy * dy); -+ } + constructor(x, y) { + this.x = x; + this.y = y; +@@= skipped -9, +11 lines =@@ + var dy = this.y - p.y; + return Math.sqrt(dx * dx + dy * dy); + } + static origin = new Point(0, 0); -+ static distance(p1, p2) { return p1.distance(p2); } -+} \ No newline at end of file + static distance(p1, p2) { return p1.distance(p2); } + } +-Point.origin = new Point(0, 0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js index 86091a4dc7..a2d3a00181 100644 --- a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js +++ b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js @@ -187,6 +187,7 @@ assignPartial(obj, { foo(...args) {} }); // args has type [string] //// [instantiateContextualTypes.js] +// #6611 function fn(values, value) { } fn(handlers, value => alert(value)); diff --git a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff index b1446de5ba..845ea67434 100644 --- a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff @@ -1,14 +1,6 @@ --- old.instantiateContextualTypes.js +++ new.instantiateContextualTypes.js -@@= skipped -186, +186 lines =@@ - - - //// [instantiateContextualTypes.js] --// #6611 - function fn(values, value) { - } - fn(handlers, value => alert(value)); -@@= skipped -22, +21 lines =@@ +@@= skipped -208, +208 lines =@@ })(N1 || (N1 = {})); passContentsToFunc(outerBoxOfString, box => box.value); class Interesting { diff --git a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js b/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js index a282da3696..32452f4acf 100644 --- a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js +++ b/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js @@ -18,6 +18,7 @@ const x1 = f1(); // Z const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> //// [instantiatedTypeAliasDisplay.js] +// Repros from #12066 const x1 = f1(); // Z const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> diff --git a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js.diff b/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js.diff deleted file mode 100644 index d53a7d7398..0000000000 --- a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.instantiatedTypeAliasDisplay.js -+++ new.instantiatedTypeAliasDisplay.js -@@= skipped -17, +17 lines =@@ - const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> - - //// [instantiatedTypeAliasDisplay.js] --// Repros from #12066 - const x1 = f1(); // Z - const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> diff --git a/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.errors.txt b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.errors.txt new file mode 100644 index 0000000000..2c1cad0c9c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.errors.txt @@ -0,0 +1,75 @@ +interfaceDeclaration3.ts(7,16): error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'. + Type 'number' is not assignable to type 'string'. +interfaceDeclaration3.ts(32,16): error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'. + Type 'number' is not assignable to type 'string'. +interfaceDeclaration3.ts(54,11): error TS2430: Interface 'I2' incorrectly extends interface 'I1'. + Types of property 'item' are incompatible. + Type 'string' is not assignable to type 'number'. + + +==== interfaceDeclaration3.ts (3 errors) ==== + interface I1 { item:number; } + + module M1 { + interface I1 { item:string; } + interface I2 { item:number; } + class C1 implements I1 { + public item:number; + ~~~~ +!!! error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. + } + class C2 implements I1 { + public item:string; + } + class C3 implements I2 { + public item:number; + } + + class C4 implements M2.I1 { + public item:string; + } + + class C5 implements M2.M3.I1 { + public item:string; + } + } + + export module M2 { + export interface I1 { item:string; } + export interface I2 { item:string; } + export module M3 { + export interface I1 { item:string; } + } + class C1 implements I1 { + public item:number; + ~~~~ +!!! error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'I1'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. + } + class C2 implements I1 { + public item:string; + } + class C3 implements I2 { + public item:string; + } + } + + class C1 implements I1 { + public item:number; + } + + class C2 implements M2.I1 { + public item:string; + } + + class C3 implements M2.M3.I1 { + public item:string; + } + + interface I2 extends I1 { item:string; } + ~~ +!!! error TS2430: Interface 'I2' incorrectly extends interface 'I1'. +!!! error TS2430: Types of property 'item' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.js b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.js new file mode 100644 index 0000000000..bbc73c51f6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.js @@ -0,0 +1,102 @@ +//// [tests/cases/compiler/interfaceDeclaration3.ts] //// + +//// [interfaceDeclaration3.ts] +interface I1 { item:number; } + +module M1 { + interface I1 { item:string; } + interface I2 { item:number; } + class C1 implements I1 { + public item:number; + } + class C2 implements I1 { + public item:string; + } + class C3 implements I2 { + public item:number; + } + + class C4 implements M2.I1 { + public item:string; + } + + class C5 implements M2.M3.I1 { + public item:string; + } +} + +export module M2 { + export interface I1 { item:string; } + export interface I2 { item:string; } + export module M3 { + export interface I1 { item:string; } + } + class C1 implements I1 { + public item:number; + } + class C2 implements I1 { + public item:string; + } + class C3 implements I2 { + public item:string; + } +} + +class C1 implements I1 { + public item:number; +} + +class C2 implements M2.I1 { + public item:string; +} + +class C3 implements M2.M3.I1 { + public item:string; +} + +interface I2 extends I1 { item:string; } + + +//// [interfaceDeclaration3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.M2 = void 0; +var M1; +(function (M1) { + class C1 { + item; + } + class C2 { + item; + } + class C3 { + item; + } + class C4 { + item; + } + class C5 { + item; + } +})(M1 || (M1 = {})); +var M2; +(function (M2) { + class C1 { + item; + } + class C2 { + item; + } + class C3 { + item; + } +})(M2 || (exports.M2 = M2 = {})); +class C1 { + item; +} +class C2 { + item; +} +class C3 { + item; +} diff --git a/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.js.diff b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.js.diff new file mode 100644 index 0000000000..45af37db82 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.js.diff @@ -0,0 +1,42 @@ +--- old.interfaceDeclaration3.js ++++ new.interfaceDeclaration3.js +@@= skipped -63, +63 lines =@@ + var M1; + (function (M1) { + class C1 { ++ item; + } + class C2 { ++ item; + } + class C3 { ++ item; + } + class C4 { ++ item; + } + class C5 { ++ item; + } + })(M1 || (M1 = {})); + var M2; + (function (M2) { + class C1 { ++ item; + } + class C2 { ++ item; + } + class C3 { ++ item; + } + })(M2 || (exports.M2 = M2 = {})); + class C1 { ++ item; + } + class C2 { ++ item; + } + class C3 { ++ item; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.symbols b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.symbols new file mode 100644 index 0000000000..35e3dd71ea --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.symbols @@ -0,0 +1,139 @@ +//// [tests/cases/compiler/interfaceDeclaration3.ts] //// + +=== interfaceDeclaration3.ts === +interface I1 { item:number; } +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 0, 0)) +>item : Symbol(I1.item, Decl(interfaceDeclaration3.ts, 0, 14)) + +module M1 { +>M1 : Symbol(M1, Decl(interfaceDeclaration3.ts, 0, 29)) + + interface I1 { item:string; } +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 2, 11)) +>item : Symbol(I1.item, Decl(interfaceDeclaration3.ts, 3, 18)) + + interface I2 { item:number; } +>I2 : Symbol(I2, Decl(interfaceDeclaration3.ts, 3, 33)) +>item : Symbol(I2.item, Decl(interfaceDeclaration3.ts, 4, 18)) + + class C1 implements I1 { +>C1 : Symbol(C1, Decl(interfaceDeclaration3.ts, 4, 33)) +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 2, 11)) + + public item:number; +>item : Symbol(C1.item, Decl(interfaceDeclaration3.ts, 5, 28)) + } + class C2 implements I1 { +>C2 : Symbol(C2, Decl(interfaceDeclaration3.ts, 7, 5)) +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 2, 11)) + + public item:string; +>item : Symbol(C2.item, Decl(interfaceDeclaration3.ts, 8, 28)) + } + class C3 implements I2 { +>C3 : Symbol(C3, Decl(interfaceDeclaration3.ts, 10, 5)) +>I2 : Symbol(I2, Decl(interfaceDeclaration3.ts, 3, 33)) + + public item:number; +>item : Symbol(C3.item, Decl(interfaceDeclaration3.ts, 11, 28)) + } + + class C4 implements M2.I1 { +>C4 : Symbol(C4, Decl(interfaceDeclaration3.ts, 13, 5)) +>M2.I1 : Symbol(M2.I1, Decl(interfaceDeclaration3.ts, 24, 18)) +>M2 : Symbol(M2, Decl(interfaceDeclaration3.ts, 22, 1)) +>I1 : Symbol(M2.I1, Decl(interfaceDeclaration3.ts, 24, 18)) + + public item:string; +>item : Symbol(C4.item, Decl(interfaceDeclaration3.ts, 15, 31)) + } + + class C5 implements M2.M3.I1 { +>C5 : Symbol(C5, Decl(interfaceDeclaration3.ts, 17, 5)) +>M2.M3.I1 : Symbol(M2.M3.I1, Decl(interfaceDeclaration3.ts, 27, 22)) +>M2.M3 : Symbol(M2.M3, Decl(interfaceDeclaration3.ts, 26, 40)) +>M2 : Symbol(M2, Decl(interfaceDeclaration3.ts, 22, 1)) +>M3 : Symbol(M2.M3, Decl(interfaceDeclaration3.ts, 26, 40)) +>I1 : Symbol(M2.M3.I1, Decl(interfaceDeclaration3.ts, 27, 22)) + + public item:string; +>item : Symbol(C5.item, Decl(interfaceDeclaration3.ts, 19, 34)) + } +} + +export module M2 { +>M2 : Symbol(M2, Decl(interfaceDeclaration3.ts, 22, 1)) + + export interface I1 { item:string; } +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 24, 18)) +>item : Symbol(I1.item, Decl(interfaceDeclaration3.ts, 25, 25)) + + export interface I2 { item:string; } +>I2 : Symbol(I2, Decl(interfaceDeclaration3.ts, 25, 40)) +>item : Symbol(I2.item, Decl(interfaceDeclaration3.ts, 26, 25)) + + export module M3 { +>M3 : Symbol(M3, Decl(interfaceDeclaration3.ts, 26, 40)) + + export interface I1 { item:string; } +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 27, 22)) +>item : Symbol(I1.item, Decl(interfaceDeclaration3.ts, 28, 29)) + } + class C1 implements I1 { +>C1 : Symbol(C1, Decl(interfaceDeclaration3.ts, 29, 5)) +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 24, 18)) + + public item:number; +>item : Symbol(C1.item, Decl(interfaceDeclaration3.ts, 30, 28)) + } + class C2 implements I1 { +>C2 : Symbol(C2, Decl(interfaceDeclaration3.ts, 32, 5)) +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 24, 18)) + + public item:string; +>item : Symbol(C2.item, Decl(interfaceDeclaration3.ts, 33, 28)) + } + class C3 implements I2 { +>C3 : Symbol(C3, Decl(interfaceDeclaration3.ts, 35, 5)) +>I2 : Symbol(I2, Decl(interfaceDeclaration3.ts, 25, 40)) + + public item:string; +>item : Symbol(C3.item, Decl(interfaceDeclaration3.ts, 36, 28)) + } +} + +class C1 implements I1 { +>C1 : Symbol(C1, Decl(interfaceDeclaration3.ts, 39, 1)) +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 0, 0)) + + public item:number; +>item : Symbol(C1.item, Decl(interfaceDeclaration3.ts, 41, 24)) +} + +class C2 implements M2.I1 { +>C2 : Symbol(C2, Decl(interfaceDeclaration3.ts, 43, 1)) +>M2.I1 : Symbol(M2.I1, Decl(interfaceDeclaration3.ts, 24, 18)) +>M2 : Symbol(M2, Decl(interfaceDeclaration3.ts, 22, 1)) +>I1 : Symbol(M2.I1, Decl(interfaceDeclaration3.ts, 24, 18)) + + public item:string; +>item : Symbol(C2.item, Decl(interfaceDeclaration3.ts, 45, 27)) +} + +class C3 implements M2.M3.I1 { +>C3 : Symbol(C3, Decl(interfaceDeclaration3.ts, 47, 1)) +>M2.M3.I1 : Symbol(M2.M3.I1, Decl(interfaceDeclaration3.ts, 27, 22)) +>M2.M3 : Symbol(M2.M3, Decl(interfaceDeclaration3.ts, 26, 40)) +>M2 : Symbol(M2, Decl(interfaceDeclaration3.ts, 22, 1)) +>M3 : Symbol(M2.M3, Decl(interfaceDeclaration3.ts, 26, 40)) +>I1 : Symbol(M2.M3.I1, Decl(interfaceDeclaration3.ts, 27, 22)) + + public item:string; +>item : Symbol(C3.item, Decl(interfaceDeclaration3.ts, 49, 30)) +} + +interface I2 extends I1 { item:string; } +>I2 : Symbol(I2, Decl(interfaceDeclaration3.ts, 51, 1)) +>I1 : Symbol(I1, Decl(interfaceDeclaration3.ts, 0, 0)) +>item : Symbol(I2.item, Decl(interfaceDeclaration3.ts, 53, 25)) + diff --git a/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.types b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.types new file mode 100644 index 0000000000..4fffc4d967 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceDeclaration3.types @@ -0,0 +1,114 @@ +//// [tests/cases/compiler/interfaceDeclaration3.ts] //// + +=== interfaceDeclaration3.ts === +interface I1 { item:number; } +>item : number + +module M1 { +>M1 : typeof M1 + + interface I1 { item:string; } +>item : string + + interface I2 { item:number; } +>item : number + + class C1 implements I1 { +>C1 : C1 + + public item:number; +>item : number + } + class C2 implements I1 { +>C2 : C2 + + public item:string; +>item : string + } + class C3 implements I2 { +>C3 : C3 + + public item:number; +>item : number + } + + class C4 implements M2.I1 { +>C4 : C4 +>M2 : typeof M2 + + public item:string; +>item : string + } + + class C5 implements M2.M3.I1 { +>C5 : C5 +>M2.M3 : any +>M2 : typeof M2 +>M3 : any + + public item:string; +>item : string + } +} + +export module M2 { +>M2 : typeof M2 + + export interface I1 { item:string; } +>item : string + + export interface I2 { item:string; } +>item : string + + export module M3 { + export interface I1 { item:string; } +>item : string + } + class C1 implements I1 { +>C1 : C1 + + public item:number; +>item : number + } + class C2 implements I1 { +>C2 : C2 + + public item:string; +>item : string + } + class C3 implements I2 { +>C3 : C3 + + public item:string; +>item : string + } +} + +class C1 implements I1 { +>C1 : C1 + + public item:number; +>item : number +} + +class C2 implements M2.I1 { +>C2 : C2 +>M2 : typeof M2 + + public item:string; +>item : string +} + +class C3 implements M2.M3.I1 { +>C3 : C3 +>M2.M3 : any +>M2 : typeof M2 +>M3 : any + + public item:string; +>item : string +} + +interface I2 extends I1 { item:string; } +>item : string + diff --git a/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.errors.txt b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.errors.txt new file mode 100644 index 0000000000..ce5a76fbbe --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.errors.txt @@ -0,0 +1,38 @@ +interfaceImplementation6.ts(9,7): error TS2420: Class 'C2' incorrectly implements interface 'I1'. + Property 'item' is private in type 'C2' but not in type 'I1'. +interfaceImplementation6.ts(13,7): error TS2420: Class 'C3' incorrectly implements interface 'I1'. + Property 'item' is missing in type 'C3' but required in type 'I1'. + + +==== interfaceImplementation6.ts (2 errors) ==== + interface I1 { + item:number; + } + + class C1 implements I1 { + public item:number; + } + + class C2 implements I1 { + ~~ +!!! error TS2420: Class 'C2' incorrectly implements interface 'I1'. +!!! error TS2420: Property 'item' is private in type 'C2' but not in type 'I1'. + private item:number; + } + + class C3 implements I1 { + ~~ +!!! error TS2420: Class 'C3' incorrectly implements interface 'I1'. +!!! error TS2420: Property 'item' is missing in type 'C3' but required in type 'I1'. +!!! related TS2728 interfaceImplementation6.ts:2:5: 'item' is declared here. + constructor() { + var item: number; + } + } + + export class Test { + private pt: I1 = { item: 1 }; + } + + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.js b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.js new file mode 100644 index 0000000000..46c62d1756 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/interfaceImplementation6.ts] //// + +//// [interfaceImplementation6.ts] +interface I1 { + item:number; +} + +class C1 implements I1 { + public item:number; +} + +class C2 implements I1 { + private item:number; +} + +class C3 implements I1 { + constructor() { + var item: number; + } +} + +export class Test { + private pt: I1 = { item: 1 }; +} + + + + +//// [interfaceImplementation6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Test = void 0; +class C1 { + item; +} +class C2 { + item; +} +class C3 { + constructor() { + var item; + } +} +class Test { + pt = { item: 1 }; +} +exports.Test = Test; diff --git a/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.js.diff b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.js.diff new file mode 100644 index 0000000000..1a9caca8bc --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.js.diff @@ -0,0 +1,23 @@ +--- old.interfaceImplementation6.js ++++ new.interfaceImplementation6.js +@@= skipped -30, +30 lines =@@ + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Test = void 0; + class C1 { ++ item; + } + class C2 { ++ item; + } + class C3 { + constructor() { +@@= skipped -9, +11 lines =@@ + } + } + class Test { +- constructor() { +- this.pt = { item: 1 }; +- } ++ pt = { item: 1 }; + } + exports.Test = Test; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.symbols b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.symbols new file mode 100644 index 0000000000..fa42f15472 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.symbols @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/interfaceImplementation6.ts] //// + +=== interfaceImplementation6.ts === +interface I1 { +>I1 : Symbol(I1, Decl(interfaceImplementation6.ts, 0, 0)) + + item:number; +>item : Symbol(I1.item, Decl(interfaceImplementation6.ts, 0, 14)) +} + +class C1 implements I1 { +>C1 : Symbol(C1, Decl(interfaceImplementation6.ts, 2, 1)) +>I1 : Symbol(I1, Decl(interfaceImplementation6.ts, 0, 0)) + + public item:number; +>item : Symbol(C1.item, Decl(interfaceImplementation6.ts, 4, 24)) +} + +class C2 implements I1 { +>C2 : Symbol(C2, Decl(interfaceImplementation6.ts, 6, 1)) +>I1 : Symbol(I1, Decl(interfaceImplementation6.ts, 0, 0)) + + private item:number; +>item : Symbol(C2.item, Decl(interfaceImplementation6.ts, 8, 24)) +} + +class C3 implements I1 { +>C3 : Symbol(C3, Decl(interfaceImplementation6.ts, 10, 1)) +>I1 : Symbol(I1, Decl(interfaceImplementation6.ts, 0, 0)) + + constructor() { + var item: number; +>item : Symbol(item, Decl(interfaceImplementation6.ts, 14, 10)) + } +} + +export class Test { +>Test : Symbol(Test, Decl(interfaceImplementation6.ts, 16, 1)) + + private pt: I1 = { item: 1 }; +>pt : Symbol(Test.pt, Decl(interfaceImplementation6.ts, 18, 19)) +>I1 : Symbol(I1, Decl(interfaceImplementation6.ts, 0, 0)) +>item : Symbol(item, Decl(interfaceImplementation6.ts, 19, 22)) +} + + + diff --git a/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.types b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.types new file mode 100644 index 0000000000..8e842c8c5a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/interfaceImplementation6.types @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/interfaceImplementation6.ts] //// + +=== interfaceImplementation6.ts === +interface I1 { + item:number; +>item : number +} + +class C1 implements I1 { +>C1 : C1 + + public item:number; +>item : number +} + +class C2 implements I1 { +>C2 : C2 + + private item:number; +>item : number +} + +class C3 implements I1 { +>C3 : C3 + + constructor() { + var item: number; +>item : number + } +} + +export class Test { +>Test : Test + + private pt: I1 = { item: 1 }; +>pt : I1 +>{ item: 1 } : { item: number; } +>item : number +>1 : 1 +} + + + diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt new file mode 100644 index 0000000000..ced31bd01b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt @@ -0,0 +1,35 @@ +internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(1,1): error TS1185: Merge conflict marker encountered. +internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(3,1): error TS1185: Merge conflict marker encountered. +internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(5,1): error TS1185: Merge conflict marker encountered. +internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(7,1): error TS1185: Merge conflict marker encountered. +internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(17,10): error TS2694: Namespace '"internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. + + +==== internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts (5 errors) ==== + <<<<<<< HEAD + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export module a { + ||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export namespace a { + ======= + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export namespace a { + >>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export interface I { + } + } + + export module c { + import b = a.I; + export var x: b; + } + + var x: c.b; + ~ +!!! error TS2694: Namespace '"internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js new file mode 100644 index 0000000000..bdb02a7e5d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts] //// + +//// [internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts] +<<<<<<< HEAD +export module a { +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +export namespace a { +======= +export namespace a { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface I { + } +} + +export module c { + import b = a.I; + export var x: b; +} + +var x: c.b; + +//// [internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c = void 0; +var c; +(function (c) { + var b = a.I; +})(c || (exports.c = c = {})); +var x; diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js.diff b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js.diff new file mode 100644 index 0000000000..8d05775abd --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js.diff @@ -0,0 +1,9 @@ +--- old.internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js ++++ new.internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js +@@= skipped -24, +24 lines =@@ + exports.c = void 0; + var c; + (function (c) { ++ var b = a.I; + })(c || (exports.c = c = {})); + var x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.symbols b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.symbols new file mode 100644 index 0000000000..ef6118207d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.symbols @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts] //// + +=== internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts === +<<<<<<< HEAD +export module a { +>a : Symbol(a, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 0, 0)) + +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +export namespace a { +======= +export namespace a { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface I { +>I : Symbol(I, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 1, 17)) + } +} + +export module c { +>c : Symbol(c, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 9, 1)) + + import b = a.I; +>b : Symbol(b, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 11, 17)) +>a : Symbol(a, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 0, 0)) +>I : Symbol(b, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 1, 17)) + + export var x: b; +>x : Symbol(x, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 13, 14)) +>b : Symbol(b, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 11, 17)) +} + +var x: c.b; +>x : Symbol(x, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 16, 3)) +>c : Symbol(c, Decl(internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts, 9, 1)) +>b : Symbol(c.b) + diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.types b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.types new file mode 100644 index 0000000000..2e52ca27eb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts] //// + +=== internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts === +<<<<<<< HEAD +export module a { +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +export namespace a { +======= +export namespace a { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface I { + } +} + +export module c { +>c : typeof c + + import b = a.I; +>b : any +>a : any +>I : b + + export var x: b; +>x : b +} + +var x: c.b; +>x : c.b +>c : any + diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt new file mode 100644 index 0000000000..33c67eae2a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt @@ -0,0 +1,42 @@ +internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(1,1): error TS1185: Merge conflict marker encountered. +internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(4,1): error TS1185: Merge conflict marker encountered. +internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(7,1): error TS1185: Merge conflict marker encountered. +internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(10,1): error TS1185: Merge conflict marker encountered. +internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(24,17): error TS2694: Namespace '"internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. + + +==== internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts (5 errors) ==== + <<<<<<< HEAD + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export module a { + export module b { + ||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export namespace a { + export namespace b { + ======= + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export namespace a { + export namespace b { + >>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + export interface I { + foo(); + } + } + } + + export module c { + import b = a.b; + export var x: b.I; + x.foo(); + } + + + export var z: c.b.I; + ~ +!!! error TS2694: Namespace '"internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js new file mode 100644 index 0000000000..ead7ebc3ca --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts] //// + +//// [internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts] +<<<<<<< HEAD +export module a { + export module b { +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +export namespace a { + export namespace b { +======= +export namespace a { + export namespace b { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface I { + foo(); + } + } +} + +export module c { + import b = a.b; + export var x: b.I; + x.foo(); +} + + +export var z: c.b.I; + +//// [internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = exports.c = void 0; +var c; +(function (c) { + var b = a.b; + c.x.foo(); +})(c || (exports.c = c = {})); diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js.diff b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js.diff new file mode 100644 index 0000000000..562b363ac5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js.diff @@ -0,0 +1,9 @@ +--- old.internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js ++++ new.internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js +@@= skipped -31, +31 lines =@@ + exports.z = exports.c = void 0; + var c; + (function (c) { ++ var b = a.b; + c.x.foo(); + })(c || (exports.c = c = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.symbols b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.symbols new file mode 100644 index 0000000000..2deb9f3148 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.symbols @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts] //// + +=== internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts === +<<<<<<< HEAD +export module a { +>a : Symbol(a, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 0, 0)) + + export module b { +>b : Symbol(b, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 1, 17)) + +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +export namespace a { + export namespace b { +======= +export namespace a { + export namespace b { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface I { +>I : Symbol(I, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 2, 21)) + + foo(); +>foo : Symbol(I.foo, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 10, 28)) + } + } +} + +export module c { +>c : Symbol(c, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 14, 1)) + + import b = a.b; +>b : Symbol(b, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 16, 17)) +>a : Symbol(a, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 0, 0)) +>b : Symbol(b, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 1, 17)) + + export var x: b.I; +>x : Symbol(x, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 18, 14)) +>b : Symbol(b, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 16, 17)) +>I : Symbol(b.I, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 2, 21)) + + x.foo(); +>x.foo : Symbol(b.I.foo, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 10, 28)) +>x : Symbol(x, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 18, 14)) +>foo : Symbol(b.I.foo, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 10, 28)) +} + + +export var z: c.b.I; +>z : Symbol(z, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 23, 10)) +>c : Symbol(c, Decl(internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts, 14, 1)) +>b : Symbol(c.b) +>I : Symbol(c.b.I) + diff --git a/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.types b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.types new file mode 100644 index 0000000000..f9a4162f19 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts] //// + +=== internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts === +<<<<<<< HEAD +export module a { + export module b { +||||||| parent of 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) +export namespace a { + export namespace b { +======= +export namespace a { + export namespace b { +>>>>>>> 42f6576e83 (Deprecate `--module amd`, `umd`, `system`, `none`; `--moduleResolution classic`; change defaults (#62669)) + export interface I { + foo(); +>foo : () => any + } + } +} + +export module c { +>c : typeof c + + import b = a.b; +>b : any +>a : any +>b : any + + export var x: b.I; +>x : b.I +>b : any + + x.foo(); +>x.foo() : any +>x.foo : () => any +>x : b.I +>foo : () => any +} + + +export var z: c.b.I; +>z : c.b.I +>c : any +>b : any + diff --git a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js b/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js index 3c9c6d1b6b..e68f399703 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js @@ -8,4 +8,5 @@ new x(); //// [intersectionOfMixinConstructorTypeAndNonConstructorType.js] +// Repro for #17388 new x(); diff --git a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js.diff deleted file mode 100644 index 186b4c63d0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.intersectionOfMixinConstructorTypeAndNonConstructorType.js -+++ new.intersectionOfMixinConstructorTypeAndNonConstructorType.js -@@= skipped -7, +7 lines =@@ - - - //// [intersectionOfMixinConstructorTypeAndNonConstructorType.js] --// Repro for #17388 - new x(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js b/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js index 5a649b1f60..02a834fc56 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js @@ -22,22 +22,12 @@ function test(value: T): Test { //// [intersectionPropertyCheck.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; +"use strict"; let obj = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property let weak = wrong; // Nested weak object type function foo(x, y) { x = y; // Mismatched property in source intersection } function test(value) { - return __assign(__assign({}, value), { hi: true }); + return Object.assign(Object.assign({}, value), { hi: true }); } diff --git a/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js.diff deleted file mode 100644 index abe516b032..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionPropertyCheck.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.intersectionPropertyCheck.js -+++ new.intersectionPropertyCheck.js -@@= skipped -21, +21 lines =@@ - - - //// [intersectionPropertyCheck.js] --"use strict"; - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js b/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js index 8986300f43..f345160ad9 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js @@ -20,6 +20,7 @@ const mySecondFunction = { const newParam = Object.assign(param1, { otherProperty: 3 }); mySecondFunction(newParam); diff --git a/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js.diff deleted file mode 100644 index 0d6173edf0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionSatisfiesConstraint.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.intersectionSatisfiesConstraint.js -+++ new.intersectionSatisfiesConstraint.js -@@= skipped -19, +19 lines =@@ - - - //// [intersectionSatisfiesConstraint.js] --"use strict"; - const myFirstFunction = (param1) => { - const newParam = Object.assign(param1, { otherProperty: 3 }); - mySecondFunction(newParam); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js b/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js index 961b7c1037..23ed81694f 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js @@ -12,9 +12,9 @@ export const Form3 = brokenFunction(parameterFn)({store: "hello"}) //// [intersectionTypeInference1.js] "use strict"; +// Repro from #8801 Object.defineProperty(exports, "__esModule", { value: true }); exports.Form3 = void 0; -// Repro from #8801 function alert(s) { } const parameterFn = (props) => alert(props.store); const brokenFunction = (f) => (o) => o; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js.diff deleted file mode 100644 index 56f35b8476..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.intersectionTypeInference1.js -+++ new.intersectionTypeInference1.js -@@= skipped -11, +11 lines =@@ - - //// [intersectionTypeInference1.js] - "use strict"; --// Repro from #8801 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Form3 = void 0; -+// Repro from #8801 - function alert(s) { } - const parameterFn = (props) => alert(props.store); - const brokenFunction = (f) => (o) => o; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js b/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js index 46e88b6ea8..a2b5d30478 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js @@ -60,6 +60,7 @@ class Foo { //// [intersectionWithConflictingPrivates.js] +"use strict"; class A { x; y; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js.diff index 4f070275ae..f3ab771060 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js.diff +++ b/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.js.diff @@ -1,10 +1,8 @@ --- old.intersectionWithConflictingPrivates.js +++ new.intersectionWithConflictingPrivates.js -@@= skipped -59, +59 lines =@@ - - +@@= skipped -61, +61 lines =@@ //// [intersectionWithConflictingPrivates.js] --"use strict"; + "use strict"; class A { + x; + y; @@ -15,7 +13,7 @@ } ab.y = 'hello'; ab = {}; -@@= skipped -24, +27 lines =@@ +@@= skipped -22, +26 lines =@@ class ViewRefFileNode extends ViewRefNode { } class CommitFileNode extends ViewRefFileNode { diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js b/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js index 0634e19246..e19a218e42 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js @@ -30,6 +30,7 @@ const xx: [number, ...number[]] = yy; //// [intersectionsAndOptionalProperties.js] +"use strict"; x = y; // Error x = z; // Error function foo(v) { diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js.diff deleted file mode 100644 index cab7556f54..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionsAndOptionalProperties.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.intersectionsAndOptionalProperties.js -+++ new.intersectionsAndOptionalProperties.js -@@= skipped -29, +29 lines =@@ - - - //// [intersectionsAndOptionalProperties.js] --"use strict"; - x = y; // Error - x = z; // Error - function foo(v) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js index 8a09619e08..6e682816f3 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js @@ -30,11 +30,11 @@ export function assertNodeProperty< //// [intersectionsOfLargeUnions.js] "use strict"; +// Repro from #23977 Object.defineProperty(exports, "__esModule", { value: true }); exports.assertIsElement = assertIsElement; exports.assertNodeTagName = assertNodeTagName; exports.assertNodeProperty = assertNodeProperty; -// Repro from #23977 function assertIsElement(node) { let nodeType = node === null ? null : node.nodeType; return nodeType === 1; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js.diff deleted file mode 100644 index 1552e303e5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.intersectionsOfLargeUnions.js -+++ new.intersectionsOfLargeUnions.js -@@= skipped -29, +29 lines =@@ - - //// [intersectionsOfLargeUnions.js] - "use strict"; --// Repro from #23977 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.assertIsElement = assertIsElement; - exports.assertNodeTagName = assertNodeTagName; - exports.assertNodeProperty = assertNodeProperty; -+// Repro from #23977 - function assertIsElement(node) { - let nodeType = node === null ? null : node.nodeType; - return nodeType === 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js index d61b378eec..4fdc0f80b9 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js @@ -40,6 +40,7 @@ export function assertNodeProperty< //// [intersectionsOfLargeUnions2.js] "use strict"; +// Repro from #24233 Object.defineProperty(exports, "__esModule", { value: true }); exports.assertIsElement = assertIsElement; exports.assertNodeTagName = assertNodeTagName; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js.diff deleted file mode 100644 index 7468281772..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.intersectionsOfLargeUnions2.js -+++ new.intersectionsOfLargeUnions2.js -@@= skipped -39, +39 lines =@@ - - //// [intersectionsOfLargeUnions2.js] - "use strict"; --// Repro from #24233 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.assertIsElement = assertIsElement; - exports.assertNodeTagName = assertNodeTagName; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/invalidStaticField.js.diff b/testdata/baselines/reference/submodule/compiler/invalidStaticField.js.diff index d9767632c3..9dbc8f8609 100644 --- a/testdata/baselines/reference/submodule/compiler/invalidStaticField.js.diff +++ b/testdata/baselines/reference/submodule/compiler/invalidStaticField.js.diff @@ -1,15 +1,9 @@ --- old.invalidStaticField.js +++ new.invalidStaticField.js -@@= skipped -7, +7 lines =@@ - class A { +@@= skipped -8, +8 lines =@@ foo() { return B.NULL; } } --let B = (() => { -- class B { -- } -- B.NOT_NULL = new B(); -- return B; --})(); -+class B { + class B { + static NOT_NULL = new B(); -+} \ No newline at end of file + } +-B.NOT_NULL = new B(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js b/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js index b2dadd9537..a26daf934a 100644 --- a/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js +++ b/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js @@ -26,6 +26,7 @@ interface Constraint> extends Runtype { //// [invariantGenericErrorElaboration.js] +"use strict"; // Repro from #19746 const wat = Num; const Foo = Obj({ foo: Num }); diff --git a/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js.diff b/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js.diff deleted file mode 100644 index 2ff68549ec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/invariantGenericErrorElaboration.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.invariantGenericErrorElaboration.js -+++ new.invariantGenericErrorElaboration.js -@@= skipped -25, +25 lines =@@ - - - //// [invariantGenericErrorElaboration.js] --"use strict"; - // Repro from #19746 - const wat = Num; - const Foo = Obj({ foo: Num }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js index f373f20796..64ad2de25b 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js @@ -12,6 +12,7 @@ export const foo3 = (type: Unresolved): void => {}; //// [isolatedDeclarationErrorTypes1.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/60192 Object.defineProperty(exports, "__esModule", { value: true }); exports.foo3 = exports.foo2 = exports.foo1 = void 0; const foo1 = (type) => { }; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff index bec6aaca54..4134efb25c 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff @@ -1,14 +1,6 @@ --- old.isolatedDeclarationErrorTypes1.js +++ new.isolatedDeclarationErrorTypes1.js -@@= skipped -11, +11 lines =@@ - - //// [isolatedDeclarationErrorTypes1.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/60192 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.foo3 = exports.foo2 = exports.foo1 = void 0; - const foo1 = (type) => { }; -@@= skipped -12, +11 lines =@@ +@@= skipped -23, +23 lines =@@ //// [isolatedDeclarationErrorTypes1.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js index 95fbefe14b..ab579cc40e 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js @@ -49,6 +49,7 @@ enum StrExt { } //// [isolatedDeclarationErrorsEnums.js] +"use strict"; var E; (function (E) { E["A"] = computed(0); diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff index edb7121bca..e9658fda0b 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff @@ -1,10 +1,7 @@ --- old.isolatedDeclarationErrorsEnums.js +++ new.isolatedDeclarationErrorsEnums.js -@@= skipped -48, +48 lines =@@ - } - - //// [isolatedDeclarationErrorsEnums.js] --"use strict"; +@@= skipped -51, +51 lines =@@ + "use strict"; var E; (function (E) { - E[E["A"] = computed(0)] = "A"; @@ -31,7 +28,7 @@ })(F || (F = {})); var Flag; (function (Flag) { -@@= skipped -26, +31 lines =@@ +@@= skipped -23, +29 lines =@@ var ExtFlags; (function (ExtFlags) { ExtFlags[ExtFlags["D"] = 2] = "D"; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js index ead291b262..32bc756193 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js @@ -28,12 +28,12 @@ export function test3(x?: Unresolved): void {} //// [isolatedDeclarationsAddUndefined2.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/60123 Object.defineProperty(exports, "__esModule", { value: true }); exports.Bar4 = exports.Bar3 = exports.Bar2 = exports.Bar = void 0; exports.test1 = test1; exports.test2 = test2; exports.test3 = test3; -// https://github.com/microsoft/TypeScript/issues/60123 class Bar { x; constructor(x) { diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff index b9c92a668b..1a37f56f75 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff @@ -1,16 +1,8 @@ --- old.isolatedDeclarationsAddUndefined2.js +++ new.isolatedDeclarationsAddUndefined2.js -@@= skipped -27, +27 lines =@@ - - //// [isolatedDeclarationsAddUndefined2.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/60123 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Bar4 = exports.Bar3 = exports.Bar2 = exports.Bar = void 0; - exports.test1 = test1; +@@= skipped -34, +34 lines =@@ exports.test2 = test2; exports.test3 = test3; -+// https://github.com/microsoft/TypeScript/issues/60123 class Bar { + x; constructor(x) { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/isolatedDeclarationsAllowJs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAllowJs.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/isolatedDeclarationsAllowJs.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAllowJs.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js b/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js index 5f68db0689..6b72a0a1e6 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js @@ -39,7 +39,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true }); //// [test4.js] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); // @ts-expect-error -const doesntexist_1 = require("./doesntexist"); +const doesntexist_1 = __importDefault(require("./doesntexist")); exports.default = doesntexist_1.default; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js.diff deleted file mode 100644 index 1e89e725c7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesExportDeclarationType.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.isolatedModulesExportDeclarationType.js -+++ new.isolatedModulesExportDeclarationType.js -@@= skipped -40, +40 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - // @ts-expect-error --var doesntexist_1 = require("./doesntexist"); -+const doesntexist_1 = require("./doesntexist"); - exports.default = doesntexist_1.default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesImportConstEnum.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedModulesImportConstEnum.js.diff deleted file mode 100644 index b8f064d666..0000000000 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesImportConstEnum.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.isolatedModulesImportConstEnum.js -+++ new.isolatedModulesImportConstEnum.js -@@= skipped -20, +20 lines =@@ - //// [file1.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var file2_1 = require("./file2"); -+const file2_1 = require("./file2"); - console.log(file2_1.Foo.BAR); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js b/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js index 43aa3ce8e0..e14f77fb88 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js @@ -16,11 +16,44 @@ export var z = x; //// [file1.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.z = exports.c1 = void 0; const module_1 = require("module"); const module_2 = require("module"); -const ns = require("module"); +const ns = __importStar(require("module")); class C extends module_2.c2.C { } let x = new module_1.c(); diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js.diff index dc33b712bd..de3aaece90 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesImportExportElision.js.diff @@ -1,16 +1,6 @@ --- old.isolatedModulesImportExportElision.js +++ new.isolatedModulesImportExportElision.js -@@= skipped -17, +17 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.z = exports.c1 = void 0; --var module_1 = require("module"); --var module_2 = require("module"); --var ns = require("module"); -+const module_1 = require("module"); -+const module_2 = require("module"); -+const ns = require("module"); - class C extends module_2.c2.C { +@@= skipped -57, +57 lines =@@ } let x = new module_1.c(); let y = ns.value; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js b/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js index 896c355db4..eb2df0c95f 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js @@ -70,11 +70,44 @@ exports.C = C; Object.defineProperty(exports, "__esModule", { value: true }); //// [user.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.NS = exports.C = void 0; // OK, has a value side const exportValue_1 = require("./exportValue"); Object.defineProperty(exports, "C", { enumerable: true, get: function () { return exportValue_1.C; } }); // OK, even though the namespace it exports is only types. -const NS = require("./exportT"); +const NS = __importStar(require("./exportT")); exports.NS = NS; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js.diff index 0b525d20bd..8f5c550e48 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesReExportType.js.diff @@ -1,6 +1,6 @@ --- old.isolatedModulesReExportType.js +++ new.isolatedModulesReExportType.js -@@= skipped -72, +72 lines =@@ +@@= skipped -105, +105 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.NS = exports.C = void 0; // OK, has a value side @@ -8,6 +8,4 @@ +const exportValue_1 = require("./exportValue"); Object.defineProperty(exports, "C", { enumerable: true, get: function () { return exportValue_1.C; } }); // OK, even though the namespace it exports is only types. --var NS = require("./exportT"); -+const NS = require("./exportT"); - exports.NS = NS; \ No newline at end of file + const NS = __importStar(require("./exportT")); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js b/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js index 51f6b41f09..9a58042032 100644 --- a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js +++ b/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js @@ -49,6 +49,7 @@ class MyMap implements Map { //// [iterableTReturnTNext.js] +"use strict"; // based on: // - https://github.com/apollographql/apollo-client/blob/8740f198805a99e01136617c4055d611b92cc231/src/react/hooks/__tests__/useMutation.test.tsx#L2328 // - https://github.com/continuedev/continue/blob/046bca088a833f8b3620412ff64e4b6f41fbb959/extensions/vscode/src/autocomplete/lsp.ts#L60 diff --git a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js.diff b/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js.diff deleted file mode 100644 index 543c57e4ed..0000000000 --- a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=false).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.iterableTReturnTNext(strictbuiltiniteratorreturn=false).js -+++ new.iterableTReturnTNext(strictbuiltiniteratorreturn=false).js -@@= skipped -48, +48 lines =@@ - - - //// [iterableTReturnTNext.js] --"use strict"; - // based on: - // - https://github.com/apollographql/apollo-client/blob/8740f198805a99e01136617c4055d611b92cc231/src/react/hooks/__tests__/useMutation.test.tsx#L2328 - // - https://github.com/continuedev/continue/blob/046bca088a833f8b3620412ff64e4b6f41fbb959/extensions/vscode/src/autocomplete/lsp.ts#L60 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js b/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js index 51f6b41f09..9a58042032 100644 --- a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js +++ b/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js @@ -49,6 +49,7 @@ class MyMap implements Map { //// [iterableTReturnTNext.js] +"use strict"; // based on: // - https://github.com/apollographql/apollo-client/blob/8740f198805a99e01136617c4055d611b92cc231/src/react/hooks/__tests__/useMutation.test.tsx#L2328 // - https://github.com/continuedev/continue/blob/046bca088a833f8b3620412ff64e4b6f41fbb959/extensions/vscode/src/autocomplete/lsp.ts#L60 diff --git a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js.diff b/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js.diff deleted file mode 100644 index 40bd0ecdec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/iterableTReturnTNext(strictbuiltiniteratorreturn=true).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.iterableTReturnTNext(strictbuiltiniteratorreturn=true).js -+++ new.iterableTReturnTNext(strictbuiltiniteratorreturn=true).js -@@= skipped -48, +48 lines =@@ - - - //// [iterableTReturnTNext.js] --"use strict"; - // based on: - // - https://github.com/apollographql/apollo-client/blob/8740f198805a99e01136617c4055d611b92cc231/src/react/hooks/__tests__/useMutation.test.tsx#L2328 - // - https://github.com/continuedev/continue/blob/046bca088a833f8b3620412ff64e4b6f41fbb959/extensions/vscode/src/autocomplete/lsp.ts#L60 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js index 7e17b0e274..d1a10a06ac 100644 --- a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js +++ b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js @@ -13,5 +13,4 @@ class Foo { } class Bar extends Foo { } -export = Bar; module.exports = Bar; diff --git a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js.diff b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js.diff deleted file mode 100644 index 8f662402ff..0000000000 --- a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.javascriptCommonjsModule.js -+++ new.javascriptCommonjsModule.js -@@= skipped -12, +12 lines =@@ - } - class Bar extends Foo { - } -+export = Bar; - module.exports = Bar; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols index bf438af52c..9d62a03803 100644 --- a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols +++ b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols @@ -10,7 +10,7 @@ class Bar extends Foo {} module.exports = Bar; >module.exports : Symbol(Bar, Decl(index.js, 0, 12)) ->module : Symbol(module.exports) +>module : Symbol("index", Decl(index.js, 0, 0)) >exports : Symbol(Bar, Decl(index.js, 0, 12)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols.diff b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols.diff index 39829663de..59cd1ad165 100644 --- a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.symbols.diff @@ -8,6 +8,6 @@ ->module : Symbol(export=, Decl(index.js, 2, 24)) ->exports : Symbol(export=, Decl(index.js, 2, 24)) +>module.exports : Symbol(Bar, Decl(index.js, 0, 12)) -+>module : Symbol(module.exports) ++>module : Symbol("index", Decl(index.js, 0, 0)) +>exports : Symbol(Bar, Decl(index.js, 0, 12)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.types.diff b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.types.diff rename to testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptDefinePropertyPrototypeNonConstructor.types.diff b/testdata/baselines/reference/submodule/compiler/javascriptDefinePropertyPrototypeNonConstructor.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/javascriptDefinePropertyPrototypeNonConstructor.types.diff rename to testdata/baselines/reference/submodule/compiler/javascriptDefinePropertyPrototypeNonConstructor.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols b/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols index e1364018d2..33b60d814f 100644 --- a/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols +++ b/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols @@ -6,7 +6,7 @@ const alias = {}; module.exports = alias; >module.exports : Symbol(alias, Decl(a.js, 0, 5)) ->module : Symbol(module.exports) +>module : Symbol("/a", Decl(a.js, 0, 0)) >exports : Symbol(alias, Decl(a.js, 0, 5)) >alias : Symbol(alias, Decl(a.js, 0, 5)) diff --git a/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols.diff b/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols.diff index b111a514cb..fdd8244b28 100644 --- a/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.symbols.diff @@ -8,7 +8,7 @@ ->module : Symbol(export=, Decl(a.js, 0, 17)) ->exports : Symbol(export=, Decl(a.js, 0, 17)) +>module.exports : Symbol(alias, Decl(a.js, 0, 5)) -+>module : Symbol(module.exports) ++>module : Symbol("/a", Decl(a.js, 0, 0)) +>exports : Symbol(alias, Decl(a.js, 0, 5)) >alias : Symbol(alias, Decl(a.js, 0, 5)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptImportDefaultBadExport.types.diff b/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.types.diff similarity index 83% rename from testdata/baselines/reference/submoduleAccepted/compiler/javascriptImportDefaultBadExport.types.diff rename to testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.types.diff index aeec21acd4..784ed9da3d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptImportDefaultBadExport.types.diff +++ b/testdata/baselines/reference/submodule/compiler/javascriptImportDefaultBadExport.types.diff @@ -8,8 +8,3 @@ +>module : { readonly alias: {}; } >exports : {} >alias : {} - - === /b.js === - import a from "./a"; -->a : any -+>a : {} diff --git a/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.js.diff b/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.js.diff index daef94d047..21bd9b3f2f 100644 --- a/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.js.diff +++ b/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.js.diff @@ -4,7 +4,7 @@ ElementsArray.isArray(new ElementsArray()); //// [a.js] --var _a, _b; +-var _a, _b, _c; class Thing { + static { + this.doSomething = () => { }; @@ -16,7 +16,8 @@ -})(); Thing.doSomething(); // GH#46468 - class ElementsArray extends Array { +-class ElementsArray extends (_c = Array) { ++class ElementsArray extends Array { + static { + const superisArray = super.isArray; + const customIsArray = (arg) => superisArray(arg); @@ -25,7 +26,7 @@ } -_b = ElementsArray; -(() => { -- const superisArray = super.isArray; +- const superisArray = Reflect.get(_c, "isArray", _b); - const customIsArray = (arg) => superisArray(arg); - _b.isArray = customIsArray; -})(); diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols index e26a7ebdd3..b95894b8c9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols @@ -3,7 +3,7 @@ === file.js === module.exports = [{ name: 'other', displayName: 'Other', defaultEnabled: true }]; >module.exports : Symbol(export=, Decl(file.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("file", Decl(file.js, 0, 0)) >exports : Symbol(export=, Decl(file.js, 0, 0)) >name : Symbol(name, Decl(file.js, 0, 19)) >displayName : Symbol(displayName, Decl(file.js, 0, 34)) diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols.diff index 86cebb8e70..bbce79bbae 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.symbols.diff @@ -7,7 +7,7 @@ ->module.exports : Symbol(module.exports, Decl(file.js, 0, 0)) ->module : Symbol(export=, Decl(file.js, 0, 0)) +>module.exports : Symbol(export=, Decl(file.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("file", Decl(file.js, 0, 0)) >exports : Symbol(export=, Decl(file.js, 0, 0)) >name : Symbol(name, Decl(file.js, 0, 19)) >displayName : Symbol(displayName, Decl(file.js, 0, 34)) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedArray.types.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedArray.types.diff rename to testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedArray.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt deleted file mode 100644 index 824d5e4f6f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -index.js(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -index.js(9,34): error TS7006: Parameter 'options' implicitly has an 'any' type. - - -==== index.js (2 errors) ==== - /** - * @typedef Options - * @property {string} opt - */ - - /** - * @param {Options} options - */ - module.exports = function loader(options) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - ~~~~~~~ -!!! error TS7006: Parameter 'options' implicitly has an 'any' type. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js index bf182d3b0a..02499abac7 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js @@ -14,15 +14,6 @@ module.exports = function loader(options) {} //// [index.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * @typedef Options - * @property {string} opt - */ -/** - * @param {Options} options - */ -export = function loader(options) { }; /** * @typedef Options * @property {string} opt @@ -34,8 +25,33 @@ module.exports = function loader(options) { }; //// [index.d.ts] +/** + * @typedef Options + * @property {string} opt + */ export type Options = { opt: string; }; -declare const _default: (options: any) => void; +declare const _default: (options: Options) => void; export = _default; + + +//// [DtsFileErrors] + + +out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== out/index.d.ts (1 errors) ==== + /** + * @typedef Options + * @property {string} opt + */ + export type Options = { + opt: string; + }; + declare const _default: (options: Options) => void; + export = _default; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff index b9cfac184e..018318dba1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff @@ -1,22 +1,6 @@ --- old.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js +++ new.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js -@@= skipped -13, +13 lines =@@ - - //// [index.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+/** -+ * @typedef Options -+ * @property {string} opt -+ */ -+/** -+ * @param {Options} options -+ */ -+export = function loader(options) { }; - /** - * @typedef Options - * @property {string} opt -@@= skipped -11, +20 lines =@@ +@@= skipped -24, +24 lines =@@ //// [index.d.ts] @@ -26,8 +10,33 @@ -declare function _exports(options: Options): void; -export = _exports; -type Options = { ++/** ++ * @typedef Options ++ * @property {string} opt ++ */ +export type Options = { opt: string; }; -+declare const _default: (options: any) => void; -+export = _default; \ No newline at end of file ++declare const _default: (options: Options) => void; ++export = _default; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++ ++ ++==== out/index.d.ts (1 errors) ==== ++ /** ++ * @typedef Options ++ * @property {string} opt ++ */ ++ export type Options = { ++ opt: string; ++ }; ++ declare const _default: (options: Options) => void; ++ export = _default; ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols index 8e050faae9..39730ae9d2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols @@ -11,7 +11,7 @@ */ module.exports = function loader(options) {} >module.exports : Symbol(export=, Decl(index.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 0)) >loader : Symbol(loader, Decl(index.js, 8, 16)) >options : Symbol(options, Decl(index.js, 8, 33)) diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols.diff index 341416ad03..8d1d235861 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols.diff @@ -7,7 +7,7 @@ ->module.exports : Symbol(module.exports, Decl(index.js, 0, 0)) ->module : Symbol(export=, Decl(index.js, 0, 0)) +>module.exports : Symbol(export=, Decl(index.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("index", Decl(index.js, 0, 0)) >exports : Symbol(export=, Decl(index.js, 0, 0)) >loader : Symbol(loader, Decl(index.js, 8, 16)) >options : Symbol(options, Decl(index.js, 8, 33)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types index a781c3469e..c839ae735a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types @@ -10,11 +10,11 @@ * @param {Options} options */ module.exports = function loader(options) {} ->module.exports = function loader(options) {} : (options: any) => void ->module.exports : (options: any) => void ->module : { "export=": (options: any) => void; } ->exports : (options: any) => void ->function loader(options) {} : (options: any) => void ->loader : (options: any) => void ->options : any +>module.exports = function loader(options) {} : (options: Options) => void +>module.exports : (options: Options) => void +>module : { "export=": (options: Options) => void; } +>exports : (options: Options) => void +>function loader(options) {} : (options: Options) => void +>loader : (options: Options) => void +>options : Options diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types.diff new file mode 100644 index 0000000000..284b64c94a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types.diff @@ -0,0 +1,11 @@ +--- old.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types ++++ new.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types +@@= skipped -11, +11 lines =@@ + module.exports = function loader(options) {} + >module.exports = function loader(options) {} : (options: Options) => void + >module.exports : (options: Options) => void +->module : { exports: (options: Options) => void; } ++>module : { "export=": (options: Options) => void; } + >exports : (options: Options) => void + >function loader(options) {} : (options: Options) => void + >loader : (options: Options) => void \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportedClassWithExtends.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportedClassWithExtends.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportedClassWithExtends.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportedClassWithExtends.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportedClassWithExtends.types.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportedClassWithExtends.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportedClassWithExtends.types.diff rename to testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportedClassWithExtends.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsGlobalFileConstFunction.types.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsGlobalFileConstFunction.types.diff rename to testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsGlobalFileConstFunctionNamed.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsGlobalFileConstFunctionNamed.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsGlobalFileConstFunctionNamed.types.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsGlobalFileConstFunctionNamed.types.diff rename to testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js index efd479b20b..94d864452f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js @@ -36,9 +36,35 @@ class C3 extends C1 { //// [a.d.ts] -export type A = { +/** + * @typedef A + * @property {string} a + */ +type A = { a: string; }; -export type B = { +type B = { b: number; }; +/** + * @typedef B + * @property {number} b + */ +declare class C1 { + /** + * @type {A} + */ + value: A; +} +declare class C2 extends C1 { + /** + * @type {A} + */ + value: A; +} +declare class C3 extends C1 { + /** + * @type {A & B} + */ + value: A & B; +} diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff index 0847a31c50..6dc3e0a2fe 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff @@ -1,36 +1,36 @@ --- old.jsDeclarationsInheritedTypes.js +++ new.jsDeclarationsInheritedTypes.js -@@= skipped -35, +35 lines =@@ - - - //// [a.d.ts] --/** -- * @typedef A -- * @property {string} a -- */ --/** -- * @typedef B -- * @property {number} b -- */ --declare class C1 { -- /** -- * @type {A} -- */ -- value: A; --} --declare class C2 extends C1 { --} --declare class C3 extends C1 { -- /** -- * @type {A & B} -- */ -- value: A & B; --} +@@= skipped -39, +39 lines =@@ + * @typedef A + * @property {string} a + */ ++type A = { ++ a: string; ++}; ++type B = { ++ b: number; ++}; + /** + * @typedef B + * @property {number} b +@@= skipped -11, +17 lines =@@ + value: A; + } + declare class C2 extends C1 { ++ /** ++ * @type {A} ++ */ ++ value: A; + } + declare class C3 extends C1 { + /** +@@= skipped -7, +11 lines =@@ + */ + value: A & B; + } -type A = { -+export type A = { - a: string; - }; +- a: string; +-}; -type B = { -+export type B = { - b: number; - }; \ No newline at end of file +- b: number; +-}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js index 236608d9bd..0bb4e6f499 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js +++ b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js @@ -47,10 +47,10 @@ NewAjax.prototype.case6_unexpectedlyResolvesPathToNodeModules; //// [index.d.ts] -export type LionRequestInit = import('@lion/ajax').LionRequestInit; /** * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit */ +export type LionRequestInit = import('@lion/ajax').LionRequestInit; export declare class NewAjax { /** * @param {LionRequestInit} [init] diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff index 7a5027b638..18975a2a3f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff @@ -1,14 +1,11 @@ --- old.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js +++ new.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js -@@= skipped -46, +46 lines =@@ - - - //// [index.d.ts] -+export type LionRequestInit = import('@lion/ajax').LionRequestInit; +@@= skipped -49, +49 lines =@@ /** * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit */ -export class NewAjax { ++export type LionRequestInit = import('@lion/ajax').LionRequestInit; +export declare class NewAjax { /** * @param {LionRequestInit} [init] diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff rename to testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt index 51082100d2..dac9af49a5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt @@ -1,13 +1,13 @@ -jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: any) => any; } | {}' is not assignable to type '{ localize: (string: any) => any; }'. - Property 'localize' is missing in type '{}' but required in type '{ localize: (string: any) => any; }'. +jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'. + Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'. ==== jsElementAccessNoContextualTypeCrash.js (1 errors) ==== var Common = {}; self['Common'] = self['Common'] || {}; ~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ localize: (string: any) => any; } | {}' is not assignable to type '{ localize: (string: any) => any; }'. -!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: any) => any; }'. +!!! error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'. +!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'. !!! related TS2728 jsElementAccessNoContextualTypeCrash.js:7:1: 'localize' is declared here. /** * @param {string} string diff --git a/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt.diff new file mode 100644 index 0000000000..001a66ef0f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.jsElementAccessNoContextualTypeCrash.errors.txt ++++ new.jsElementAccessNoContextualTypeCrash.errors.txt +@@= skipped -0, +0 lines =@@ +-jsElementAccessNoContextualTypeCrash.js(2,1): error TS2741: Property 'localize' is missing in type '{}' but required in type 'typeof Common'. ++jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'. ++ Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'. + + + ==== jsElementAccessNoContextualTypeCrash.js (1 errors) ==== + var Common = {}; + self['Common'] = self['Common'] || {}; + ~~~~~~~~~~~~~~ +-!!! error TS2741: Property 'localize' is missing in type '{}' but required in type 'typeof Common'. ++!!! error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'. ++!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'. + !!! related TS2728 jsElementAccessNoContextualTypeCrash.js:7:1: 'localize' is declared here. + /** + * @param {string} string \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types index d1bc8f8328..5c6be51a7f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types +++ b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types @@ -2,16 +2,16 @@ === jsElementAccessNoContextualTypeCrash.js === var Common = {}; ->Common : { localize: (string: any) => any; } ->{} : { localize: (string: any) => any; } +>Common : { localize: (string: string) => string; } +>{} : { localize: (string: string) => string; } self['Common'] = self['Common'] || {}; ->self['Common'] = self['Common'] || {} : { localize: (string: any) => any; } | {} ->self['Common'] : { localize: (string: any) => any; } +>self['Common'] = self['Common'] || {} : { localize: (string: string) => string; } | {} +>self['Common'] : { localize: (string: string) => string; } >self : Window & typeof globalThis >'Common' : "Common" ->self['Common'] || {} : { localize: (string: any) => any; } | {} ->self['Common'] : { localize: (string: any) => any; } +>self['Common'] || {} : { localize: (string: string) => string; } | {} +>self['Common'] : { localize: (string: string) => string; } >self : Window & typeof globalThis >'Common' : "Common" >{} : {} @@ -21,14 +21,14 @@ self['Common'] = self['Common'] || {}; * @return {string} */ Common.localize = function (string) { ->Common.localize = function (string) { return string;} : (string: any) => any ->Common.localize : (string: any) => any ->Common : { localize: (string: any) => any; } ->localize : (string: any) => any ->function (string) { return string;} : (string: any) => any ->string : any +>Common.localize = function (string) { return string;} : (string: string) => string +>Common.localize : (string: string) => string +>Common : { localize: (string: string) => string; } +>localize : (string: string) => string +>function (string) { return string;} : (string: string) => string +>string : string return string; ->string : any +>string : string }; diff --git a/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types.diff b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types.diff new file mode 100644 index 0000000000..5c55fbecf8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsElementAccessNoContextualTypeCrash.types.diff @@ -0,0 +1,34 @@ +--- old.jsElementAccessNoContextualTypeCrash.types ++++ new.jsElementAccessNoContextualTypeCrash.types +@@= skipped -1, +1 lines =@@ + + === jsElementAccessNoContextualTypeCrash.js === + var Common = {}; +->Common : typeof Common +->{} : {} ++>Common : { localize: (string: string) => string; } ++>{} : { localize: (string: string) => string; } + + self['Common'] = self['Common'] || {}; +->self['Common'] = self['Common'] || {} : {} +->self['Common'] : typeof Common ++>self['Common'] = self['Common'] || {} : { localize: (string: string) => string; } | {} ++>self['Common'] : { localize: (string: string) => string; } + >self : Window & typeof globalThis + >'Common' : "Common" +->self['Common'] || {} : {} +->self['Common'] : typeof Common ++>self['Common'] || {} : { localize: (string: string) => string; } | {} ++>self['Common'] : { localize: (string: string) => string; } + >self : Window & typeof globalThis + >'Common' : "Common" + >{} : {} +@@= skipped -21, +21 lines =@@ + Common.localize = function (string) { + >Common.localize = function (string) { return string;} : (string: string) => string + >Common.localize : (string: string) => string +->Common : typeof Common ++>Common : { localize: (string: string) => string; } + >localize : (string: string) => string + >function (string) { return string;} : (string: string) => string + >string : string \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt index 3be4b9a200..4ec5325f9f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt @@ -1,8 +1,7 @@ -enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. -index.js(4,17): error TS2503: Cannot find namespace 'Host'. -index.js(8,21): error TS2304: Cannot find name 'Host'. -index.js(13,11): error TS2503: Cannot find namespace 'Host'. -index.js(18,11): error TS2503: Cannot find namespace 'Host'. +enumDef.js(14,21): error TS1003: Identifier expected. +index.js(4,17): error TS2702: 'Host' only refers to a type, but is being used as a namespace here. +index.js(13,11): error TS2702: 'Host' only refers to a type, but is being used as a namespace here. +index.js(18,11): error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ==== enumDef.js (1 errors) ==== @@ -20,39 +19,38 @@ index.js(18,11): error TS2503: Cannot find namespace 'Host'. */ /** * @typedef {string} + */ + +!!! error TS1003: Identifier expected. Host.UserMetrics.Blah = { - ~~~~ -!!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. x: 12 } -==== index.js (4 errors) ==== +==== index.js (3 errors) ==== var Other = {}; Other.Cls = class { /** * @param {!Host.UserMetrics.Action} p ~~~~ -!!! error TS2503: Cannot find namespace 'Host'. +!!! error TS2702: 'Host' only refers to a type, but is being used as a namespace here. */ method(p) {} usage() { this.method(Host.UserMetrics.Action.WindowDocked); - ~~~~ -!!! error TS2304: Cannot find name 'Host'. } } /** * @type {Host.UserMetrics.Bargh} ~~~~ -!!! error TS2503: Cannot find namespace 'Host'. +!!! error TS2702: 'Host' only refers to a type, but is being used as a namespace here. */ var x = "ok"; /** * @type {Host.UserMetrics.Blah} ~~~~ -!!! error TS2503: Cannot find namespace 'Host'. +!!! error TS2702: 'Host' only refers to a type, but is being used as a namespace here. */ var y = "ok"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt.diff new file mode 100644 index 0000000000..de61884fc1 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt.diff @@ -0,0 +1,60 @@ +--- old.jsEnumCrossFileExport.errors.txt ++++ new.jsEnumCrossFileExport.errors.txt +@@= skipped -0, +0 lines =@@ +- ++enumDef.js(14,21): error TS1003: Identifier expected. ++index.js(4,17): error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ++index.js(13,11): error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ++index.js(18,11): error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ++ ++ ++==== enumDef.js (1 errors) ==== ++ var Host = {}; ++ Host.UserMetrics = {}; ++ /** @enum {number} */ ++ Host.UserMetrics.Action = { ++ WindowDocked: 1, ++ WindowUndocked: 2, ++ ScriptsBreakpointSet: 3, ++ TimelineStarted: 4, ++ }; ++ /** ++ * @typedef {string} Host.UserMetrics.Bargh ++ */ ++ /** ++ * @typedef {string} ++ ++ */ ++ ++!!! error TS1003: Identifier expected. ++ Host.UserMetrics.Blah = { ++ x: 12 ++ } ++==== index.js (3 errors) ==== ++ var Other = {}; ++ Other.Cls = class { ++ /** ++ * @param {!Host.UserMetrics.Action} p ++ ~~~~ ++!!! error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ++ */ ++ method(p) {} ++ usage() { ++ this.method(Host.UserMetrics.Action.WindowDocked); ++ } ++ } ++ ++ /** ++ * @type {Host.UserMetrics.Bargh} ++ ~~~~ ++!!! error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ++ */ ++ var x = "ok"; ++ ++ /** ++ * @type {Host.UserMetrics.Blah} ++ ~~~~ ++!!! error TS2702: 'Host' only refers to a type, but is being used as a namespace here. ++ */ ++ var y = "ok"; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols index f2af004d3e..bf0e0ccf1e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols @@ -37,9 +37,11 @@ Host.UserMetrics.Action = { * @typedef {string} */ Host.UserMetrics.Blah = { +>Host.UserMetrics.Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) >Host.UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) >Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) >UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) +>Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) x: 12 >x : Symbol(x, Decl(enumDef.js, 15, 25)) @@ -67,6 +69,13 @@ Other.Cls = class { >this.method : Symbol(Cls.method, Decl(index.js, 1, 19)) >this : Symbol(Cls, Decl(index.js, 1, 11)) >method : Symbol(Cls.method, Decl(index.js, 1, 19)) +>Host.UserMetrics.Action.WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) +>Host.UserMetrics.Action : Symbol(Action, Decl(enumDef.js, 1, 22)) +>Host.UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) +>UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) +>Action : Symbol(Action, Decl(enumDef.js, 1, 22)) +>WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) } } diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff index 17125d1a52..cacd083c2b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff @@ -39,9 +39,11 @@ ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) ->UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Blah : Symbol(Host.UserMetrics.Blah, Decl(enumDef.js, 8, 2), Decl(enumDef.js, 15, 17), Decl(enumDef.js, 13, 3)) ++>Host.UserMetrics.Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) +>Host.UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) +>UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) ++>Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) x: 12 >x : Symbol(x, Decl(enumDef.js, 15, 25)) @@ -61,16 +63,20 @@ /** * @param {!Host.UserMetrics.Action} p -@@= skipped -32, +30 lines =@@ - >this.method : Symbol(Cls.method, Decl(index.js, 1, 19)) +@@= skipped -33, +33 lines =@@ >this : Symbol(Cls, Decl(index.js, 1, 11)) >method : Symbol(Cls.method, Decl(index.js, 1, 19)) -->Host.UserMetrics.Action.WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) + >Host.UserMetrics.Action.WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) ->Host.UserMetrics.Action : Symbol(Host.UserMetrics.Action, Decl(enumDef.js, 1, 22), Decl(enumDef.js, 3, 17), Decl(enumDef.js, 2, 4)) ->Host.UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) ->UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Action : Symbol(Host.UserMetrics.Action, Decl(enumDef.js, 1, 22), Decl(enumDef.js, 3, 17), Decl(enumDef.js, 2, 4)) -->WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) ++>Host.UserMetrics.Action : Symbol(Action, Decl(enumDef.js, 1, 22)) ++>Host.UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) ++>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) ++>UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) ++>Action : Symbol(Action, Decl(enumDef.js, 1, 22)) + >WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) } - } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types index 31d40349d8..21bb730b00 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types @@ -2,23 +2,23 @@ === enumDef.js === var Host = {}; ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } Host.UserMetrics = {}; ->Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } +>Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } /** @enum {number} */ Host.UserMetrics.Action = { >Host.UserMetrics.Action = { WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } ->Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } >Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >{ WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } @@ -47,11 +47,11 @@ Host.UserMetrics.Action = { */ Host.UserMetrics.Blah = { >Host.UserMetrics.Blah = { x: 12} : { x: number; } ->Host.UserMetrics.Blah : any ->Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Blah : any +>Host.UserMetrics.Blah : { x: number; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Blah : { x: number; } >{ x: 12} : { x: number; } x: 12 @@ -85,13 +85,13 @@ Other.Cls = class { >this.method : (p: Host.UserMetrics.Action) => void >this : this >method : (p: Host.UserMetrics.Action) => void ->Host.UserMetrics.Action.WindowDocked : any ->Host.UserMetrics.Action : any ->Host.UserMetrics : any ->Host : any ->UserMetrics : any ->Action : any ->WindowDocked : any +>Host.UserMetrics.Action.WindowDocked : number +>Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } +>WindowDocked : number } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types.diff similarity index 75% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff rename to testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types.diff index 6acccc05c0..691473114e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types.diff @@ -6,8 +6,8 @@ var Host = {}; ->Host : typeof Host ->{} : {} -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } Host.UserMetrics = {}; ->Host.UserMetrics = {} : typeof Host.UserMetrics @@ -15,11 +15,11 @@ ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics ->{} : {} -+>Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ++>Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } /** @enum {number} */ Host.UserMetrics.Action = { @@ -28,30 +28,26 @@ ->Host.UserMetrics : typeof Host.UserMetrics ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics -+>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } >Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >{ WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } -@@= skipped -45, +45 lines =@@ - */ +@@= skipped -46, +46 lines =@@ Host.UserMetrics.Blah = { >Host.UserMetrics.Blah = { x: 12} : { x: number; } -->Host.UserMetrics.Blah : { x: number; } + >Host.UserMetrics.Blah : { x: number; } ->Host.UserMetrics : typeof Host.UserMetrics ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics -->Blah : { x: number; } -+>Host.UserMetrics.Blah : any -+>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Blah : any ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } + >Blah : { x: number; } >{ x: 12} : { x: number; } - x: 12 -@@= skipped -13, +13 lines =@@ +@@= skipped -12, +12 lines =@@ } === index.js === var Other = {}; @@ -77,28 +73,20 @@ usage() { >usage : () => void -@@= skipped -10, +10 lines =@@ - >this.method : (p: Host.UserMetrics.Action) => void - >this : this +@@= skipped -12, +12 lines =@@ >method : (p: Host.UserMetrics.Action) => void -->Host.UserMetrics.Action.WindowDocked : number -->Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } + >Host.UserMetrics.Action.WindowDocked : number + >Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } ->Host.UserMetrics : typeof Host.UserMetrics ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics -->Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } -->WindowDocked : number -+>Host.UserMetrics.Action.WindowDocked : any -+>Host.UserMetrics.Action : any -+>Host.UserMetrics : any -+>Host : any -+>UserMetrics : any -+>Action : any -+>WindowDocked : any ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } + >Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } + >WindowDocked : number } - } - -@@= skipped -14, +14 lines =@@ +@@= skipped -12, +12 lines =@@ * @type {Host.UserMetrics.Bargh} */ var x = "ok"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff rename to testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt deleted file mode 100644 index eec29dde07..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -index.js(3,8): error TS2339: Property 'devtools' does not exist on type '{}'. - - -==== index.js (1 errors) ==== - var chrome = {} - Object.defineProperty(chrome, 'devtools', { value: {}, enumerable: true }) - chrome.devtools.inspectedWindow = {} - ~~~~~~~~ -!!! error TS2339: Property 'devtools' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExpandoObjectDefineProperty.types.diff b/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExpandoObjectDefineProperty.types.diff rename to testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js index 635b4c6367..7b4d092edc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js @@ -17,4 +17,4 @@ declare const _default: { customSymbol: symbol; }; export = _default; -export var customSymbol2 = Symbol("custom"); +export declare var customSymbol2: symbol; diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js.diff b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js.diff index 4094b52ae4..9d7a1df712 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.js.diff @@ -10,4 +10,4 @@ + customSymbol: symbol; +}; +export = _default; -+export var customSymbol2 = Symbol("custom"); \ No newline at end of file ++export declare var customSymbol2: symbol; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols index 916f7562f3..97e0d789a1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols @@ -8,7 +8,7 @@ const customSymbol = Symbol("custom"); // This is a common pattern in Node’s built-in modules: module.exports = { >module.exports : Symbol(export=, Decl(file.js, 0, 38)) ->module : Symbol(module.exports) +>module : Symbol("file", Decl(file.js, 0, 0)) >exports : Symbol(export=, Decl(file.js, 0, 38)) customSymbol, diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff index a3d9141331..eaa913850e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff @@ -8,7 +8,7 @@ ->module : Symbol(module, Decl(file.js, 0, 38)) ->exports : Symbol(module.exports, Decl(file.js, 0, 0)) +>module.exports : Symbol(export=, Decl(file.js, 0, 38)) -+>module : Symbol(module.exports) ++>module : Symbol("file", Decl(file.js, 0, 0)) +>exports : Symbol(export=, Decl(file.js, 0, 38)) customSymbol, diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.types.diff b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.types.diff rename to testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols index 59a81b14aa..f93ac01044 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols @@ -11,7 +11,7 @@ class Abcde { module.exports = { >module.exports : Symbol(export=, Decl(test.js, 3, 1)) ->module : Symbol(module.exports) +>module : Symbol("/test", Decl(test.js, 0, 0)) >exports : Symbol(export=, Decl(test.js, 3, 1)) Abcde diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols.diff index 4ca5aa83b5..76c3d4efcc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.symbols.diff @@ -17,7 +17,7 @@ ->module : Symbol(module, Decl(test.js, 3, 1)) ->exports : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 31)) +>module.exports : Symbol(export=, Decl(test.js, 3, 1)) -+>module : Symbol(module.exports) ++>module : Symbol("/test", Decl(test.js, 0, 0)) +>exports : Symbol(export=, Decl(test.js, 3, 1)) Abcde diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff rename to testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation2.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols index affbb5282d..ecf70c434b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols @@ -3,7 +3,7 @@ === /test.js === module.exports = { >module.exports : Symbol(export=, Decl(test.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("/test", Decl(test.js, 0, 0)) >exports : Symbol(export=, Decl(test.js, 0, 0)) a: "ok" diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols.diff index 9ae26854b6..b51576a353 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.symbols.diff @@ -8,7 +8,7 @@ ->module : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 27)) ->exports : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 27)) +>module.exports : Symbol(export=, Decl(test.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("/test", Decl(test.js, 0, 0)) +>exports : Symbol(export=, Decl(test.js, 0, 0)) a: "ok" diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation2.types.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation2.types.diff rename to testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation2.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols index ec76d78072..8baf80c215 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols @@ -3,12 +3,12 @@ === /x.js === module.exports.x = 1; >module.exports : Symbol(export=, Decl(x.js, 0, 21)) ->module : Symbol(module.exports) +>module : Symbol("/x", Decl(x.js, 0, 0)) >exports : Symbol(export=, Decl(x.js, 0, 21)) module.exports = require("./y.js"); >module.exports : Symbol(export=, Decl(x.js, 0, 21)) ->module : Symbol(module.exports) +>module : Symbol("/x", Decl(x.js, 0, 0)) >exports : Symbol(export=, Decl(x.js, 0, 21)) >require : Symbol(require) diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff index 4f7e0ab0db..948a04b845 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff @@ -10,14 +10,14 @@ ->exports : Symbol(module.exports, Decl(x.js, 0, 0)) ->x : Symbol(x, Decl(x.js, 0, 0), Decl(y.d.ts, 0, 0)) +>module.exports : Symbol(export=, Decl(x.js, 0, 21)) -+>module : Symbol(module.exports) ++>module : Symbol("/x", Decl(x.js, 0, 0)) +>exports : Symbol(export=, Decl(x.js, 0, 21)) module.exports = require("./y.js"); ->module.exports : Symbol(module.exports, Decl(x.js, 0, 0)) ->module : Symbol(export=, Decl(x.js, 0, 21)) +>module.exports : Symbol(export=, Decl(x.js, 0, 21)) -+>module : Symbol(module.exports) ++>module : Symbol("/x", Decl(x.js, 0, 0)) >exports : Symbol(export=, Decl(x.js, 0, 21)) >require : Symbol(require) ->"./y.js" : Symbol("/y", Decl(y.d.ts, 0, 0)) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff rename to testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js index 30fd9c4e05..ebe7145997 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js @@ -55,8 +55,6 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // These are a few examples of existing alternative uses of @overload tag. // They will not work as expected with our implementation, but we are // trying to make sure that our changes do not result in any crashes here. @@ -108,17 +106,53 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.d.ts] -export type callback = (error: any, result: any) ; - - -//// [DtsFileErrors] - - -dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. - - -==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== - export type callback = (error: any, result: any) ; - ~ -!!! error TS1005: '=>' expected. - \ No newline at end of file +declare function Example1(value: any): any; +declare const example1: { + /** + * @overload Example1(value) + * Creates Example1 + * @param value [String] + */ + constructor: (value: any, options: any) => void; +}; +declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any; +declare function Example2(): any; +declare const example2: { + /** + * Example 2 + * + * @overload Example2(value) + * Creates Example2 + * @param value [String] + * @param secretAccessKey [String] + * @param sessionToken [String] + * @example Creates with string value + * const example = new Example(''); + * @overload Example2(options) + * Creates Example2 + * @option options value [String] + * @example Creates with options object + * const example = new Example2({ + * value: '', + * }); + */ + constructor: () => void; +}; +declare function evaluate(): any; +type callback = (error: any, result: any) => any; +declare const example3: { + /** + * @overload evaluate(options = {}, [callback]) + * Evaluate something + * @note Something interesting + * @param options [map] + * @return [string] returns evaluation result + * @return [null] returns nothing if callback provided + * @callback callback function (error, result) + * If callback is provided it will be called with evaluation result + * @param error [Error] + * @param result [String] + * @see callback + */ + evaluate: (options: any, callback: any) => void; +}; diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff index 72bb7b12fe..f2d21bc5a2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff @@ -1,24 +1,17 @@ --- old.jsFileAlternativeUseOfOverloadTag.js +++ new.jsFileAlternativeUseOfOverloadTag.js -@@= skipped -54, +54 lines =@@ - - - //// [jsFileAlternativeUseOfOverloadTag.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - // These are a few examples of existing alternative uses of @overload tag. - // They will not work as expected with our implementation, but we are - // trying to make sure that our changes do not result in any crashes here. -@@= skipped -51, +53 lines =@@ +@@= skipped -105, +105 lines =@@ //// [jsFileAlternativeUseOfOverloadTag.d.ts] -declare namespace example1 { -- /** -- * @overload Example1(value) -- * Creates Example1 -- * @param value [String] -- */ ++declare function Example1(value: any): any; ++declare const example1: { + /** + * @overload Example1(value) + * Creates Example1 + * @param value [String] + */ - function constructor(value: any): any; -} -declare namespace example2 { @@ -63,19 +56,41 @@ - export { constructor_1 as constructor }; -} -declare namespace example3 { -- /** -- * @overload evaluate(options = {}, [callback]) -- * Evaluate something -- * @note Something interesting -- * @param options [map] -- * @return [string] returns evaluation result -- * @return [null] returns nothing if callback provided -- * @callback callback function (error, result) -- * If callback is provided it will be called with evaluation result -- * @param error [Error] -- * @param result [String] -- * @see callback -- */ ++ constructor: (value: any, options: any) => void; ++}; ++declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any; ++declare function Example2(): any; ++declare const example2: { ++ /** ++ * Example 2 ++ * ++ * @overload Example2(value) ++ * Creates Example2 ++ * @param value [String] ++ * @param secretAccessKey [String] ++ * @param sessionToken [String] ++ * @example Creates with string value ++ * const example = new Example(''); ++ * @overload Example2(options) ++ * Creates Example2 ++ * @option options value [String] ++ * @example Creates with options object ++ * const example = new Example2({ ++ * value: '', ++ * }); ++ */ ++ constructor: () => void; ++}; ++declare function evaluate(): any; ++type callback = (error: any, result: any) => any; ++declare const example3: { + /** + * @overload evaluate(options = {}, [callback]) + * Evaluate something +@@= skipped -63, +48 lines =@@ + * @param result [String] + * @see callback + */ - function evaluate(): any; -} -/** @@ -83,17 +98,5 @@ - * If callback is provided it will be called with evaluation result - */ -type callback = (error: any, result: any) => any; -+export type callback = (error: any, result: any) ; -+ -+ -+//// [DtsFileErrors] -+ -+ -+dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. -+ -+ -+==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== -+ export type callback = (error: any, result: any) ; -+ ~ -+!!! error TS1005: '=>' expected. -+ \ No newline at end of file ++ evaluate: (options: any, callback: any) => void; ++}; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols index 0d43d5d884..dfaa58631f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols @@ -3,7 +3,7 @@ === foo.js === module.exports = function () { >module.exports : Symbol(export=, Decl(foo.js, 0, 0)) ->module : Symbol(module.exports) +>module : Symbol("foo", Decl(foo.js, 0, 0)) >exports : Symbol(export=, Decl(foo.js, 0, 0)) class A { } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols.diff index 4a77227c48..b0e5ce1d65 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.symbols.diff @@ -7,7 +7,7 @@ ->module.exports : Symbol(module.exports, Decl(foo.js, 0, 0)) ->module : Symbol(export=, Decl(foo.js, 0, 0)) +>module.exports : Symbol(export=, Decl(foo.js, 0, 0)) -+>module : Symbol(module.exports) ++>module : Symbol("foo", Decl(foo.js, 0, 0)) >exports : Symbol(export=, Decl(foo.js, 0, 0)) class A { } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassPropertyInitalizationInObjectLiteral.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassPropertyInitalizationInObjectLiteral.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileClassPropertyInitalizationInObjectLiteral.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassSelfReferencedProperty.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileClassSelfReferencedProperty.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassSelfReferencedProperty.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileClassSelfReferencedProperty.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationBindDeepExportsAssignment.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationBindDeepExportsAssignment.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationBindDeepExportsAssignment.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationBindDeepExportsAssignment.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationBindDeepExportsAssignment.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationBindDeepExportsAssignment.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationBindDeepExportsAssignment.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationBindDeepExportsAssignment.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.errors.txt deleted file mode 100644 index db630a3221..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -error TS5055: Cannot write file 'a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.js (0 errors) ==== - class c { - method(a) { - let x = a => this.method(a); - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.symbols deleted file mode 100644 index d79e0966e5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.symbols +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationClassMethodContainingArrowFunction.ts] //// - -=== a.js === -class c { ->c : Symbol(c, Decl(a.js, 0, 0)) - - method(a) { ->method : Symbol(c.method, Decl(a.js, 0, 9)) ->a : Symbol(a, Decl(a.js, 1, 11)) - - let x = a => this.method(a); ->x : Symbol(x, Decl(a.js, 2, 11)) ->a : Symbol(a, Decl(a.js, 2, 15)) ->this.method : Symbol(c.method, Decl(a.js, 0, 9)) ->this : Symbol(c, Decl(a.js, 0, 0)) ->method : Symbol(c.method, Decl(a.js, 0, 9)) ->a : Symbol(a, Decl(a.js, 2, 15)) - } -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.types deleted file mode 100644 index 9e38800cb6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationClassMethodContainingArrowFunction.types +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationClassMethodContainingArrowFunction.ts] //// - -=== a.js === -class c { ->c : c - - method(a) { ->method : (a: any) => void ->a : any - - let x = a => this.method(a); ->x : (a: any) => void ->a => this.method(a) : (a: any) => void ->a : any ->this.method(a) : void ->this.method : (a: any) => void ->this : this ->method : (a: any) => void ->a : any - } -} - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationDecoratorSyntax.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDecoratorSyntax.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationDecoratorSyntax.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationDecoratorSyntax.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.errors.txt deleted file mode 100644 index e246e2ba5d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -a.ts(1,10): error TS2393: Duplicate function implementation. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== b.js (0 errors) ==== - function foo() { - return 10; - } -==== a.ts (1 errors) ==== - function foo() { - ~~~ -!!! error TS2393: Duplicate function implementation. - return 30; - } - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.symbols deleted file mode 100644 index 95e1a34d96..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.symbols +++ /dev/null @@ -1,16 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateFunctionImplementation.ts] //// - -=== b.js === -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0), Decl(a.ts, 0, 0)) - - return 10; -} -=== a.ts === -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0), Decl(a.ts, 0, 0)) - - return 30; -} - - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.types deleted file mode 100644 index a12a4b908e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementation.types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateFunctionImplementation.ts] //// - -=== b.js === -function foo() { ->foo : { (): number; (): number; } - - return 10; ->10 : 10 -} -=== a.ts === -function foo() { ->foo : { (): number; (): number; } - - return 30; ->30 : 30 -} - - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt deleted file mode 100644 index 2171b2715c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -a.ts(1,10): error TS2393: Duplicate function implementation. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (1 errors) ==== - function foo() { - ~~~ -!!! error TS2393: Duplicate function implementation. - return 30; - } - -==== b.js (0 errors) ==== - function foo() { - return 10; - } - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.symbols deleted file mode 100644 index 56a11f9287..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.symbols +++ /dev/null @@ -1,17 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.ts] //// - -=== a.ts === -function foo() { ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(b.js, 0, 0)) - - return 30; -} - -=== b.js === -function foo() { ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(b.js, 0, 0)) - - return 10; -} - - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.types deleted file mode 100644 index 8cf49d3bd1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.types +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateFunctionImplementationFileOrderReversed.ts] //// - -=== a.ts === -function foo() { ->foo : { (): number; (): number; } - - return 30; ->30 : 30 -} - -=== b.js === -function foo() { ->foo : { (): number; (): number; } - - return 10; ->10 : 10 -} - - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.errors.txt deleted file mode 100644 index 17fcb9ecac..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - var x = 10; - -==== b.js (0 errors) ==== - var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.symbols deleted file mode 100644 index 6966b38384..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.symbols +++ /dev/null @@ -1,10 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateVariable.ts] //// - -=== a.ts === -var x = 10; ->x : Symbol(x, Decl(a.ts, 0, 3), Decl(b.js, 0, 3)) - -=== b.js === -var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked ->x : Symbol(x, Decl(a.ts, 0, 3), Decl(b.js, 0, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.types deleted file mode 100644 index 0485264641..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariable.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateVariable.ts] //// - -=== a.ts === -var x = 10; ->x : number ->10 : 10 - -=== b.js === -var x = "hello"; // Error is recorded here, but suppressed because the js file isn't checked ->x : number ->"hello" : "hello" - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.errors.txt deleted file mode 100644 index 9501bfbd57..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -a.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== b.js (0 errors) ==== - var x = "hello"; - -==== a.ts (1 errors) ==== - var x = 10; // Error reported - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. -!!! related TS6203 b.js:1:5: 'x' was also declared here. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.symbols deleted file mode 100644 index d122fd9ec3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.symbols +++ /dev/null @@ -1,10 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts] //// - -=== b.js === -var x = "hello"; ->x : Symbol(x, Decl(b.js, 0, 3), Decl(a.ts, 0, 3)) - -=== a.ts === -var x = 10; // Error reported ->x : Symbol(x, Decl(b.js, 0, 3), Decl(a.ts, 0, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.types deleted file mode 100644 index cabb99161d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationDuplicateVariableErrorReported.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationDuplicateVariableErrorReported.ts] //// - -=== b.js === -var x = "hello"; ->x : string ->"hello" : "hello" - -=== a.ts === -var x = 10; // Error reported ->x : string ->10 : 10 - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.errors.txt deleted file mode 100644 index e54b4b5efe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - -==== b.js (0 errors) ==== - function foo() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.symbols deleted file mode 100644 index 427342522f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.symbols +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationEmitDeclarations.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== b.js === -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.types deleted file mode 100644 index 6a130e285c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitDeclarations.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationEmitDeclarations.ts] //// - -=== a.ts === -class c { ->c : c -} - -=== b.js === -function foo() { ->foo : () => void -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.errors.txt deleted file mode 100644 index 31f187a95a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5055: Cannot write file 'c.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5055: Cannot write file 'c.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - -==== b.js (0 errors) ==== - /// - function foo() { - } - -==== c.js (0 errors) ==== - function bar() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.symbols deleted file mode 100644 index 587047e774..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationEmitTrippleSlashReference.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== b.js === -/// -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0)) -} - -=== c.js === -function bar() { ->bar : Symbol(bar, Decl(c.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.types deleted file mode 100644 index 4c97cbff39..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitTrippleSlashReference.types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationEmitTrippleSlashReference.ts] //// - -=== a.ts === -class c { ->c : c -} - -=== b.js === -/// -function foo() { ->foo : () => void -} - -=== c.js === -function bar() { ->bar : () => void -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt deleted file mode 100644 index 2d0b682034..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -error TS5055: Cannot write file 'c.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'c.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - -==== b.ts (0 errors) ==== - /// - function foo() { - } - -==== c.js (0 errors) ==== - function bar() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols deleted file mode 100644 index 5f713588b9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== b.ts === -/// -function foo() { ->foo : Symbol(foo, Decl(b.ts, 0, 0)) -} - -=== c.js === -function bar() { ->bar : Symbol(bar, Decl(c.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types deleted file mode 100644 index 7d380f8968..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationErrorOnDeclarationsWithJsFileReferenceWithOut.ts] //// - -=== a.ts === -class c { ->c : c -} - -=== b.ts === -/// -function foo() { ->foo : () => void -} - -=== c.js === -function bar() { ->bar : () => void -} - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExternalPackageError.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationExternalPackageError.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExternalPackageError.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationExternalPackageError.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.errors.txt deleted file mode 100644 index 71d995fb16..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -error TS5055: Cannot write file 'a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.js (0 errors) ==== - function foo(a) { - for (let a = 0; a < 10; a++) { - // do something - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.symbols deleted file mode 100644 index 18994a6597..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.symbols +++ /dev/null @@ -1,16 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts] //// - -=== a.js === -function foo(a) { ->foo : Symbol(foo, Decl(a.js, 0, 0)) ->a : Symbol(a, Decl(a.js, 0, 13)) - - for (let a = 0; a < 10; a++) { ->a : Symbol(a, Decl(a.js, 1, 12)) ->a : Symbol(a, Decl(a.js, 1, 12)) ->a : Symbol(a, Decl(a.js, 1, 12)) - - // do something - } -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.types deleted file mode 100644 index 0b5c583561..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetBeingRenamed.types +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts] //// - -=== a.js === -function foo(a) { ->foo : (a: any) => void ->a : any - - for (let a = 0; a < 10; a++) { ->a : number ->0 : 0 ->a < 10 : boolean ->a : number ->10 : 10 ->a++ : number ->a : number - - // do something - } -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.errors.txt deleted file mode 100644 index b04087814f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== b.js (0 errors) ==== - let a = 10; - b = 30; - -==== a.ts (0 errors) ==== - let b = 30; - a = 10; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.symbols deleted file mode 100644 index e7327adb55..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.symbols +++ /dev/null @@ -1,16 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationLetDeclarationOrder.ts] //// - -=== b.js === -let a = 10; ->a : Symbol(a, Decl(b.js, 0, 3)) - -b = 30; ->b : Symbol(b, Decl(a.ts, 0, 3)) - -=== a.ts === -let b = 30; ->b : Symbol(b, Decl(a.ts, 0, 3)) - -a = 10; ->a : Symbol(a, Decl(b.js, 0, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.types deleted file mode 100644 index e8596b8b46..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder.types +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationLetDeclarationOrder.ts] //// - -=== b.js === -let a = 10; ->a : number ->10 : 10 - -b = 30; ->b = 30 : 30 ->b : number ->30 : 30 - -=== a.ts === -let b = 30; ->b : number ->30 : 30 - -a = 10; ->a = 10 : 10 ->a : number ->10 : 10 - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.errors.txt deleted file mode 100644 index 6fcc471480..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - let b = 30; - a = 10; -==== b.js (0 errors) ==== - let a = 10; - b = 30; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.symbols deleted file mode 100644 index 5f8fb8408f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.symbols +++ /dev/null @@ -1,16 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationLetDeclarationOrder2.ts] //// - -=== a.ts === -let b = 30; ->b : Symbol(b, Decl(a.ts, 0, 3)) - -a = 10; ->a : Symbol(a, Decl(b.js, 0, 3)) - -=== b.js === -let a = 10; ->a : Symbol(a, Decl(b.js, 0, 3)) - -b = 30; ->b : Symbol(b, Decl(a.ts, 0, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.types deleted file mode 100644 index 77b87151ee..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationLetDeclarationOrder2.types +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationLetDeclarationOrder2.ts] //// - -=== a.ts === -let b = 30; ->b : number ->30 : 30 - -a = 10; ->a = 10 : 10 ->a : number ->10 : 10 - -=== b.js === -let a = 10; ->a : number ->10 : 10 - -b = 30; ->b = 30 : 30 ->b : number ->30 : 30 - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.errors.txt deleted file mode 100644 index 0bc8b29be8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -error TS5055: Cannot write file 'c.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'c.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - -==== b.ts (0 errors) ==== - /// - //no error on above reference since not emitting declarations - function foo() { - } - -==== c.js (0 errors) ==== - function bar() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.symbols deleted file mode 100644 index f9a7be2474..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.symbols +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== b.ts === -/// -//no error on above reference since not emitting declarations -function foo() { ->foo : Symbol(foo, Decl(b.ts, 0, 0)) -} - -=== c.js === -function bar() { ->bar : Symbol(bar, Decl(c.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.types deleted file mode 100644 index 6347d6b89b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.types +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationNoErrorWithoutDeclarationsWithJsFileReferenceWithOut.ts] //// - -=== a.ts === -class c { ->c : c -} - -=== b.ts === -/// -//no error on above reference since not emitting declarations -function foo() { ->foo : () => void -} - -=== c.js === -function bar() { ->bar : () => void -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt deleted file mode 100644 index 32c9cb870e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -error TS5055: Cannot write file '/src/a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -/src/a.js(1,1): error TS8013: Non-null assertions can only be used in TypeScript files. - - -!!! error TS5055: Cannot write file '/src/a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /src/a.js (1 errors) ==== - 0! - ~~ -!!! error TS8013: Non-null assertions can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.symbols deleted file mode 100644 index 1804a9bac8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.symbols +++ /dev/null @@ -1,6 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationNonNullAssertion.ts] //// - -=== /src/a.js === - -0! - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.types deleted file mode 100644 index 8d2f97d97b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.types +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationNonNullAssertion.ts] //// - -=== /src/a.js === -0! ->0! : 0 ->0 : 0 - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.errors.txt deleted file mode 100644 index 0a4d382583..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -error TS5055: Cannot write file 'a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.js (0 errors) ==== - function foo(...a) { } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.symbols deleted file mode 100644 index 77e06465c1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.symbols +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationRestParameter.ts] //// - -=== a.js === -function foo(...a) { } ->foo : Symbol(foo, Decl(a.js, 0, 0)) ->a : Symbol(a, Decl(a.js, 0, 13)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.types deleted file mode 100644 index ace365e6e6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParameter.types +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationRestParameter.ts] //// - -=== a.js === -function foo(...a) { } ->foo : (...a: any[]) => void ->a : any[] - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.errors.txt deleted file mode 100644 index d3d29142c5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS5055: Cannot write file 'a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.js (0 errors) ==== - function foo() { - var a = 10; - var b = "Hello"; - return { - a, - b - }; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.symbols deleted file mode 100644 index 4cde6bb927..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.symbols +++ /dev/null @@ -1,22 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationShortHandProperty.ts] //// - -=== a.js === -function foo() { ->foo : Symbol(foo, Decl(a.js, 0, 0)) - - var a = 10; ->a : Symbol(a, Decl(a.js, 1, 7)) - - var b = "Hello"; ->b : Symbol(b, Decl(a.js, 2, 7)) - - return { - a, ->a : Symbol(a, Decl(a.js, 3, 12)) - - b ->b : Symbol(b, Decl(a.js, 4, 10)) - - }; -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.types deleted file mode 100644 index 163af24a00..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationShortHandProperty.types +++ /dev/null @@ -1,26 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationShortHandProperty.ts] //// - -=== a.js === -function foo() { ->foo : () => { a: number; b: string; } - - var a = 10; ->a : number ->10 : 10 - - var b = "Hello"; ->b : string ->"Hello" : "Hello" - - return { ->{ a, b } : { a: number; b: string; } - - a, ->a : number - - b ->b : string - - }; -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt deleted file mode 100644 index 852f133911..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -error TS5055: Cannot write file '/src/a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -/src/a.js(1,6): error TS8016: Type assertion expressions can only be used in TypeScript files. -/src/a.js(2,10): error TS17008: JSX element 'string' has no corresponding closing tag. -/src/a.js(3,1): error TS1005: 'undefined; - ~~~~~~ -!!! error TS17008: JSX element 'string' has no corresponding closing tag. - - -!!! error TS1005: 'undefined; ->v : Symbol(v, Decl(a.js, 1, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.types deleted file mode 100644 index 161d671433..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.types +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationTypeAssertions.ts] //// - -=== /src/a.js === -0 as number; ->0 as number : number ->0 : 0 - -var v = undefined; ->v : any ->undefined; : any ->string : any - -> : any - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.errors.txt deleted file mode 100644 index e54b4b5efe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - -==== b.js (0 errors) ==== - function foo() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.symbols deleted file mode 100644 index 047a93e777..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.symbols +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithEnabledCompositeOption.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== b.js === -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.types deleted file mode 100644 index 1d05fbf535..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithEnabledCompositeOption.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithEnabledCompositeOption.ts] //// - -=== a.ts === -class c { ->c : c -} - -=== b.js === -function foo() { ->foo : () => void -} - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationWithMapFileAsJs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithMapFileAsJs.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationWithMapFileAsJs.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationWithMapFileAsJs.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.errors.txt deleted file mode 100644 index e54b4b5efe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5055: Cannot write file 'b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== a.ts (0 errors) ==== - class c { - } - -==== b.js (0 errors) ==== - function foo() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.symbols deleted file mode 100644 index b0a7e0781e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.symbols +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithOut.ts] //// - -=== a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== b.js === -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.types deleted file mode 100644 index 14a06c2efd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOut.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithOut.ts] //// - -=== a.ts === -class c { ->c : c -} - -=== b.js === -function foo() { ->foo : () => void -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt deleted file mode 100644 index d18c2df691..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /a.ts (0 errors) ==== - class c { - } - -==== /b.d.ts (0 errors) ==== - declare function foo(): boolean; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.symbols deleted file mode 100644 index 83307d0418..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.symbols +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.ts] //// - -=== /a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== /b.d.ts === -declare function foo(): boolean; ->foo : Symbol(foo, Decl(b.d.ts, 0, 0)) - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.types deleted file mode 100644 index 981206ee1f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.types +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.ts] //// - -=== /a.ts === -class c { ->c : c -} - -=== /b.d.ts === -declare function foo(): boolean; ->foo : () => boolean - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.errors.txt deleted file mode 100644 index 863ab21fdb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS5055: Cannot write file '/b.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - - -!!! error TS5055: Cannot write file '/b.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /a.ts (0 errors) ==== - class c { - } - -==== /b.js (0 errors) ==== - function foo() { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.symbols deleted file mode 100644 index aa24bde9fe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.symbols +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.ts] //// - -=== /a.ts === -class c { ->c : Symbol(c, Decl(a.ts, 0, 0)) -} - -=== /b.js === -function foo() { ->foo : Symbol(foo, Decl(b.js, 0, 0)) -} - diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.types deleted file mode 100644 index 6003007983..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.types +++ /dev/null @@ -1,12 +0,0 @@ -//// [tests/cases/compiler/jsFileCompilationWithOutFileNameSameAsInputJsFile.ts] //// - -=== /a.ts === -class c { ->c : c -} - -=== /b.js === -function foo() { ->foo : () => void -} - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileESModuleWithEnumTag.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileESModuleWithEnumTag.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileESModuleWithEnumTag.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileESModuleWithEnumTag.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional.errors.txt deleted file mode 100644 index 8e0c4dc746..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -bar.ts(1,1): error TS2554: Expected 3 arguments, but got 0. -bar.ts(2,1): error TS2554: Expected 3 arguments, but got 1. -bar.ts(3,1): error TS2554: Expected 3 arguments, but got 2. - - -==== foo.js (0 errors) ==== - function f(a, b, c) { } - - -==== bar.ts (3 errors) ==== - f(); - ~ -!!! error TS2554: Expected 3 arguments, but got 0. -!!! related TS6210 foo.js:1:12: An argument for 'a' was not provided. - f(1); - ~ -!!! error TS2554: Expected 3 arguments, but got 1. -!!! related TS6210 foo.js:1:15: An argument for 'b' was not provided. - f(1, 2); - ~ -!!! error TS2554: Expected 3 arguments, but got 2. -!!! related TS6210 foo.js:1:18: An argument for 'c' was not provided. - f(1, 2, 3); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional2.errors.txt deleted file mode 100644 index 83cde6079b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional2.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -bar.ts(1,1): error TS2554: Expected 3 arguments, but got 0. -bar.ts(2,1): error TS2554: Expected 3 arguments, but got 1. -bar.ts(3,1): error TS2554: Expected 3 arguments, but got 2. - - -==== foo.js (0 errors) ==== - /** - * @param a - * @param b - * @param c - */ - function f(a, b, c) { } - - -==== bar.ts (3 errors) ==== - f(); // Error - ~ -!!! error TS2554: Expected 3 arguments, but got 0. -!!! related TS6210 foo.js:6:12: An argument for 'a' was not provided. - f(1); // Error - ~ -!!! error TS2554: Expected 3 arguments, but got 1. -!!! related TS6210 foo.js:6:15: An argument for 'b' was not provided. - f(1, 2); // Error - ~ -!!! error TS2554: Expected 3 arguments, but got 2. -!!! related TS6210 foo.js:6:18: An argument for 'c' was not provided. - - f(1, 2, 3); // OK - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional2.errors.txt.diff new file mode 100644 index 0000000000..7502dd5e15 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionParametersAsOptional2.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.jsFileFunctionParametersAsOptional2.errors.txt ++++ new.jsFileFunctionParametersAsOptional2.errors.txt +@@= skipped -0, +0 lines =@@ +-bar.ts(1,1): error TS2554: Expected 3 arguments, but got 0. +-bar.ts(2,1): error TS2554: Expected 3 arguments, but got 1. +-bar.ts(3,1): error TS2554: Expected 3 arguments, but got 2. +- +- +-==== foo.js (0 errors) ==== +- /** +- * @param a +- * @param b +- * @param c +- */ +- function f(a, b, c) { } +- +- +-==== bar.ts (3 errors) ==== +- f(); // Error +- ~ +-!!! error TS2554: Expected 3 arguments, but got 0. +-!!! related TS6210 foo.js:6:12: An argument for 'a' was not provided. +- f(1); // Error +- ~ +-!!! error TS2554: Expected 3 arguments, but got 1. +-!!! related TS6210 foo.js:6:15: An argument for 'b' was not provided. +- f(1, 2); // Error +- ~ +-!!! error TS2554: Expected 3 arguments, but got 2. +-!!! related TS6210 foo.js:6:18: An argument for 'c' was not provided. +- +- f(1, 2, 3); // OK +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types index f5e4e23f89..da9d594ec0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types @@ -23,13 +23,13 @@ export function Foo() { } * @return {void} */ Foo.prototype.bar = function (a, b) { } ->Foo.prototype.bar = function (a, b) { } : (a: any, b: any) => void +>Foo.prototype.bar = function (a, b) { } : (a: string | number, b?: string) => void >Foo.prototype.bar : any >Foo.prototype : any >Foo : () => void >prototype : any >bar : any ->function (a, b) { } : (a: any, b: any) => void ->a : any ->b : any +>function (a, b) { } : (a: string | number, b?: string) => void +>a : string | number +>b : string diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads4.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types.diff similarity index 76% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads4.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types.diff index 65bb97d4fa..6a989b006f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads4.types.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads4.types.diff @@ -14,7 +14,7 @@ */ Foo.prototype.bar = function (a, b) { } ->Foo.prototype.bar = function (a, b) { } : { (a: string): void; (a: number, b: string): void; } -+>Foo.prototype.bar = function (a, b) { } : (a: any, b: any) => void ++>Foo.prototype.bar = function (a, b) { } : (a: string | number, b?: string) => void >Foo.prototype.bar : any >Foo.prototype : any ->Foo : typeof Foo @@ -22,8 +22,6 @@ >prototype : any >bar : any ->function (a, b) { } : { (a: string): void; (a: number, b: string): void; } -->a : string | number -->b : string -+>function (a, b) { } : (a: any, b: any) => void -+>a : any -+>b : any ++>function (a, b) { } : (a: string | number, b?: string) => void + >a : string | number + >b : string diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.types.diff b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.types.diff b/testdata/baselines/reference/submodule/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.types.diff rename to testdata/baselines/reference/submodule/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.js.diff b/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.js.diff deleted file mode 100644 index 280dbab05a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsNoImplicitAnyNoCascadingReferenceErrors.js -+++ new.jsNoImplicitAnyNoCascadingReferenceErrors.js -@@= skipped -17, +17 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var somelib_1 = require("./somelib"); -+const somelib_1 = require("./somelib"); - class MyFoo extends somelib_1.Foo { - constructor() { - super(); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsSelfReferencingArgumentsFunction.types.diff b/testdata/baselines/reference/submodule/compiler/jsSelfReferencingArgumentsFunction.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsSelfReferencingArgumentsFunction.types.diff rename to testdata/baselines/reference/submodule/compiler/jsSelfReferencingArgumentsFunction.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt index 4147bce1d5..f3bf77a415 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt @@ -1,9 +1,12 @@ /a.js(1,13): error TS1098: Type parameter list cannot be empty. +/a.js(1,14): error TS1139: Type parameter declaration expected. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @param {<} x */ ~~ !!! error TS1098: Type parameter list cannot be empty. + ~ +!!! error TS1139: Type parameter declaration expected. function f(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js b/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js index 917d6ddac3..b4585c5b55 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js +++ b/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js @@ -60,6 +60,39 @@ var v = import(String()); //// [jsdocInTypeScript.js] +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); class T { prop; } @@ -90,4 +123,4 @@ var E = {}; E[""]; // make sure import types in JSDoc are not resolved /** @type {import("should-not-be-resolved").Type} */ -var v = Promise.resolve(`${String()}`).then(s => require(s)); +var v = Promise.resolve(`${String()}`).then(s => __importStar(require(s))); diff --git a/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js.diff b/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js.diff index afcfd4e612..fb618d4330 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsdocInTypeScript.js.diff @@ -1,8 +1,8 @@ --- old.jsdocInTypeScript.js +++ new.jsdocInTypeScript.js -@@= skipped -60, +60 lines =@@ - - //// [jsdocInTypeScript.js] +@@= skipped -93, +93 lines =@@ + }; + })(); class T { + prop; } @@ -16,10 +16,4 @@ -var M = N; // Error: @typedef does not create namespaces in TypeScript code. // Not legal JSDoc, but that shouldn't matter in TypeScript. /** - * @type {{foo: (function(string, string): string)}} -@@= skipped -12, +10 lines =@@ - E[""]; - // make sure import types in JSDoc are not resolved - /** @type {import("should-not-be-resolved").Type} */ --var v = Promise.resolve("".concat(String())).then(function (s) { return require(s); }); -+var v = Promise.resolve(`${String()}`).then(s => require(s)); \ No newline at end of file + * @type {{foo: (function(string, string): string)}} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt index 1b0b2a8cd2..e7e5e429a5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt @@ -1,12 +1,15 @@ example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +example.js(3,19): error TS1005: '}' expected. -==== example.js (1 errors) ==== +==== example.js (2 errors) ==== // @ts-check /** * @type {function(@foo)} ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~ +!!! error TS1005: '}' expected. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff similarity index 87% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff index d1fab64b56..fbc195cf2e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff @@ -8,9 +8,10 @@ - -==== example.js (3 errors) ==== +example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++example.js(3,19): error TS1005: '}' expected. + + -+==== example.js (1 errors) ==== ++==== example.js (2 errors) ==== // @ts-check /** * @type {function(@foo)} @@ -23,5 +24,7 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~ ++!!! error TS1005: '}' expected. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocRestParameter.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff rename to testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsonFileImportChecksCallCorrectlyTwice.js.diff b/testdata/baselines/reference/submodule/compiler/jsonFileImportChecksCallCorrectlyTwice.js.diff deleted file mode 100644 index dd8de95162..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsonFileImportChecksCallCorrectlyTwice.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsonFileImportChecksCallCorrectlyTwice.js -+++ new.jsonFileImportChecksCallCorrectlyTwice.js -@@= skipped -35, +35 lines =@@ - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var data_json_1 = __importDefault(require("./data.json")); -+const data_json_1 = __importDefault(require("./data.json")); - fn(data_json_1.default.foo); - fn(data_json_1.default.foo); // <-- shouldn't error! - function fn(arg) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js b/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js index 7444e18d4a..c537ca89a1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js +++ b/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js @@ -11,4 +11,5 @@ declare var React: any; //// [jsxAttributeWithoutExpressionReact.js] -React.createElement(View, null, React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); +React.createElement(View, null, + React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); diff --git a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js.diff b/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js.diff deleted file mode 100644 index d422561af4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsxAttributeWithoutExpressionReact.js -+++ new.jsxAttributeWithoutExpressionReact.js -@@= skipped -10, +10 lines =@@ - - - //// [jsxAttributeWithoutExpressionReact.js] --React.createElement(View, null, -- React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); -+React.createElement(View, null, React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js index 089e12841d..f727bbc481 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js +++ b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js @@ -17,10 +17,43 @@ export const Hoc = ( //// [jsxCallElaborationCheckNoCrash1.js] "use strict"; +/// +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Hoc = void 0; -/// -const React = require("react"); +const React = __importStar(require("react")); const Hoc = (TagElement) => { const Component = () => React.createElement(TagElement, null); return Component; diff --git a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff deleted file mode 100644 index c1dbfd53f8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsxCallElaborationCheckNoCrash1.js -+++ new.jsxCallElaborationCheckNoCrash1.js -@@= skipped -16, +16 lines =@@ - - //// [jsxCallElaborationCheckNoCrash1.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Hoc = void 0; --var React = require("react"); -+/// -+const React = require("react"); - const Hoc = (TagElement) => { - const Component = () => React.createElement(TagElement, null); - return Component; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js index e98f1efae1..f7b1c2fcf8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js @@ -13,6 +13,9 @@ const a = ( //// [index.js] +"use strict"; /// /// -const a = (React.createElement("main", null, (React.createElement("div", null)), React.createElement("span", null))); +const a = (React.createElement("main", null, + (React.createElement("div", null)), + React.createElement("span", null))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff deleted file mode 100644 index 60fa1c536d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsxChildWrongType.js -+++ new.jsxChildWrongType.js -@@= skipped -12, +12 lines =@@ - - - //// [index.js] --"use strict"; - /// - /// --const a = (React.createElement("main", null, -- (React.createElement("div", null)), -- React.createElement("span", null))); -+const a = (React.createElement("main", null, (React.createElement("div", null)), React.createElement("span", null))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js index 3c3753387f..be8a7dd9cf 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js @@ -18,6 +18,9 @@ const b = ( ); //// [index.js] +"use strict"; /// /// -const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); +const b = (React.createElement(Foo, null, + React.createElement("div", null), + "aa")); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff deleted file mode 100644 index 0f17e08fc4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsxChildrenArrayWrongType.js -+++ new.jsxChildrenArrayWrongType.js -@@= skipped -17, +17 lines =@@ - ); - - //// [index.js] --"use strict"; - /// - /// --const b = (React.createElement(Foo, null, -- React.createElement("div", null), -- "aa")); -+const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js index d83e1ba831..003aef6a08 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js @@ -25,6 +25,7 @@ const argchild = {p => "y"} const mismatched = {() => 12} //// [jsxChildrenGenericContextualTypes.jsx] +"use strict"; const Elem = (p) =>

; Elem({ prop: { a: "x" }, children: i => ({ a: "z" }) }); const q = ({ a: "z" })}/>; diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js.diff deleted file mode 100644 index f570d9e0ed..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenGenericContextualTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsxChildrenGenericContextualTypes.js -+++ new.jsxChildrenGenericContextualTypes.js -@@= skipped -24, +24 lines =@@ - const mismatched = {() => 12} - - //// [jsxChildrenGenericContextualTypes.jsx] --"use strict"; - const Elem = (p) =>
; - Elem({ prop: { a: "x" }, children: i => ({ a: "z" }) }); - const q = ({ a: "z" })}/>; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js index 0570331206..521c173d4f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js @@ -80,12 +80,45 @@ var a = //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Blah = Blah; exports.Blah2 = Blah2; exports.Blah3 = Blah3; /// -const React = require("react"); +const React = __importStar(require("react")); function Blah(props) { return React.createElement(React.Fragment, null); } @@ -94,7 +127,9 @@ var a = React.createElement(Blah, null, x => x); // Blah components don't accept text as child elements var a = React.createElement(Blah, null, "Hello unexpected text!"); // Blah components don't accept multiple children. -var a = React.createElement(Blah, null, x => "" + x, x => "" + x); +var a = React.createElement(Blah, null, + x => "" + x, + x => "" + x); function Blah2(props) { return React.createElement(React.Fragment, null); } @@ -103,7 +138,9 @@ var a = React.createElement(Blah2, null, x => x); // Blah2 components don't accept text as child elements var a = React.createElement(Blah2, null, "Hello unexpected text!"); // Blah2 components don't accept multiple children of the wrong type. -var a = React.createElement(Blah2, null, x => x, x => x); +var a = React.createElement(Blah2, null, + x => x, + x => x); function Blah3(props) { return React.createElement(React.Fragment, null); } @@ -112,4 +149,6 @@ var a = React.createElement(Blah3, null, x => x); // Blah3 components don't accept text as child elements var a = React.createElement(Blah3, null, "Hello unexpected text!"); // Blah3 components don't accept multiple children of the wrong type. -var a = React.createElement(Blah3, null, x => x, x => x); +var a = React.createElement(Blah3, null, + x => x, + x => x); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff deleted file mode 100644 index 9240c8544f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.jsxChildrenIndividualErrorElaborations.js -+++ new.jsxChildrenIndividualErrorElaborations.js -@@= skipped -84, +84 lines =@@ - exports.Blah2 = Blah2; - exports.Blah3 = Blah3; - /// --var React = require("react"); -+const React = require("react"); - function Blah(props) { - return React.createElement(React.Fragment, null); - } -@@= skipped -9, +9 lines =@@ - // Blah components don't accept text as child elements - var a = React.createElement(Blah, null, "Hello unexpected text!"); - // Blah components don't accept multiple children. --var a = React.createElement(Blah, null, -- x => "" + x, -- x => "" + x); -+var a = React.createElement(Blah, null, x => "" + x, x => "" + x); - function Blah2(props) { - return React.createElement(React.Fragment, null); - } -@@= skipped -11, +9 lines =@@ - // Blah2 components don't accept text as child elements - var a = React.createElement(Blah2, null, "Hello unexpected text!"); - // Blah2 components don't accept multiple children of the wrong type. --var a = React.createElement(Blah2, null, -- x => x, -- x => x); -+var a = React.createElement(Blah2, null, x => x, x => x); - function Blah3(props) { - return React.createElement(React.Fragment, null); - } -@@= skipped -11, +9 lines =@@ - // Blah3 components don't accept text as child elements - var a = React.createElement(Blah3, null, "Hello unexpected text!"); - // Blah3 components don't accept multiple children of the wrong type. --var a = React.createElement(Blah3, null, -- x => x, -- x => x); -+var a = React.createElement(Blah3, null, x => x, x => x); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js index 354a537461..bbec75351d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js @@ -28,10 +28,43 @@ export class App extends React.Component<{}> { //// [jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js] "use strict"; +/// +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.App = void 0; -/// -const React = require("react"); +const React = __importStar(require("react")); function TabLayout(props) { return React.createElement("div", null); } diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff deleted file mode 100644 index 4f2d8d312a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js -+++ new.jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js -@@= skipped -27, +27 lines =@@ - - //// [jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); - exports.App = void 0; --var React = require("react"); -+/// -+const React = require("react"); - function TabLayout(props) { - return React.createElement("div", null); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js index a4dc7e7d0d..105528019f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js @@ -17,6 +17,9 @@ const b = ( ); //// [other.js] +"use strict"; /// /// -const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); +const b = (React.createElement(Foo, null, + React.createElement("div", null), + "aa")); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff deleted file mode 100644 index a6b8208467..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsxChildrenWrongType.js -+++ new.jsxChildrenWrongType.js -@@= skipped -16, +16 lines =@@ - ); - - //// [other.js] --"use strict"; - /// - /// --const b = (React.createElement(Foo, null, -- React.createElement("div", null), -- "aa")); -+const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt index c8e84730f2..384c3e74b4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt @@ -14,7 +14,7 @@ file.tsx(2,19): error TS2322: Type '{}' is not assignable to type 'IntrinsicClas "name": "@types/react", "version": "0.0.1", "main": "", - "types": "index.d.ts", + "types": "index.d.ts" } ==== node_modules/@types/react/index.d.ts (0 errors) ==== interface IntrinsicClassAttributesAlias { diff --git a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js index 0b71ffe9f6..474c490d7e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js +++ b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js @@ -8,7 +8,7 @@ export const a = ; "name": "@types/react", "version": "0.0.1", "main": "", - "types": "index.d.ts", + "types": "index.d.ts" } //// [index.d.ts] interface IntrinsicClassAttributesAlias { diff --git a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js index ee76f869af..5881830d2c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js +++ b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js @@ -612,24 +612,46 @@ export interface ReactSelectProps extends React.Props +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; }; - return __assign.apply(this, arguments); -}; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.createReactSingleSelect = createReactSingleSelect; -/// -const React = require("react"); +const React = __importStar(require("react")); function createReactSingleSelect(WrappedComponent) { return (props) => { - return (React.createElement(ReactSelectClass, __assign({}, props, { multi: false, autosize: false, value: props.value, onChange: (value) => { + return (React.createElement(ReactSelectClass, Object.assign({}, props, { multi: false, autosize: false, value: props.value, onChange: (value) => { if (props.onChange) { props.onChange(value === null ? undefined : value); } diff --git a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff deleted file mode 100644 index 1a21218483..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsxComplexSignatureHasApplicabilityError.js -+++ new.jsxComplexSignatureHasApplicabilityError.js -@@= skipped -611, +611 lines =@@ - - //// [jsxComplexSignatureHasApplicabilityError.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -14, +13 lines =@@ - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.createReactSingleSelect = createReactSingleSelect; --var React = require("react"); -+/// -+const React = require("react"); - function createReactSingleSelect(WrappedComponent) { - return (props) => { - return (React.createElement(ReactSelectClass, __assign({}, props, { multi: false, autosize: false, value: props.value, onChange: (value) => { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js b/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js index 5a46f01ece..15cf5b343c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js +++ b/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js @@ -42,6 +42,7 @@ const elem6 = ; //// [jsxComponentTypeErrors.jsx] +"use strict"; function FunctionComponent({ type }) { return { type diff --git a/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js.diff b/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js.diff index 4ce429b405..9ffd36fa50 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxComponentTypeErrors.js.diff @@ -1,14 +1,6 @@ --- old.jsxComponentTypeErrors.js +++ new.jsxComponentTypeErrors.js -@@= skipped -41, +41 lines =@@ - - - //// [jsxComponentTypeErrors.jsx] --"use strict"; - function FunctionComponent({ type }) { - return { - type -@@= skipped -10, +9 lines =@@ +@@= skipped -51, +51 lines =@@ return ; }; class ClassComponent { diff --git a/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js b/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js index 23b8bedbef..163d4d1aa9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js +++ b/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js @@ -23,6 +23,7 @@ function NoticeList(props: Props) { ; //// [jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.jsx] +"use strict"; function NoticeList(props) { return null; } diff --git a/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js.diff b/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js.diff deleted file mode 100644 index 0b5907b8e8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js -+++ new.jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js -@@= skipped -22, +22 lines =@@ - ; - - //// [jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.jsx] --"use strict"; - function NoticeList(props) { - return null; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.types.diff b/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.types.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.types.diff rename to testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js b/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js index 39e44df363..c2ed65ac55 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js +++ b/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js @@ -19,6 +19,7 @@ class ElemClass implements JSX.ElementClass { const elem = //// [jsxElementClassTooManyParams.jsx] +"use strict"; class ElemClass { props; constructor(props) { diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js.diff b/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js.diff index 2cd0bb4f1a..10b7d42fa8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxElementClassTooManyParams.js.diff @@ -1,10 +1,8 @@ --- old.jsxElementClassTooManyParams.js +++ new.jsxElementClassTooManyParams.js -@@= skipped -18, +18 lines =@@ - const elem = - +@@= skipped -20, +20 lines =@@ //// [jsxElementClassTooManyParams.jsx] --"use strict"; + "use strict"; class ElemClass { + props; constructor(props) { diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementType.js b/testdata/baselines/reference/submodule/compiler/jsxElementType.js index f1fc1a1f37..06f1f898b7 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxElementType.js @@ -116,9 +116,42 @@ declare global { //// [jsxElementType.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); let Component; const RenderElement = ({ title }) => React.createElement("div", null, title); Component = RenderElement; diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxElementType.js.diff index a68ad5ac7d..bb33f9e8b6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxElementType.js.diff @@ -1,9 +1,9 @@ --- old.jsxElementType.js +++ new.jsxElementType.js -@@= skipped -115, +115 lines =@@ - - //// [jsxElementType.js] - "use strict"; +@@= skipped -148, +148 lines =@@ + return result; + }; + })(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { @@ -15,11 +15,7 @@ -}; Object.defineProperty(exports, "__esModule", { value: true }); /// --var React = require("react"); -+const React = require("react"); - let Component; - const RenderElement = ({ title }) => React.createElement("div", null, title); - Component = RenderElement; + const React = __importStar(require("react")); @@= skipped -34, +25 lines =@@ React.createElement(RenderArray, { title: "react" }); React.createElement(RenderArray, { excessProp: true }); diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js b/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js index 8db5f67eed..b4970f18ba 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js +++ b/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js @@ -25,9 +25,42 @@ let c = ; //// [jsxElementTypeLiteral.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); // should be fine - `ElementType` accepts `div` let a = React.createElement("div", null); // should be an error - `ElementType` does not accept `span` diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js.diff b/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js.diff deleted file mode 100644 index 3e5c4e37d0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteral.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxElementTypeLiteral.js -+++ new.jsxElementTypeLiteral.js -@@= skipped -26, +26 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var React = require("react"); -+const React = require("react"); - // should be fine - `ElementType` accepts `div` - let a = React.createElement("div", null); - // should be an error - `ElementType` does not accept `span` \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js b/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js index 4ac375ed69..ff8e83ea53 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js +++ b/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js @@ -26,9 +26,42 @@ let c = ; //// [jsxElementTypeLiteralWithGeneric.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); // should be fine - `ElementType` accepts `div` let a = React.createElement("div", null); // Should be an error. diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js.diff b/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js.diff deleted file mode 100644 index e24b0f3772..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxElementTypeLiteralWithGeneric.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxElementTypeLiteralWithGeneric.js -+++ new.jsxElementTypeLiteralWithGeneric.js -@@= skipped -27, +27 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var React = require("react"); -+const React = require("react"); - // should be fine - `ElementType` accepts `div` - let a = React.createElement("div", null); - // Should be an error. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js b/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js index 7c3ecfb686..3d93b20c1f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js +++ b/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js @@ -18,6 +18,7 @@ function B() { //// [a.js] +"use strict"; function A() { return React.createElement("package", null); } diff --git a/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js.diff b/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js.diff deleted file mode 100644 index 8f8f318dd6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxElementsAsIdentifierNames.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsxElementsAsIdentifierNames.js -+++ new.jsxElementsAsIdentifierNames.js -@@= skipped -17, +17 lines =@@ - - - //// [a.js] --"use strict"; - function A() { - return React.createElement("package", null); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js index 9961ba8b5a..182c16e9cc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js +++ b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js @@ -21,10 +21,44 @@ const element = ( //// [jsxEmptyExpressionNotCountedAsChild.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); function Wrapper(props) { return React.createElement("div", null, props.children); } -const element = (React.createElement(Wrapper, null, React.createElement("div", null, "Hello"))); +const element = (React.createElement(Wrapper, null, + React.createElement("div", null, "Hello"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff deleted file mode 100644 index e75b72d689..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.jsxEmptyExpressionNotCountedAsChild(jsx=react).js -+++ new.jsxEmptyExpressionNotCountedAsChild(jsx=react).js -@@= skipped -22, +22 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var React = require("react"); -+const React = require("react"); - function Wrapper(props) { - return React.createElement("div", null, props.children); - } --const element = (React.createElement(Wrapper, null, -- React.createElement("div", null, "Hello"))); -+const element = (React.createElement(Wrapper, null, React.createElement("div", null, "Hello"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsx).js.diff b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsx).js.diff index 345ffbaac1..3d6a980f16 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsx).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsx).js.diff @@ -1,11 +1,8 @@ --- old.jsxEmptyExpressionNotCountedAsChild(jsx=react-jsx).js +++ new.jsxEmptyExpressionNotCountedAsChild(jsx=react-jsx).js -@@= skipped -21, +21 lines =@@ - //// [jsxEmptyExpressionNotCountedAsChild.js] - "use strict"; +@@= skipped -23, +23 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_runtime_1 = require("react/jsx-runtime"); -+const jsx_runtime_1 = require("react/jsx-runtime"); + const jsx_runtime_1 = require("react/jsx-runtime"); function Wrapper(props) { - return (0, jsx_runtime_1.jsx)("div", { children: props.children }); + return jsx_runtime_1.jsx("div", { children: props.children }); diff --git a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsxdev).js.diff b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsxdev).js.diff index 536da522f2..16b1877734 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsxdev).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react-jsxdev).js.diff @@ -1,11 +1,7 @@ --- old.jsxEmptyExpressionNotCountedAsChild(jsx=react-jsxdev).js +++ new.jsxEmptyExpressionNotCountedAsChild(jsx=react-jsxdev).js -@@= skipped -21, +21 lines =@@ - //// [jsxEmptyExpressionNotCountedAsChild.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); -+const jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); +@@= skipped -24, +24 lines =@@ + const jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); const _jsxFileName = "jsxEmptyExpressionNotCountedAsChild.tsx"; function Wrapper(props) { - return (0, jsx_dev_runtime_1.jsxDEV)("div", { children: props.children }, void 0, false, { fileName: _jsxFileName, lineNumber: 9, columnNumber: 11 }, this); diff --git a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js index cbd2b8fb00..c64a015bd6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js +++ b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js @@ -20,23 +20,45 @@ const myHoc = ( //// [jsxExcessPropsAndAssignability.js] "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; +/// +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); }; - return __assign.apply(this, arguments); -}; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -/// -const React = require("react"); +const React = __importStar(require("react")); const myHoc = (ComposedComponent) => { const WrapperComponent = null; const props = null; - React.createElement(WrapperComponent, __assign({}, props, { myProp: '1000000' })); - React.createElement(WrapperComponent, __assign({}, props, { myProp: 1000000 })); + React.createElement(WrapperComponent, Object.assign({}, props, { myProp: '1000000' })); + React.createElement(WrapperComponent, Object.assign({}, props, { myProp: 1000000 })); }; diff --git a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff deleted file mode 100644 index 961aefabfb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsxExcessPropsAndAssignability.js -+++ new.jsxExcessPropsAndAssignability.js -@@= skipped -19, +19 lines =@@ - - //// [jsxExcessPropsAndAssignability.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -13, +12 lines =@@ - return __assign.apply(this, arguments); - }; - Object.defineProperty(exports, "__esModule", { value: true }); --var React = require("react"); -+/// -+const React = require("react"); - const myHoc = (ComposedComponent) => { - const WrapperComponent = null; - const props = null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js index faba591900..18800eb73b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js @@ -9,4 +9,8 @@ declare var Frag: any; //// [jsxFactoryAndJsxFragmentFactory.js] h(Frag, null); -h(Frag, null, h("span", null, "1"), h(Frag, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(Frag, null, + h("span", null, "1"), + h(Frag, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js.diff deleted file mode 100644 index 7b47493d91..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactory.js -+++ new.jsxFactoryAndJsxFragmentFactory.js -@@= skipped -8, +8 lines =@@ - - //// [jsxFactoryAndJsxFragmentFactory.js] - h(Frag, null); --h(Frag, null, -- h("span", null, "1"), -- h(Frag, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(Frag, null, h("span", null, "1"), h(Frag, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js index a724406b71..b6882ec8ec 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js @@ -8,4 +8,8 @@ declare var h: any; //// [jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js] h(React.Fragment, null); -h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(React.Fragment, null, + h("span", null, "1"), + h(React.Fragment, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js.diff deleted file mode 100644 index 77b56ccfe3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js -+++ new.jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js -@@= skipped -7, +7 lines =@@ - - //// [jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js] - h(React.Fragment, null); --h(React.Fragment, null, -- h("span", null, "1"), -- h(React.Fragment, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js index a9d22fd0db..83b4e2ee67 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js @@ -8,4 +8,8 @@ declare var h: any; //// [jsxFactoryAndJsxFragmentFactoryNull.js] h(null, null); -h(null, null, h("span", null, "1"), h(null, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(null, null, + h("span", null, "1"), + h(null, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js.diff deleted file mode 100644 index 4069a9e30f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactoryNull.js -+++ new.jsxFactoryAndJsxFragmentFactoryNull.js -@@= skipped -7, +7 lines =@@ - - //// [jsxFactoryAndJsxFragmentFactoryNull.js] - h(null, null); --h(null, null, -- h("span", null, "1"), -- h(null, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(null, null, h("span", null, "1"), h(null, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js index de9f387250..a62a05ca0b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js @@ -8,4 +8,8 @@ declare var h: any; //// [jsxFactoryButNoJsxFragmentFactory.js] h(React.Fragment, null); -h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(React.Fragment, null, + h("span", null, "1"), + h(React.Fragment, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js.diff deleted file mode 100644 index 4456fecc25..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryButNoJsxFragmentFactory.js -+++ new.jsxFactoryButNoJsxFragmentFactory.js -@@= skipped -7, +7 lines =@@ - - //// [jsxFactoryButNoJsxFragmentFactory.js] - h(React.Fragment, null); --h(React.Fragment, null, -- h("span", null, "1"), -- h(React.Fragment, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentAndFactoryUsedOnFragmentUse.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentAndFactoryUsedOnFragmentUse.js.diff deleted file mode 100644 index 931f70d63b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentAndFactoryUsedOnFragmentUse.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsxFragmentAndFactoryUsedOnFragmentUse.js -+++ new.jsxFragmentAndFactoryUsedOnFragmentUse.js -@@= skipped -20, +20 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.a = void 0; --var jsx_1 = require("./jsx"); -+const jsx_1 = require("./jsx"); - exports.a = (0, jsx_1.element)(jsx_1.fragment, null, "fragment text"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js index 72870d3a61..56a90bc5f3 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js @@ -24,5 +24,7 @@ exports.Counter = Counter; const react_1 = require("react"); function Counter({ count = 0 }) { const [cnt, setCnt] = null; - return (0, react_1.createElement)(react_1.Fragment, null, (0, react_1.createElement)("p", null, cnt), (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); + return (0, react_1.createElement)(react_1.Fragment, null, + (0, react_1.createElement)("p", null, cnt), + (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); } diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff deleted file mode 100644 index c831aea953..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsxFragmentFactoryNoUnusedLocals.js -+++ new.jsxFragmentFactoryNoUnusedLocals.js -@@= skipped -20, +20 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Counter = Counter; - /// --var react_1 = require("react"); -+const react_1 = require("react"); - function Counter({ count = 0 }) { - const [cnt, setCnt] = null; -- return (0, react_1.createElement)(react_1.Fragment, null, -- (0, react_1.createElement)("p", null, cnt), -- (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); -+ return (0, react_1.createElement)(react_1.Fragment, null, (0, react_1.createElement)("p", null, cnt), (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff deleted file mode 100644 index c2e0779654..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsxFragmentFactoryReference(jsx=react-jsx).errors.txt -+++ new.jsxFragmentFactoryReference(jsx=react-jsx).errors.txt -@@= skipped -0, +0 lines =@@ --jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - - - ==== jsxFragmentFactoryReference.tsx (1 errors) ==== -@@= skipped -5, +5 lines =@@ - content = () => ( - <> - ~~ --!!! error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff deleted file mode 100644 index cd429f045a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt -+++ new.jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt -@@= skipped -0, +0 lines =@@ --jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - - - ==== jsxFragmentFactoryReference.tsx (1 errors) ==== -@@= skipped -5, +5 lines =@@ - content = () => ( - <> - ~~ --!!! error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -+!!! error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js index 05222697a5..1ae3253789 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js @@ -11,6 +11,7 @@ const jsxWithReactFragment = {test}; //// [a.js] +"use strict"; /// /// const test = () => "asd"; diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js.diff deleted file mode 100644 index eb2d2a3bc6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsxFragmentWrongType.js -+++ new.jsxFragmentWrongType.js -@@= skipped -10, +10 lines =@@ - - - //// [a.js] --"use strict"; - /// - /// - const test = () => "asd"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js b/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js index 3671dbff27..bc5ece570a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js @@ -12,8 +12,41 @@ const m = //// [jsxHasLiteralType.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const React = require("react"); +const React = __importStar(require("react")); class MyComponent extends React.Component { } const m = React.createElement(MyComponent, { x: "a" }); diff --git a/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js.diff deleted file mode 100644 index 7be5e063dd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxHasLiteralType.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxHasLiteralType.js -+++ new.jsxHasLiteralType.js -@@= skipped -12, +12 lines =@@ - //// [jsxHasLiteralType.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var React = require("react"); -+const React = require("react"); - class MyComponent extends React.Component { - } - const m = React.createElement(MyComponent, { x: "a" }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js b/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js index 4b509a3ec5..73e2571bb5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js +++ b/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js @@ -11,8 +11,41 @@ const tag =
; //// [jsxImportForSideEffectsNonExtantNoError.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); require("./App.css"); // doesn't actually exist const tag = React.createElement("div", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js.diff b/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js.diff deleted file mode 100644 index 0cacd6ca78..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxImportForSideEffectsNonExtantNoError.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsxImportForSideEffectsNonExtantNoError.js -+++ new.jsxImportForSideEffectsNonExtantNoError.js -@@= skipped -12, +12 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var React = require("react"); -+const React = require("react"); - require("./App.css"); // doesn't actually exist - const tag = React.createElement("div", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js b/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js index 98c6fac2ea..94e701f39b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js +++ b/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js @@ -15,8 +15,11 @@ let x = Test; // emit test_1.default //// [consumer.jsx] "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); /// -const Test_1 = require("Test"); +const Test_1 = __importDefault(require("Test")); let x = Test_1.default; // emit test_1.default ; // ? diff --git a/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js.diff b/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js.diff deleted file mode 100644 index 2ff8ed15ca..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxImportInAttribute.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsxImportInAttribute.js -+++ new.jsxImportInAttribute.js -@@= skipped -16, +16 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var Test_1 = require("Test"); -+const Test_1 = require("Test"); - let x = Test_1.default; // emit test_1.default - ; // ? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxImportSourceNonPragmaComment.js.diff b/testdata/baselines/reference/submodule/compiler/jsxImportSourceNonPragmaComment.js.diff deleted file mode 100644 index 4ba41a3fec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxImportSourceNonPragmaComment.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxImportSourceNonPragmaComment.js -+++ new.jsxImportSourceNonPragmaComment.js -@@= skipped -20, +20 lines =@@ - exports.default = Component; - /* eslint-disable react/react-in-jsx-scope -- Unaware of @jsxImportSource */ - /** @jsxImportSource @emotion/react */ --var react_1 = require("@emotion/react"); -+const react_1 = require("@emotion/react"); - function Component() { - return ((el: T) { //// [jsxIntrinsicElementsCompatability.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); function SomeComponent(props) { // Just so the return value is RectElement, the rendered element doesnt matter return React.createElement("div", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsCompatability.js.diff b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsCompatability.js.diff deleted file mode 100644 index f7b3bea966..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsCompatability.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxIntrinsicElementsCompatability.js -+++ new.jsxIntrinsicElementsCompatability.js -@@= skipped -15, +15 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var React = require("react"); -+const React = require("react"); - function SomeComponent(props) { - // Just so the return value is RectElement, the rendered element doesnt matter - return React.createElement("div", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js index 6b3db37414..b54a60b262 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js +++ b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js @@ -33,9 +33,42 @@ const l = />; // existing type argument with no internal issues //// [jsxIntrinsicElementsTypeArgumentErrors.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +const React = __importStar(require("react")); // opening + closing const a = React.createElement("div", null); // empty type args const b = React.createElement("div", null); // trailing comma type args diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js.diff b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js.diff deleted file mode 100644 index c67464a392..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicElementsTypeArgumentErrors.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxIntrinsicElementsTypeArgumentErrors.js -+++ new.jsxIntrinsicElementsTypeArgumentErrors.js -@@= skipped -34, +34 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - /// --var React = require("react"); -+const React = require("react"); - // opening + closing - const a = React.createElement("div", null); // empty type args - const b = React.createElement("div", null); // trailing comma type args \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js index 912b0e85c5..3ce4928120 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js +++ b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js @@ -12,8 +12,41 @@ const tag = {"Title"}; //// [jsxIntrinsicUnions.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +const React = __importStar(require("react")); const El = Math.random() ? 'h1' : 'h2'; const tag = React.createElement(El, { className: "ok", key: "key" }, "Title"); diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff deleted file mode 100644 index 3ca0818f87..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsxIntrinsicUnions.js -+++ new.jsxIntrinsicUnions.js -@@= skipped -11, +11 lines =@@ - - //// [jsxIntrinsicUnions.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); --var React = require("react"); -+/// -+const React = require("react"); - const El = Math.random() ? 'h1' : 'h2'; - const tag = React.createElement(El, { className: "ok", key: "key" }, "Title"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js index 1c70ee3d23..899453a487 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js +++ b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js @@ -28,9 +28,42 @@ const d = ; // Technically OK, but probably //// [jsxIssuesErrorWhenTagExpectsTooManyArguments.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// -const React = require("react"); +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +const React = __importStar(require("react")); function MyComp4(props, context, bad, verybad) { return React.createElement("div", null); } diff --git a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff deleted file mode 100644 index 3125094b86..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.jsxIssuesErrorWhenTagExpectsTooManyArguments.js -+++ new.jsxIssuesErrorWhenTagExpectsTooManyArguments.js -@@= skipped -27, +27 lines =@@ - - //// [jsxIssuesErrorWhenTagExpectsTooManyArguments.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); --var React = require("react"); -+/// -+const React = require("react"); - function MyComp4(props, context, bad, verybad) { - return React.createElement("div", null); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js.diff index 6196964fdf..b634c12a86 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js.diff @@ -1,15 +1,13 @@ --- old.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js +++ new.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js -@@= skipped -33, +33 lines =@@ - //// [test.js] +@@= skipped -34, +34 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_runtime_1 = require("/jsx/jsx-runtime"); + const jsx_runtime_1 = require("/jsx/jsx-runtime"); -const Title = (props) => (0, jsx_runtime_1.jsx)("h1", { children: props.children }); -(0, jsx_runtime_1.jsx)(Title, { children: "Hello, world!" }); -const Wrong = (props) => (0, jsx_runtime_1.jsx)("h1", { children: props.offspring }); -(0, jsx_runtime_1.jsx)(Wrong, { children: "Byebye, world!" }); -+const jsx_runtime_1 = require("/jsx/jsx-runtime"); +const Title = (props) => jsx_runtime_1.jsx("h1", { children: props.children }); +jsx_runtime_1.jsx(Title, { children: "Hello, world!" }); +const Wrong = (props) => jsx_runtime_1.jsx("h1", { children: props.offspring }); diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js.diff index aef716b7f0..64ccffb3f2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js.diff @@ -1,11 +1,8 @@ --- old.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js +++ new.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js -@@= skipped -33, +33 lines =@@ - //// [test.js] - "use strict"; +@@= skipped -35, +35 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); -+const jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); + const jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); const _jsxFileName = "/test.tsx"; -const Title = (props) => (0, jsx_dev_runtime_1.jsxDEV)("h1", { children: props.children }, void 0, false, { fileName: _jsxFileName, lineNumber: 1, columnNumber: 47 }, this); -(0, jsx_dev_runtime_1.jsxDEV)(Title, { children: "Hello, world!" }, void 0, false, { fileName: _jsxFileName, lineNumber: 1, columnNumber: 74 }, this); diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexport.js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexport.js.diff index 86a236decb..c66d601acc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexport.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexport.js.diff @@ -1,11 +1,9 @@ --- old.jsxNamespaceGlobalReexport.js +++ new.jsxNamespaceGlobalReexport.js -@@= skipped -108, +108 lines =@@ - "use strict"; +@@= skipped -109, +109 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Comp = void 0; --var jsx_runtime_1 = require("preact/jsx-runtime"); + const jsx_runtime_1 = require("preact/jsx-runtime"); -const Comp = () => (0, jsx_runtime_1.jsx)("div", {}); -+const jsx_runtime_1 = require("preact/jsx-runtime"); +const Comp = () => jsx_runtime_1.jsx("div", {}); exports.Comp = Comp; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexportMissingAliasTarget.js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexportMissingAliasTarget.js.diff index c52ffb7cb8..1e810b4adb 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexportMissingAliasTarget.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceGlobalReexportMissingAliasTarget.js.diff @@ -1,11 +1,9 @@ --- old.jsxNamespaceGlobalReexportMissingAliasTarget.js +++ new.jsxNamespaceGlobalReexportMissingAliasTarget.js -@@= skipped -104, +104 lines =@@ - "use strict"; +@@= skipped -105, +105 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Comp = void 0; --var jsx_runtime_1 = require("preact/jsx-runtime"); + const jsx_runtime_1 = require("preact/jsx-runtime"); -const Comp = () => (0, jsx_runtime_1.jsx)("div", {}); -+const jsx_runtime_1 = require("preact/jsx-runtime"); +const Comp = () => jsx_runtime_1.jsx("div", {}); exports.Comp = Comp; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespace.js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespace.js.diff index 94896cadcc..ae5f34a376 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespace.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespace.js.diff @@ -1,11 +1,9 @@ --- old.jsxNamespaceImplicitImportJSXNamespace.js +++ new.jsxNamespaceImplicitImportJSXNamespace.js -@@= skipped -104, +104 lines =@@ - "use strict"; +@@= skipped -105, +105 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Comp = void 0; --var jsx_runtime_1 = require("preact/jsx-runtime"); + const jsx_runtime_1 = require("preact/jsx-runtime"); -const Comp = () => (0, jsx_runtime_1.jsx)("div", {}); -+const jsx_runtime_1 = require("preact/jsx-runtime"); +const Comp = () => jsx_runtime_1.jsx("div", {}); exports.Comp = Comp; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).js.diff index 50c71fe543..881b74c41a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).js.diff @@ -1,11 +1,9 @@ --- old.jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).js +++ new.jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).js -@@= skipped -67, +67 lines =@@ - "use strict"; +@@= skipped -68, +68 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Comp = void 0; --var jsx_runtime_1 = require("@emotion/react/jsx-runtime"); + const jsx_runtime_1 = require("@emotion/react/jsx-runtime"); -const Comp = () => (0, jsx_runtime_1.jsx)("div", { css: "color: hotpink;" }); -+const jsx_runtime_1 = require("@emotion/react/jsx-runtime"); +const Comp = () => jsx_runtime_1.jsx("div", { css: "color: hotpink;" }); exports.Comp = Comp; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.js.diff index 50f2558812..6bc104b0a4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.js.diff @@ -1,11 +1,8 @@ --- old.jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.js +++ new.jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.js -@@= skipped -68, +68 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -70, +70 lines =@@ exports.Comp = void 0; --var jsx_runtime_1 = require("@emotion/react/jsx-runtime"); -+const jsx_runtime_1 = require("@emotion/react/jsx-runtime"); + const jsx_runtime_1 = require("@emotion/react/jsx-runtime"); /* @jsxImportSource @emotion/react */ -const Comp = () => (0, jsx_runtime_1.jsx)("div", { css: "color: hotpink;" }); +const Comp = () => jsx_runtime_1.jsx("div", { css: "color: hotpink;" }); diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js.diff index 06c32b4f64..262f674887 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js.diff @@ -1,13 +1,11 @@ --- old.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js +++ new.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js -@@= skipped -24, +24 lines =@@ - //// [test.js] +@@= skipped -25, +25 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_runtime_1 = require("/jsx/jsx-runtime"); + const jsx_runtime_1 = require("/jsx/jsx-runtime"); -const Title = (props) => (0, jsx_runtime_1.jsx)("h1", { children: props.children }); -const element = (0, jsx_runtime_1.jsx)(Title, { children: "Hello, world!" }); -+const jsx_runtime_1 = require("/jsx/jsx-runtime"); +const Title = (props) => jsx_runtime_1.jsx("h1", { children: props.children }); +const element = jsx_runtime_1.jsx(Title, { children: "Hello, world!" }); //// [jsx-dev-runtime.js] diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js.diff index 40af9ba871..756aa357b1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js.diff @@ -1,11 +1,8 @@ --- old.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js +++ new.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js -@@= skipped -24, +24 lines =@@ - //// [test.js] - "use strict"; +@@= skipped -26, +26 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); --var jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); -+const jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); + const jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); const _jsxFileName = "/test.tsx"; -const Title = (props) => (0, jsx_dev_runtime_1.jsxDEV)("h1", { children: props.children }, void 0, false, { fileName: _jsxFileName, lineNumber: 1, columnNumber: 47 }, this); -const element = (0, jsx_dev_runtime_1.jsxDEV)(Title, { children: "Hello, world!" }, void 0, false, { fileName: _jsxFileName, lineNumber: 3, columnNumber: 16 }, this); diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespacePrefixInNameReact.js b/testdata/baselines/reference/submodule/compiler/jsxNamespacePrefixInNameReact.js index 71d7334c9a..ddf6313cff 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespacePrefixInNameReact.js +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespacePrefixInNameReact.js @@ -34,17 +34,6 @@ var upcaseComponent2 = ; // Parsed as instrinsic //// [jsxNamespacePrefixInNameReact.js] -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; var justElement1 = React.createElement("a:element", null); var justElement2 = React.createElement("a:element", null); var justElement3 = React.createElement("a:element", { attr: "value" }); @@ -65,9 +54,9 @@ var justAttribute3 = React.createElement("element", { "a:attr": "value" }, "text var both1 = React.createElement("a:element", { "a:attr": "value" }); var both2 = React.createElement("a:element", { "k:attr": "value" }); var both3 = React.createElement("a:element", { "a:attr": "value" }, "text"); -var endOfIdent1 = React.createElement("a:attr", __assign({}, "value")); +var endOfIdent1 = React.createElement("a:attr", Object.assign({}, "value")); var endOfIdent2 = React.createElement("a", { "attr:": "value" }); var beginOfIdent1 = < , a, attr = { "value": } / > ; -var beginOfIdent2 = React.createElement("a:attr", __assign({}, "value")); +var beginOfIdent2 = React.createElement("a:attr", Object.assign({}, "value")); var upcaseComponent1 = React.createElement("ns:Upcase", null); // Parsed as intrinsic var upcaseComponent2 = React.createElement("Upcase:element", null); // Parsed as instrinsic diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js b/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js index 0cb4cdfcf2..cb3ef17685 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js @@ -22,6 +22,39 @@ exports.createElement = createElement; function createElement(element, props, ...children) { } //// [index.js] "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); -const MyLib = require("./library"); +const MyLib = __importStar(require("./library")); const content = MyLib.createElement("my-element", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js.diff deleted file mode 100644 index 2847d547d3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceReexports.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsxNamespaceReexports.js -+++ new.jsxNamespaceReexports.js -@@= skipped -22, +22 lines =@@ - //// [index.js] - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --var MyLib = require("./library"); -+const MyLib = require("./library"); - const content = MyLib.createElement("my-element", null); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxPartialSpread.js.diff b/testdata/baselines/reference/submodule/compiler/jsxPartialSpread.js.diff deleted file mode 100644 index 36644f33cb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxPartialSpread.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsxPartialSpread.js -+++ new.jsxPartialSpread.js -@@= skipped -19, +19 lines =@@ - exports.Repro = Repro; - /// - const Select = (p) =>

; --var react_1 = __importDefault(require("react")); -+const react_1 = __importDefault(require("react")); - function Repro({ SelectProps = {} }) { - return (